-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
52 lines (44 loc) · 1.83 KB
/
Makefile
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
PYTHON=python
PYEXT=$(shell $(PYTHON)-config --extension-suffix 2>/dev/null || echo ".so")
PYINC=$(shell $(PYTHON)-config --includes)
DARWIN := $(shell uname|grep Darwin)
ifdef DARWIN
LIBLDFLAG=-install_name @rpath/libcorrectionlib.so
PYLDFLAG=-undefined dynamic_lookup -Wl,-rpath,'@loader_path/lib'
else
LIBLDFLAG=
PYLDFLAG=-Wl,-rpath,'$$ORIGIN/lib'
endif
OSXFLAG=$(shell uname|grep -q Darwin && echo "-undefined dynamic_lookup")
CFLAGS=--std=c++17 -O3 -Wall -fPIC -Irapidjson/include -Ipybind11/include -Icpp-peglib -Ixxhash -Ipcg-cpp/include $(PYINC) -Iinclude
PREFIX ?= correctionlib
STRVER=$(shell git describe --tags)
MAJOR=$(shell git describe --tags|sed -n "s/v\([0-9]\+\)\..*/\1/p")
MINOR=$(shell git describe --tags|sed -n "s/v[0-9]\+\.\([0-9]\+\)\..*/\1/p")
.PHONY: build all clean install pythonbinding
all: pythonbinding
include/correctionlib_version.h: include/version.h.in
sed "s/@CORRECTIONLIB_VERSION@/$(STRVER)/;s/@correctionlib_VERSION_MAJOR@/$(MAJOR)/;s/@correctionlib_VERSION_MINOR@/$(MINOR)/" $< > $@
build/%.o: src/%.cc include/correctionlib_version.h
mkdir -p build
$(CXX) $(CFLAGS) -c $< -o $@
lib/libcorrectionlib.so: build/correction.o build/formula_ast.o
mkdir -p lib
$(CXX) -pthread -lz -fPIC -shared $(LIBLDFLAG) $^ -o $@
pythonbinding: build/python.o lib/libcorrectionlib.so
$(CXX) -fPIC -shared $(PYLDFLAG) $< -Llib -lcorrectionlib -o _core$(PYEXT)
touch __init__.py
install: pythonbinding
mkdir -p $(PREFIX)/include
mkdir -p $(PREFIX)/lib
install -m 644 include/correction.h $(PREFIX)/include
install -m 644 include/correctionlib_version.h $(PREFIX)/include
install -m 755 _core$(PYEXT) $(PREFIX)
install -m 755 lib/libcorrectionlib.so $(PREFIX)/lib
install -m 644 __init__.py $(PREFIX)
clean:
rm -rf build
rm -f demo
rm -f data/examples.json*
rm -f include/correctionlib_version.h
rm -f __init__.py _core*