File: Makefile

package info (click to toggle)
pythia8 8.1.65-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 22,660 kB
  • sloc: cpp: 59,593; xml: 30,509; php: 6,649; sh: 796; makefile: 353; ansic: 33
file content (229 lines) | stat: -rw-r--r-- 7,164 bytes parent folder | download
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
#
# 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

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)/libpythia.$(SHAREDSUFFIX).$(UPVER)
  targets+=$(LIBDIRARCH)/liblhapdfdummy.a
  targets+=$(LIBDIR)/liblhapdfdummy.$(SHAREDSUFFIX).$(UPVER)
else
  targets=$(LIBDIRARCH)/libpythia8.a
  targets+=$(LIBDIRARCH)/liblhapdfdummy.a
endif

ifneq (x$(HEPMCLOCATION),x)
 targets+=$(LIBDIRARCH)/libhepmcinterface.a
 ifeq ($(SHAREDLIBS),yes)
  targets+=$(LIBDIR)/libhepmcinterface.$(SHAREDSUFFIX).$(UPVER)
 endif
endif


all: $(targets) config.mk

config.mk: ./configure
	./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)/libpythia.$(SHAREDSUFFIX).$(UPVER): $(objects)
	@mkdir -p $(LIBDIR)
	$(CXX) $(LDFLAGSSHARED) -o $@ $(objects) $(LDFLAGLIBNAME),libpythia.so.8
	ln -s $(notdir $@) $(LIBDIR)/libpythia.$(SHAREDSUFFIX).8
	ln -s $(notdir $@) $(LIBDIR)/libpythia8.$(SHAREDSUFFIX)
	ln -s $(notdir $@) $(LIBDIR)/libpythia.$(SHAREDSUFFIX)

$(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).$(UPVER): $(objdum)
	@mkdir -p $(LIBDIR)
	$(CXX) $(LDFLAGSSHARED) -o $@ $(objdum) $(LDFLAGLIBNAME),liblhapdfdummy.so.8
	ln -s $(notdir $@) $(LIBDIR)/liblhapdfdummy.$(SHAREDSUFFIX).8
	ln -s $(notdir $@) $(LIBDIR)/liblhapdfdummy.$(SHAREDSUFFIX)

$(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 : hepmcinterface/%.cc config.mk
	@mkdir -p $(MYTMPDIR)
	$(CXX) $(CXXFLAGS) $(CXXFLAGSSHARED) $(HEPMCVFLAG) -c -I$(INCDIR) $(HEPMCINCLUDE) $< -o $@

   $(MYTMPDIR)/archive/%.o : hepmcinterface/%.cc config.mk
	@mkdir -p $(MYTMPDIR)/archive
	$(CXX) $(CXXFLAGS) $(HEPMCVFLAG) -c -I$(INCDIR) $(HEPMCINCLUDE) $< -o $@

   $(MYTMPDIR)/%.d : hepmcinterface/%.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 : hepmcinterface/%.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 hepmcinterface/%.cc,$(MYTMPDIR)/%.o,$(wildcard hepmcinterface/*.cc))
   objectsIarch := $(patsubst hepmcinterface/%.cc,$(MYTMPDIR)/archive/%.o,$(wildcard hepmcinterface/*.cc))

   $(LIBDIR)/libhepmcinterface.$(SHAREDSUFFIX).$(UPVER) : $(objectsI)
	@mkdir -p $(LIBDIR)
	$(CXX) $(LDFLAGSSHARED) $(objectsI) -o $@ $(LDFLAGLIBNAME),libhepmcinterface.so.8
	ln -s $(notdir $@) $(LIBDIR)/libhepmcinterface.$(SHAREDSUFFIX).8
	ln -s $(notdir $@) $(LIBDIR)/libhepmcinterface.$(SHAREDSUFFIX)

   $(LIBDIRARCH)/libhepmcinterface.a : $(objectsIarch)
	@mkdir -p $(LIBDIRARCH)
	ar cru $(LIBDIRARCH)/libhepmcinterface.a $(objectsIarch)

   depsI := $(patsubst hepmcinterface/%.cc,$(MYTMPDIR)/%.d,$(wildcard hepmcinterface/*.cc))
   depsIarch := $(patsubst hepmcinterface/%.cc,$(MYTMPDIR)/archive/%.d,$(wildcard hepmcinterface/*.cc))

   ifeq (,$(findstring clean, $(MAKECMDGOALS)))
   -include $(depsI)
   -include $(depsIarch)
   endif

 else

   $(LIBDIRARCH)/libhepmcinterface.a $(LIBDIR)/libhepmcinterface.$(SHAREDSUFFIX).$(UPVER) :
	@echo $(HEPMCERROR)



 endif

endif

# Clean up: remove (almost?) everything that cannot be recreated.

.PHONY: clean distclean

clean:
	rm -rf $(MYTMPDIR)
	rm -rf $(LIBDIR)
	rm -rf $(BINDIR)
	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 \#*;
	cd $(SRCDIR); rm -f *~; rm -f \#*; cd -
	cd $(INCDIR); 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 hepmcinterface; 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 -