1 # Top level Makefile for AliRoot System
3 # Author: Jan-Erik Revsbech (revsbech@fys.ku.dk)
4 # Developed on idea of Boris Polichtchouk (Boris.Polichtchouk@cern.ch), 15/4/2001
14 CLEAN=$(findstring clean,$(MAKECMDGOALS))
16 #-------------------------------------------------------------------------------
17 # IRST coding rule check
19 IRST_INSTALLDIR=$(ALICE)/local/IRST
20 IRST_CONFIG_DIR=$(IRST_INSTALLDIR)/userConfig/ALICE
21 CLASSPATH=$(IRST_INSTALLDIR)
22 export CLASSPATH IRST_INSTALLDIR IRST_CONFIG_DIR
23 CODE_CHECK=java rules.ALICE.ALICERuleChecker
24 REV_ENG=$(IRST_INSTALLDIR)/scripts/revEng.sh
26 SMELL_DETECTOR_DIR=$(IRST_INSTALLDIR)/smell-detector
28 #-------------------------------------------------------------------------------
30 CXX := $(shell root-config --cxx)
31 F77 := $(shell root-config --f77)
32 CC := $(shell root-config --cc)
34 #-------------------------------------------------------------------------------
35 # Include machine dependent macros
37 -include build/Makefile.$(ALICE_TARGET)
39 #-------------------------------------------------------------------------------
40 # Check if called with debug
42 ifeq ($(ALIDEBUG),YES)
43 override ALICE_TARGET := $(ALICE_TARGET)DEBUG
44 FFLAGS := -g $(filter-out -O%,$(FFLAGS))
45 CXXFLAGS := -g $(filter-out -O%,$(CXXFLAGS))
46 CFLAGS := -g $(filter-out -O%,$(CFLAGS))
47 SOFLAGS := -g $(filter-out -O%,$(SOFLAGS))
48 LDFLAGS := -g $(filter-out -O%,$(LDFLAGS))
51 #-------------------------------------------------------------------------------
52 # Check if called with profile
54 ifeq ($(ALIPROFILE),YES)
55 override ALICE_TARGET := $(ALICE_TARGET)PROF
63 #-------------------------------------------------------------------------------
64 # Check if DATE is installed
66 ifneq ($(shell which date-config | grep "^/"),)
67 DATEFLAGS := -DALI_DATE $(shell date-config --cflags | tr \" \')
68 CXXFLAGS += $(DATEFLAGS)
69 CFLAGS += $(DATEFLAGS)
70 CINTFLAGS += $(DATEFLAGS)
71 DEPINC += $(DATEFLAGS)
72 DMONLIBS := $(shell date-config --monitorlibs)
74 DATEFLAGS := -D`uname` -DDATE_SYS=`uname` -Dlong32='int' \
75 -Dlong64='long long' -DdatePointer='long'
76 CXXFLAGS += $(DATEFLAGS)
77 CFLAGS += $(DATEFLAGS)
78 CINTFLAGS += $(DATEFLAGS)
79 DEPINC += $(DATEFLAGS)
83 #-------------------------------------------------------------------------------
85 ROOTCONFIG := root-config
86 ROOTLIBDIR := $(shell $(ROOTCONFIG) --libdir)
87 ROOTPLUGDIR := $(ROOTLIBDIR)/$(dir $(shell $(ROOTCONFIG) --version))
88 ROOTINCDIR := $(shell $(ROOTCONFIG) --incdir)
89 ROOTCLIBS := $(shell $(ROOTCONFIG) --glibs) \
103 CHECKALIEN := $(shell root-config --has-alien)
104 CHECKXML := $(shell root-config --has-xml)
106 #-------------------------------------------------------------------------------
107 # Location where to install libraries and binaries and common header files
109 LIBPATH := lib/tgt_$(ALICE_TARGET)
110 BINPATH := bin/tgt_$(ALICE_TARGET)
111 EXPORTDIR := $(ALICE_ROOT)/include
112 BINLIBDIRS := -L$(ALICE_ROOT)/$(LIBPATH)
114 #-------------------------------------------------------------------------------
118 $(warning MAKECMDGOALS=$(MAKECMDGOALS))
121 ALIROOTMODULES := STEER PHOS TRD TPC ZDC MUON PMD FMD TOF ITS \
122 ACORDE HMPID T0 BCM STRUCT EVGEN RALICE VZERO \
123 THijing THbtp EMCAL \
124 THerwig TEPEMGEN FASTSIM TPHIC RAW MONITOR ANALYSIS \
125 JETAN HLT LHC ESDCheck STAT TTherminator CORRFW DPMJET TDPMjet \
126 PWG0 PWG1 PWG2 PWG3 PWG4 TRIGGER
128 # Additional generators
129 ALIROOTMODULES += TUHKMgen
130 ALIROOTMODULES += EPOS
132 ifneq ($(shell $(ROOTCONFIG) --has-pythia8), no)
133 ALIROOTMODULES += PYTHIA8
136 ifneq ($(shell $(ROOTCONFIG) --has-opengl), no)
137 ALIROOTMODULES += EVE
140 ifeq ($(findstring TFluka,$(MAKECMDGOALS)),TFluka)
141 ALIROOTMODULES += TFluka
144 ifeq ($(findstring THydjet,$(MAKECMDGOALS)),THydjet)
145 ALIROOTMODULES += THydjet
148 ifeq ($(findstring SHUTTLE,$(MAKECMDGOALS)),SHUTTLE)
149 ALIROOTMODULES += SHUTTLE
152 CERNMODULES := LHAPDF HIJING MICROCERN HERWIG
153 ifneq ($(wildcard $(ROOTINCDIR)/TPythia6.h),)
154 CERNMODULES += PYTHIA6
157 MODULES := $(ALIROOTMODULES) $(CERNMODULES) ALIROOT
159 MODDIRS := $(MODULES)
161 #-------------------------------------------------------------------------------
162 # Default include dirs for C++, Fortran, Cint, and dependencies
163 # The module directory will be added by each module
165 GENINC := -I$(ALICE_ROOT)/include -I$(shell root-config --incdir)
166 RCFLAGS := $(shell root-config --cflags)
167 RLFLAGS := $(shell root-config --ldflags)
168 CXXFLAGS += $(GENINC) $(RCFLAGS)
169 CXXFLAGSNO += $(GENINC) $(RCFLAGS)
170 CFLAGS += $(GENINC) $(RCFLAGS)
171 CINTFLAGS += $(GENINC) $(RCFLAGS)
173 LDFLAGS += $(RLFLAGS)
174 SOFLAGS += $(RLFLAGS)
177 #-------------------------------------------------------------------------------
178 # Libraries to link binaries against
179 # Libraries will be linked against SHLIB
182 ALILIBS := -L$(LIBDIR) -lMUON -lTPC -lPMD -lTRD -lFMD -lTOF \
183 -lITS -lPHOS -lACORDE -lHMPID -lVZERO -lZDC -lSTRUCT \
184 -lT0 -lEVGEN -lSTEER -lTRIGGER
186 LIBS := $(ROOTCLIBS) $(ROOTPLIBS) $(SYSLIBS)
188 ARVERSIONFILE := $(EXPORTDIR)/ARVersion.h
189 SVNREV := $(strip $(shell LANG=C LANGUAGE=C svn info | grep "Last Changed Rev:" | \
191 SVNBRANCH := $(subst //alisoft.cern.ch/AliRoot/,,$(shell svn info | grep "URL:" | cut -d: -f3 ))
193 #-------------------------------------------------------------------------------
196 default: $(ARVERSIONFILE)
197 $(MUTE)$(MAKE) aliroot
199 #-------------------------------------------------------------------------------
200 # Write header file with aliroot svn version and url
202 $(ARVERSIONFILE): $(ALICE_ROOT)/.svn/entries $(EXPORTDIR)
203 $(MUTE)rm -f $(ARVERSIONFILE)
204 @echo "***** Making $(ARVERSIONFILE) *****"
205 @echo "#ifndef ALIROOT_ARVersion" >> $@
206 @echo "#define ALIROOT_ARVersion" >> $@
207 @echo "#define ALIROOT_SVN_REVISION $(SVNREV)" >> $@
208 @echo "#define ALIROOT_SVN_BRANCH \"$(SVNBRANCH)\"" >> $@
210 #-------------------------------------------------------------------------------
211 # Each module will add to these macros
219 #-------------------------------------------------------------------------------
220 # Dependencies of module.mk files if not cleaning
223 include build/module.dep
226 #-------------------------------------------------------------------------------
227 # Check if module.mk is present for the library
229 %.mk: build/module.tpl build/header.tpl build/clean.tpl share/alibtool
231 @echo "***** Creating $@ file *****";
233 @share/alibtool mkmodule $(patsubst %/module.mk,%,$@) > $@;
235 #-------------------------------------------------------------------------------
236 # If making modules, not not include anything
238 ifeq ($(findstring modules,$(MAKECMDGOALS)),)
240 #-------------------------------------------------------------------------------
241 # Include the modules
243 -include $(patsubst %,%/module.mk,$(MODULES))
245 #-------------------------------------------------------------------------------
246 # If cleaning, do not include dependencies or module.mk files.
250 #-------------------------------------------------------------------------------
251 # Include dependencies if not making them!
253 ifneq ($(MAKECMDGOALS),depend)
254 ifneq ($(MAKECMDGOALS),)
257 $(warning INCLUDEFILES=$(INCLUDEFILES))
259 -include $(INCLUDEFILES)
266 #-------------------------------------------------------------------------------
267 # Include dummy dependency file *MUST* be last includefile
269 include build/dummy.d
272 #-------------------------------------------------------------------------------
275 .PHONY: alilibs aliroot makedistr clean distclean clean-all \
276 htmldoc profile modules depend
278 modules: $(patsubst %,%/module.mk,$(MODULES))
280 ifeq ($(ALIPROFILE),YES)
281 alilibs: $(LIBPATH) modules $(ALLLIBS) $(ALLALIBS)
283 alilibs: $(LIBPATH) modules $(ALLLIBS)
286 aliroot: alilibs $(BINPATH) $(ALLEXECS)
288 ALIRECO.par: macros/loadlibsrec.C STEER/PROOF-INF.ALIRECO/SETUP.C
289 $(MUTE)echo "***** Creating package archive" $@ "*****"
290 $(MUTE)rm -rf ALIRECO
291 $(MUTE)mkdir -p ALIRECO/PROOF-INF
292 $(MUTE)cat $^ > ALIRECO/PROOF-INF/SETUP.C
293 (tar cfzh $@ ALIRECO 2> /dev/null && echo "Package archive" $@ "created in" $(PWD)/$@) || (tar cfzh /tmp/$@ ALIRECO 2> /dev/null && echo "Package archive" $@ "created in /tmp/"$@)
294 $(MUTE)rm -rf ALIRECO
296 ROOTALIBDIR:=$(shell root-config --libdir)
298 ALIMDCSPECFILE=$(RAWDIRO)/alimdc.spec
299 ALIMDCVERSION=$(subst -,.,$(notdir $(subst /RAW/mdc.h,,$(shell svn info RAW/mdc.h | grep "URL:" | cut -d: -f3 ))))
300 ALIMDCRELEASE=$(firstword $(shell svn info RAW/mdc.h | grep "Revision:" | cut -d: -f2 ))
302 alimdc-rpm: alimdc-static alimdc-specfile
303 $(MUTE)rm -rf alimdc-root
304 $(MUTE)mkdir -p alimdc-root/opt/alimdc/lib
305 $(MUTE)mkdir -p alimdc-root/opt/alimdc/include
306 $(MUTE)cp RAW/mdc.h alimdc-root/opt/alimdc/include
307 $(MUTE)cp $(LIBPATH)/libAliMDC.a \
308 $(ROOTALIBDIR)/libRoot.a \
309 $(ROOTALIBDIR)/libfreetype.a $(ROOTALIBDIR)/libpcre.a \
310 alimdc-root/opt/alimdc/lib
312 $(MUTE)case `uname -m` in \
313 i?86*) ALIMDCARCHDIR=i386;;\
314 ia64*) ALIMDCARCHDIR=ia64;;\
315 x86_64*) ALIMDCARCHDIR=x86_64;;\
316 *) echo "Unknown architecture: `uname -m`"; exit 1;;\
318 mkdir -p RPMS/$$ALIMDCARCHDIR; \
319 rpmbuild --verbose --define "_topdir $(ALICE_ROOT)" --define "_tmppath $(ALICE_ROOT)" -bb $(ALIMDCSPECFILE); \
320 cp -p RPMS/$$ALIMDCARCHDIR/alimdc-*.rpm .;
321 $(MUTE)rm -rf alimdc-root
323 @echo "***** alimdc RPM created and put $(ALICE_ROOT) folder *****"
325 alimdc-specfile: $(RAWDIRO)
326 $(MUTE)rm -rf $(ALIMDCSPECFILE)
327 @echo "***** Making alimdc RPM spec-file $(ALIMDCSPECFILE) *****"
328 @echo "# RPM specfile for alimdc static libs" >> $(ALIMDCSPECFILE)
329 @echo "# Package contains both ROOT and AliRoot" >> $(ALIMDCSPECFILE)
330 @echo "# static libs needed by mStreamRecorder" >> $(ALIMDCSPECFILE)
331 @echo "# in order to ROOT-ify the incoming raw" >> $(ALIMDCSPECFILE)
332 @echo "# data" >> $(ALIMDCSPECFILE)
333 @echo "# Example how-to build alimdc RPM:" >> $(ALIMDCSPECFILE)
334 @echo "# cd $ALICE_ROOT" >> $(ALIMDCSPECFILE)
335 @echo "# make alimdc-rpm" >> $(ALIMDCSPECFILE)
336 @echo "" >> $(ALIMDCSPECFILE)
337 @echo "Summary: AliMDC static libraries" >> $(ALIMDCSPECFILE)
338 @echo "Name: alimdc" >> $(ALIMDCSPECFILE)
339 @echo "Version: $(ALIMDCVERSION)" >> $(ALIMDCSPECFILE)
340 @echo "Release: $(ALIMDCRELEASE)" >> $(ALIMDCSPECFILE)
341 @echo "# Copyright: CERN Alice Off-line" >> $(ALIMDCSPECFILE)
342 @echo "License: CERN Alice Off-line" >> $(ALIMDCSPECFILE)
343 @echo "Vendor: ALICE Core Off-line Group" >> $(ALIMDCSPECFILE)
344 @echo "URL: http://aliceinfo.cern.ch" >> $(ALIMDCSPECFILE)
345 @echo "Group: Applications/Alice" >> $(ALIMDCSPECFILE)
346 @echo "Prefix: /opt/%{name}" >> $(ALIMDCSPECFILE)
347 @echo "BuildRoot: %{_tmppath}/%{name}-root" >> $(ALIMDCSPECFILE)
348 @echo "" >> $(ALIMDCSPECFILE)
349 @echo "# automatic dependencies" >> $(ALIMDCSPECFILE)
350 @echo "AutoReqProv: yes" >> $(ALIMDCSPECFILE)
351 @echo "" >> $(ALIMDCSPECFILE)
352 @echo "# list here required RPM packages for runtime" >> $(ALIMDCSPECFILE)
353 @echo "Requires: glibc" >> $(ALIMDCSPECFILE)
354 @echo "" >> $(ALIMDCSPECFILE)
355 @echo "Provides: alimdc" >> $(ALIMDCSPECFILE)
356 @echo "" >> $(ALIMDCSPECFILE)
357 @echo "# description of the package" >> $(ALIMDCSPECFILE)
358 @echo "%description" >> $(ALIMDCSPECFILE)
359 @echo "Package contains both ROOT and AliRoot" >> $(ALIMDCSPECFILE)
360 @echo "static libs needed by mStreamRecorder" >> $(ALIMDCSPECFILE)
361 @echo "in order to ROOT-ify the incoming raw" >> $(ALIMDCSPECFILE)
362 @echo "data. The package version correspond to" >> $(ALIMDCSPECFILE)
363 @echo "the AliRoot one." >> $(ALIMDCSPECFILE)
364 @echo "" >> $(ALIMDCSPECFILE)
365 @echo "# list of files to be installed" >> $(ALIMDCSPECFILE)
366 @echo "%files" >> $(ALIMDCSPECFILE)
367 @echo "%defattr (-,root,root)" >> $(ALIMDCSPECFILE)
368 @echo "%{prefix}/lib/libAliMDC.a" >> $(ALIMDCSPECFILE)
369 @echo "%{prefix}/lib/libRoot.a" >> $(ALIMDCSPECFILE)
370 @echo "%{prefix}/lib/libpcre.a" >> $(ALIMDCSPECFILE)
371 @echo "%{prefix}/lib/libfreetype.a" >> $(ALIMDCSPECFILE)
372 @echo "%{prefix}/include/mdc.h" >> $(ALIMDCSPECFILE)
374 alimdc-static: $(LIBPATH) $(BINPATH) $(RAWDatabaseALIB) $(MDCALIB) $(ESDALIB) $(STEERBaseALIB) $(alimdcCXXO)
375 $(MUTE)rm -rf $(LIBPATH)/libAliMDC.a
377 mkdir junk && cd junk && ar x ../$(RAWDatabaseALIB) && ar x ../$(MDCALIB) && ar x ../$(ESDALIB) && ar x ../$(STEERBaseALIB) && ar r ../$(LIBPATH)/libAliMDC.a *.o && cd .. && rm -rf junk
378 $(LD) $(LDFLAGS) -o $(BINPATH)/alimdca $(alimdcCXXO) \
379 $(LIBPATH)/libAliMDC.a \
380 $(ROOTALIBDIR)/libRoot.a \
381 $(ROOTALIBDIR)/libfreetype.a $(ROOTALIBDIR)/libpcre.a \
382 -pthread -ldl -lcurses
384 alilibs-static: $(LIBPATH) modules $(ALLALIBS)
386 include build/MakefileDA
388 #-------------------------------------------------------------------------------
389 # Single Makefile "distribution": Makefile + modules + mkdepend scripts
390 makedistr: $(MODULES)
391 tar -cvf MakeDistr.tar $(patsubst %,%/*.pkg,$(MODULES)) \
392 Makefile create build/*
396 depend: $(INCLUDEFILES)
400 @echo "***** Entering DEBUG mode. *****"
402 @(export ALIDEBUG=YES && $(MAKE) aliroot)
406 @echo "***** Entering PROFILE mode. *****"
408 @(export ALIPROFILE=YES && $(MAKE) aliroot)
412 @echo "***** Making $@ *****"
418 @echo "***** Making $@ *****"
424 @echo "***** Making $@ *****"
428 build/dummy.d: $(EXPORTFILES)
429 @(if [ ! -f $@ ] ; then \
434 @echo "***** No target clean, use one of these *****"
435 @echo " clean-aliroot : Clean up all aliroot libraries"
436 @echo " clean-MODULENAME : Clean everything from module MODULENAME"
437 @echo " clean-all : Cleans up everything, including cern libraires"
438 @echo " distclean : Like clean-all + clean all tgt_*'s"
439 @echo " clean-modules : Clean all module.mk files in all modules"
440 @echo " clean-libs : Clean all libraries (not object files)"
441 @echo "********************************************"
443 clean-all: clean-modules clean-libs clean-bins
445 @echo "***** Cleaning up everything ****"
447 $(MUTE)rm -rf $(patsubst %,%/tgt_$(ALICE_TARGET),$(MODULES))
448 $(MUTE)rm -rf $(EXPORTDIR)
451 $(MUTE)rm -rf */tgt_* bin lib
453 #-------------------------------------------------------------------------------
454 # This cleans only libraries that are not CERN-libraries
456 clean-aliroot: $(patsubst %,%/module.mk,$(ALIROOTMODULES)) $(patsubst %,clean-%,$(ALIROOTMODULES))
458 CHECKMODULES := $(MODULES)
459 CHECKMODULES := $(filter-out TPHIC,$(CHECKMODULES))
460 CHECKMODULES := $(filter-out LHAPDF,$(CHECKMODULES))
461 CHECKMODULES := $(filter-out MICROCERN,$(CHECKMODULES))
463 check-all: $(patsubst %,%/module.mk,$(CHECKMODULES)) $(patsubst %,check-%,$(CHECKMODULES))
465 smell-all: $(patsubst %,%/module.mk,$(CHECKMODULES)) $(patsubst %,smell-%,$(CHECKMODULES))
467 reveng-all: $(patsubst %,%/module.mk,$(CHECKMODULES)) $(patsubst %,reveng-%,$(CHECKMODULES))
469 revdisp-all: $(patsubst %,%/module.mk,$(CHECKMODULES)) $(patsubst %,revdisp-%,$(CHECKMODULES))
471 smell-all: $(patsubst %,%/module.mk,$(CHECKMODULES)) $(patsubst %,smell-%,$(CHECKMODULES))
475 @echo "***** Cleaning up G__ files *****"
477 $(MUTE)rm -rf */tgt_$(ALICE_TARGET)/G__*
481 @echo "***** Cleaning up module.mk and temporary compilation files *****"
483 $(MUTE)rm -rf $(patsubst %,%/module.mk,$(MODULES))
484 $(MUTE)rm -rf $(patsubst %,%/tgt_$(ALICE_TARGET),$(MODULES))
488 @echo "***** Cleaning up dependencies *****"
490 $(MUTE)echo rm `find . -name "*.d"`
494 @echo "***** Cleaning up .o files *****"
496 $(MUTE)echo rm `find . -name "*.o"`
500 @echo "***** Cleaning up library files *****"
502 $(MUTE)rm -rf lib/tgt_$(ALICE_TARGET)/*
506 @echo "***** Cleaning up binary files *****"
508 $(MUTE)rm -rf bin/tgt_$(ALICE_TARGET)
510 clean-check-all: $(patsubst %,%/module.mk,$(CHECKMODULES)) $(patsubst %,clean-check-%,$(CHECKMODULES))
512 clean-smell-all: $(patsubst %,%/module.mk,$(CHECKMODULES)) $(patsubst %,clean-smell-%,$(CHECKMODULES))
514 clean-reveng-all: $(patsubst %,%/module.mk,$(CHECKMODULES)) $(patsubst %,clean-reveng-%,$(CHECKMODULES))
517 @rm -rf html/roothtml
521 aliroot -q -b "mkhtml.C(0,1)" ;\
522 ls ../macros/*.C > /tmp/macros ;\
523 for i in $(ALIROOTMODULES) ; do \
524 ls ../$$i/*.C 2>/dev/null >> /tmp/macros ;\
526 for i in `cat /tmp/macros` ; do \
528 aliroot -b -q "mkhtml.C(\"$$i\")" > /dev/null ;\
531 @ln -s ../picts html/picts
532 @ln -s ../../picts html/roothtml/picts
533 @ln -s ../../../picts html/roothtml/src/picts
534 @ln -s ../../../picts html/roothtml/examples/picts