Returned to old version where parameters are given at first point.
[u/mrichter/AliRoot.git] / JETAN / Makefile
CommitLineData
03747640 1# $Id$
2#
3# Makefile for the jetan package (standalone)
4
5ifdef ALIVERBOSE
6MUTE:=
7else
8MUTE:=@
9endif
10
11#-------------------------------------------------------------------------------
12# Include library definition
13
14include $(ALICE_ROOT)/build/Makefile.config
15
16#-------------------------------------------------------------------------------
17# Location where to install libraries and binaries and common header files
18
19LIBPATH := ./lib/tgt_$(ALICE_TARGET)
20BINPATH := ./bin/tgt_$(ALICE_TARGET)
21EXPORTDIR := $(ALICE_ROOT)/include
22BINLIBDIRS := -L$(ALICE_ROOT)/$(LIBPATH)
23
24#-------------------------------------------------------------------------------
25# Include machine dependent macros
26
27include $(ALICE_ROOT)/build/Makefile.$(ALICE_TARGET)
28
29#-------------------------------------------------------------------------------
30# Check if called with debug
31
32ifeq ($(ALIDEBUG),YES)
33override ALICE_TARGET := $(ALICE_TARGET)DEBUG
34FFLAGS := -g $(filter-out -O%,$(FFLAGS))
35CXXFLAGS := -g $(filter-out -O%,$(CXXLAGS))
36CFLAGS := -g $(filter-out -O%,$(CLAGS))
37SOFLAGS := -g $(filter-out -O%,$(SOFLAGS))
38LDFLAGS := -g $(filter-out -O%,$(LDFLAGS))
39endif
40
41#-------------------------------------------------------------------------------
42# Check if called with profile
43
44ifeq ($(ALIPROFILE),YES)
45override ALICE_TARGET := $(ALICE_TARGET)PROF
46FFLAGS += -pg
47CXXFLAGS += -pg
48CFLAGS += -pg
49SOFLAGS += -pg
50LDFLAGS += -pg
51endif
52
53#-------------------------------------------------------------------------------
54# Check if DATE is installed
55
56ifdef DATE_ROOT
57DATEFLAGS = -DALI_DATE -D${DATE_SYS} -DDATE_SYS=${DATE_SYS} -Dlong32=${DATE_LONG32} \
58 -Dlong64=${DATE_LONG64} -DdatePointer=${DATE_POINTER}
59CXXFLAGS += $(DATEFLAGS)
60CFLAGS += $(DATEFLAGS)
61CINTFLAGS += $(DATEFLAGS)
62DEPINC += $(DATEFLAGS)
63endif
64
65#-------------------------------------------------------------------------------
66# Default include dirs for C++, Fortran, Cint, and dependencies
67# The module directory will be added by each module
68
69GENINC := -I$(ALICE_ROOT)/include -I$(shell root-config --incdir)
70CXXFLAGS += $(GENINC)
71CXXFLAGSNO += $(GENINC)
72CINTFLAGS += $(GENINC)
73DEPINC += $(GENINC)
74
75LIBS := $(GLIBS) $(ROOTLIBS) $(SYSLIBS)
76
77#Determine if it's a library or a executable
78TYPE=lib
79
80# Package head directory, source and include directories
81CURDIR=$(shell pwd)
82MODDIR:=.
83MODDIRS:=$(MODDIR)
84MODDIRI:=$(MODDIR)
85MODDIRO:=./.objs
86
87# Reseting variables before importing pkg-file
88SRCS:=
89HDRS:=
90FSRCS:=
91DHDR:=
92CSRCS:=
93CHDRS:=
94EINCLUDE:=
95EDEFINE:=
96ELIBS:=
97ELIBSDIR:=
98PACKFFLAGS:=
99PACKCXXFLAGS:=
100PACKCFLAGS:=
101PACKDYFLAGS:=
102PACKSOFLAGS:=
103EXPORT:=
104EHDRS:=
105CINTHDRS:=
106ARLIBS:=
107SHLIBS:=
108SUBDIR:=
109
110include libJETAN.pkg
111
112ifndef PACKFFLAGS
113JETANFFLAGS:=$(FFLAGS)
114else
115JETANFFLAGS:=$(PACKFFLAGS)
116endif
117
118ifndef PACKCFLAGS
119JETANCFLAGS:=$(CFLAGS)
120else
121JETANCFLAGS:=$(PACKCFLAGS)
122endif
123
124ifndef PACKCXXFLAGS
125JETANCXXFLAGS:=$(CXXFLAGS)
126else
127JETANCXXFLAGS:=$(PACKCXXFLAGS)
128endif
129
130ifndef PACKSOFLAGS
131JETANSOFLAGS:=$(SOFLAGS)
132else
133JETANSOFLAGS:=$(PACKSOFLAGS)
134endif
135
136ifdef DYEXT
137ifndef PACKDYFLAGS
138JETANDYFLAGS:=$(DYFLAGS)
139else
140JETANDYFLAGS:=$(PACKDYFLAGS)
141endif
142endif
143
144ifndef PACKDCXXFLAGS
145JETANDCXXFLAGS:=$(CXXFLAGSNO)
146else
147JETANDCXXFLAGS:=$(PACKDCXXFLAGS)
148endif
149
150
151ifdef DHDR
152WITHDICT=YES
153else
154WITHDICT=
155endif
156
157# Headerfiles exported to common place:
158JETANEXPORT:=$(EXPORT)
159JETANEXPORTDEST:=$(patsubst %,$(EXPORTDIR)/%,$(EXPORT))
160
161
162#Extra include,libs, defines etc.
163
042d3031 164JETANDEFINE:=$(EDEFINE) -DNOUQHEADERINFO
03747640 165
042d3031 166JETANINC:=$(patsubst %,-I$(ALICE_ROOT)/%,$(EINCLUDE)) -I.
03747640 167
168JETANELIBS:=$(patsubst %,-l%,$(ELIBS))
169JETANELIBSDEP:=$(patsubst %,lib/tgt_$(ALICE_TARGET)/lib%.$(SOEXT),$(ELIBS))
170JETANELIBSDIR:=$(patsubst %,-L%,$(ELIBSDIR))
171
172#c sources and headers
173
174JETANCS:=$(patsubst %,$(MODDIR)/%,$(CSRCS))
175JETANCH:=$(patsubst %,$(MODDIR)/%,$(CHDRS))
176
177#Fortran sources
178JETANFS:=$(patsubst %,$(MODDIR)/%,$(FSRCS))
179
180#c++ sources and header
181JETANS:=$(patsubst %,$(MODDIR)/%,$(SRCS))
182JETANH:=$(patsubst %,$(MODDIR)/%,$(HDRS)) $(EHDRS)
183
184#c++ source subdirectories
185JETANSDIR:=$(SUBDIR)
186
187#############################################################################
188#
189# If special rootcint headerfiles is specified use them
190# else use all headers
191
192ifndef CINTHDRS
193JETANCINTHDRS:=$(JETANH)
194else
195JETANCINTHDRS:=$(CINTHDRS)
196endif
197#############################################################################
198
199# Package Dictionary
200
201JETANDH:=$(MODDIR)/$(DHDR)
202
203
204#All objects
205JETANCO:=$(patsubst %,$(MODDIRO)/%, $(CSRCS:.c=.o))
206TEMP:=$(FSRCS:.F=.o)
207JETANFO:=$(patsubst %,$(MODDIRO)/%, $(TEMP:.f=.o))
208JETANO:= $(patsubst %,$(MODDIRO)/%, $(SRCS:.cxx=.o)) $(JETANFO) $(JETANCO)
209
210
211
212ifdef WITHDICT
213 JETANDS:=$(MODDIRO)/G__JETAN.cxx
214 JETANDO:=$(MODDIRO)/G__JETAN.o
215 JETANDDEP:=$(JETANDO:.o=.d)
216 JETANDEP:=$(JETANO:.o=.d) $(JETANDDEP)
217else
218 JETANDS:=
219 JETANDO:=
220 JETANDDEP:=
221 JETANDEP:=$(JETANO:.o=.d)
222endif
223
224
225#The actual library file
226
227JETANLIB:=$(LIBPATH)/libJETAN.$(SOEXT)
228
229ifneq ($(DYEXT),)
230JETANDLIB:=$(LIBPATH)/libJETAN.$(DYEXT)
231endif
232
233JETANALIB:=$(LIBPATH)/libJETAN.$(AEXT)
234
235#Add this to the modules libs
236JETANLIBS += $(JETANLIB)
237JETANALIBS += $(JETANALIB)
238ifneq ($(DYEXT),)
239JETANDLIBS += $(JETANDLIB)
240endif
241
242#The actual binary file
243
244JETANBIN:=$(BINPATH)/JETAN
245
246#Add to modules list of binaries
247JETANBINS += $(JETANBIN)
248
249# Use in the main Makefile
250
251ifeq ($(TYPE),lib)
252ALLLIBS += $(JETANLIB)
253ALLALIBS += $(JETANALIB)
254ifneq ($(DYEXT),)
255ALLLIBS += $(JETANDLIB)
256endif
257BINLIBS += -lJETAN
258else
259ALLEXECS += $(JETANBIN)
260endif
261
262ifeq ($(DYEXT),)
263JETANLIB := $(JETANLIB)
264else
265JETANLIB := $(JETANLIB)
266endif
267
268# include all dependence files
269INCLUDEFILES +=$(JETANDEP)
270
271EXPORTFILES += $(JETANEXPORTDEST)
272
273#local rules
274
275#The exportfiles only include if any!!
276
277ifdef JETANEXPORT
278#$(JETANEXPORTDEST): $(patsubst %,JETAN/%,$(JETANEXPORT))
279
280$(JETANEXPORTDEST): $(EXPORTDIR)/%.h: JETAN/%.h
281ifndef ALIQUIET
282 @echo "***** Copying file $^ to $@ *****"
283endif
284 @[ -d $(dir $@) ] || mkdir -p $(dir $@)
285 @cp $^ $@
286endif
287
288#------------------------------------------------------------------------
289
290$(JETANLIB):$(JETANO) $(JETANDO)
291ifndef ALIQUIET
292 @echo "***** Linking library $@ *****"
293endif
294 $(MUTE)mkdir -p $(LIBPATH)
295 $(MUTE)TMPDIR=/tmp/JETAN$$$$.`date +%M%S` ; \
296 export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \
297 find $(CURDIR)/.objs/ -name '*.o' -exec ln -s {} . \; ;\
298 \rm -f $(CURDIR)/$@ ;\
299 TMPLIB=$(notdir $(JETANLIB)); export TMPLIB;\
300 $(SHLD) $(JETANSOFLAGS) -o $(CURDIR)/$@ $(notdir $(JETANO) $(JETANDO)) $(JETANELIBSDIR) $(JETANELIBS) $(SHLIB);\
301 chmod a-w $(CURDIR)/$@ ;\
302 cd $(ALICE_ROOT) ; \rm -rf $$TMPDIR
303
304ifneq ($(DYEXT),)
305$(JETANDLIB):$(JETANO) $(JETANDO)
306ifndef ALIQUIET
307 @echo "***** Linking library $@ *****"
308endif
309 $(MUTE)mkdir -p $(LIBPATH)
310 $(MUTE)TMPDIR=/tmp/JETAN$$$$.`date +%M%S` ; \
311 export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \
312 find $(CURDIR)/.objs/ -name '*.o' -exec ln -s {} . \; ;\
313 \rm -f $(CURDIR)/$@ ;\
314 $(DYLD) $(JETANDYFLAGS) -o $(CURDIR)/$@ $(notdir $(JETANO) $(JETANDO)) $(JETANELIBSDIR) $(JETANELIBS) $(DYLIB);\
315 chmod a-w $(CURDIR)/$@ ;\
316 cd $(ALICE_ROOT) ; \rm -rf $$TMPDIR
317endif
318
319#------------------------------------------------------------------------
320
321$(JETANALIB):$(JETANO) $(JETANDO)
322ifndef ALIQUIET
323 @echo "***** Linking static library $@ *****"
324endif
325 $(MUTE)mkdir -p $(LIBPATH)
326 $(MUTE)TMPDIR=/tmp/JETAN$$$$.`date +%M%S` ; \
327 export TMPDIR; mkdir -p $$TMPDIR ; cd $$TMPDIR ; \
328 find $(CURDIR)/JETAN/tgt_$(ALICE_TARGET) -name '*.o' -exec ln -s {} . \; ;\
329 \rm -f $(CURDIR)/$@ ;\
330 TMPLIB=$(notdir $(JETANLIB)); export TMPLIB;\
331 $(ALLD) $(ALFLAGS) $(CURDIR)/$@ $(notdir $(JETANO) $(JETANDO)) $(JETANELIBSDIR) $(JETANELIBS) $(ALLIB);\
332 cd $(CURDIR) ; \rm -rf $$TMPDIR
333 $(MUTE)chmod a-w $@
334
335
336$(JETANBIN):$(JETANO) $(JETANDO) $(JETANELIBSDEP)
337ifndef ALIQUIET
338 @echo "***** Making executable $@ *****"
339endif
340ifeq ($(ALIPROFILE),YES)
341 $(MUTE)$(LD) $(LDFLAGS) $(JETANO) $(ARLIBS) $(SHLIBS) $(LIBS) $(EXEFLAGS) -o $@
342else
343 $(MUTE)$(LD) $(LDFLAGS) $(JETANO) $(JETANDO) $(BINLIBDIRS) $(JETANELIBSDIR) $(JETANELIBS) $(LIBS) $(EXEFLAGS) -o $@
344endif
345
346$(JETANDS): $(JETANCINTHDRS) $(JETANDH)
347ifndef ALIQUIET
348 @echo "***** Creating $@ *****";
349endif
350 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
351 @\rm -f $(patsubst %.cxx,%.d, $@)
352 $(MUTE)rootcint -f $@ -c $(JETANDEFINE) $(CINTFLAGS) $(JETANINC) $(JETANCINTHDRS) $(JETANDH)
353
354$(JETANDO): $(JETANDS)
355ifndef ALIQUIET
356 @echo "***** Compiling $< *****";
357endif
358 $(MUTE)$(CXX) $(JETANDEFINE) -c $(JETANINC) -I$(ALICE_ROOT) $< -o $@ $(JETANDCXXFLAGS)
359
360#Different targets for the module
361
362ifeq ($(TYPE),lib)
363all-JETAN: $(JETANLIB)
364ifneq ($(DYEXT),)
365all-JETAN: $(JETANDLIB)
366endif
367else
368all-JETAN: $(JETANBIN)
369endif
370
371depend-JETAN: $(JETANDEP)
372
373# determination of object files
374$(MODDIRO)/%.o: $(MODDIR)/%.cxx $(MODDIRO)/%.d
375ifndef ALIQUIET
376 @echo "***** Compiling $< *****";
377endif
378 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
379 $(MUTE)$(CXX) $(JETANDEFINE) -c $(JETANINC) $< -o $@ $(JETANCXXFLAGS)
380
381$(MODDIRO)/%.o: $(MODDIR)/%.F $(MODDIRO)/%.d
382ifndef ALIQUIET
383 @echo "***** Compiling $< *****";
384endif
385 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
386 $(MUTE)$(F77) -c $(JETANINC) $< -o $@ $(JETANFFLAGS)
387
388$(MODDIRO)/%.o: $(MODDIR)/%.f $(MODDIRO)/%.d
389ifndef ALIQUIET
390 @echo "***** Compiling $< *****";
391endif
392 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
393 $(MUTE)$(F77) -c $(JETANINC) $< -o $@ $(JETANFFLAGS)
394
395$(MODDIRO)/%.o: $(MODDIR)/%.c $(MODDIRO)/%.d
396ifndef ALIQUIET
397 @echo "***** Compiling $< *****";
398endif
399 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
400 $(MUTE)$(CC) $(JETANDEFINE) -c $(JETANINC) $< -o $@ $(JETANCFLAGS)
401
402$(JETANDDEP): $(JETANDS)
403ifndef ALIQUIET
404 @echo "***** Making dependences for $< *****";
405endif
406 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
407 @$(ALICE_ROOT)/share/alibtool depend "$(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@
408
409$(MODDIRO)/%.d: $(MODDIRS)/%.cxx
410ifndef ALIQUIET
411 @echo "***** Making dependences for $< *****";
412endif
413 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
414 @$(ALICE_ROOT)/share/alibtool depend "$(JETANDEFINE) $(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@
415$(MODDIRO)/%.d: $(MODDIRS)/%.f
416ifndef ALIQUIET
417 @echo "***** Making dependences for $< *****";
418endif
419 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
420 @$(ALICE_ROOT)/share/alibtool dependF "$(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@
421$(MODDIRO)/%.d: $(MODDIRS)/%.F
422ifndef ALIQUIET
423 @echo "***** Making dependences for $< *****";
424endif
425 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
426 $(MUTE)share/alibtool dependF "$(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@
427$(MODDIRO)/%.d: $(MODDIRS)/%.c
428ifndef ALIQUIET
429 @echo "***** Making dependences for $< *****";
430endif
431 @(if [ ! -d '$(dir $@)' ]; then echo "***** Making directory $(dir $@) *****"; mkdir -p $(dir $@); fi;)
432 @$(ALICE_ROOT)/share/alibtool depend "$(JETANDEFINE) $(JETANELIBSDIR) $(JETANINC) $(DEPINC) $<" > $@
433
434.PRECIOUS: $(patsubst %.cxx,$(MODDIRO)/%.d,$(SRCS))
435.PRECIOUS: $(patsubst %.c,$(MODDIRO)/%.d,$(CSRCS))
436.PRECIOUS: $(patsubst %.F,$(MODDIRO)/%.d,$(patsubst %.f,$(MODDIRO)/%.d,$(FSRCS)))
437
438
439# Clean option for the whole module
440clean:
441ifndef ALIQUIET
442 @echo "***** Cleaning JETAN *****"
443endif
444 $(MUTE)rm -rf $(MODDIRO)
445 $(MUTE)rm -rf lib
446 $(MUTE)rm -rf $(BINPATH)