forked from joaopela/HEPFW
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakefile
executable file
·154 lines (126 loc) · 4.8 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
ifndef HEPFWSYS
$(error Variable HEPFWSYS is not set... Aborting)
endif
#Necessary to use shell built-in commands
SHELL = bash
CXX = g++
LD = g++
MAKEDEPEND = g++ $(CXXFLAGS) -M
vpath %.h src/
vpath %.cxx src/
.PHONY: all dict obj lib bin docs clean test
BASEDIR = $(shell pwd)
# Define include paths
USERINCLUDES += -I$(ROOTSYS)/include/
USERINCLUDES += -I$(ROOFITSYS)/include/
# USERINCLUDES += -I$(CMSSW_BASE)/src/
USERINCLUDES += -I$(CMS_PATH)/$(SCRAM_ARCH)/external/boost/1.47.0/include/
USERINCLUDES += -I$(realpath $(HEPFWSYS)/src/)
# Define libraries to link
USERLIBS += $(shell root-config --cflags --libs)
USERLIBS += -lGenVector -lTreePlayer -lTMVA
# USERLIBS += -L$(ROOFITSYS)/lib/ -lRooFit -lRooFitCore
USERLIBS += -L$(CMS_PATH)/$(SCRAM_ARCH)/external/boost/1.47.0/lib/ -lboost_regex -lboost_program_options -lboost_filesystem
USERLIBS += -L$(HEPFWSYS)/lib/
# USERLIBS += -L$(CMSSW_BASE)/lib/$(SCRAM_ARCH) -lUserCodeICHiggsTauTau
# USERLIBS += -L$(CMSSW_RELEASE_BASE)/lib/$(SCRAM_ARCH) -lFWCoreFWLite -lPhysicsToolsFWLite -lCommonToolsUtils
# CXXFLAGS = -Wall -W -Wno-unused-function -Wno-parentheses -Wno-char-subscripts -Wno-unused-parameter -O2
CXXFLAGS = -g -W -Wall -O2 -fPIC `root-config --cflags`
# Next line is necessary to compile C++0x code with g++ 4.6.X
CXXFLAGS += -std=c++0x
CXXFLAGS += -Wno-deprecated-declarations
CXXFLAGS += -Wno-unused-parameter
CXXFLAGS += -Wno-unused-but-set-variable
CXXFLAGS += $(USERINCLUDES)
LDFLAGS = -shared -W -Wall -fPIC `root-config --ldflags --cflags`
# File extensions
OBJ_EXT = o
EXE_EXT = exe
SRC_EXT = cxx
HEA_EXT = h
# Lists of packages, files and targets
PKGS = $(subst src/,,$(wildcard src/*))
SPKG = $(subst src/,,$(wildcard src/*/*))
SRCS = $(wildcard src/*/*/src/*.cxx)
HEAS = $(wildcard src/*/*/interface/*.h)
LIBS = $(patsubst %,lib/libHEPFW%.so,$(PKGS))
OBJS = $(patsubst src/%,lib/%,$(subst $(SRC_EXT),$(OBJ_EXT),$(wildcard src/*/*/src/*.cxx)))
BINS = $(subst src/,lib/,$(subst $(SRC_EXT),$(EXE_EXT),$(wildcard src/*/*/exe/*.cxx)))
DICT = src/DataFormats/ICHiggsTauTau/src/dict.cxx
# Pre-processing
SCAN = src/FWCore/Framework/scan/ModulesScan.h src/FWCore/Framework/scan/PostProcessingModulesScan.h
-include $(OBJS:.o=.d)
-include $(BINS:.exe=.d)
all: | dict pre obj lib bin
# *** Scanning for new modules ***
# This is made over two stages:
# 1) Event modules scan
# 2) Post processing modules scan
#
# NOTE: The use of the python command is intended to use
# the CMSSW version of this command and not the system version
# which is currently for my studies SLC5
pre: $(SCAN)
src/FWCore/Framework/scan/ModulesScan.h: $(HEAS)
@python $(HEPFWSYS)/bin/hepfwModulesScan.py --EventProcessing
src/FWCore/Framework/scan/PostProcessingModulesScan.h: $(HEAS)
@python $(HEPFWSYS)/bin/hepfwModulesScan.py --PostProcessing
# Making dictionaries
dict: $(DICT)
# TODO: Make this depend on the actual objects where for which dictionaries will be made
# This should be possible by running dependencies checker on the produced dict file after production
src/DataFormats/ICHiggsTauTau/src/dict.cxx: DataFormats/ICHiggsTauTau/Linkdef.h
@cd src/; rootcint -f DataFormats/ICHiggsTauTau/src/dict.cxx -c -Wall -W -O2 -fPIC `root-config --cflags` -I$ROOTSYS/include -I./ -p DataFormats/ICHiggsTauTau/interface/* DataFormats/ICHiggsTauTau/Linkdef.h
# Building objects
obj: $(OBJS) $(SCAN) $(DICT)
@echo "Objects done!"
@echo ""
lib: $(LIBS) $(SCAN) $(DICT)
@echo "Libraries done!"
@echo ""
bin: $(BINS) $(SCAN) $(DICT)
@echo "Binaries done!"
@echo ""
# Rules to make objects and dependencies
lib/%.o : src/%.cxx
@echo "----->Compiling object: " $@
@$(shell mkdir -p $(dir $@);)
@$(MAKEDEPEND) -MMD -o lib/$*.d $<
@$(CXX) $(CXXFLAGS) -c $< -o $@
# Rules to make libraries
lib/%.so : $(OBJS)
@echo "----->Producing shared lib: " $@
@$(LD) $(LDFLAGS) -o $@ $(filter $(patsubst %,lib/%,$(subst libHEPFW,,$*))%,$(OBJS)) `root-config --glibs`
# Rules to make executables
lib/%.exe : src/%.cxx $(LIBS)
@echo "----->Producing binary: " $@
@$(shell mkdir -p $(dir $@);)
@$(MAKEDEPEND) -MMD -o lib/$*.d $<
@$(shell rm -f bin/$(notdir $(subst .exe,,$@));)
@$(CXX) -o $@ $(CXXFLAGS) $(USERLIBS) $(patsubst lib%.so,-l%,$(notdir $(LIBS))) $<
@$(shell ln -s $(HEPFWSYS)/$@ bin/$(notdir $(subst .exe,,$@));)
clean:
@echo "-----> Cleaning scan files"
@rm -r $(SCAN)
@echo "-----> Cleaning Objects"
@rm -fR $(HEPFWSYS)/lib/*/
@echo "-----> Cleaning Libraries"
@rm -fR $(HEPFWSYS)/lib/*.so
@echo "-----> Cleaning Binaries"
@find bin/ -maxdepth 1 -type l -exec rm -f {} \;
@echo "-----> Cleaning Documentation"
@rm -fr ../html
docs:
@$(shell doxygen lib/Doxyfile;)
test:
@echo "PKGS : "$(PKGS)
@echo "SKGS : "$(SPKG)
@echo ""
@echo "SRCS : "$(SRCS)
@echo "HEAS : "$(HEAS)
@echo "OBJS : "$(OBJS)
@echo ""
@echo "EXES : "$(EXES)
@echo "BINS : "$(BINS)
@echo ""
@echo "LIBS : "$(LIBS)