1 | # ESAF : Euso Simulation and Analysis Framework |
---|
2 | # $Id: makeso.gmk 2960 2011-07-06 06:06:59Z mabl $ |
---|
3 | # |
---|
4 | # makeso.gmk |
---|
5 | # |
---|
6 | # Common part of GNUmakefile with shared libraries creation |
---|
7 | # |
---|
8 | # You can pass PACKAGES_EXCLUDE=name which will cause the build process to |
---|
9 | # ignore src/name.cc during build. |
---|
10 | |
---|
11 | DUMMY := $(shell [ ! -d $(PACKAGETMP) ] && mkdir -p $(PACKAGETMP) ) |
---|
12 | |
---|
13 | |
---|
14 | # Dictionary variables |
---|
15 | PACKAGEL := include/LinkDef.hh |
---|
16 | PACKAGED := G___$(PACKAGENAME)Dict |
---|
17 | PACKAGEDS := $(PACKAGETMP)/$(PACKAGED).cc |
---|
18 | PACKAGEDH := $(PACKAGEDS:.cc=.h) |
---|
19 | PACKAGEDO := $(PACKAGEDS:.cc=.o) |
---|
20 | |
---|
21 | # Check if PACKAGES_EXCLUDE is given and print info |
---|
22 | ifdef PACKAGES_EXCLUDE |
---|
23 | PACKAGE_IGNORES := $(patsubst %,src/%.cc,$(PACKAGES_EXCLUDE)) |
---|
24 | PACKAGE_IGNOREH := $(patsubst %,include/%.hh,$(PACKAGES_EXCLUDE)) |
---|
25 | $(info INFO: Ignoring package $(PACKAGES_EXCLUDE)...) |
---|
26 | endif |
---|
27 | |
---|
28 | PACKAGES := $(filter-out $(PACKAGE_IGNORES), $(wildcard src/*.cc)) |
---|
29 | PACKAGEH := $(filter-out $(wildcard include/*LinkDef.hh) $(PACKAGE_IGNOREH),$(wildcard include/*.hh)) |
---|
30 | PACKAGEO := $(patsubst src/%.cc,$(PACKAGETMP)/%.o,$(PACKAGES)) |
---|
31 | PACKAGEDEP := $(PACKAGEO:.o=.d) |
---|
32 | |
---|
33 | PACKAGEINC := $(PACKAGEH:include%=$(INCLUDEDIR)%) |
---|
34 | |
---|
35 | CXXFLAGS += -I. |
---|
36 | |
---|
37 | # Since ROOT does not provide off64_t types, we define it here to suppress warnings during |
---|
38 | # dictionary building of files which include zlib.h. |
---|
39 | CINT_FLAGS := -Doff64_t=int64_t |
---|
40 | |
---|
41 | $(PACKAGELIB): $(PACKAGETMP)/obj.last |
---|
42 | @echo Building $(@F)... |
---|
43 | @$(CXX) --shared $(CXXFLAGS) $(PACKAGEDO) $(PACKAGEO) -L$(LIBDIR) -o $@ |
---|
44 | |
---|
45 | $(PACKAGEDO): $(PACKAGEDS) |
---|
46 | @echo Compiling $(<F) |
---|
47 | @$(CXX) -c $(CXXFLAGS) $< -o $@ |
---|
48 | |
---|
49 | |
---|
50 | $(PACKAGEDS): $(PACKAGEH) $(PACKAGEL) |
---|
51 | @echo Building $(@F) dictionary... |
---|
52 | ifdef CPPVERBOSE |
---|
53 | rootcint -v4 -f $@ -c -p $(CINT_FLAGS) $(INCLUDES) $(PACKAGEH) $(PACKAGEL) |
---|
54 | else |
---|
55 | @rootcint -v4 -f $@ -c -p $(CINT_FLAGS) $(INCLUDES) $(PACKAGEH) $(PACKAGEL) |
---|
56 | endif |
---|
57 | obj: $(PACKAGETMP)/obj.last |
---|
58 | |
---|
59 | lib: includes $(PACKAGELIB) |
---|
60 | |
---|
61 | dict: includes $(PACKAGEDS) |
---|
62 | |
---|
63 | # Touch the versioning file |
---|
64 | $(PACKAGETMP)/obj.last: $(PACKAGEO) $(PACKAGEDO) |
---|
65 | @touch $@ |
---|
66 | |
---|
67 | # Build objects |
---|
68 | $(PACKAGETMP)/%.o : src/%.cc |
---|
69 | @echo Compiling $(<F) |
---|
70 | ifdef CPPVERBOSE |
---|
71 | $(CXX) -c $(CXXFLAGS) $< -o $@ |
---|
72 | else |
---|
73 | @$(CXX) -c $(CXXFLAGS) $< -o $@ |
---|
74 | endif |
---|
75 | |
---|
76 | cleandep: |
---|
77 | @echo Cleaning up dependencies |
---|
78 | @rm -f $(PACKAGEDEP) |
---|
79 | |
---|
80 | cleandict: |
---|
81 | @echo Cleaning up dictionary |
---|
82 | @rm -f $(PACKAGEDH) $(PACKAGEDS) $(PACKAGEDO) |
---|
83 | |
---|
84 | clean: |
---|
85 | @echo Cleaning up $(PACKAGENAME) |
---|
86 | @rm -f $(PACKAGELIB) |
---|
87 | @rm -rf $(PACKAGETMP) |
---|
88 | @rm -f tags |
---|
89 | |
---|
90 | map: |
---|
91 | @echo \'$(PACKAGELIBDEP)\' |
---|
92 | $(ELIBMAP) -r $(ESAFMAP) -l $(PACKAGELIB) \ |
---|
93 | -d $(PACKAGELIBDEP) -c $(PACKAGEL) |
---|
94 | |
---|
95 | includes: $(PACKAGEINC) |
---|
96 | |
---|
97 | #dependencies |
---|
98 | $(PACKAGETMP)/%.d: src/%.cc |
---|
99 | @echo Making dependency for file $<... |
---|
100 | @touch $@ |
---|
101 | @set -e; rmkdepend -f- -Y -w3000 -- $(CXXFLAGS) $< 2> /dev/null \ |
---|
102 | | sed 's!$(<D)/\($*\)\.o[ :]*!$(PACKAGETMP)/\1.o $@ : !g' > $@; \ |
---|
103 | [ -s $@ ] || rm -f $@ |
---|
104 | |
---|
105 | $(INCLUDEDIR)/%.hh: include/%.hh |
---|
106 | @if [ -d $(INCLUDEDIR) ]; then cp $< $@; echo Updating $<; fi |
---|
107 | |
---|
108 | ifneq ($(MAKECMDGOALS),clean) |
---|
109 | ifneq ($(MAKECMDGOALS),cleandep) |
---|
110 | ifneq ($(PACKAGEDEP),) |
---|
111 | -include $(PACKAGEDEP) |
---|
112 | endif |
---|
113 | endif |
---|
114 | endif |
---|
115 | |
---|
116 | .PHONY: obj lib dict cleandep cleandict clean tags doc map includes |
---|
117 | |
---|
118 | tags: |
---|
119 | # @echo Creating tags file |
---|
120 | @-ctags -l c++ -T -S -w src/*.cc include/*.hh |
---|
121 | |
---|
122 | doc: |
---|
123 | @echo Updating classes and paths... |
---|
124 | @$(ESAFPACKAGES)/tools/MakeListOfClasses.pl $(PACKAGENAME) dummy $(ESAFDOC) |
---|