This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
70 lines (51 loc) · 2.33 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
BLD := bld
SRC := src
RELEASE := release
CXX := clang++
CFLAGS := -Wall -std=c++11 -Wno-c++11-narrowing
PYTHON_INC := -I/usr/include/python3.4m -I/usr/include/python3.3m -I/usr/include/python3.2
INC := -I$(SRC)
FSKUBE_SRCS := $(BLD)/fsk.cpp $(BLD)/rs232.cpp $(BLD)/stackmat.cpp $(BLD)/logging.cpp $(BLD)/capi.cpp $(BLD)/digitizer.cpp
FSKUBE_OBJS := $(FSKUBE_SRCS:.cpp=.o)
PYTHONWRAPPER_OBJS := $(FSKUBE_OBJS) $(BLD)/fskube_wrap.o
# Create BLD and RELEASE directory if necessary
$(shell mkdir -p $(BLD) $(RELEASE))
.PHONY: all py js jsmin check clean serve release
default: $(FSKUBE_OBJS)
all: default py js jsmin
release: $(RELEASE)/fskube.js
py: $(BLD)/_fskube.so
js: $(BLD)/fskube.js
# Autogenerated dependencies trick from
# http://scottmcpeak.com/autodepend/autodepend.html
-include $(PYTHONWRAPPER_OBJS:.o=.d)
$(BLD)/_fskube.so: $(PYTHONWRAPPER_OBJS)
$(CXX) -shared -lrt $^ -o $@
$(RELEASE)/fskube.js: $(BLD)/fskube.js
cp $^ $@
# Since some cpp files are autogenerated and end up in the BLD directory,
# treat all cpp files as being in the bld directory. This is a simple rule
# to copy those cpp files that are not actually autogenerated.
$(BLD)/%.cpp: $(SRC)/%.cpp
cp $< $@
# Make recognizes that the cpp files we copied into BLD are "intermediate" files,
# and will kindly automatically delete them after compilation. However, the
# dependency information generated by CXX points at these BLD files.
# http://www.gnu.org/software/make/manual/html_node/Chained-Rules.html
# details this trick to prevent the deletion of "intermediate" files.
.PRECIOUS: $(BLD)/%.cpp
$(BLD)/%.o: $(BLD)/%.cpp
$(CXX) -c -fPIC $(CFLAGS) $(INC) $(PYTHON_INC) $< -o $@
$(CXX) -MM -MT $(BLD)/$*.o $(CFLAGS) $(INC) $(PYTHON_INC) $< > $(BLD)/$*.d
$(BLD)/fskube.py $(BLD)/fskube_wrap.cpp $(BLD)/fskube_wrap.h: $(FSKUBE_SRCS) $(SRC)/fskube.i
swig -builtin -python -c++ -o $(BLD)/fskube_wrap.cpp $(SRC)/fskube.i
# Similar dependency trick as above.
# TODO "--closure 1 -O3" to compress resulting javascript
$(BLD)/fskube.js: $(FSKUBE_SRCS) $(SRC)/embind.cpp $(SRC)/wrap_c.js
em++ $(CFLAGS) $(INC) --bind $(SRC)/embind.cpp $(FSKUBE_SRCS) -s EXPORTED_FUNCTIONS="['_getLogLevels', '_setLogLevels']" --post-js $(SRC)/wrap_c.js -o $@
check: py
PYTHONPATH=$(BLD) python3 -m unittest discover -s test/ -p *Test.py
clean:
rm -rf $(BLD)
serve: release
python -m SimpleHTTPServer