-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
306 lines (242 loc) · 8.73 KB
/
Makefile
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# hamc = Hall A Monte Carlo
# R. Michaels, May 2008
# Update Jan 2018 with USEFORTRAN option
# Update Aug 2018 add the water cell "experiment"
# Choose the compiler.
GCC=g++
GLD=g++
MAKENODICTIONARY=1
# Using fortran-dependent code (LeRose functions) uncomment this.
# Lately we rely on HRSTRans (libhrstrans) for transport.
# USEFORTRAN=1
export OSNAME := $(shell uname)
ifeq ($(OSNAME),SunOS)
ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs)
ROOTGLIBS = $(shell root-config --glibs)
CXX = $(GCC)
CXXFLAGS = -KPIC -DSUNVERS -I$(ROOTSYS)/include -I$(MAINDIR)
CXXFLAGS += $(ROOTCFLAGS)
LD = $(GLD)
LDFLAGS = -g -D
SOFLAGS = -G
GLIB = -lm -lc -lgen -lw -lnsl -ldl
SLIB = -L/opt/SUNWspro/SC4.2/lib -lF77 -lM77 -lsunmath
ET_AC_FLAGS = -D_REENTRANT -D_POSIX_THREAD_SEMANTICS
ET_CFLAGS = -mt -fast -xO5 -KPIC $(ET_AC_FLAGS) -DSUNVERS
ONLIBS = -lposix4 -lnsl -lsocket -lresolv
LIBS = $(GLIB) /usr/lib64/libg2c.so.0
endif
# Linux with egcs
ifeq ($(OSNAME),Linux)
ROOTLIBS = $(shell root-config --libs)
ROOTGLIBS = $(shell root-config --glibs)
INCLUDES = -I$(ROOTSYS)/include
CXX = $(GCC)
CXXFLAGS = -fno-exceptions -fpermissive -std=c++11 -fPIC $(INCLUDES)
LD = $(GLD)
LDFLAGS =
SOFLAGS = -shared
GLIBS = $(ROOTGLIBS) -L/usr/X11R6/lib -lXpm -lX11
ET_AC_FLAGS = -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS
ET_CFLAGS = -02 -fPIC -I. $(ET_AC_FLAGS) -DLINUXVERS
ONLIBS = -lieee -lpthread -ldl -lresolv
LIBS = $(GLIBS) $(ROOTLIBS) $(ROOTGLIBS) /usr/lib64/libg2c.so.0
endif
HRSTRANSLIB = /home/robertmichaels/hrstrans/hrstrans
HRSTCORRLIB = /home/robertmichaels/trkcorr/lib
MAKEDEPEND = $(GCC)
ALL_LIBS = $(LIBS) $(HRSTRANSLIB)/libhrstrans.so $(HRSTCORRLIB)/libtrkcorr.so
SRCDIR=./src
INCLUDES += -I$(SRCDIR)
INCLUDES += -I$(HRSTRANSLIB)
INCLUDES += -I$(HRSTCORRLIB)
ifdef PROFILE
CXXFLAGS += -pg
endif
ifdef OPTIMIZE
CXXFLAGS += -O
else
CXXFLAGS += -g -ggdb
endif
SRC = $(SRCDIR)/hamcExpt.C $(SRCDIR)/hamcSingles.C $(SRCDIR)/hamcPhysics.C \
$(SRCDIR)/hamcEvent.C $(SRCDIR)/hamcSpecHRS.C \
$(SRCDIR)/hamcTrans.C $(SRCDIR)/hamcTransMat.C \
$(SRCDIR)/hamcAccAvg.C \
$(SRCDIR)/hamcTransGuido.C \
$(SRCDIR)/hamcTHRSTrans.C \
$(SRCDIR)/hamcTarget.C \
$(SRCDIR)/hamcEloss.C $(SRCDIR)/hamcKine.C \
$(SRCDIR)/hamcTrack.C $(SRCDIR)/hamcBeam.C $(SRCDIR)/hamcTrackOut.C \
$(SRCDIR)/hamcInout.C $(SRCDIR)/THaString.C $(SRCDIR)/hamcMultScatt.C
# Fortran-dependent sources
# which of these you need depends on what you are compiling.
# too tired to think much now, but
# Ler4deg was for CREX
# WarmSeptum for CREX-I, ColdSeptum is largely irrelevant.
# LerHRS is Std. HRS, so HAPPEX-III etc.
#FORSRC=$(SRCDIR)/hamcTransLer4deg.C \
# $(SRCDIR)/hamcTransLerWarmSeptum.C \
# $(SRCDIR)/hamcTransLerColdSeptum.C \
# $(SRCDIR)/hamcTransLerHRS.C
FORSRC=$(SRCDIR)/hamcTransLerHRS.C $(SRCDIR)/hamcTransLerWarmSeptum.C $(SRCDIR)/hamcTransLerColdSeptum.C $(SRCDIR)/hamcTransLer4deg.C
ifdef USEFORTRAN
SRC+=$(FORSRC)
CXXFLAGS += -DUSEFORTRAN -lgfortran
endif
DEPS = $(SRC:.C=.d)
DEP = $(SRC:.C=.d)
HEAD = $(SRC:.C=.h)
PROGS = prex happex water
ifdef DOPVDIS
PROGS += pvdis
endif
HAMCLIBS = libhamc.a
HAMCLIBS_NODICT = libhamc_NODICT.a
# Make the dictionary
ifdef MAKENODICTIONARY
OBJS = $(SRC:.C=_NODICT.o)
else
OBJS = $(SRC:.C=.o)
OBJS += hamcDict.o
endif
ifdef USEFORTRAN
# PREX-I or C-REX Optics HRS+septum
#OBJS += $(SRCDIR)/crex_4degr.o $(SRCDIR)/prex_forward.o $(SRCDIR)/monte_trans_hrs.o $(SRCDIR)/R6_forward.o $(SRCDIR)/ls_6d_forward.o
# Standard HRS Optics, i.e. HRS w/out Septum
#OBJS += $(SRCDIR)/prex_retune_for.o $(SRCDIR)/monte_trans_hrs.o $(SRCDIR)/R6_forward.o $(SRCDIR)/ls_6d_forward.o
# Try a combination
OBJS += $(SRCDIR)/crex_4degr.o $(SRCDIR)/prex_retune_for.o $(SRCDIR)/monte_trans_hrs.o $(SRCDIR)/R6_forward.o $(SRCDIR)/ls_6d_forward.o
endif
# PREX experiment
PREX_SRC = ./PREX/main_PREX.C ./PREX/hamcExptPREX.C ./PREX/hamcPhyPREX.C ./PREX/hamcTgtPREX.C
# Make the dictionary
ifdef MAKENODICTIONARY
PREX_OBJS = $(PREX_SRC:.C=_NODICT.o)
else
PREX_OBJS = $(PREX_SRC:.C=.o)
endif
# HAPPEX experiment
HAPPEX_SRC = ./HAPPEX/main_HAPPEX.C ./HAPPEX/hamcExptHAPPEX.C ./HAPPEX/hamcPhyHAPPEX.C ./HAPPEX/hamcTgtHAPPEX.C
# Make the dictionary
ifdef MAKENODICTIONARY
HAPPEX_OBJS = $(HAPPEX_SRC:.C=_NODICT.o)
else
HAPPEX_OBJS = $(HAPPEX_SRC:.C=.o)
endif
# WATER cell
Water_SRC = ./Water/main_Water.C ./Water/hamcExptWater.C ./Water/hamcPhyWater.C ./Water/hamcTgtWater.C
# Make the dictionary
ifdef MAKENODICTIONARY
Water_OBJS = $(Water_SRC:.C=_NODICT.o)
else
Water_OBJS = $(Water_SRC:.C=.o)
endif
# PVDIS experiment
PVDIS_SRC = ./PVDIS/main_PVDIS.C ./PVDIS/hamcExptPVDIS.C ./PVDIS/hamcPhyPVDIS.C ./PVDIS/hamcTgtPVDIS.C
ifdef MAKENODICTIONARY
PVDIS_OBJS = $(PVDIS_SRC:.C=_NODICT.o)
else
PVDIS_OBJS = $(PVDIS_SRC:.C=.o)
endif
ifdef DOPVDIS
PVDIS_OBJS += ./PVDIS/getpdf_mrst2003c.o ./PVDIS/mrst2003c.o ./PVDIS/NextUn.o ./PVDIS/r1998.o ./PVDIS/readpdf_single.o ./PVDIS/xsec.o
endif
install: all
all: $(PROGS) $(HAMCLIBS) $(HAMCLIBS_NODICT) libhamc.so
prex: $(PREX_OBJS) $(PREX_HEAD) $(OBJS) $(SRC) $(HEAD)
rm -f $@
$(LD) $(CXXFLAGS) -o $@ $(OBJS) $(PREX_OBJS) $(ALL_LIBS)
happex: $(HAPPEX_OBJS) $(HAPPEX_HEAD) $(OBJS) $(SRC) $(HEAD)
rm -f $@
$(LD) $(CXXFLAGS) -o $@ $(OBJS) $(HAPPEX_OBJS) $(ALL_LIBS)
water: $(Water_OBJS) $(Water_HEAD) $(OBJS) $(SRC) $(HEAD)
rm -f $@
$(LD) $(CXXFLAGS) -o $@ $(OBJS) $(Water_OBJS) $(ALL_LIBS)
# Note, PVDIS relies heavily on Fortran. This needs to be fixed if
# we care about it (noted, Jan 2018).
ifdef DOPVDIS
pvdis: $(PVDIS_OBJS) $(PVDIS_HEAD) $(OBJS) $(SRC) $(HEAD)
rm -f $@
$(LD) $(CXXFLAGS) -o $@ $(OBJS) $(PVDIS_OBJS) $(ALL_LIBS)
endif
$(HAMCLIBS_NODICT): $(LOBJS_NODICT) $(LSRC) $(HEAD)
rm -f $@
ar cr $@ $(LOBJS)
$(HAMCLIBS): $(LOBJS) $(LSRC) $(HEAD)
rm -f $@
ar cr $@ $(LOBJS)
# These are FORTRAN-dependent codes.
# They are obsolescent (soon to be obsolete), to be replaced
# by hrstranslib.
ifdef USEFORTRAN
# 4 degree Septum (April 2013)
$(SRCDIR)/crex_4degr.o: $(SRCDIR)/crex_4degr.f
rm -f $@
cd $(SRCDIR) ; g77 -c -fPIC crex_4degr.f ; cd ../
# Tune B (what was used during production)
$(SRCDIR)/prex_forward.o: $(SRCDIR)/prex_forward.f
rm -f $@
cd $(SRCDIR) ; g77 -c -fPIC prex_forward.f ; cd ../
#Replace 3 lines below with 3 lines above for standard HRS optics
# Tune Y:
$(SRCDIR)/prex_retune_for.o: $(SRCDIR)/prex_retune_for.f
rm -f $@
cd $(SRCDIR) ; g77 -c -fPIC prex_retune_for.f ; cd ../
$(SRCDIR)/monte_trans_hrs.o: $(SRCDIR)/monte_trans_hrs.f
rm -f $@
cd $(SRCDIR) ; g77 -c -fPIC monte_trans_hrs.f ; cd ../
$(SRCDIR)/ls_6d_forward.o: $(SRCDIR)/ls_6d_forward.f
rm -f $@
cd $(SRCDIR) ; g77 -c -fPIC ls_6d_forward.f ; cd ../
$(SRCDIR)/R6_forward.o: $(SRCDIR)/R6_forward.f
rm -f $@
cd $(SRCDIR) ; g77 -c -fPIC R6_forward.f ; cd ../
endif
############################# PVDIS OBJS ###############
# The PVDIS code wont work until we fix or replace fortran, I believe.
ifdef USEFORTRAN
./PVDIS/getpdf_mrst2003c.o: ./PVDIS/getpdf_mrst2003c.f ./PVDIS/mrst2003c.o ./PVDIS/NextUn.o ./PVDIS/r1998.o ./PVDIS/readpdf_single.o
rm -f $@
cd ./PVDIS/; g77 -c -fPIC getpdf_mrst2003c.f mrst2003c.o NextUn.o r1998.o readpdf_single.o; cd ../
./PVDIS/mrst2003c.o: ./PVDIS/mrst2003c.f
rm -f $@
cd ./PVDIS/; g77 -c -fPIC mrst2003c.f; cd ../
./PVDIS/NextUn.o: ./PVDIS/NextUn.f
rm -f $@
cd ./PVDIS/; g77 -c -fPIC NextUn.f; cd ../
./PVDIS/r1998.o: ./PVDIS/r1998.f
rm -f $@
cd ./PVDIS/; g77 -c -fPIC r1998.f; cd ../
./PVDIS/readpdf_single.o: ./PVDIS/readpdf_single.f
rm -f $@
cd ./PVDIS/; g77 -c -fPIC readpdf_single.f; cd ../
./PVDIS/xsec.o: ./PVDIS/xsec.f
rm -f $@
cd ./PVDIS/; g77 -c -fPIC xsec.f; cd ../
endif
################################################################
libhamc.so: $(OBJS) $(HEAD)
$(CXX) $(SOFLAGS) -O -o libhamc.so $(OBJS) $(ALL_LIBS)
# Dictionary
hamcDict.C: $(OBJS) hamcLinkDef.h
@echo "Generating Decoder Dictionary..."
$(ROOTSYS)/bin/rootcint -f hamcDict.C -c -p $(HEAD) hamcLinkDef.h
# create a tar file of ./$(VERS)/* (all code)
tarfile: clean version
tar cvf $(VERS).tar ./$(VERS)
clean:
rm -f $(SRCDIR)/*.o core hamcDict* $(PROGS) $(HAMCLIBS) $(HAMCLIBS_NODICT) libhamc.so ./PREX/*.o ./HAPPEX/*.o ./PVDIS/*.o ./Water/*.o
realclean: clean
rm -f *.d *.tar *~
%.o: %.C
$(CXX) $(CXXFLAGS) -c $<
%_NODICT.o: %.C
$(CXX) $(CXXFLAGS) -c -DNODICT -o $*_NODICT.o $<
%.d: %.C
@echo Creating dependencies for $<
@$(SHELL) -ec '$(MAKEDEPEND) -MM $(INCLUDES) -c $< \
| sed '\''s%^.*\.o%$*\.o%g'\'' \
| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
[ -s $@ ] || rm -f $@'
-include $(DEPS)