-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGNUmakefile
More file actions
36 lines (21 loc) · 961 Bytes
/
GNUmakefile
File metadata and controls
36 lines (21 loc) · 961 Bytes
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
36
# This is a "GNU make" make file. It uses GNU make extensions.
PY_VER := $(shell pkg-config python3 --modversion)
# I have noticed that the "pkg-config python-3" output is somewhat broken,
# so I had to roll my own "pkg-config python-3 --libs" and other things.
PY_LIBDIR := $(shell pkg-config python-$(PY_VER) --variable=libdir)
PY_CFLAGS := $(shell pkg-config python-$(PY_VER) --cflags)
PY_LDFLAGS := -L$(PY_LIBDIR) -lpython$(PY_VER) -Wl,-rpath -Wl,$(PY_LIBDIR)
PYBIND11_CPPFLAGS := $(shell python3 -m pybind11 --includes)
CXXFLAGS := -g -Wall -Werror -std=c++11
SLIBS := mod.so
mod.lo_CPPFLAGS := $(PY_CFLAGS) $(PYBIND11_CPPFLAGS)
mod.so_LDFLAGS := $(PY_LDFLAGS)
# default target
build: $(SLIBS)
%.lo: %.cpp
$(CXX) $(CXXFLAGS) $($@_CPPFLAGS) -fPIC -c -o $@ $<
# How to build a DSO (dynamic shared object) library (module).
$(SLIBS): %.so: %.lo
$(CXX) $(CXXFLAGS) --shared -o $@ $< $($@_LDFLAGS)
clean cleaner:
rm -f *.so *.lo *.o $(SLIBS)