1 | ################################################################################ |
---|
2 | # Makefile for building a HepMC executable with the gcc compiler |
---|
3 | # |
---|
4 | # Matt.Dobbs@CERN.CH 1.2000 |
---|
5 | # |
---|
6 | # This makefiles also works to compile the example programs. |
---|
7 | # I.E.: syntax for compiling the example_MyPythia.cc example: |
---|
8 | # gmake example_MyPythia.exe |
---|
9 | # or simply gmake all to compile all examples. |
---|
10 | # |
---|
11 | ################################################################################ Define directory paths |
---|
12 | # You may have to change GENSERdir and/or other variables |
---|
13 | # |
---|
14 | HepMCdir = /afs/cern.ch/sw/lcg/external/HepMC/2.06.08/x86_64-slc5-gcc41-opt |
---|
15 | HepMClib = -L$(HepMCdir)/lib -lHepMC |
---|
16 | HepMCfiolib = -L$(HepMCdir)/lib -lHepMCfio |
---|
17 | GENSERdir = |
---|
18 | Pythia_LIB = -L$(GENSERdir)/lib -Wl,-rpath -Wl,$(GENSERdir)/lib \ |
---|
19 | -lpythia6_403 -lpythia6_403_dumm -lpythia6_403_pdfdumm |
---|
20 | Herwig_LIB = -L$(GENSERdir)/lib -Wl,-rpath -Wl,$(GENSERdir)/lib \ |
---|
21 | -lherwig6_510 -lherwig6_510_dumm -lherwig6_510_pdfdumm |
---|
22 | |
---|
23 | ################################################################################ Compiler options |
---|
24 | # |
---|
25 | CXX = g++ |
---|
26 | F77 = gfortran |
---|
27 | INCLUDES = -I$(HepMCdir)/include -I$(CLHEPdir)/include |
---|
28 | CXXFLAGS = -O -ansi -pedantic -Wall -D_GNU_SOURCE -O2 -g $(INCLUDES) |
---|
29 | ifeq "$(CXX)" "g++" |
---|
30 | FLAGS = $(DFLG) -fno-second-underscore $(INCDIR) |
---|
31 | else |
---|
32 | FLAGS = $(DFLG) $(INCDIR) |
---|
33 | endif |
---|
34 | |
---|
35 | LINK_LIBS = |
---|
36 | |
---|
37 | UNAME = $(shell uname) |
---|
38 | ifneq "$(UNAME)" "Darwin" |
---|
39 | LINK_LIBS += -Wl,-rpath -Wl,$(HepMCdir)/lib |
---|
40 | endif |
---|
41 | |
---|
42 | ifeq "$(UNAME)" "Linux" |
---|
43 | ifeq "$(F77)" "gfortran" |
---|
44 | LINK_LIBS += -lgfortran |
---|
45 | else |
---|
46 | LINK_LIBS += -lg2c |
---|
47 | endif |
---|
48 | endif |
---|
49 | |
---|
50 | initpydata_OBJ= initpydata.o |
---|
51 | pythia_OBJ = initPythia.o initpydata.o |
---|
52 | HDRS = $(HepMCdir)/include/HepMC/*.h *.h |
---|
53 | EXAMPLES = example_MyHerwig.exe \ |
---|
54 | example_MyPythia.exe \ |
---|
55 | example_MyPythiaOnlyToHepMC.exe \ |
---|
56 | example_PythiaStreamIO.exe \ |
---|
57 | testPythiaCopies.exe \ |
---|
58 | testHerwigCopies.exe |
---|
59 | |
---|
60 | ################################################################################ definition of the compiler options |
---|
61 | # -I location of directory containing include files |
---|
62 | # -L location of directory containing libraries |
---|
63 | # -lname include the library from -L location called libname.a |
---|
64 | # -lg2c is the library containing info on converting fortran to C |
---|
65 | # -lf is the library containing the intrinsic for HPUX only. |
---|
66 | # -shared make a shared library as output |
---|
67 | # -fPIC produce position independent code |
---|
68 | # necessary on some platforms (including HPUX) for -shared |
---|
69 | # -fpic ^^ same(?) |
---|
70 | # -O optimizes |
---|
71 | # -g produces output for the debugger |
---|
72 | # -pg produces output for gprof profiler |
---|
73 | # note: if you want to see all warnings and ensure ansi standard |
---|
74 | # compatibility, use: |
---|
75 | # -pipe -ansi -pedantic -fnonnull-objects \ |
---|
76 | # -W -Wall -Wwrite-strings -Wpointer-arith -Wnested-externs \ |
---|
77 | # -Woverloaded-virtual -Wbad-function-cast -fnonnull-objects |
---|
78 | # The proper order for cernlib libraries is: |
---|
79 | # -lpawlib -lgraflib -lgrafX11 -lmathlib -lkernlib -lpacklib -ljetset74 |
---|
80 | # |
---|
81 | # makefile syntax: |
---|
82 | # for target thedir/target.suf from source anotherdir/source.suf2 |
---|
83 | # ${*D} = thedir |
---|
84 | # ${*F} = target |
---|
85 | # $* = thedir/target |
---|
86 | # $@ = thedir/target.suf |
---|
87 | # $< = anotherdir/source.suf2 |
---|
88 | # |
---|
89 | |
---|
90 | ############################################################################### |
---|
91 | # |
---|
92 | .SUFFIXES: .o .cxx .f .exe |
---|
93 | all: $(EXAMPLES) |
---|
94 | |
---|
95 | example_MyHerwig.exe: example_MyHerwig.o |
---|
96 | @echo "Building $@ ..." |
---|
97 | $(CXX) $(FLAGS) example_MyHerwig.o \ |
---|
98 | $(HepMClib) $(HepMCfiolib) \ |
---|
99 | $(Herwig_LIB) $(LINK_LIBS) -o $@ |
---|
100 | |
---|
101 | example_MyPythia.exe: $(initpydata_OBJ) $(pythia_OBJ) example_MyPythia.o |
---|
102 | @echo "Building $@ ..." |
---|
103 | $(CXX) $(FLAGS) $(pythia_OBJ) example_MyPythia.o \ |
---|
104 | $(HepMClib) $(HepMCfiolib) \ |
---|
105 | $(Pythia_LIB) $(LINK_LIBS) -o $@ |
---|
106 | |
---|
107 | example_MyPythiaOnlyToHepMC.exe: $(initpydata_OBJ) $(pythia_OBJ) example_MyPythiaOnlyToHepMC.o |
---|
108 | @echo "Building $@ ..." |
---|
109 | $(CXX) $(FLAGS) $(pythia_OBJ) example_MyPythiaOnlyToHepMC.o \ |
---|
110 | $(HepMClib) $(HepMCfiolib) \ |
---|
111 | $(Pythia_LIB) $(LINK_LIBS) -o $@ |
---|
112 | |
---|
113 | example_PythiaStreamIO.exe: $(initpydata_OBJ) $(pythia_OBJ) example_PythiaStreamIO.o |
---|
114 | @echo "Building $@ ..." |
---|
115 | $(CXX) $(FLAGS) $(pythia_OBJ) example_PythiaStreamIO.o \ |
---|
116 | $(HepMClib) $(HepMCfiolib) \ |
---|
117 | $(Pythia_LIB) $(LINK_LIBS) -o $@ |
---|
118 | |
---|
119 | testPythiaCopies.exe: $(initpydata_OBJ) $(pythia_OBJ) testPythiaCopies.o |
---|
120 | @echo "Building $@ ..." |
---|
121 | $(CXX) $(FLAGS) $(pythia_OBJ) testPythiaCopies.o \ |
---|
122 | $(HepMClib) $(HepMCfiolib) \ |
---|
123 | $(Pythia_LIB) $(LINK_LIBS) -o $@ |
---|
124 | |
---|
125 | testHerwigCopies.exe: testHerwigCopies.o |
---|
126 | @echo "Building $@ ..." |
---|
127 | $(CXX) $(FLAGS) testHerwigCopies.o \ |
---|
128 | $(HepMClib) $(HepMCfiolib) \ |
---|
129 | $(Herwig_LIB) $(LINK_LIBS) -o $@ |
---|
130 | |
---|
131 | ############################################################################### |
---|
132 | # instructions for building a .o file from a .cxx file |
---|
133 | # |
---|
134 | .cc.o: $(HDRS) $< |
---|
135 | @echo "Compiling $< with $(CXX) ..." |
---|
136 | @$(CXX) $(CXXFLAGS) -c $< -o $@ |
---|
137 | |
---|
138 | ############################################################################### |
---|
139 | # instructions for building a .o file from a .f file |
---|
140 | # |
---|
141 | .f.o: $< |
---|
142 | @echo "Compiling $< with $(F77) ..." |
---|
143 | @$(F77) $(FLAGS) -c $< -o $@ |
---|
144 | |
---|
145 | ############################################################################### |
---|
146 | # gmake clean removes all garbage from HepMC directories. |
---|
147 | # |
---|
148 | clean: |
---|
149 | rm -f *.o |
---|
150 | |
---|
151 | ############################################################################### |
---|
152 | # gmake distclean removes all compiled libraries, executables, +garbage |
---|
153 | # to prepare the package for distribution |
---|
154 | distclean: |
---|
155 | $(MAKE) clean --no-print-directory |
---|
156 | rm -f *.exe |
---|
157 | rm -f *.dat |
---|
158 | |
---|