aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 46e2a6e9a158411d3bb90ba930b5d717f7887167 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
.POSIX:

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)

.c.o:
	$(CC) -fPIC -c -o $@ $< $$(pkg-config --cflags python$(PY_MAJOR)) $(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"

uninstall:
	-rm -f -- "$(DESTDIR)$(PYTHONDIR)/site-packages/native_bus.so"
	-rm -f -- "$(DESTDIR)$(PYTHONDIR)/site-packages/bus"

clean:
	-rm -rf -- __pycache__ *.pyc *.pyo *.o *.so

.SUFFIXES:
.SUFFIXES: .o .c .pyx

.PHONY: all install uninstall clean