]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PYTHIA8/pythia8145/Makefile
Coverity fixes
[u/mrichter/AliRoot.git] / PYTHIA8 / pythia8145 / Makefile
CommitLineData
9419eeef 1#
2# Libraries Makefile. Some ideas from Geant4 Makefiles
3#
4# M. Kirsanov 07.04.2006
5# Modified 18.11.2006
6# 26.03.2008 CLHEP dependency removed
7# N. Lavesson 28.04.2009 clean/distclean separated
8# M. Kirsanov 21.07.2009 Mac-OSX flags added
9
10SHELL = /bin/sh
11
12-include config.mk
13
14# flags:
15#
16#FFLAGSSHARED = -fPIC
17CFLAGSSHARED = -fPIC
18CXXFLAGSSHARED = -fPIC
19
20
21HEPMCERROR=
22ifneq (x$(HEPMCLOCATION),x)
23 ifeq ($(wildcard $(HEPMCLOCATION)/include/HepMC/*.h),)
24 HEPMCERROR= HepMC interface: ERROR, no HepMC headers found in ${HEPMCLOCATION}/include/HepMC
25 endif
26endif
27
28# Location of directories.
29TMPDIR=tmp
30TOPDIR=$(shell \pwd)
31INCDIR=include
32SRCDIR=src
33LIBDIR=lib
34LIBDIRARCH=lib/archive
35BINDIR=bin
36
37# Location of libraries to be built.
38ifeq ($(SHAREDLIBS),yes)
39 targets=$(LIBDIRARCH)/libpythia8.a
40 targets+=$(LIBDIR)/libpythia8.$(SHAREDSUFFIX)
41 targets+=$(LIBDIRARCH)/liblhapdfdummy.a
42 targets+=$(LIBDIR)/liblhapdfdummy.$(SHAREDSUFFIX)
43else
44 targets=$(LIBDIRARCH)/libpythia8.a
45 targets+=$(LIBDIRARCH)/liblhapdfdummy.a
46endif
47
48ifneq (x$(HEPMCLOCATION),x)
49 targets+=$(LIBDIRARCH)/libhepmcinterface.a
50 ifeq ($(SHAREDLIBS),yes)
51 targets+=$(LIBDIR)/libhepmcinterface.$(SHAREDSUFFIX)
52 endif
53endif
54
55
56all: $(targets) config.mk
57
58config.mk: ./configure
59 ./configure
60
61# Main part: build Pythia8 library.
62
63$(TMPDIR)/%.o : $(SRCDIR)/%.cc
64 @mkdir -p $(TMPDIR)
65 $(CXX) $(CXXFLAGS) $(CXXFLAGSSHARED) -c -I$(INCDIR) $< -o $@
66
67$(TMPDIR)/archive/%.o : $(SRCDIR)/%.cc
68 @mkdir -p $(TMPDIR)/archive
69 $(CXX) $(CXXFLAGS) -c -I$(INCDIR) $< -o $@
70
71$(TMPDIR)/%.o : lhapdfdummy/%.cc
72 @mkdir -p $(TMPDIR)
73 $(CXX) $(CXXFLAGS) $(CXXFLAGSSHARED) -c -I$(INCDIR) $< -o $@
74
75$(TMPDIR)/archive/%.o : lhapdfdummy/%.cc
76 @mkdir -p $(TMPDIR)/archive
77 $(CXX) $(CXXFLAGS) -c -I$(INCDIR) $< -o $@
78
79# Creating the dependency files *.d
80# The compiler with option -M is used to build the dependency strings. They
81# are further edited with sed (stream editor). The first sed command adds the
82# dependency for the *.d files themselves, the second one is needed because
83# object files are put in the directory different from src. The last line
84# removes empty *.d files produced in case of error.
85
86ifeq ($(SHAREDLIBS),yes)
87 $(TMPDIR)/%.d : $(SRCDIR)/%.cc
88 @echo Making dependency for file $<; \
89 mkdir -p $(TMPDIR); \
90 $(CC) -M -I$(INCDIR) $< | \
91 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' | \
92 sed 's/$*\.o/$(TMPDIR)\/$*.o/' > $@; \
93 [ -s $@ ] || rm -f $@
94endif
95
96$(TMPDIR)/archive/%.d : $(SRCDIR)/%.cc
97 @echo Making dependency for file $<; \
98 mkdir -p $(TMPDIR)/archive; \
99 $(CC) -M -I$(INCDIR) $< | \
100 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' | \
101 sed 's/$*\.o/$(TMPDIR)\/archive\/$*.o/' > $@; \
102 [ -s $@ ] || rm -f $@
103
104objects := $(patsubst $(SRCDIR)/%.cc,$(TMPDIR)/%.o,$(wildcard $(SRCDIR)/*.cc))
105objectsarch := $(patsubst $(SRCDIR)/%.cc,$(TMPDIR)/archive/%.o,$(wildcard $(SRCDIR)/*.cc))
106
107$(LIBDIR)/libpythia8.$(SHAREDSUFFIX): $(objects)
108 @mkdir -p $(LIBDIR)
109 $(CXX) $(LDFLAGSSHARED) -o $@ $(objects) $(LDFLAGLIBNAME),$(notdir $@)
110
111$(LIBDIRARCH)/libpythia8.a: $(objectsarch)
112 @mkdir -p $(LIBDIRARCH)
113 ar cru $@ $(objectsarch)
114
115objdum := $(patsubst lhapdfdummy/%.cc,$(TMPDIR)/%.o,$(wildcard lhapdfdummy/*.cc))
116objdumarch := $(patsubst lhapdfdummy/%.cc,$(TMPDIR)/archive/%.o,$(wildcard lhapdfdummy/*.cc))
117
118$(LIBDIR)/liblhapdfdummy.$(SHAREDSUFFIX): $(objdum)
119 @mkdir -p $(LIBDIR)
120 $(CXX) $(LDFLAGSSHARED) -o $@ $(objdum) $(LDFLAGLIBNAME),$(notdir $@)
121
122$(LIBDIRARCH)/liblhapdfdummy.a: $(objdumarch)
123 @mkdir -p $(LIBDIRARCH)
124 ar cru $@ $(objdumarch)
125
126deps := $(patsubst $(SRCDIR)/%.cc,$(TMPDIR)/%.d,$(wildcard $(SRCDIR)/*.cc))
127depsarch := $(patsubst $(SRCDIR)/%.cc,$(TMPDIR)/archive/%.d,$(wildcard $(SRCDIR)/*.cc))
128
129
130# The "if" below is needed in order to avoid producing the dependency files
131# when you want to just clean
132
133ifeq (,$(findstring clean, $(MAKECMDGOALS)))
134-include $(deps)
135-include $(depsarch)
136endif
137
138# Build HepMC interface part if HepMC location is set.
139
140ifneq (x$(HEPMCLOCATION),x)
141 HEPMCINCLUDE=-I$(HEPMCLOCATION)/include
142
143 ifeq (x$(HEPMCERROR),x)
144
145 $(TMPDIR)/%.o : hepmcinterface/%.cc config.mk
146 @mkdir -p $(TMPDIR)
147 $(CXX) $(CXXFLAGS) $(CXXFLAGSSHARED) $(HEPMCVFLAG) -c -I$(INCDIR) $(HEPMCINCLUDE) $< -o $@
148
149 $(TMPDIR)/archive/%.o : hepmcinterface/%.cc config.mk
150 @mkdir -p $(TMPDIR)/archive
151 $(CXX) $(CXXFLAGS) $(HEPMCVFLAG) -c -I$(INCDIR) $(HEPMCINCLUDE) $< -o $@
152
153 $(TMPDIR)/%.d : hepmcinterface/%.cc
154 @echo Making dependency for file $<; \
155 mkdir -p $(TMPDIR); \
156 $(CC) -M -I$(INCDIR) $(HEPMCINCLUDE) $< | \
157 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' | \
158 sed 's/$*.o/$(TMPDIR)\/$*.o/' > $@; \
159 [ -s $@ ] || rm -f $@
160
161 $(TMPDIR)/archive/%.d : hepmcinterface/%.cc
162 @echo Making dependency for file $<; \
163 mkdir -p $(TMPDIR)/archive; \
164 $(CC) -M -I$(INCDIR) $(HEPMCINCLUDE) $< | \
165 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' | \
166 sed 's/$*.o/$(TMPDIR)\/archive\/$*.o/' > $@; \
167 [ -s $@ ] || rm -f $@
168
169 objectsI := $(patsubst hepmcinterface/%.cc,$(TMPDIR)/%.o,$(wildcard hepmcinterface/*.cc))
170 objectsIarch := $(patsubst hepmcinterface/%.cc,$(TMPDIR)/archive/%.o,$(wildcard hepmcinterface/*.cc))
171
172 $(LIBDIR)/libhepmcinterface.$(SHAREDSUFFIX) : $(objectsI)
173 @mkdir -p $(LIBDIR)
174 $(CXX) $(LDFLAGSSHARED) $(objectsI) -o $@ $(LDFLAGLIBNAME),$(notdir $@)
175
176 $(LIBDIRARCH)/libhepmcinterface.a : $(objectsIarch)
177 @mkdir -p $(LIBDIRARCH)
178 ar cru $(LIBDIRARCH)/libhepmcinterface.a $(objectsIarch)
179
180 depsI := $(patsubst hepmcinterface/%.cc,$(TMPDIR)/%.d,$(wildcard hepmcinterface/*.cc))
181 depsIarch := $(patsubst hepmcinterface/%.cc,$(TMPDIR)/archive/%.d,$(wildcard hepmcinterface/*.cc))
182
183 ifeq (,$(findstring clean, $(MAKECMDGOALS)))
184 -include $(depsI)
185 -include $(depsIarch)
186 endif
187
188 else
189
190 $(LIBDIRARCH)/libhepmcinterface.a $(LIBDIR)/libhepmcinterface.$(SHAREDSUFFIX) :
191 @echo $(HEPMCERROR)
192
193
194
195 endif
196
197endif
198
199# Clean up: remove (almost?) everything that cannot be recreated.
200
201.PHONY: clean distclean
202
203clean:
204 rm -rf $(TMPDIR)
205 rm -rf $(LIBDIR)
206 rm -rf $(BINDIR)
207 cd examples; rm -f *.exe; cd -
208
209distclean: clean
210 rm -f config.mk
211 rm -f *~; rm -f \#*;
212 cd $(SRCDIR); rm -f *~; rm -f \#*; cd -
213 cd $(INCDIR); rm -f *~; rm -f \#*; cd -
214 cd xmldoc; rm -f *~; rm -f \#*; cd -
215 cd htmldoc; rm -f *~; rm -f \#*; cd -
216 cd phpdoc; rm -f *~; rm -f \#*; cd -
217 cd hepmcinterface; rm -f *~; rm -f \#*; cd -
218 cd lhapdfdummy; rm -f *~; rm -f \#*; cd -
219 cd examples; rm -f *~; rm -f \#*; rm -f core*; rm -f config.*; cd -
220