-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
143 lines (109 loc) · 6.4 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
##################################################################################
# 26. Nov. 2018, Editor: Yu-Wei Kao #
# References: #
# 1) https://hiltmon.com/blog/2013/07/03/a-simple-c-plus-plus-project-structure/ #
# 2) http://mropengate.blogspot.com/2018/01/makefile.html #
# 3) https://stackoverflow.com/questions/5950395/makefile-to-compile-multiple-c-programs
# 4) http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
# 5) https://www.wooster.edu/_media/files/academics/areas/computer-science/resources/makefile-tut.pdf
##################################################################################
ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs) -lMinuit
ROOTGLIBS = $(shell root-config --glibs)
# CC := clang --analyze # and comment out the linker last line for sanity
CC := g++ # This is the main compiler
SRCDIR := src
BUILDDIR := build
TARGET := bin/check
TARGET0 := bin/covarianceMatrixStudy
TARGET1 := bin/preselection
#TARGET1 := bin_2/preselection
#TARGET1 := bin_3/preselection
TARGET2 := bin/selection
TARGET3 := bin/generalChiSquareStudy_hadronic_exe
TARGET3b := bin/generalChiSquareStudy_leptonic_exe
TARGET4 := bin/preselection_npustudy
TARGET5 := bin/myKinFit
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
CFLAGS := $(shell root-config --cflags) -g -O3 #-Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL #-Wall -Wextra
LIB := $(shell root-config --libs) -lMinuit
INC := -I include
all: build/libHistFactory.so ${TARGET} ${TARGET0} ${TARGET1} ${TARGET2} $(TARGET3) $(TARGET3b) $(TARGET4)
#all: ${TARGET} ${TARGET0} ${TARGET1} ${TARGET2} $(TARGET3) $(TARGET4) $(TARGET5)
build/libHistFactory.so: include/hist_factory.h include/hist_factory.cpp
@echo "####### Building library build/libHistFactory.so"
@gcc -fPIC -shared $(ROOTCFLAGS) $(ROOTLIBS) -I. include/hist_factory.cpp -o build/libHistFactory.so
#$(TARGET): $(OBJECTS)
# @echo " Linking..."
# @echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB)
$(TARGET): build/check.o
@echo " Linking..."
@echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB)
$(TARGET0): build/covarianceMatrixStudy.o
@echo " Linking..."
@echo " $(CC) $^ -o $(TARGET0) $(LIB)"; $(CC) $^ -o $(TARGET0) $(LIB)
$(TARGET1): build/preselection.o build/genMatching.o
@echo " Linking..."
@echo " $(CC) $^ -o $(TARGET1) $(LIB)"; $(CC) $^ -o $(TARGET1) $(LIB)
$(TARGET2): build/selection.o build/ctag_reshaping.o
@echo " Linking for selection cpp..."
@echo " $(CC) $^ -o $(TARGET2) -L/wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit -lKinFit $(LIB)"; $(CC) $^ -o $(TARGET2) -L/wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit -lKinFit $(LIB)
$(TARGET3): build/generalChiSquareStudy_hadronic_exe.o build/libHistFactory.so build/gen_reco_performance_helper.o
@echo " Linking for generalChiSquareStudy_hadronic_exe cpp..."
@echo " $(CC) $^ -o $(TARGET3) $(LIB)"; $(CC) $^ -o $(TARGET3) $(LIB)
$(TARGET3b): build/generalChiSquareStudy_leptonic_exe.o build/libHistFactory.so
@echo " Linking for generalChiSquareStudy_leptonic_exe cpp..."
@echo " $(CC) $^ -o $(TARGET3b) -L/wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit -lKinFit $(LIB)"; $(CC) $^ -o $(TARGET3b) -L/wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit -lKinFit $(LIB)
$(TARGET4): build/preselection_npustudy.o
@echo " Linking for preselection_npustudy cpp..."
@echo " $(CC) $^ -o $(TARGET4) $(LIB)"; $(CC) $^ -o $(TARGET4) $(LIB)
$(TARGET5): build/myKinFit.o
@echo " Linking for myKinFit cpp..."
@echo " $(CC) $^ -o $(TARGET5) -L/wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit -lKinFit $(LIB)"; $(CC) $^ -o $(TARGET5) -L/wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit -lKinFit $(LIB)
#$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
build/check.o: src/check.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
build/covarianceMatrixStudy.o: src/covarianceMatrixStudy.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
build/preselection.o: src/preselection_exe.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
build/genMatching.o: include/genMatching.cc
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
build/ctag_reshaping.o: include/ctag_reshaping.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
build/gen_reco_performance_helper.o: include/gen_reco_performance_helper.cc include/gen_reco_performance_helper.h
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
build/selection.o: src/selection.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) -I /wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) -I /wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit $(CFLAGS) $(INC) -c -o $@ $<
build/generalChiSquareStudy_hadronic_exe.o: src/generalChiSquareStudy_hadronic_exe.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
build/generalChiSquareStudy_leptonic_exe.o: src/generalChiSquareStudy_leptonic_exe.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) -I /wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) -I /wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit $(CFLAGS) $(INC) -c -o $@ $<
build/preselection_npustudy.o: src/preselection_npustudy.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $<
build/myKinFit.o: src/myKinFit.cpp
@mkdir -p $(BUILDDIR)
@echo " $(CC) -I /wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) -I /wk_cms2/ykao/CMSSW_9_4_10/src/2017/TopKinFit $(CFLAGS) $(INC) -c -o $@ $<
clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET3b) $(TARGET4) $(TARGET5)"
$(RM) -r $(BUILDDIR) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET3b) $(TARGET4) $(TARGET5)
# Tests
tester:
$(CC) $(CFLAGS) test/tester.cpp $(INC) $(LIB) -o bin/tester
# Spikes
ticket:
$(CC) $(CFLAGS) spikes/ticket.cpp $(INC) $(LIB) -o bin/ticket
.PHONY: clean