-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
90 lines (71 loc) · 2.75 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
CXX := $(shell root-config --cxx)
CXXFLAGS := $(shell root-config --cflags) -fPIC
LDFLAGS := $(shell root-config --glibs)
VERSION := $(shell root-config --version | cut -d'.' -f1)
ifeq ($(VERSION),6)
DICTEXE = rootcling
MINOR := $(shell root-config --version | cut -d'.' -f2 | cut -d'/' -f1)
LT20 := $(shell [ $(MINOR) -lt 20 ] && echo true)
ifeq ($(LT20),true)
DICTFLAGS = -c -p
endif
else
DICTEXE = rootcint
DICTFLAGS = -c -p
endif
PACKAGE = OscProb
HEADERS := $(filter-out $(CURDIR)/inc/LinkDef.h, $(wildcard $(CURDIR)/inc/*.h))
SOURCES := $(wildcard $(CURDIR)/src/*.cxx)
TARGET = lib$(PACKAGE)
TARGET_LIB = $(CURDIR)/lib/$(TARGET).so
TARGET_PCM = $(CURDIR)/lib/$(TARGET)_rdict.pcm
DICTIONARY = $(CURDIR)/tmp/$(TARGET).cxx
#Eigen library
Eigen_INCS = ${CURDIR}/eigen
INCDIRS = -I$(CURDIR) -I$(CURDIR)/inc -I$(Eigen_INCS)
override CXXFLAGS += $(INCDIRS)
# the sets of directories to do various things in
MATRIX = $(CURDIR)/MatrixDecomp/libMatrixDecomp.so
SUBDIRS = MatrixDecomp
BUILDDIRS = $(SUBDIRS:%=build-%)
CLEANDIRS = $(SUBDIRS:%=clean-%)
PREMDIR = $(CURDIR)/PremTables
MODEL3DDIR = $(CURDIR)/EarthTables
PREMFILE = $(PREMDIR)/prem_default.txt
PREM3DFILE = $(MODEL3DDIR)/earth_binned_default.txt
PREMINC = $(CURDIR)/inc/prem_default.hpp
# Define list of submodules
SUBMODULES = $(shell grep path .gitmodules | sed 's/.*= //')
SUBMODULES := $(patsubst %,%/.git,$(SUBMODULES))
all: $(SUBMODULES) $(BUILDDIRS) $(PREMINC) $(TARGET_LIB)
$(TARGET_LIB): $(DICTIONARY) $(SOURCES) $(MATRIX)
@echo " Building $(PACKAGE)..."
@mkdir -p lib
@$(CXX) $(CXXFLAGS) -O3 -shared -o$@ $^ $(LDFLAGS)
$(DICTIONARY): $(HEADERS) inc/LinkDef.h
@echo " Making dictionary for $(PACKAGE)..."
@mkdir -p tmp
@$(DICTEXE) -f $@ $(DICTFLAGS) $(INCDIRS) $^
@if [ -e $(DICTIONARY:%.cxx=%_rdict.pcm) ] ; then mkdir -p lib && mv $(DICTIONARY:%.cxx=%_rdict.pcm) $(TARGET_PCM) ; fi # ROOT 6
$(SUBMODULES):
@echo " $@ not found. Trying to initialize submodule..."
@echo " git submodule update --init"
@git submodule update --init
$(BUILDDIRS):
@exec $(MAKE) -s -C $(@:build-%=%)
$(CLEANDIRS):
@exec $(MAKE) -s -C $(@:clean-%=%) clean
$(PREMINC): $(PREMDIR) $(PREMFILE) $(MODEL3DDIR) $(PREM3DFILE)
@echo "#include <string>" > $@
@echo "const std::string PREM_DIR = \"$(PREMDIR)\";" >> $@
@echo "const std::string MODEL3D_DIR = \"$(MODEL3DDIR)\";" >> $@
@echo "const std::string PREM_DEFAULT = \"$(PREMFILE)\";" >> $@
@echo "const std::string PREM3D_DEFAULT = \"$(PREM3DFILE)\";" >> $@
test: $(TARGET_LIB)
@cd test && root -l -b -q ../tutorial/LoadOscProb.C TestMethods.C
@cd test && root -l -b -q ../tutorial/LoadOscProb.C StressTest.C
clean: $(CLEANDIRS)
@echo " Cleaning $(PACKAGE)..."
@rm -f $(PREMINC)
@rm -rf tmp lib
.PHONY: $(SUBDIRS) $(BUILDDIRS) $(CLEANDIRS) test clean all