-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
143 lines (115 loc) · 4.21 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
# this is a standalone makefile for building this package independent
# of any external framework
#
# if you are aiming at using this framework in connection with other
# packages, please use RootCore for build
#
# for questions or comments, please contact [email protected]
# change names (and possibly paths) of binaries
CXX=g++
ROOTCONFIG=root-config
ADDCFLAGS=
ADDCXXFLAGS=-Wno-misleading-indentation
ADDROOTCXXFLAGS=
ADDLDFLAGS=
DICTFLAGS=
-include MyConfig.mk
ifndef ROOTCINT
ifeq ($(shell root-config --version | cut -d. -f1 ),6)
ROOTCINT=rootcling -v0
else
ROOTCINT=rootcint
CINTFLAGS=-c
endif
endif
# you might want to set the TQPATH variable to point towards your
# (primary) checkout directory of the QFramework
ifndef TQPATH
TQPATH = $(PWD)
endif
# verbosity control
ifeq ($(MAKE_VERBOSE),)
MAKE_SILENT=@
else
MAKE_SILENT=
endif
# directory structure
SRC_DIR=Root
INC_DIR=QFramework
LIB_DIR=lib
OBJ_DIR=obj
# setup compiler flags
CFLAGS = -I/usr/include/libxml2 -I. `xml2-config --cflags`
ifeq ($(shell ${CXX} --version | grep -q clang),1)
CXXFLAGS = -Wall -pedantic -std=c++14 $(ADDCXXFLAGS) $(VCXXFLAGS) -Wno-deprecated-declarations -Wno-tautological-compare $(ADDCFLAGS) -fPIC
else
CXXFLAGS = -Wall -pedantic -std=c++14 $(ADDCXXFLAGS) $(VCXXFLAGS) -Wno-deprecated-declarations $(ADDCFLAGS) -fPIC
endif
ROOTCXXFLAGS = -I$(shell $(ROOTCONFIG) --incdir) $(ADDROOTCXXFLAGS)
# setup linker flags
LIBS = -pthread -m64 -lxml2 `xml2-config --libs`
SOFLAGS = -shared
ROOTLIBS = $(shell $(ROOTCONFIG) --libs) -lTreePlayer -lHistPainter
ROOTLDFLAGS = $(shell $(ROOTCONFIG) --ldflags)
# automatically search for all classes and headers
SOURCES = $(shell ls $(SRC_DIR)/TQ*.cxx)
TEMPLATES = $(shell ls $(INC_DIR)/TQ*.tpp)
HEADERS_ = $(shell ls $(INC_DIR)/TQ*.h)
HEADERS = $(HEADERS_:$(SRC_DIR)/%=$(INC_DIR)/%)
OBJECTS_ = $(SOURCES:.cxx=.o)
OBJECTS = $(OBJECTS_:$(SRC_DIR)/%=$(OBJ_DIR)/%)
DICTHDR = $(OBJ_DIR)/QFrameworkCINT.h
DICTSRC = $(OBJ_DIR)/QFrameworkCINT.cxx
DICTOBJ = $(OBJ_DIR)/QFrameworkCINT.dict
#ifeq ($(shell echo | g++ -E --std=c++11 - &> /dev/null && echo $$?),0)
# obligatory 'all' target
all: $(LIB_DIR)/libQFramework.so $(LIB_DIR)/QFrameworkCINT_rdict.pcm pythonbindings | $(DICTOBJ)
#else
# print warning if compiler is not c++11-compliant
#cpp11warn:
# @echo "please use a c++11-compliant compiler!"
#endif
# create directory required for build
$(LIB_DIR):
@echo "creating lib directory"
$(MAKE_SILENT)mkdir $(LIB_DIR)
$(OBJ_DIR):
@echo "creating obj directory"
$(MAKE_SILENT)mkdir $(OBJ_DIR)
# generate LinkDef.h (and other input files)
ADDTARGETS=$(SRC_DIR)/definitions.h $(SRC_DIR)/locals.h $(SRC_DIR)/LinkDef.h
$(ADDTARGETS): addtargets
addtargets: $(HEADERS)
@echo "creating LinkDef.h"
$(MAKE_SILENT)cd $(TQPATH)/cmt && bash precompile.RootCore
$(TQPATH)/lib/QFramework.py: $(LIB_DIR)
$(MAKE_SILENT)ln -sf $(TQPATH)/python $(TQPATH)/lib/QFramework
pythonbindings: $(TQPATH)/lib/QFramework.py
$(MAKE_SILENT)echo "please ensure that the following is part of your \$$PYTHONPATH:"
$(MAKE_SILENT)echo " "$(TQPATH)/lib
$(MAKE_SILENT)echo "your current \$$PYTHONPATH is:"
$(MAKE_SILENT)echo " "$(PYTHONPATH)
# create the dictionaries
# currently, this still uses CINT
# at some point, we will switch to ROOT6
$(DICTSRC) $(DICTHDR): $(HEADERS) $(ADDTARGETS) | $(OBJ_DIR)
@echo "creating dictionary"
$(MAKE_SILENT)$(ROOTCINT) -f $(DICTSRC) $(CINTFLAGS) $(CFLAGS) -p $(HEADERS) $(SRC_DIR)/LinkDef.h
# actually compile the code
$(DICTOBJ): $(DICTSRC)
@echo "compiling dictionary"
$(MAKE_SILENT)$(CXX) -c $(CFLAGS) $(CXXFLAGS) $(DICTFLAGS) $(ROOTCXXFLAGS) $^ -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cxx $(SRC_DIR)/locals.h $(SRC_DIR)/definitions.h | $(OBJ_DIR)
@echo "compiling $@"
$(MAKE_SILENT)$(CXX) -c $(CFLAGS) $(CXXFLAGS) $(ROOTCXXFLAGS) $(SRC_DIR)/$*.cxx -o $@
# do the linking
$(LIB_DIR)/libQFramework.so: $(DICTOBJ) $(OBJECTS) | $(LIB_DIR)
@echo "linking shared object"
$(MAKE_SILENT)$(CXX) $(SOFLAGS) $^ -o $@ $(ROOTLDFLAGS) $(LIBS) $(ROOTLIBS) $(ADDLDFLAGS)
# copy the pcm file
$(LIB_DIR)/QFrameworkCINT_rdict.pcm: $(OBJ_DIR)/QFrameworkCINT.cxx | $(LIB_DIR)
@cp $(OBJ_DIR)/QFrameworkCINT_rdict.pcm $@
cleanconfig:
rm $(ADDTARGETS)
clean: cleanconfig
rm -rf obj lib