-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
153 lines (128 loc) · 4.12 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
#---------------=============== ROOT RELATED ===============---------------
ROOTCONFIG := root-config
ARCH := $(shell $(ROOTCONFIG) --arch)
PLATFORM := $(shell $(ROOTCONFIG) --platform)
ALTCC := $(shell $(ROOTCONFIG) --cc)
ALTCXX := $(shell $(ROOTCONFIG) --cxx)
ALTF77 := $(shell $(ROOTCONFIG) --f77)
ALTLD := $(shell $(ROOTCONFIG) --ld)
#CXX =
ObjSuf = o
SrcSuf = cxx
ExeSuf =
DllSuf = so
OutPutOpt = -o # keep whitespace after "-o"
ifeq (debug,$(findstring debug,$(ROOTBUILD)))
OPT = -g
OPT2 = -g
else
ifneq ($(findstring debug, $(strip $(shell $(ROOTCONFIG) --config))),)
OPT = -g
OPT2 = -g
else
OPT = -O
OPT2 = -O2
endif
endif
ROOTCFLAGS := $(shell $(ROOTCONFIG) --cflags)
ROOTLDFLAGS := $(shell $(ROOTCONFIG) --ldflags)
ROOTLIBS := $(shell $(ROOTCONFIG) --libs)
ROOTGLIBS := $(shell $(ROOTCONFIG) --glibs)
HASTHREAD := $(shell $(ROOTCONFIG) --has-thread)
ROOTDICTTYPE := $(shell $(ROOTCONFIG) --dicttype)
#NOSTUBS := $(shell $(ROOTCONFIG) --nostubs)
ROOTCINT := rootcint
# Stub Functions Generation
ifeq ($(NOSTUBS),yes)
ROOTCINT = export CXXFLAGS="$(CXXFLAGS)"; $(ROOTSYS)/core/utils/src/rootcint_nostubs.sh -$(ROOTDICTTYPE)
endif
ifeq ($(ARCH),linuxx8664gcc)
# Linux with egcs, gcc 2.9x, gcc 3.x
CXX = g++
CXXFLAGS = $(OPT2) -Wall -fPIC
LD = g++
LDFLAGS = $(OPT2) -L/usr/local/lib -lnsl -lz -lm -lSpectrum
SOFLAGS = -shared
endif
CXXFLAGS += $(ROOTCFLAGS)
LDFLAGS += $(ROOTLDFLAGS)
LIBS = $(ROOTLIBS) $(SYSLIBS)
GLIBS = $(ROOTGLIBS) $(SYSLIBS)
GLIBS += -lSpectrum -LTBufferClasses
ifneq ($(ALTCC),)
CC = $(ALTCC)
endif
ifneq ($(ALTCXX),)
CXX = $(ALTCXX)
endif
ifneq ($(ALTF77),)
F77 = $(ALTF77)
endif
ifneq ($(ALTLD),)
LD = $(ALTLD)
endif
ifneq ($(findstring g++, $(CXX)),)
GCC_MAJOR := $(shell $(CXX) -dumpversion 2>&1 | cut -d'.' -f1)
GCC_MINOR := $(shell $(CXX) -dumpversion 2>&1 | cut -d'.' -f2)
endif
CFLAGS = -Wall -ggdb $(CXXFLAGS) $(LDFLAGS) $(ROOTCFLAGS) $(ROOTLDFLAGS) $(ROOTLIBS) $(ROOTGLIBS)
#---------------=============== ROOT RELATED ===============---------------
#---------------=============== MAIN MAKEFILE ===============---------------
CC = g++
TARGET = plotCaenGeckoLogs
SOURCE = plotCaenGeckoLogs.cpp TLogPlotter.cpp TLogStorage.cpp TAsciiFileReader.cpp TSingleLogLine.cpp TLogFileReader.cpp cliParams.cpp cliParser.cpp
INCLUDE = -I./ $(AN_INCLUDE_DIR)
## end more includes
OBJ=$(join $(addsuffix obj/, $(dir $(SOURCE))), $(notdir $(SOURCE:.cpp=.o)))
## Fix dependency destination to be ../.dep relative to the src dir
DEPENDS=$(join $(addsuffix .dep/, $(dir $(SOURCE))), $(notdir $(SOURCE:.cpp=.d)))
## Default rule executed
all: $(TARGET)
@true
#install:
# @echo "Installing binary in /bin folder"
# @-sudo cp emmadiagnostics /bin
## Clean Rule
clean:
@echo "Removing .o files"
@-rm -f $(TARGET) $(OBJ) $(DEPENDS)
@echo "Removing root dictionary files"
@-rm -f $(ROOTDICT) $(ROOTDICT:.cpp=.h)
@echo "Removing obj folders"
@-rmdir obj
@echo "Removing .dep folders"
@-rmdir .dep
## Rule for making the actual target
$(TARGET): $(OBJ)
@echo "============="
@echo "Linking the target $@"
@echo "============="
@$(CC) $(CFLAGS) -o $@ $^ $(GLIBS)
@echo -- Link finished --
## Generic compilation rule
%.o : %.cpp
@mkdir -p $(dir $@)
@echo "============="
@echo "Compiling $<"
@$(CC) $(CFLAGS) -c $< -o $@
## Rules for object files from .cpp files
## Object file for each file is put in obj directory
obj/%.o : %.cpp
@mkdir -p $(dir $@)
@echo "============="
@echo "Compiling $<"
@$(CC) $(CFLAGS) -c $< -o $@
## Make dependancy rules
.dep/%.d: %.cpp
@mkdir -p $(dir $@)
@echo "============="
@echo Building dependencies file for $*.o
@$(SHELL) -ec '$(CC) -M $(CFLAGS) $< | sed "s^$*.o^obj/$*.o^" > $@'
## Make root dictionary
$(ROOTDICT): $(ROOTDICTSRC)
@echo "============="
@echo "Generating dictionary $<"
@$(ROOTCINT) -f $(ROOTDICT) -c $(ROOTDICTSRC)
## Include the dependency files
-include $(DEPENDS)
#---------------=============== MAIN MAKEFILE ===============---------------