-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
142 lines (112 loc) · 3.78 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
#-----------------------------------------------------------------------
# File: Makefile refpriors
#
# Description: This file contains the instructions to compile
# and link the refpriors programs
#
# Created: 24-Jul-2008 Harrison B. Prosper
#-----------------------------------------------------------------------
ifndef ROOTSYS
$(error ROOTSYS not defined - please set up Root)
endif
# Sub-directories
srcdir := src
tmpdir := tmp
bindir := bin
libdir := lib
testdir := test
# Set this equal to the @ symbol to suppress display of instructions
# while make executes
ifdef verbose
AT :=
else
AT := @
endif
# Get list of sources to be compiled into applications
appsrcs := $(wildcard $(testdir)/*.cc)
# Construct names of object models from list of sources
appobjs := $(subst $(testdir)/,$(tmpdir)/,$(appsrcs:.cc=.o))
# Construct list of applications
applications := $(subst $(testdir)/,$(bindir)/,$(appsrcs:.cc=))
# Get list of sources to be made into shared libraries
srcs := $(wildcard $(srcdir)/*.cc)
objs := $(subst $(srcdir)/,$(tmpdir)/,$(srcs:.cc=.o))
sharedlibs := $(libdir)/libBayesianLikelihood.so
# Display list of applications to be built
say := $(shell echo -e "Apps: $(applications)" >& 2)
say := $(shell echo -e "Libs: $(sharedlibs)" >& 2)
say := $(shell echo -e "Srcs: $(srcs)" >& 2)
say := $(shell echo -e "Objs: $(objs)" >& 2)
#$(error bye!)
# Libraries
libs := \
$(shell root-config --libs) -lMathMore -lMathCore -lRooFit \
-L$(libdir) \
-lMinuit
#-----------------------------------------------------------------------
# Define which compilers and linkers to use
# C++ Compiler
ifdef GCC_DIR
CXX := $(GCC_DIR)/bin/g++
LD := $(GCC_DIR)/bin/g++
LDSHARED:= $(GCC_DIR)/bin/g++ -shared
else
CXX := g++
LD := g++
LDSHARED:= g++ -shared
endif
# C++ Linker
# Define paths to be searched for C++ header files (#include ....)
CPPFLAGS:= -I. -I include $(shell root-config --cflags)
# Define compiler flags to be used
# -c perform compilation step only
# -g include debug information in the executable file
# -O2 use 2nd level of optimization
# -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 -O -ansi -Wall -pipe -fPIC
# Linker flags
LDFLAGS := -g
# Libraries
# System libraries reside in /usr/lib and /lib. They are usually
# shared libraries, identified by the file extension ".so".
LIBS := -lm $(libs)
# 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: $(sharedlibs) $(applications)
bin: $(applications)
lib: $(sharedlibs)
# Syntax:
# list of targets : target pattern : source pattern
$(sharedlibs) : $(objs)
@echo "---> Linking $@"
@echo $(AT)$(LDSHARED) $(LDFLAGS) -fPIC $(objs) -o $@
$(AT)$(LDSHARED) $(LDFLAGS) -fPIC $(objs) -o $@
# Make applications depend on shared libraries to force the latter
# to be built first
$(applications) : $(bindir)/% : $(tmpdir)/%.o $(sharedlibs)
@echo "---> Linking $@"
echo $(AT)$(LD) $(objs) $(LDFLAGS) $< $(LIBS) -o $@
$(AT)$(LD) $(objs) $(LDFLAGS) $< $(LIBS) -o $@
$(appobjs) : $(tmpdir)/%.o : $(testdir)/%.cc
@echo "---> Compiling `basename $<`"
@echo $(AT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o $@ #>& $*.FAILED
$(AT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o $@ #>& $*.FAILED
$(AT)rm -rf $*.FAILED
$(objs) : $(tmpdir)/%.o : $(srcdir)/%.cc
@echo "---> Compiling `basename $<`"
@echo $(AT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o $@ #>& $*.FAILED
$(AT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o $@ #>& $*.FAILED
$(AT)rm -rf $*.FAILED
# Define clean up rules
clean :
rm -rf $(tmpdir)/*.o
veryclean :
rm -rf $(tmpdir)/*.o $(bindir)/* $(libdir)/*.so