forked from JeffersonLab/analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
397 lines (340 loc) · 11.7 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
#------------------------------------------------------------------------------
# Compile extra debugging code (slight performance impact)
export WITH_DEBUG = 1
# Compile debug version
#export DEBUG = 1
# Include libraries for reading from the ET ring
# (only for adaq? machines with the Coda libraries )
#export ONLINE_ET = 1
#------------------------------------------------------------------------------
# SOVERSION should be numerical only - it becomes the shared lib soversion
# EXTVERS (optional) describes the build, e.g. "dbg", "et", "gcc33" etc.
SOVERSION := 1.6
PATCH := 0
VERSION := $(SOVERSION).$(PATCH)
EXTVERS := -beta3
#EXTVERS := -et
NAME := analyzer-$(VERSION)
VERCODE := $(shell echo $(subst ., ,$(SOVERSION)) $(PATCH) | \
awk '{ print $$1*65536 + $$2*256 + $$3 }')
#------------------------------------------------------------------------------
MACHINE := $(shell uname -s)
ARCH := linux
ifeq ($(MACHINE),Darwin)
ARCH := macosx
endif
ifndef PLATFORM
PLATFORM = bin
endif
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
ROOTBIN := $(shell root-config --bindir)
ROOTINC := -I$(shell root-config --incdir)
CXX := $(shell root-config --cxx)
CC := $(shell root-config --cc)
HA_DIR := $(shell pwd)
DCDIR := hana_decode
LIBDIR := $(shell pwd)
HALLALIBS := -L$(LIBDIR) -lHallA -ldc
SUBDIRS := $(DCDIR)
INCDIRS := $(addprefix $(HA_DIR)/, src $(SUBDIRS))
HA_DICT := haDict
LIBS :=
GLIBS :=
INCLUDES := $(addprefix -I, $(INCDIRS) )
ifdef CODA
EVIO_ARCH := $(shell uname -s)-$(shell uname -m)
export EVIO_LIBDIR := $(CODA)/$(EVIO_ARCH)/lib
export EVIO_INCDIR := $(CODA)/$(EVIO_ARCH)/include
else
# If EVIO environment not defined, define it to point here and build locally
EVIODIR := $(shell pwd)/evio
SUBDIRS += evio
export EVIO_LIBDIR := $(LIBDIR)
export EVIO_INCDIR := $(EVIODIR)
LIBEVIO := $(LIBDIR)/libevio.so
endif
HALLALIBS += -L$(EVIO_LIBDIR) -levio
ifeq ($(ARCH),linux)
# Linux with egcs (>= RedHat 5.2)
ifdef DEBUG
CXXFLG := -g -O0
LDFLAGS := -g -O0
DEFINES :=
else
# CXXFLG := -O2 -march=pentium4
CXXFLG := -O
LDFLAGS := -O
DEFINES := -DNDEBUG
endif
DEFINES += -DLINUXVERS
CXXFLG += -Wall -fPIC
CXXEXTFLG = -Woverloaded-virtual
LD := $(CXX)
LDCONFIG := /sbin/ldconfig -n $(LIBDIR)
SOFLAGS := -shared
SONAME := -Wl,-soname=
#FIXME: should be configure'd:
CXXVER := $(shell g++ --version | head -1 | sed 's/.* \([0-9]\)\..*/\1/')
DEFINES += $(shell getconf LFS_CFLAGS)
ifeq ($(CXXVER),4)
CXXEXTFLG += -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
DICTCXXFLG := -Wno-strict-aliasing
endif
endif
ifeq ($(ARCH),macosx)
# Mac OS X with gcc >= 3.x or clang++ >= 5
ifdef DEBUG
CXXFLG := -g -O0
LDFLAGS := -g -O0
DEFINES :=
else
CXXFLG := -O
LDFLAGS := -O
DEFINES := -DNDEBUG
endif
DEFINES += -DMACVERS
CXXFLG += -Wall -fPIC
CXXEXTFLG = -Woverloaded-virtual
LD := $(CXX)
LDCONFIG :=
SOFLAGS := -shared -Wl,-undefined,dynamic_lookup
SONAME := -Wl,-install_name,
ifeq ($(CXX),clang++)
CXXEXTFLG += -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
else
#FIXME: should be configure'd:
CXXVER := $(shell g++ --version | head -1 | sed 's/.* \([0-9]\)\..*/\1/')
ifeq ($(CXXVER),4)
CXXEXTFLG += -Wextra -Wno-missing-field-initializers
DICTCXXFLG := -Wno-strict-aliasing
endif
endif
endif
#FIXME: requires gcc 3 or up - test in configure script
DEFINES += -DHAS_SSTREAM
# ifdef ONLINE_ET
# # ONLIBS is needed for ET
# ET_AC_FLAGS := -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS
# ET_CFLAGS := -02 -fPIC -I. $(ET_AC_FLAGS) -DLINUXVERS
# LIBET := $(CODA)/Linux/lib/libet.so
# ONLIBS := $(LIBET) -lieee -lpthread -ldl -lresolv
# DEFINES += -DONLINE_ET
# HALLALIBS += $(ONLIBS)
# endif
ifdef WITH_DEBUG
DEFINES += -DWITH_DEBUG
endif
CXXFLAGS = $(CXXFLG) $(CXXEXTFLG) $(ROOTCFLAGS) $(INCLUDES) $(DEFINES)
CFLAGS = $(CXXFLG) $(ROOTCFLAGS) $(INCLUDES) $(DEFINES)
LIBS += $(ROOTLIBS) $(SYSLIBS)
GLIBS += $(ROOTGLIBS) $(SYSLIBS)
DEFINES += $(PODD_EXTRA_DEFINES)
export ARCH LIBDIR CXX LD SOFLAGS SONAME CXXFLG LDFLAGS DEFINES
export VERSION SOVERSION VERCODE CXXEXTFLG
$(info Compiling for $(ARCH) with $(CXX))
#------------------------------------------------------------------------------
SRC := src/THaFormula.C src/THaVform.C src/THaVhist.C \
src/THaVar.C src/THaVarList.C src/THaCut.C \
src/THaNamedList.C src/THaCutList.C src/THaInterface.C \
src/THaRunBase.C src/THaCodaRun.C src/THaRun.C \
src/THaRunParameters.C \
src/THaDetMap.C src/THaApparatus.C src/THaDetector.C \
src/THaSpectrometer.C src/THaSpectrometerDetector.C \
src/THaHRS.C \
src/THaDecData.C src/BdataLoc.C src/THaOutput.C src/THaString.C \
src/THaTrackingDetector.C src/THaNonTrackingDetector.C \
src/THaPidDetector.C src/THaSubDetector.C \
src/THaAnalysisObject.C src/THaDetectorBase.C src/THaRTTI.C \
src/THaPhysicsModule.C src/THaVertexModule.C \
src/THaTrackingModule.C \
src/THaAnalyzer.C src/THaPrintOption.C \
src/THaBeam.C src/THaIdealBeam.C \
src/THaRasteredBeam.C src/THaRaster.C\
src/THaBeamDet.C src/THaBPM.C src/THaUnRasteredBeam.C\
src/THaTrack.C src/THaPIDinfo.C src/THaParticleInfo.C \
src/THaCluster.C src/THaArrayString.C \
src/THaScintillator.C src/THaShower.C \
src/THaTotalShower.C src/THaCherenkov.C \
src/THaEvent.C src/THaTrackID.C src/THaVDC.C \
src/THaVDCPlane.C src/THaVDCChamber.C src/THaVDCPoint.C \
src/THaVDCWire.C src/THaVDCHit.C src/THaVDCCluster.C \
src/THaVDCTimeToDistConv.C src/THaVDCTrackID.C \
src/THaVDCAnalyticTTDConv.C \
src/THaVDCPointPair.C src/VDCeff.C \
src/THaElectronKine.C src/THaReactionPoint.C \
src/THaReacPointFoil.C \
src/THaTwoarmVertex.C src/THaAvgVertex.C \
src/THaExtTarCor.C src/THaDebugModule.C src/THaTrackInfo.C \
src/THaGoldenTrack.C \
src/THaPrimaryKine.C src/THaSecondaryKine.C \
src/THaCoincTime.C src/THaS2CoincTime.C \
src/THaTrackProj.C \
src/THaPostProcess.C src/THaFilter.C \
src/THaElossCorrection.C src/THaTrackEloss.C \
src/THaBeamModule.C src/THaBeamInfo.C src/THaEpicsEbeam.C \
src/THaBeamEloss.C \
src/THaTrackOut.C src/THaTriggerTime.C \
src/THaHelicityDet.C src/THaG0HelicityReader.C \
src/THaG0Helicity.C src/THaADCHelicity.C src/THaHelicity.C \
src/THaPhotoReaction.C src/THaSAProtonEP.C \
src/THaTextvars.C src/THaQWEAKHelicity.C \
src/THaQWEAKHelicityReader.C src/THaEvtTypeHandler.C \
src/THaScalerEvtHandler.C src/THaEpicsEvtHandler.C \
src/THaEvt125Handler.C
# ifdef ONLINE_ET
# SRC += src/THaOnlRun.C
# endif
OBJ := $(SRC:.C=.o)
RCHDR := $(SRC:.C=.h) src/THaGlobals.h
HDR := $(RCHDR) src/VarDef.h src/VarType.h src/ha_compiledata.h
DEP := $(SRC:.C=.d) src/main.d
OBJS := $(OBJ) $(HA_DICT).o
HA_LINKDEF := src/HallA_LinkDef.h
LIBHALLA := $(LIBDIR)/libHallA.so
LIBDC := $(LIBDIR)/libdc.so
#------------------------------------------------
PROGRAMS := analyzer
PODDLIBS := $(LIBHALLA) $(LIBDC)
ifdef EVIODIR
PODDLIBS += $(LIBEVIO)
endif
all: subdirs
set -e; for i in $(PROGRAMS); do $(MAKE) $$i; done
src/ha_compiledata.h: Makefile
@echo "#ifndef ANALYZER_COMPILEDATA_H" > $@
@echo "#define ANALYZER_COMPILEDATA_H" >> $@
@echo "" >> $@
@echo "#define HA_INCLUDEPATH \"$(INCDIRS)\"" >> $@
@echo "#define HA_VERSION \"$(VERSION)$(EXTVERS)\"" >> $@
@echo "#define ANALYZER_VERSION_CODE $(VERCODE)" >> $@
@echo "#define ANALYZER_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))" >> $@
@echo "" >> $@
@echo "#endif" >> $@
src/THaInterface.o: src/ha_compiledata.h
subdirs: $(SUBDIRS)
$(SUBDIRS):
set -e; $(MAKE) -C $@
#---------- Core libraries -----------------------------------------
$(LIBHALLA).$(VERSION): $(HDR) $(OBJS)
ifeq ($(strip $(SONAME)),)
$(LD) $(LDFLAGS) $(SOFLAGS) -o $@ $(OBJS)
else
$(LD) $(LDFLAGS) $(SOFLAGS) $(SONAME)$(notdir $(LIBHALLA).$(SOVERSION)) -o $@ $(OBJS)
endif
@echo "$@ done"
$(LIBHALLA).$(SOVERSION): $(LIBHALLA).$(VERSION)
ifneq ($(strip $(LDCONFIG)),)
$(LDCONFIG)
else
rm -f $@
ln -s $(notdir $<) $@
endif
$(LIBHALLA): $(LIBHALLA).$(SOVERSION)
cd $(LIBDIR)
rm -f $@
ln -s $(notdir $<) $@
$(LIBDC).$(SOVERSION): $(LIBDC).$(VERSION)
ifneq ($(strip $(LDCONFIG)),)
$(LDCONFIG)
else
rm -f $@
ln -s $(notdir $<) $@
endif
ifneq ($(strip $(LDCONFIG)),)
$(LDCONFIG)
else
rm -f $@
ln -s $(notdir $<) $@
endif
ifdef EVIODIR
$(DCDIR): evio
endif
$(LIBDC): $(LIBDC).$(SOVERSION)
rm -f $@
ln -s $(notdir $<) $@
ifeq ($(ARCH),linux)
$(HA_DICT).o: $(HA_DICT).C
$(CXX) $(CXXFLAGS) $(DICTCXXFLG) -o $@ -c $^
endif
$(HA_DICT).C: $(RCHDR) $(HA_LINKDEF)
@echo "Generating dictionary $(HA_DICT)..."
$(ROOTBIN)/rootcint -f $@ -c $(ROOTINC) $(INCLUDES) $(DEFINES) $^
#---------- Main program -------------------------------------------
analyzer: src/main.o $(PODDLIBS)
$(LD) $(LDFLAGS) $< $(HALLALIBS) $(GLIBS) -o $@
#---------- Maintenance --------------------------------------------
clean:
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
rm -f *.{so,a,o,os} *.so.*
rm -f $(PROGRAMS) $(HA_DICT).* *~
cd src; rm -f ha_compiledata.h *.{o,os} *~
realclean: clean
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i realclean; done
find . -name "*.d" -exec rm {} \;
srcdist:
rm -f ../$(NAME)
ln -s $(PWD) ../$(NAME)
tar -czv -f ../$(NAME).tar.gz -X .exclude -C .. \
$(addprefix $(NAME)/, \
ChangeLog $(wildcard README*) Makefile .exclude .gitignore \
SConstruct $(wildcard *.py) scons \
src $(DCDIR) Calib DB examples contrib utils docs SDK \
evio/Makefile evio/Makefile.libsrc)
install: all
ifndef ANALYZER
$(error $$ANALYZER environment variable not defined)
endif
ifneq ($(ANALYZER),$(shell pwd))
@echo "Installing in $(ANALYZER) ..."
@mkdir -p $(ANALYZER)/{$(PLATFORM),include,src/src,docs,DB,examples,SDK}
cp -pu $(SRC) $(HDR) $(HA_LINKDEF) $(ANALYZER)/src/src
cp -pu $(HDR) $(ANALYZER)/include
tar cf - $(shell find examples docs SDK -type f | grep -v '*~') | \
tar xf - -C $(ANALYZER)
cp -pu Makefile ChangeLog $(ANALYZER)/src
cp -pru DB $(ANALYZER)/
@echo "Installing in $(ANALYZER)/$(PLATFORM) ..."
for lib in $(filter-out $(LIBEVIO), $(PODDLIBS)); do \
rm -f $(ANALYZER)/$(PLATFORM)/$(notdir $$lib); \
rm -f $(ANALYZER)/$(PLATFORM)/$(notdir $$lib).$(SOVERSION); \
rm -f $(ANALYZER)/$(PLATFORM)/$(notdir $$lib).$(VERSION); \
cp -af $$lib $$lib.$(SOVERSION) $$lib.$(VERSION) \
$(ANALYZER)/$(PLATFORM) 2>/dev/null; \
done
rm -f $(ANALYZER)/$(PLATFORM)/libevio.so
ifdef LIBEVIO
cp -af $(LIBEVIO) $(ANALYZER)/$(PLATFORM)
endif
rm -f $(ANALYZER)/$(PLATFORM)/analyzer $(ANALYZER)/$(PLATFORM)/$(NAME)
cp -pf $(PROGRAMS) $(ANALYZER)/$(PLATFORM)/
ifneq ($(PLATFORM),bin)
rm -f $(ANALYZER)/bin
ln -s $(ANALYZER)/$(PLATFORM) $(ANALYZER)/bin
endif
ifneq ($(NAME),analyzer)
mv $(ANALYZER)/$(PLATFORM)/analyzer $(ANALYZER)/$(PLATFORM)/$(NAME)
ln -s $(NAME) $(ANALYZER)/$(PLATFORM)/analyzer
endif
set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install; done
else
@echo "Everything already installed"
endif
###--- DO NOT CHANGE ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT
### YOU ARE DOING
.PHONY: all clean realclean srcdist subdirs $(SUBDIRS)
.SUFFIXES:
%.o: %.C
ifeq ($(strip $(MAKEDEPEND)),)
$(CXX) $(CXXFLAGS) -MMD -o $@ -c $<
@mv -f $*.d $*.d.tmp
else
$(CXX) $(CXXFLAGS) -o $@ -c $<
$(MAKEDEPEND) $(ROOTINC) $(INCLUDES) $(DEFINES) -c $< > $*.d.tmp
endif
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp
-include $(DEP)