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