-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.common
92 lines (64 loc) · 2.31 KB
/
Makefile.common
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
.SUFFIXES: .i .cc .c .so .o _wrap.o .py
.PHONY: swig clean_subdirs subdirs $(SUBDIRS)
IncludeDirs = -I ~/script/ -I ~/script/vcflib/
BoostLib = -lboost_program_options -lboost_iostreams
HDF5Lib = -lhdf5_cpp -lhdf5 -L/usr/lib/x86_64-linux-gnu/hdf5/serial
## CXXTARGETS, CXXLDFLAGS, CTARGETS, CLDFLAGS, ExtraTargets will be defined in child Makefiles
#CXXTARGETS =
#CXXStaticTargets =
StaticStartFlags = -Wl,--no-as-needed -Wl,-Bstatic -static-libgcc -static-libstdc++
StaticEndFlags = -Wl,-Bdynamic -lz -lpthread -ldl
CXXFLAGS = -fPIC -O3 -std=c++11 -Wl,--no-as-needed -I /usr/include/hdf5/serial
# -std=c++0x
# -std=c++11
# -std=gnu++11
CXXCOMPILER = g++
CXXLDFLAGS = $(HDF5Lib)
#CTARGETS =
CFLAGS = -fPIC -O2 -Wl,--no-as-needed
CCOMPILER = gcc
#CLDFLAGS =
#SharedLibTargets =
SharedLibFlags = -shared -fPIC
#StaticLibTargets =
#ExtraTargets
#SRCS
all: depend $(CXXStaticTargets) $(CXXTARGETS) $(CTARGETS) $(SharedLibTargets) $(StaticLibTargets) $(ExtraTargets) subdirs
$(StaticLibTargets): %.a: %.o
-ar crfvs $@ $<
$(SharedLibTargets): %.so: %.o
-$(CXXCOMPILER) $< $(SharedLibFlags) -o $@ $(CXXLDFLAGS)
#.o.so:
# -$(CXXCOMPILER) $< $(SharedLibFlags) -o $@ $(CXXLDFLAGS)
$(CXXTARGETS): %: %.o
-$(CXXCOMPILER) $< $(CXXFLAGS) -o $@ $(CXXLDFLAGS)
$(CXXStaticTargets): %: %.o
-$(CXXCOMPILER) $< $(CXXFLAGS) -o $@ $(StaticStartFlags) $(CXXLDFLAGS) $(StaticEndFlags)
.cc.o:
-$(CXXCOMPILER) $< $(CXXFLAGS) $(IncludeDirs) -c -o $@
$(CTARGETS): %: %.o
-$(CCOMPILER) $< $(CFLAGS) -o $@ $(CLDFLAGS)
.c.o:
-$(CCOMPILER) $< $(CFLAGS) $(IncludeDirs) -c -o $@
#.c: $(wildcard ~/script/pymodule/include/*.h)
#.cc: $(wildcard ~/script/pymodule/include/*.h)
### 2013.08.21 generate auto-dependency for each source code file through "gcc -MM". so that change of .h files would trigger re-compilation as well.
depend: .depend
.depend: $(SRCS)
rm -f ./.depend
-$(CXXCOMPILER) $^ $(CXXFLAGS) $(IncludeDirs) -MM >>./.depend;
include .depend
subdirs:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir all; \
done
clean_subdirs:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean; \
done
common_clean:
rm -f ./.depend
-rm *.h.gch
-rm -f *.o *.so $(CXXStaticTargets) $(CXXTARGETS) $(CTARGETS) $(SharedLibTargets) $(StaticLibTargets) $(ExtraTargets)
#$(CXXTARGETS) $(CTARGETS) $(ExtraTargets) $(SharedLibTargets)
clean: clean_subdirs common_clean