Adding flexibility to submission macros
[u/mrichter/AliRoot.git] / PWG0 / Makefile
1 # $Id$
2
3 include Makefile.arch
4
5 PACKAGE = PWG0base
6 default-target: lib$(PACKAGE).so
7
8 ALICEINC      = -I.
9
10 ### define include dir for local case and par case
11 ifneq ($(ESD_INCLUDE),)
12    ALICEINC += -I../$(ESD_INCLUDE)
13         ifneq ($(STEERBase_INCLUDE),)
14                 ALICEINC += -I../$(STEERBase_INCLUDE)
15         endif                           
16         ifneq ($(AOD_INCLUDE),)
17                 ALICEINC += -I../$(AOD_INCLUDE)
18         endif
19         ifneq ($(ANALYSIS_INCLUDE),)
20                 ALICEINC += -I../$(ANALYSIS_INCLUDE)
21         endif
22         ifneq ($(ANALYSISalice_INCLUDE),)
23                 ALICEINC += -I../$(ANALYSISalice_INCLUDE)
24         endif
25 else
26   ifneq ($(ALICE_ROOT),)
27     ALICEINC += -I$(ALICE_ROOT)/include -I$(ALICE_ROOT)/PYTHIA6 -I$(ALICE_ROOT)/EVGEN -I$(ALICE_ROOT)/RAW -I$(ALICE_ROOT)/TPC  -I$(ALICE_ROOT)/PWG0
28 else
29   endif
30 endif
31
32 # for building of PWG0dep.par
33 ifneq ($(PWG0base_INCLUDE),)
34   ALICEINC += -I../$(PWG0base_INCLUDE)
35 endif
36
37 CXXFLAGS     += $(ALICEINC) -g
38
39 SRCS     = $(wildcard *.cxx */*.cxx)
40 HDRS     = $(SRCS:.cxx=.h)
41 DHDR     = $(PACKAGE)LinkDef.h
42
43 DHDR_PWG0base := $(DHDR)
44 HDRS_PWG0base := $(HDRS)
45 SRCS_PWG0base := $(SRCS) G__$(PACKAGE).cxx
46 OBJS_PWG0base := $(SRCS_PWG0base:.cxx=.o)
47
48 PARFILE       = $(PACKAGE).par
49
50 lib$(PACKAGE).so: $(OBJS_PWG0base)
51         @echo "Linking" $@ ...
52         @/bin/rm -f $@
53 ifeq ($(PLATFORM),macosx)
54 # We need to make both the .dylib and the .so
55                 $(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@
56 ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
57 ifeq ($(MACOSX_MINOR),4)
58                 ln -sf $@ $(subst .$(DllSuf),.so,$@)
59 else
60                 $(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
61                    $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
62 endif
63 endif
64 else
65 ifeq ($(PLATFORM),win32)
66                 bindexplib $* $^ > $*.def
67                 lib -nologo -MACHINE:IX86 $^ -def:$*.def \
68                    $(OutPutOpt)$(EVENTLIB)
69                 $(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \
70                    $(OutPutOpt)$@
71 else
72                 $(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(EXPLLINKLIBS)
73 endif
74 endif
75         @chmod a+x $@
76         @echo "done"
77
78 %.o:    %.cxx %.h
79         $(CXX) $(CXXFLAGS) -c $< -o $@
80
81 G__$(PACKAGE).cxx G__$(PACKAGE).h: $(HDRS_PWG0base) $(DHDR_PWG0base)
82         @echo "Generating dictionary ..."
83         rootcint -f $@ -c $(ALICEINC) $^
84
85 clean:
86         @rm -f $(OBJS_PWG0base) $(OBJS_PWG0dep) $(OBJS_PWG0selectors) *.so G__PWG0base.* G__PWG0dep.* G__PWG0selectors.* $(PARFILE)
87
88 ### CREATE PAR FILE
89
90 $(PARFILE): $(patsubst %,$(PACKAGE)/%,$(filter-out G__%, $(HDRS_PWG0base) $(SRCS_PWG0base) $(DHDR_PWG0base) Makefile Makefile.arch PROOF-INF))
91         @echo "Creating archive" $@ ...
92         @tar cfzh $@ $(PACKAGE)
93         @rm -rf $(PACKAGE)
94         @echo "done"
95
96 $(PACKAGE)/Makefile: Makefile #.$(PACKAGE)
97         @echo Copying $< to $@ with transformations
98         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
99         @sed 's/include \$$(ROOTSYS)\/test\/Makefile.arch/include Makefile.arch/' < $^ > $@
100
101 $(PACKAGE)/Makefile.arch: $(ROOTSYS)/test/Makefile.arch
102         @echo Copying $< to $@
103         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
104         @cp -a $^ $@
105
106 $(PACKAGE)/PROOF-INF: PROOF-INF.$(PACKAGE)
107         @echo Copying $< to $@
108         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
109         @cp -a -r $^ $@
110
111 $(PACKAGE)/%: %
112         @echo Copying $< to $@
113         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
114         @cp -a $< $@
115
116 test-%.par: %.par
117         @echo "INFO: The file $< is now tested, in case of an error check in par-tmp."
118         @mkdir -p par-tmp
119         @cd par-tmp; tar xfz ../$<;     cd $(subst .par,,$<); PROOF-INF/BUILD.sh
120         @rm -rf par-tmp
121         @echo "INFO: Testing succeeded (already cleaned up)"