-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (82 loc) · 3.43 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
# Compiler and shell
CC = g++
SHELL = /bin/bash
RM = rm -f
# Extensions
SRCEXT = cpp
HDREXT = h
OBJEXT = o
LIBEXT = so
# Directories
PWD = $(shell pwd)
SRCDIR = src
BINSRCDIR = app
LIBSRCDIR = lib
HDRDIR = include
OBJDIR = build
LIBDIR = lib
BINDIR = bin
# Where the output is
OUTPUT = $(OBJDIR)/*/*.$(OBJEXT) $(OBJDIR)/*.$(OBJEXT) $(LIBDIR)/*.$(LIBEXT) $(BINDIR)/*
LOGDIRS = latex/figs latex/results ntuples scripts/log scripts/tables
# ROOT
ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs)
ROOTLIBDIR = $(shell root-config --libdir)
EXTRA_ROOTLIBS = -lRooFit -lRooStats -lRooFitCore
ROOTLIBFLAGS = -L$(ROOTLIBDIR) -Wl,--as-needed $(ROOTLIBS) $(EXTRA_ROOTLIBS) -Wl,-rpath,$(ROOTLIBDIR)
# Submodules
COMMONDIR = common
COMCXXFLAGS = $(shell make -sC $(COMMONDIR) cflags)
COMLIBS = $(shell make -sC $(COMMONDIR) libs)
COMLIBDIR = $(shell make -sC $(COMMONDIR) libdir)
COMLIBFLAGS = -L$(COMLIBDIR) -Wl,--as-needed $(COMLIBS) -Wl,-rpath,$(COMLIBDIR)
CLONEDIR = CloneTagger
CLONECXXFLAGS = $(shell make -sC $(CLONEDIR) cflags)
CLONELIBS = $(shell make -sC $(CLONEDIR) libs)
CLONELIBDIR = $(shell make -sC $(CLONEDIR) libdir)
CLONELIBFLAGS = -L$(CLONELIBDIR) -Wl,--as-needed $(CLONELIBS) -Wl,-rpath,$(CLONELIBDIR)
ERFDIR = ExtraRooFit
ERFCXXFLAGS = $(shell make -sC $(ERFDIR) cflags)
ERFLIBS = $(shell make -sC $(ERFDIR) libs)
ERFLIBDIR = $(shell make -sC $(ERFDIR) libdir)
ERFLIBFLAGS = -L$(ERFLIBDIR) -Wl,--as-needed $(ERFLIBS) -Wl,-rpath,$(ERFLIBDIR)
SUBMODULES = $(COMMONDIR) $(CLONEDIR) $(ERFDIR)
# GSL and Boost
EXTRA_LIBFLAGS = -Wl,--as-needed -lgsl -lgslcblas -lboost_program_options
# Get files and make list of objects and libraries
BINSRCS := $(shell find $(SRCDIR)/$(BINSRCDIR) -name '*.$(SRCEXT)')
LIBSRCS := $(shell find $(SRCDIR)/$(LIBSRCDIR) -name '*.$(SRCEXT)')
HDRS := $(shell find $(HDRDIR) -name '*.$(HDREXT)')
LIBS := $(patsubst $(SRCDIR)/$(LIBSRCDIR)/%.$(SRCEXT), $(LIBDIR)/lib%.$(LIBEXT), $(LIBSRCS))
BINS := $(patsubst $(SRCDIR)/$(BINSRCDIR)/%.$(SRCEXT), $(BINDIR)/%, $(BINSRCS))
# Compiler flags
CXXFLAGS = -Wall -fPIC -I$(HDRDIR) $(COMCXXFLAGS) $(CLONECXXFLAGS) $(ERFCXXFLAGS) $(ROOTCFLAGS) --std=c++1y
LOCAL_LIBFLAGS = -L$(LIBDIR) $(patsubst $(LIBDIR)/lib%.$(LIBEXT), -l%, $(LIBS)) -Wl,-rpath,$(PWD)/$(LIBDIR)
EXTERNAL_LIBFLAGS = $(COMLIBFLAGS) $(CLONELIBFLAGS) $(ROOTLIBFLAGS) $(EXTRA_LIBFLAGS) $(ERFLIBFLAGS)
LIBFLAGS = -Wl,--no-undefined -Wl,--no-allow-shlib-undefined $(LOCAL_LIBFLAGS) $(EXTERNAL_LIBFLAGS)
.PHONY: all $(SUBMODULES) clean
all : $(LIBS) $(BINS) | $(LOGDIRS)
$(SUBMODULES) :
make -C $@
# Build binaries
$(BINDIR)/% : $(OBJDIR)/$(BINSRCDIR)/%.$(OBJEXT) $(LIBS) | $(BINDIR) $(SUBMODULES)
@echo "Linking $@"
@$(CC) $< -o $@ $(LIBPREFIX) $(LIBFLAGS)
# Build libraries
$(LIBDIR)/lib%.$(LIBEXT) : $(OBJDIR)/$(LIBSRCDIR)/%.$(OBJEXT) $(HDRS) | $(LIBDIR) $(SUBMODULES)
@echo "Making shared object $@"
@$(CC) -shared $< -o $@ $(EXTERNAL_LIBFLAGS)
# Build objects
$(OBJDIR)/%.$(OBJEXT) : $(SRCDIR)/%.$(SRCEXT) $(HDRS) | $(OBJDIR) $(OBJDIR)/$(LIBSRCDIR) $(OBJDIR)/$(BINSRCDIR)
@echo "Compiling $@"
@$(CC) -c $< -o $@ $(CXXFLAGS)
# Make directories
$(LOGDIRS) $(BINDIR) $(LIBDIR) $(OBJDIR) $(OBJDIR)/$(LIBSRCDIR) $(OBJDIR)/$(BINSRCDIR) :
mkdir -p $@
# Remove all the output
clean :
$(RM) $(OUTPUT)
make -C $(COMMONDIR) clean
make -C $(CLONEDIR) clean
make -C $(ERFDIR) clean