]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
Start a Python module
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 28 Dec 2017 18:32:45 +0000 (18:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 28 Dec 2017 18:32:45 +0000 (18:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
configure.ac
src/python/locationmodule.c [new file with mode: 0644]

index 00763a8ad88d0d0121faec39c3260d0bc4769805..4a6aacf91b6a99a99b01e3199ebd5866ed4f2a1e 100644 (file)
@@ -9,7 +9,6 @@ AM_CPPFLAGS = \
        -I${top_srcdir}/src
 
 AM_CFLAGS = ${my_CFLAGS} \
-       -fvisibility=hidden \
        -ffunction-sections \
        -fdata-sections
 
@@ -30,6 +29,7 @@ SED_PROCESS = \
        -e 's,@includedir\@,$(includedir),g' \
        < $< > $@ || rm $@
 
+pythondir    = $(pyexecdir)
 pkgconfigdir = $(libdir)/pkgconfig
 
 %.pc: %.pc.in Makefile
@@ -57,6 +57,10 @@ src_libloc_la_SOURCES =\
 
 EXTRA_DIST += src/libloc.sym
 
+src_libloc_la_CFLAGS = \
+       $(AM_CFLAGS) \
+       -fvisibility=hidden
+
 src_libloc_la_LDFLAGS = \
        $(AM_LDFLAGS) \
        -version-info $(LIBLOC_CURRENT):$(LIBLOC_REVISION):$(LIBLOC_AGE) \
@@ -74,6 +78,26 @@ EXTRA_DIST += \
 CLEANFILES += \
        src/libloc.pc
 
+pkgpyexec_LTLIBRARIES = \
+       src/python/location.la
+
+src_python_location_la_SOURCES = \
+       src/python/locationmodule.c
+
+src_python_location_la_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(PYTHON_CFLAGS)
+
+src_python_location_la_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       -shared \
+       -module \
+       -avoid-version
+
+src_python_location_la_LIBADD = \
+       src/libloc.la \
+       $(PYTHON_LIBS)
+
 TESTS = \
        src/test-libloc \
        src/test-stringpool \
index b27e11bd8f18943e8680b78f828f2317d05d452f..79ae5e6195d42c8cc9f2d94ed08a10fb8ac8393c 100644 (file)
@@ -68,6 +68,10 @@ my_CFLAGS="\
 "
 AC_SUBST([my_CFLAGS])
 
+# Python
+AM_PATH_PYTHON([3.4])
+PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
+
 AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_FILES([
         Makefile
diff --git a/src/python/locationmodule.c b/src/python/locationmodule.c
new file mode 100644 (file)
index 0000000..dfd951d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+       libloc - A library to determine the location of someone on the Internet
+
+       Copyright (C) 2017 IPFire Development Team <info@ipfire.org>
+
+       This library is free software; you can redistribute it and/or
+       modify it under the terms of the GNU Lesser General Public
+       License as published by the Free Software Foundation; either
+       version 2.1 of the License, or (at your option) any later version.
+
+       This library is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+       Lesser General Public License for more details.
+*/
+
+#include <Python.h>
+
+PyMODINIT_FUNC PyInit_location(void);
+
+static PyMethodDef location_module_methods[] = {
+       { NULL },
+};
+
+static struct PyModuleDef location_module = {
+       .m_base = PyModuleDef_HEAD_INIT,
+       .m_name = "location",
+       .m_size = -1,
+       .m_doc = "Python module for libloc",
+       .m_methods = location_module_methods,
+};
+
+PyMODINIT_FUNC PyInit_location(void) {
+       PyObject* m = PyModule_Create(&location_module);
+       if (!m)
+               return NULL;
+
+       return m;
+}