-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
155 lines (116 loc) · 4.69 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
CC=g++
LD=g++
GCC_VERSION=$(shell g++ --version | head -1 | cut -f 3 -d' ' | cut -f 1 -d'.')
ifeq ($(GCC_VERSION), 3)
F77=g77
F77LDFLAGS=-lg2c
else
F77=gfortran
F77LDFLAGS=-lgfortran
endif
#O2 for optimization, g for debugging, pg for profiling
SPECIALFLAGS= -fpic -g -Wall -O2 #-O1 #-pg# -O2
ROOTAUXCFLAGS=$(shell root-config --auxcflags)
ROOTCFLAGS=$(shell root-config --cflags)
ROOTLIBS=$(shell root-config --libs) -lMinuit2
LFLAGS= $(SPECIALFLAGS) -lz $(F77LDFLAGS) -lgsl -lgslcblas -lm
BOOSTLINKFLAGS=-lboost_thread -lpthread
# change path for MacPort or fink@MacOS
ifeq (exists, $(shell [ -d /opt/local/include/boost ] && echo exists))
BOOSTFLAGS=-I/opt/local/include/boost -I/opt/local/include
LFLAGS += -L/opt/local/lib
BOOSTLINKFLAGS=-lboost_thread-mt -lpthread
else ifeq (exists, $(shell [ -d /sw/include/boost ] && echo exists))
BOOSTFLAGS=-I/sw/include/boost -I/sw/include
SPECIALFLAGS += -arch i386
LFLAGS += -L/sw/lib
else ifneq ($(wildcard /usr/lib64/libboost_thread-mt.so),)
BOOSTLINKFLAGS=-lboost_thread-mt
#-lpthread
else
BOOSTFLAGS=-I/usr/include/boost
endif
RCXX=$(SPECIALFLAGS) $(BOOSTFLAGS) -I. $(ROOTCFLAGS) -DSTANDALONE
RLXX=$(LFLAGS) $(ROOTLIBS) $(BOOSTLINKFLAGS) #-lrt -lpthread # -lposix4
ROOTSYS=$(shell root-config --prefix)
KALIBRIDIR=$(PWD)
#other .cc files
OTHERSRCS=ControlPlotsComparison.cc caliber.cc compareControlPlots.cc JetMETCorFactorsFactory.cc toy.cc
#all files that end up in the Kalibri library:
SRCS=$(filter-out $(OTHERSRCS),$(wildcard *.cc))
OBJS = $(SRCS:.cc=.o)
.PHONY: clean bins libs plugins all PUreweighting lbfgs
all: include libs plugins bins
bin:
@mkdir -p bin
lib:
@mkdir -p lib
tmp:
@mkdir -p tmp
include:
@mkdir -p include
clean:
@rm -rf ti_files tmp lib bin share
@rm -f *~ *.o *# *.d *.bkp junk caliber libKalibri.so *.cfi fort.* .#*
libs: include lib
bins: plugins bin bin/junk bin/caliber
plugins: PUreweighting lbfgs lib lib/libJetMETCor.so
PUreweighting: PUReweighting/LumiReweightingStandAlone.h
lbfgs: include/lbfgs.h lib/liblbfgs.so
lbfgs.o: lbfgs.F
$(F77) $(RCXX) -fno-automatic -fno-backslash -O -c lbfgs.F
lib/libKalibri.so: include/lbfgs.h $(OBJS) lbfgs.o
$(LD) $(RCXX) -shared $^ $(RLXX) -o lib/libKalibri.so
@echo '-> Kalibri library created.'
liblbfgs/configure: liblbfgs/configure.in
@cd liblbfgs && autoconf
liblbfgs/Makefile: liblbfgs/configure
@cd liblbfgs && ./configure --enable-sse2 --prefix=$(KALIBRIDIR)
@echo '-> liblbfgs configured.'
liblbfgs/configure.in:
@git submodule init
@git submodule update
@cd liblbfgs && libtoolize --force
@cd liblbfgs && aclocal
@cd liblbfgs && autoheader
@cd liblbfgs && automake --force-missing --add-missing
include/lbfgs.h lib/liblbfgs.so lib/liblbfgs.a: liblbfgs/Makefile
@cd liblbfgs && $(MAKE) && $(MAKE) install
@echo '-> shared library lib/liblbfgs.so created.'
bin/junk: $(OBJS) lbfgs.o caliber.o lib/liblbfgs.a
$(LD) $^ $(RLXX) lib/liblbfgs.a -o bin/junk
@ln -s -f bin/junk
@echo '-> static Kalibri executable created.'
bin/caliber: caliber.o lib/libKalibri.so lib/liblbfgs.so
$(LD) caliber.o $(RLXX) -Llib -lKalibri -llbfgs -o bin/caliber
@ln -f -s bin/caliber
@echo '-> shared Kalibri executable created.'
#special targets:
toy: ToyMC.o toy.o ConfigFile.o
$(LD) ToyMC.o toy.o ConfigFile.o $(RLXX) -o toy
@echo '-> toy MC executable created.'
comp: ControlPlotsComparison.o compareControlPlots.o
$(LD) ControlPlotsComparison.o compareControlPlots.o $(RLXX) -o compControlPlots
@echo '-> Comparison executable created. Type "compControlPlots" to compare control plots.'
#target for plugins:
lib/libJetMETCor.so: lib/libJetMETObjects.so lib/libKalibri.so JetMETCorFactorsFactory.o
$(LD) $(RCXX) -shared JetMETCorFactorsFactory.o lib/libJetMETObjects.so lib/libKalibri.so $(RLXX) -o lib/libJetMETCor.so
@echo '-> JetMETCor plugin created.'
lib/libJetMETObjects.so: bin lib tmp JetMETObjects
cd JetMETObjects && $(MAKE) STANDALONE_DIR=${PWD} ROOTSYS=${ROOTSYS} CXXFLAGS='${RCXX}' lib
JetMETObjects:
cp -r /afs/cern.ch/cms/slc5_amd64_gcc462/cms/cmssw/CMSSW_5_3_20/src/CondFormats/JetMETObjects .
cd JetMETObjects && patch -p0 < ../JetMETObjects.patch
rm -f JetMETObjects/CondFormats; ln -sf ../ JetMETObjects/CondFormats
PUReweighting/LumiReweightingStandAlone.h:
mkdir PUReweighting
cp /afs/cern.ch/cms/slc5_amd64_gcc462/cms/cmssw/CMSSW_5_3_20/src/PhysicsTools/Utilities/interface/LumiReweightingStandAlone.h PUReweighting/.
cd PUReweighting && patch LumiReweightingStandAlone.h ../LumiReweightingStandAlone.patch
Kalibri.o: include/lbfgs.h
caliber.o: include/lbfgs.h
#rules
.cc.o:
$(CC) $(RCXX) -MMD -c -o $@ $<
@sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.d
-include $(SRCS:%.cc=%.d) $(OTHERSRCS:%.cc=%.d)