Cleanup of makefiles
[u/mrichter/AliRoot.git] / build / module.tpl
CommitLineData
117cfc60 1#-*- Mode: Makefile -*-
f0a26826 2
f347de98 3
f0a26826 4ifndef PACKFFLAGS
5@PACKAGE@FFLAGS:=$(FFLAGS)
6else
7@PACKAGE@FFLAGS:=$(PACKFFLAGS)
8endif
9
10ifndef PACKCFLAGS
11@PACKAGE@CFLAGS:=$(CFLAGS)
12else
13@PACKAGE@CFLAGS:=$(PACKCFLAGS)
14endif
15
16ifndef PACKCXXFLAGS
17@PACKAGE@CXXFLAGS:=$(CXXFLAGS)
18else
19@PACKAGE@CXXFLAGS:=$(PACKCXXFLAGS)
20endif
21
88cb7938 22ifndef PACKSOFLAGS
23@PACKAGE@SOFLAGS:=$(SOFLAGS)
24else
25@PACKAGE@SOFLAGS:=$(PACKSOFLAGS)
26endif
27
28ifdef DYEXT
29ifndef PACKDYFLAGS
30@PACKAGE@DYFLAGS:=$(DYFLAGS)
31else
32@PACKAGE@DYFLAGS:=$(PACKDYFLAGS)
33endif
34endif
35
810722e6 36ifndef PACKDCXXFLAGS
19ca05d1 37@PACKAGE@DCXXFLAGS:=$(CXXFLAGSNO)
810722e6 38else
117cfc60 39@PACKAGE@DCXXFLAGS:=$(PACKDCXXFLAGS)
810722e6 40endif
41
f0a26826 42
43ifdef DHDR
44WITHDICT=YES
45else
46WITHDICT=
47endif
48
f347de98 49# Headerfiles exported to common place:
50@PACKAGE@EXPORT:=$(EXPORT)
51@PACKAGE@EXPORTDEST:=$(patsubst %,$(EXPORTDIR)/%,$(EXPORT))
52
53
67fd7264 54#Extra include,libs, defines etc.
55
56@PACKAGE@DEFINE:=$(EDEFINE)
f347de98 57
58@PACKAGE@INC:=$(patsubst %,-I%,$(EINCLUDE)) -I@MODULE@
59
f0a26826 60@PACKAGE@ELIBS:=$(patsubst %,-l%,$(ELIBS))
61@PACKAGE@ELIBSDIR:=$(patsubst %,-L%,$(ELIBSDIR))
62
63#c sources and headers
64
65@PACKAGE@CS:=$(patsubst %,$(MODDIR)/%,$(CSRCS))
66@PACKAGE@CH:=$(patsubst %,$(MODDIR)/%,$(CHDRS))
67
68#Fortran sources
69@PACKAGE@FS:=$(patsubst %,$(MODDIR)/%,$(FSRCS))
70
71#c++ sources and header
72@PACKAGE@S:=$(patsubst %,$(MODDIR)/%,$(SRCS))
f347de98 73@PACKAGE@H:=$(patsubst %,$(MODDIR)/%,$(HDRS)) $(EHDRS)
74
eec15521 75#c++ source subdirectories
76@PACKAGE@SDIR:=$(SUBDIR)
77
f347de98 78#############################################################################
79#
80# If special rootcint headerfiles is specified use them
81# else use all headers
f0a26826 82
f347de98 83ifndef CINTHDRS
84@PACKAGE@CINTHDRS:=$(@PACKAGE@H)
85else
86@PACKAGE@CINTHDRS:=$(CINTHDRS)
87endif
88#############################################################################
f0a26826 89
90# Package Dictionary
91
92@PACKAGE@DH:=$(MODDIR)/$(DHDR)
93
94
95#All objects
96@PACKAGE@CO:=$(patsubst %,$(MODDIRO)/%, $(CSRCS:.c=.o))
97TEMP:=$(FSRCS:.F=.o)
98@PACKAGE@FO:=$(patsubst %,$(MODDIRO)/%, $(TEMP:.f=.o))
99@PACKAGE@O:= $(patsubst %,$(MODDIRO)/%, $(SRCS:.cxx=.o)) $(@PACKAGE@FO) $(@PACKAGE@CO)
100
d47d6108 101
102
f0a26826 103ifdef WITHDICT
104 @PACKAGE@DS:=$(MODDIRO)/G__@PACKAGE@.cxx
105 @PACKAGE@DO:=$(MODDIRO)/G__@PACKAGE@.o
106 @PACKAGE@DDEP:=$(@PACKAGE@DO:.o=.d)
107 @PACKAGE@DEP:=$(@PACKAGE@O:.o=.d) $(@PACKAGE@DDEP)
108else
109 @PACKAGE@DS:=
110 @PACKAGE@DO:=
111 @PACKAGE@DDEP:=
112 @PACKAGE@DEP:=$(@PACKAGE@O:.o=.d)
113endif
114
115
116#The actual library file
117
118@PACKAGE@LIB:=$(LIBPATH)/lib@PACKAGE@.$(SOEXT)
40c469d5 119
120ifneq ($(DYEXT),)
121@PACKAGE@DLIB:=$(LIBPATH)/lib@PACKAGE@.$(DYEXT)
122endif
123
2d8cad5a 124@PACKAGE@ALIB:=$(LIBPATH)/lib@PACKAGE@.$(AEXT)
f0a26826 125
d47d6108 126#Add this to the modules libs
127@MODULE@LIBS += $(@PACKAGE@LIB)
2d8cad5a 128@MODULE@ALIBS += $(@PACKAGE@ALIB)
40c469d5 129ifneq ($(DYEXT),)
130@MODULE@DLIBS += $(@PACKAGE@DLIB)
131endif
d47d6108 132
f0a26826 133#The actual binary file
134
135@PACKAGE@BIN:=$(BINPATH)/@PACKAGE@
136
d47d6108 137#Add to modules list of binaries
138@MODULE@BINS += $(@PACKAGE@BIN)
f0a26826 139
f347de98 140# Use in the main Makefile
f0a26826 141
142ifeq ($(TYPE),lib)
143ALLLIBS += $(@PACKAGE@LIB)
2d8cad5a 144ALLALIBS += $(@PACKAGE@ALIB)
40c469d5 145ifneq ($(DYEXT),)
146ALLLIBS += $(@PACKAGE@DLIB)
147endif
f0a26826 148BINLIBS += -l@PACKAGE@
149else
150ALLEXECS += $(@PACKAGE@BIN)
151endif
152
40c469d5 153ifeq ($(DYEXT),)
154@PACKAGE@LIB := $(@PACKAGE@LIB)
155else
156@PACKAGE@LIB := $(@PACKAGE@LIB)
157endif
158
f0a26826 159# include all dependency files
160INCLUDEFILES +=$(@PACKAGE@DEP)
161
f347de98 162EXPORTFILES += $(@PACKAGE@EXPORTDEST)
f0a26826 163
164#local rules
165
f347de98 166#The exportfiles only include if any!!
167
168ifdef @PACKAGE@EXPORT
896cb507 169#$(@PACKAGE@EXPORTDEST): $(patsubst %,@MODULE@/%,$(@PACKAGE@EXPORT))
170
171$(@PACKAGE@EXPORTDEST): $(EXPORTDIR)/%.h: @MODULE@/%.h
15142e2f 172ifndef ALIQUIET
ba419e66 173 @echo "***** Copying file $^ to $@ *****"
15142e2f 174endif
f347de98 175 @[ -d $(dir $@) ] || mkdir $(dir $@)
ba419e66 176 @cp $^ $@
f347de98 177endif
178
88cb7938 179#------------------------------------------------------------------------
180
f0a26826 181$(@PACKAGE@LIB):$(@PACKAGE@O) $(@PACKAGE@DO) @MODULE@/module.mk
15142e2f 182ifndef ALIQUIET
f0a26826 183 @echo "***** Linking library $@ *****"
15142e2f 184endif
faeab8a4 185 $(MUTE)TMPDIR=/tmp/@MODULE@$$$$.`date +%M%S` ; \
117cfc60 186 export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \
faeab8a4 187 find $(CURDIR)/@MODULE@/tgt_$(ALICE_TARGET) -name '*.o' -exec ln -s {} . \; ;\
043a26ce 188 \rm -f $(CURDIR)/$@ ;\
7930dd19 189 TMPLIB=$(notdir $(@PACKAGE@LIB)); export TMPLIB;\
ce4e6d58 190 $(SHLD) $(@PACKAGE@SOFLAGS) -o $(CURDIR)/$@ $(notdir $(@PACKAGE@O) $(@PACKAGE@DO)) $(@PACKAGE@ELIBSDIR) $(@PACKAGE@ELIBS) $(SHLIB);\
191 chmod a-w $(CURDIR)/$@ ;\
fe250300 192 cd $(ALICE_ROOT) ; \rm -rf $$TMPDIR
810722e6 193
40c469d5 194ifneq ($(DYEXT),)
195$(@PACKAGE@DLIB):$(@PACKAGE@O) $(@PACKAGE@DO) @MODULE@/module.mk
196ifndef ALIQUIET
197 @echo "***** Linking library $@ *****"
198endif
199 $(MUTE)TMPDIR=/tmp/@MODULE@$$$$.`date +%M%S` ; \
117cfc60 200 export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \
40c469d5 201 find $(CURDIR)/@MODULE@/tgt_$(ALICE_TARGET) -name '*.o' -exec ln -s {} . \; ;\
fe250300 202 \rm -f $(CURDIR)/$@ ;\
ce4e6d58 203 $(DYLD) $(@PACKAGE@DYFLAGS) -o $(CURDIR)/$@ $(notdir $(@PACKAGE@O) $(@PACKAGE@DO)) $(@PACKAGE@ELIBSDIR) $(@PACKAGE@ELIBS) $(DYLIB);\
204 chmod a-w $(CURDIR)/$@ ;\
fe250300 205 cd $(ALICE_ROOT) ; \rm -rf $$TMPDIR
40c469d5 206endif
207
88cb7938 208#------------------------------------------------------------------------
209
2d8cad5a 210$(@PACKAGE@ALIB):$(@PACKAGE@O) $(@PACKAGE@DO) @MODULE@/module.mk
211ifndef ALIQUIET
212 @echo "***** Linking static library $@ *****"
213endif
214 $(MUTE)TMPDIR=/tmp/@MODULE@$$$$.`date +%M%S` ; \
117cfc60 215 export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \
2d8cad5a 216 find $(CURDIR)/@MODULE@/tgt_$(ALICE_TARGET) -name '*.o' -exec ln -s {} . \; ;\
7930dd19 217 \rm -f $(CURDIR)/$@ ;\
218 TMPLIB=$(notdir $(@PACKAGE@LIB)); export TMPLIB;\
043a26ce 219 $(ALLD) $(ALFLAGS) $(CURDIR)/$@ $(notdir $(@PACKAGE@O) $(@PACKAGE@DO)) $(@PACKAGE@ELIBSDIR) $(@PACKAGE@ELIBS) $(ALLIB);\
220 cd $(CURDIR) ; \rm -rf $$TMPDIR
2d8cad5a 221 $(MUTE)chmod a-w $@
222
223
f0a26826 224$(@PACKAGE@BIN):$(@PACKAGE@O) $(@PACKAGE@DO) @MODULE@/module.mk
15142e2f 225ifndef ALIQUIET
226 @echo "***** Making executable $@ *****"
227endif
2d8cad5a 228ifeq ($(ALIPROFILE),YES)
2d8cad5a 229 $(MUTE)$(LD) $(LDFLAGS) $(@PACKAGE@O) $(ARLIBS) $(SHLIBS) $(LIBS) $(EXEFLAGS) -o $@
2d8cad5a 230else
231 $(MUTE)$(LD) $(LDFLAGS) $(@PACKAGE@O) $(@PACKAGE@DO) $(BINLIBDIRS) $(@PACKAGE@ELIBSDIR) $(@PACKAGE@ELIBS) $(LIBS) $(EXEFLAGS) -o $@
232endif
f0a26826 233
6bb8c070 234$(@PACKAGE@DS): $(@PACKAGE@CINTHDRS) $(@PACKAGE@DH) @MODULE@/module.mk
15142e2f 235ifndef ALIQUIET
f0a26826 236 @echo "***** Creating $@ *****";
15142e2f 237endif
f0a26826 238 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
043a26ce 239 @\rm -f $(patsubst %.cxx,%.d, $@)
67fd7264 240 $(MUTE)rootcint -f $@ -c $(@PACKAGE@DEFINE) $(CINTFLAGS) $(@PACKAGE@INC) $(@PACKAGE@CINTHDRS) $(@PACKAGE@DH)
f0a26826 241
242$(@PACKAGE@DO): $(@PACKAGE@DS)
15142e2f 243ifndef ALIQUIET
244 @echo "***** Compiling $< *****";
245endif
117cfc60 246 $(MUTE)$(CXX) $(@PACKAGE@DEFINE) -c $(@PACKAGE@INC) -I$(ALICE_ROOT) $< -o $@ $(@PACKAGE@DCXXFLAGS)
f0a26826 247
248#Different targets for the module
249
5edd655b 250ifeq ($(TYPE),lib)
5864aa62 251all-@PACKAGE@: $(@PACKAGE@LIB)
40c469d5 252ifneq ($(DYEXT),)
253all-@PACKAGE@: $(@PACKAGE@DLIB)
254endif
5edd655b 255else
256all-@PACKAGE@: $(@PACKAGE@BIN)
257endif
258
f0a26826 259depend-@PACKAGE@: $(@PACKAGE@DEP)
260
261# determination of object files
262$(MODDIRO)/%.o: $(MODDIR)/%.cxx $(MODDIRO)/%.d
15142e2f 263ifndef ALIQUIET
264 @echo "***** Compiling $< *****";
265endif
f0a26826 266 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
67fd7264 267 $(MUTE)$(CXX) $(@PACKAGE@DEFINE) -c $(@PACKAGE@INC) $< -o $@ $(@PACKAGE@CXXFLAGS)
f0a26826 268
269$(MODDIRO)/%.o: $(MODDIR)/%.F $(MODDIRO)/%.d
15142e2f 270ifndef ALIQUIET
271 @echo "***** Compiling $< *****";
272endif
f0a26826 273 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
15142e2f 274 $(MUTE)$(F77) -c $(@PACKAGE@INC) $< -o $@ $(@PACKAGE@FFLAGS)
f0a26826 275
276$(MODDIRO)/%.o: $(MODDIR)/%.f $(MODDIRO)/%.d
15142e2f 277ifndef ALIQUIET
278 @echo "***** Compiling $< *****";
279endif
f0a26826 280 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
15142e2f 281 $(MUTE)$(F77) -c $(@PACKAGE@INC) $< -o $@ $(@PACKAGE@FFLAGS)
f0a26826 282
283$(MODDIRO)/%.o: $(MODDIR)/%.c $(MODDIRO)/%.d
15142e2f 284ifndef ALIQUIET
285 @echo "***** Compiling $< *****";
286endif
f0a26826 287 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
67fd7264 288 $(MUTE)$(CC) $(@PACKAGE@DEFINE) -c $(@PACKAGE@INC) $< -o $@ $(@PACKAGE@CFLAGS)
f0a26826 289
290$(@PACKAGE@DDEP): $(@PACKAGE@DS)
15142e2f 291ifndef ALIQUIET
f0a26826 292 @echo "***** Making dependencies for $< *****";
15142e2f 293endif
f0a26826 294 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
295 @share/alibtool depend "$(@PACKAGE@ELIBSDIR) $(@PACKAGE@INC) $(DEPINC) $<" > $@
296
d47d6108 297$(MODDIRO)/%.d: $(MODDIRS)/%.cxx
15142e2f 298ifndef ALIQUIET
f0a26826 299 @echo "***** Making dependencies for $< *****";
15142e2f 300endif
f0a26826 301 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
67fd7264 302 @share/alibtool depend "$(@PACKAGE@DEFINE) $(@PACKAGE@ELIBSDIR) $(@PACKAGE@INC) $(DEPINC) $<" > $@
896cb507 303$(MODDIRO)/%.d: $(MODDIRS)/%.f
15142e2f 304ifndef ALIQUIET
f0a26826 305 @echo "***** Making dependencies for $< *****";
15142e2f 306endif
f0a26826 307 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
896cb507 308 @share/alibtool dependF "$(@PACKAGE@ELIBSDIR) $(@PACKAGE@INC) $(DEPINC) $<" > $@
309$(MODDIRO)/%.d: $(MODDIRS)/%.F
15142e2f 310ifndef ALIQUIET
f0a26826 311 @echo "***** Making dependencies for $< *****";
15142e2f 312endif
f0a26826 313 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
15142e2f 314 $(MUTE)share/alibtool dependF "$(@PACKAGE@ELIBSDIR) $(@PACKAGE@INC) $(DEPINC) $<" > $@
896cb507 315$(MODDIRO)/%.d: $(MODDIRS)/%.c
15142e2f 316ifndef ALIQUIET
f0a26826 317 @echo "***** Making dependencies for $< *****";
15142e2f 318endif
f0a26826 319 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
67fd7264 320 @share/alibtool depend "$(@PACKAGE@DEFINE) $(@PACKAGE@ELIBSDIR) $(@PACKAGE@INC) $(DEPINC) $<" > $@
b9d0a01d 321
7e96fcc7 322@PACKAGE@CHECKS := $(patsubst %.cxx,@MODULE@/check/%.viol,$(SRCS))
b9d0a01d 323
7e96fcc7 324check-@MODULE@: $(@PACKAGE@CHECKS)
b9d0a01d 325
326# IRST coding rule check
7e96fcc7 327@MODULE@/check/%.i : @MODULE@/%.cxx
b9d0a01d 328 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
329 $(MUTE)$(CXX) -E $(@PACKAGE@DEFINE) $(@PACKAGE@INC) $< > $@ $(@PACKAGE@CXXFLAGS)
330 @cd $(dir $@) ; $(IRST_INSTALLDIR)/patch/patch4alice.prl $(notdir $@)
331
eec15521 332# IRST coding rule check
333@MODULE@/check/$(SUBDIR)/%.viol : @MODULE@/check/$(SUBDIR)/%.i
334 @cd @MODULE@ ; [ -r @MODULE@ ] || ln -s ../@MODULE@ @MODULE@
88eed770 335 $(MUTE)echo $@ ; $(CODE_CHECK) $< ./@MODULE@/$(@PACKAGE@SDIR) > $@
eec15521 336
b9d0a01d 337# IRST coding rule check
7e96fcc7 338@MODULE@/check/%.viol : @MODULE@/check/%.i
339 @cd @MODULE@ ; [ -r @MODULE@ ] || ln -s ../@MODULE@ @MODULE@
88eed770 340 $(MUTE)echo $@ ; $(CODE_CHECK) $< ./@MODULE@ > $@
b9d0a01d 341
342@PACKAGE@PREPROC = $(patsubst %.viol,%.i,$(@PACKAGE@CHECKS))
343
344@PACKAGE@REVENGS = $(patsubst %.viol,%.ii,$(@PACKAGE@CHECKS))
345
346.SECONDARY: $(@PACKAGE@REVENGS) $(@PACKAGE@PREPROC)
347
348reveng-@PACKAGE@: @PACKAGE@/check/classDiagram.dot
349
350@PACKAGE@/check/classDiagram.dot: $(@PACKAGE@PREPROC)
351 @$(REV_ENG) $^
352 @-mv classDiagram.dot $@
353
354revdisp-@PACKAGE@: reveng-@PACKAGE@
355 @echo revdisp for @PACKAGE@
356 @cd @PACKAGE@/check ; \
357 $(IRST_INSTALLDIR)/webreveng/create-class-diagram-pages.sh
358 @sed -e "s/\@PACKAGE\@/@PACKAGE@/g" < $(ALICE_ROOT)/build/HomePage.html > @PACKAGE@/check/HomePage.html
359