forked from cghuh/ttbarToBsToTauTau
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
153 lines (123 loc) · 4.35 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
#----------------------------------------------------------------------------
# Description: Makefile to build analyzers
# Created: Thu Jul 26 16:24:24 2018 by mkanalyzer.py
# Author: Sezen Sekmen
#----------------------------------------------------------------------------
ifndef ROOTSYS
$(error *** Please set up Root)
endif
name := BoostAnalyzer
# Sub-directories
srcdir := src
tmpdir := tmp
libdir := lib
incdir := include
$(shell mkdir -p tmp)
$(shell mkdir -p lib)
# Set this equal to the @ symbol to suppress display of instructions
# while make executes
ifdef verbose
AT :=
else
AT := @
endif
#-----------------------------------------------------------------------
# sources and objects
#-----------------------------------------------------------------------
header := $(incdir)/tnm.h
linkdef := $(incdir)/linkdef.h
cinthdr := $(srcdir)/dictionary.h
cintsrc := $(srcdir)/dictionary.cc
# Construct list of sources to be compiled into applications
appsrcs := $(wildcard *.cc)
appobjects := $(addprefix $(tmpdir)/,$(appsrcs:.cc=.o))
# Construct list of applications
applications := $(appsrcs:.cc=)
# Construct list of sources to be compiled into shared library
ccsrcs := $(filter-out $(cintsrc),$(wildcard $(srcdir)/*.cc))
sources := $(ccsrcs) $(cintsrc)
objects := $(subst $(srcdir)/,$(tmpdir)/,$(sources:.cc=.o))
# Display list of applications to be built
#say := $(shell echo "appsrcs: $(appsrcs)" >& 2)
#say := $(shell echo "appobjects: $(appobjects)" >& 2)
#say := $(shell echo "objects: $(objects)" >& 2)
#$(error bye!)
#-----------------------------------------------------------------------
# Define which compilers and linkers to use
#-----------------------------------------------------------------------
# If clang++ exists use it, otherwise use g++
COMPILER:= $(shell which clang++)
ifneq ($(COMPILER),)
CXX := clang++
LINK := clang++
else
CXX := g++
LINK := g++
endif
CINT := rootcint
#-----------------------------------------------------------------------
# Define paths to be searched for C++ header files (#include ....)
#-----------------------------------------------------------------------
CPPFLAGS:= -I. -I$(incdir) -I$(srcdir) $(shell root-config --cflags)
# Define compiler flags to be used
# -c perform compilation step only
# -g include debug information in the executable file
# -O2 optimize
# -ansi require strict adherance to C++ standard
# -Wall warn if source uses any non-standard C++
# -pipe communicate via different stages of compilation
# using pipes rather than temporary files
CXXFLAGS:= -c -g -O2 -ansi -Wall -pipe -fPIC
# C++ Linker
# set path to ROOT libraries (Mac OS workaround)
LD := $(LINK) -Wl,-rpath,$(ROOTSYS)/lib
OS := $(shell uname -s)
ifeq ($(OS),Darwin)
LDSHARED := $(LD) -dynamiclib
LDEXT := .dylib
else
LDSHARED := $(LD) -shared
LDEXT := .so
endif
# Linker flags
LDFLAGS := -g -lGenVector
# Libraries
LIBS := $(shell root-config --libs) -L$(libdir) -lMinuit -lMathCore
sharedlib := $(libdir)/libtnm$(LDEXT)
#-----------------------------------------------------------------------
# Rules
# The structure of a rule is
# target : source
# command
# The command makes a target from the source.
# $@ refers to the target
# $< refers to the source
#-----------------------------------------------------------------------
all: $(sharedlib) $(applications)
bin: $(applications)
lib: $(sharedlib)
# Syntax:
# list of targets : target pattern : source pattern
# Make applications depend on shared libraries to force the latter
# to be built first
$(applications) : % : $(tmpdir)/%.o $(sharedlib)
@echo "---> Linking $@"
$(AT)$(LD) $(LDFLAGS) $< $(LIBS) -ltnm -o $@
$(appobjects) : $(tmpdir)/%.o : %.cc
@echo "---> Compiling application `basename $<`"
$(AT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o $@ # >& $*.FAILED
@rm -rf $*.FAILED
$(sharedlib) : $(objects)
@echo "---> Linking `basename $@`"
$(AT)$(LDSHARED) $(LDFLAGS) -fPIC $(objects) $(LIBS) -o $@
$(objects) : $(tmpdir)/%.o : $(srcdir)/%.cc
@echo "---> Compiling `basename $<`"
$(AT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o $@ # >& $*.FAILED
$(AT)rm -rf $*.FAILED
$(cintsrc) : $(header) $(linkdef)
@echo "---> Generating dictionary `basename $@`"
$(AT)$(CINT) -f $@ -c -I. -Iinclude -I$(ROOTSYS)/include $+
$(AT)mv $(srcdir)/*.pcm $(libdir)
# Define clean up rules
clean :
rm -rf $(tmpdir)/* $(libdir)/* $(srcdir)/dictionary*