-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
119 lines (95 loc) · 3.1 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
# makefile for SUSY ntuple skimmer
# Author: Dan Guest ([email protected])
# Created: Wed Jul 4 15:30:40 CEST 2012
# --- set dirs
BIN := bin
SRC := src
INC := include
DICT := dict
DEP := $(BIN)
ifndef ROOTCOREDIR
$(error "couldn't find ROOTCOREDIR")
endif
SUSYTOOLS_INC := $(shell ./map_libs.sh -i )
# set search path
vpath %.o $(BIN)
vpath %.cxx $(SRC)
vpath %.hh $(INC) $(SUSYTOOLS_INC)
vpath %.h $(INC) $(SUSYTOOLS_INC)
vpath %Dict.h $(DICT)
vpath %Dict.cxx $(DICT)
# --- load in root config
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTLDFLAGS := $(shell root-config --ldflags)
ROOTLIBS += -lTreePlayer #don't know why this isn't loaded by default
ROOTLIBS += -lTMVA #don't know why this isn't loaded by default
ROOTLIBS += -lXMLParser #don't know why this isn't loaded by default
ROOTLIBS += -lEG #for TParticle
# --- set compiler and flags (roll c options and include paths together)
CXXFLAGS := -O2 -Wall -fPIC -I$(INC) $(SUSYTOOLS_INC:%=-I%) -g
COMPILER_NAME := $(notdir ${CXX})
ifeq ($(COMPILER_NAME), g++)
LDFLAGS := -Wl,-no-undefined
endif
LIBS := $(shell ./map_libs.sh -l )
# rootstuff
CXXFLAGS += $(ROOTCFLAGS)
LDFLAGS += $(ROOTLDFLAGS)
LIBS += $(ROOTLIBS)
# pystuff (roll the linking options and libraries together)
PY_LDFLAGS := $(LDFLAGS)
PY_LDFLAGS += $(PY_LIB)
PY_LDFLAGS += -shared
# dependency flags
DEPINCLUDE := -I$(INC) $(SUSYTOOLS_INC:%=-I%) -I$(shell root-config --incdir)
DEPFLAGS = -M -MP -MT $(BIN)/$*.o -MT $(DEP)/$*.d $(DEPINCLUDE) $(PY_FLAGS)
# ---- define objects
TOBJ := SusyBuffer.o
T_DICTS := $(TOBJ:.o=Dict.o)
GEN_OBJ := SmartChain.o CutCounter.o CtagCalibration.o sbottom_functions.o
GEN_OBJ += PileupReweighting.o
GEN_OBJ += sbottom_functions.o mctlib.o
EXE_OBJ := cutflow.o
ALLDEPOBJ := $(TOBJ) $(EXE_OBJ) $(GEN_OBJ)
ALLOBJ := $(ALLDEPOBJ) $(TDICTS)
OUTPUT := cutflow
all: $(OUTPUT)
$(OUTPUT): $(ALLOBJ:%=$(BIN)/%)
@echo "linking $^ --> $@"
@$(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)
# --------------------------------------------------
# root dictionary generation
$(DICT)/%Dict.cxx: %.h LinkDef.hh
@echo making dict $@
@mkdir -p $(DICT)
@rm -f $(DICT)/$*Dict.h $(DICT)/$*Dict.cxx
@rootcint $@ -c $(INC)/$*.h
@sed -i 's,#include "$(INC)/\(.*\)",#include "\1",g' $(DICT)/$*Dict.h
$(BIN)/%Dict.o: $(DICT)/%Dict.cxx
@mkdir -p $(BIN)
@echo compiling dict $@
@$(CXX) $(CXXFLAGS) $(ROOTCFLAGS) -c $< -o $@
# compile rule
$(BIN)/%.o: %.cxx
@echo compiling $<
@mkdir -p $(BIN)
@$(CXX) -c $(CXXFLAGS) $< -o $@
# use auto dependency generation
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),rmdep)
include $(ALLDEPOBJ:%.o=$(DEP)/%.d)
endif
endif
$(DEP)/%.d: %.cxx
@echo making dependencies for $<
@mkdir -p $(DEP)
@$(CXX) $(DEPFLAGS) $< -o $@
# clean
.PHONY : clean rmdep
CLEANLIST = *~ *.o *.o~ *.d core
clean:
rm -fr $(CLEANLIST) $(CLEANLIST:%=$(BIN)/%) $(CLEANLIST:%=$(DEP)/%)
rm -fr $(BIN) $(OUTPUT) $(DICT) $(DEP)
rmdep:
rm -f $(DEP)/*.d