diff options
-rw-r--r-- | Makefile | 19 | ||||
-rw-r--r-- | config.mk | 14 |
2 files changed, 18 insertions, 15 deletions
@@ -3,33 +3,30 @@ CONFIGFILE = config.mk include $(CONFIGFILE) -PY_MAJOR = $$(python --version 2>&1 | cut -d . -f 1 | cut -d ' ' -f 2) -PY_MINOR = $$(python$(PYTHON_MAJOR) --version 2>&1 | cut -d . -f 2) - all: native_bus.so -native_bus.so: native_bus.o - $(CC) -o $@ native_bus.o -shared $(LDFLAGS) +.o.so: + $(CC) -o $@ $< -shared $(LDFLAGS) .c.o: - $(CC) -fPIC -c -o $@ $< $$(pkg-config --cflags python$(PY_MAJOR)) $(CFLAGS) $(CPPFLAGS) + $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS) .pyx.c: if ! $(CYTHON) -$(PY_MAJOR) -v $< -o $@ ; then rm $@; false; fi install: native_bus.so - mkdir -p -- "$(DESTDIR)$(PYTHONDIR)/site-packages" - cp -- bus.py native_bus.so "$(DESTDIR)$(PYTHONDIR)/site-packages" + mkdir -p -- "$(DESTDIR)$(PYTHONPKGDIR)" + cp -- bus.py native_bus.so "$(DESTDIR)$(PYTHONPKGDIR)/" uninstall: - -rm -f -- "$(DESTDIR)$(PYTHONDIR)/site-packages/native_bus.so" - -rm -f -- "$(DESTDIR)$(PYTHONDIR)/site-packages/bus" + -rm -f -- "$(DESTDIR)$(PYTHONPKGDIR)/native_bus.so" + -rm -f -- "$(DESTDIR)$(PYTHONPKGDIR)/bus" clean: -rm -rf -- __pycache__ *.pyc *.pyo *.o *.so .SUFFIXES: -.SUFFIXES: .o .c .pyx +.SUFFIXES: .so .o .c .pyx .PHONY: all install uninstall clean @@ -1,10 +1,16 @@ -PREFIX = /usr/local +PREFIX = /usr MANPREFIX = $(PREFIX)/share/man PYTHONDIR = $(PREFIX)/lib/python$(PY_MAJOR).$(PY_MINOR) +PYTHONPKGDIR = $(PYTHONDIR)/site-packages + +CC = cc +CYTHON = cython +PYTHON = python$(PY_VERSION) CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOUCE -D_XOPEN_SOURCE=700 -CFLAGS = -std=c99 -O2 $$(pkg-config --cflags python$(PY_MAJOR)) $(CPPFLAGS) +CFLAGS = -std=c99 -O2 $$(pkg-config --cflags python$(PY_MAJOR)) LDFLAGS = -s $$(pkg-config --libs python$(PY_MAJOR)) -lbus -CYTHON = cython -PYTHON = python$(PY_MAJOR) +PY_MAJOR = $$(python --version 2>&1 | cut -d . -f 1 | cut -d ' ' -f 2) +PY_MINOR = $$(python$(PYTHON_MAJOR) --version 2>&1 | cut -d . -f 2) +PY_VERSION = $(PY_MAJOR).$(PY_MINOR) |