-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
141 lines (101 loc) · 3.87 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
#
# General Makefile for the package
#
#
# Replace the wildcard expression with .cc file list if you do
# not want to compile all .cc files in this directory
#
TOPDIR= $(shell pwd)
BINDIR = $(TOPDIR)/bin
LIBDIR = $(TOPDIR)/lib
SRCDIR = $(TOPDIR)/src
INCDIR = $(TOPDIR)/include
OBJDIR = $(TOPDIR)/obj
USER_SRCS = $(wildcard $(SRCDIR)/*.cc)
HEADERS_DICT = $(INCDIR)/MathUtils.h $(INCDIR)/SpectrumUtils.h $(INCDIR)/ForwardFolder.h
OBJS = $(USER_SRCS:.cc=.o)
MAIN_SRC = UnfoldSpectrum.cc
MAIN_OBJ = $(MAIN_SRC:.cc=.o)
## Get platform 32/64 bit
LBITS = $(shell getconf LONG_BIT)
# Set executable a name
ROOT_CLASS_DICT= ClassDictionary.cc
SHARED_LIB = libSpectrumUnfolder.so
EXE = SpectrumUnfolder
#
#############################################################
## You should not need to change anything below this line ###
.PHONY: all depend clean
######################################
### CPPFLAGS & CXXFLAGS ############
######################################
CPPFLAGS = -I$(INCDIR)
ifeq ($(LBITS),64)
# do 64 bit stuff here
CPPFLAGS += -I/usr/include -pthread -m64
CXXFLAGS = -std=c++11 -O2 -Wall -Wunused -Wuninitialized -Woverloaded-virtual -fPIC -pthread -m64
SYSLIBDIR = /usr/lib/x86_64-linux-gnu
else
# do 32 bit stuff here
CPPFLAGS += -I/usr/include -pthread -m32
CXXFLAGS = -std=c++11 -O2 -Wall -Wunused -Wuninitialized -Woverloaded-virtual -fPIC -pthread -m32
SYSLIBDIR = /usr/lib
endif
SOFLAGS = -fPIC -ggdb3 -Wall -shared
CPPFLAGS_ROOT= -I$(ROOTSYS)/include
CPPFLAGS += $(CPPFLAGS_ROOT)
###########################
### LDFLAGS ############
###########################
LDFLAGS_ROOT = $(shell root-config --libs) -L$(ROOTSYS)/lib -lSpectrum -lMathMore -lMinuit
LDFLAGS_SYSTEM = -L$(SYSLIBDIR) -lrt
LDFLAGS = $(LDFLAGS_ROOT)
################################################################
all: PRINTINFO GETOBJS $(SHARED_LIB) $(EXE) PUTOBJS
PRINTINFO:
@echo 'Compiling $(EXE) on a $(LBITS) bit machine' \
GETOBJS:
@echo "Put object and lib files again to $(SRCDIR) dir"
- mv -f $(OBJDIR)/*.o $(SRCDIR) 2>/dev/null
- mv -f $(LIBDIR)/$(SHARED_LIB) $(TOPDIR) 2>/dev/null
- mv -f $(LIBDIR)/ClassDictionary_rdict.pcm $(TOPDIR) 2>/dev/null
- mv -f $(BINDIR)/$(EXE) $(TOPDIR) 2>/dev/null
PUTOBJS:
@echo "Moving object files to $(OBJDIR) dir, binariers to $(BINDIR) and libraries to $(LIB) dir"
- mv -f $(SRCDIR)/*.o $(OBJDIR) 2>/dev/null
- mv -f *.o $(OBJDIR) 2>/dev/null
- mv -f $(SHARED_LIB) $(LIBDIR) 2>/dev/null
- mv -f ClassDictionary_rdict.pcm $(LIBDIR) 2>/dev/null
- mv -f $(EXE) $(BINDIR) 2>/dev/null
$(ROOT_CLASS_DICT): $(HEADERS_DICT) LinkDef.h
@echo "Generating $@ ROOT dictionary class ..."
rootcling -f $@ -c $(CXXFLAGS) $(CPPFLAGS) -p $^
# rootcint -f $@ -c -p $(CPPFLAGS) $^
$(SHARED_LIB): $(ROOT_CLASS_DICT) $(USER_SRCS)
@echo "Generating $@ shared library ..."
@$(CXX) $(CXXFLAGS) $(SOFLAGS) $(CPPFLAGS) $^ -o $@ $(LDFLAGS)
$(EXE): $(MAIN_SRC) $(OBJS) ClassDictionary.o
@echo "Building SpectrumUnfolder ..."
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) -L$(TOPDIR) -lSpectrumUnfolder
#############################################################
# gcc can generate the dependency list
depend: Make-depend
Make-depend: $(USER_SRCS)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -MM $^ > $@
clean:
- rm -f *.o $(OBJDIR)/*.o $(SRCDIR)/*.o
- rm -f $(EXE) $(BINDIR)/$(EXE)
- rm -f $(SHARED_LIB) $(LIBDIR)/$(SHARED_LIB)
- rm -f ClassDictionary.cc ClassDictionary.h ClassDictionary_rdict.pcm $(LIBDIR)/ClassDictionary_rdict.pcm
- rm -f core Make-depend
#############################################################
# 'make run' will run the thing
#############################################################
# the lines below are for running with debugger 'make run_gdb'
.INTERMEDIATE: gdb.cmdl
# batch mode gdb needs a file with commands
gdb.cmdl:
echo "r -b bootstrap.xml" > $@
run_gdb: gdb.cmdl $(EXE)
gdb -batch -x $< ./$(EXE) && touch $@
include Make-depend