aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2019-05-08 22:01:55 +1200
committerDavid Phillips <david@sighup.nz>2019-05-08 22:43:07 +1200
commitccb9881319276e94fdede79c46c4f0d4c981dc41 (patch)
treef59898dd1881328b9fbf06160a194627462e56a7 /lib
parentb01e76ae9cc32ee92e4203fe6d1c0e2f9edfe766 (diff)
downloadalarmd-ccb9881319276e94fdede79c46c4f0d4c981dc41.tar.xz
Refactor build process, use setup.pyHEADmaster
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile19
-rw-r--r--lib/python/Makefile16
-rw-r--r--lib/python/setup.py17
3 files changed, 36 insertions, 16 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 4961c4e..ade9772 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,18 +1,25 @@
+include ../config.mk
+
CFLAGS += -I../inc/
-all: python
+all: libalarm.so
-python: libalarm.so
- make -C python
+libalarm.so.1: libalarm.o
+ $(CC) -shared -o $@ $< $(LDFLAGS) -Wl,-soname,libalarm.so.1
-%.so: %.o
- $(CC) -shared -o $@ $< $(LDFLAGS)
+libalarm.so: libalarm.so.1
+ ln -sf $^ $@
%.o: %.c
$(CC) -c -o $@ $< $(LDFLAGS) $(CFLAGS)
+install:
+ install -Dm755 libalarm.so.1 "$(DESTDIR)/$(PREFIX)/lib/libalarm.so.1"
+ ln -sf libalarm.so.1 "$(DESTDIR)/$(PREFIX)/lib/libalarm.so"
+ make -C python install
+
clean:
- rm -f libalarm.{s,}o
+ rm -f libalarm.o libalarm.so.1
make -C python clean
.PHONY: python
diff --git a/lib/python/Makefile b/lib/python/Makefile
index e260e64..e23cc9d 100644
--- a/lib/python/Makefile
+++ b/lib/python/Makefile
@@ -1,16 +1,12 @@
-CFLAGS += -fPIC \
- -I../../inc/ \
- $(shell pkg-config --cflags python3)
+include ../../config.mk
-all: alarms.so
+all:
+ $(PYTHON) setup.py build
-%.so: %.o
- $(CC) -shared -o $@ $< $(LDFLAGS)
-
-%.o: %.c
- $(CC) -c -o $@ $< $(CFLAGS)
+install:
+ $(PYTHON) setup.py install --root="$(DESTDIR)/$(PREFIX)"
.PHONY: clean
clean:
- - rm -f alarms.{s,}o
+ - rm -rf build *.egg-info
diff --git a/lib/python/setup.py b/lib/python/setup.py
new file mode 100644
index 0000000..5e3c673
--- /dev/null
+++ b/lib/python/setup.py
@@ -0,0 +1,17 @@
+from setuptools import setup, Extension
+
+if __name__ == "__main__":
+ setup(
+ name="alarms",
+ version="0.1",
+ ext_modules=[
+ Extension(
+ "alarms",
+ language = "C",
+ sources = [ "alarms.c" ],
+ extra_compile_args = [ "-I../../inc" ],
+ libraries = [ "alarm", "uuid" ],
+ library_dirs = [ "../" ]
+ )
+ ]
+ )