forked from PolyChord/PolyChordLite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
124 lines (95 loc) · 3.54 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
# List of available example likelihoods
EXAMPLES = gaussian pyramidal rastrigin twin_gaussian random_gaussian himmelblau rosenbrock eggbox half_gaussian fitting gaussian_shell gaussian_shells object_detection
# Your likelihood programs
PROGRAMS = polychord_fortran polychord_CC polychord_CC_ini
# Directories
SRC_DIR = $(PWD)/src
DRIVERS_DIR = $(SRC_DIR)/drivers
POLYCHORD_DIR = $(SRC_DIR)/polychord
LIKELIHOOD_DIR = $(PWD)/likelihoods
EXAMPLES_DIR = $(LIKELIHOOD_DIR)/examples
BIN_DIR = $(PWD)/bin
LIB_DIR = $(PWD)/lib
export DRIVERS_DIR POLYCHORD_DIR PYPOLYCHORD_DIR LIKELIHOOD_DIR EXAMPLES_DIR BIN_DIR LIB_DIR
PYTHON=python
# Whether to use MPI
ifeq "$(shell uname)" "Linux"
MPI=1
else
MPI=
endif
# Whether to compile in debugging mode
DEBUG=
export MPI DEBUG
# We can autodetect the compiler type on unix systems via the shell.
# if you want to override this then just run make with
# make COMPILER_TYPE=<your type>
# where <your type> is gnu or intel
ifeq "$(shell which ifort >/dev/null 2>&1; echo $$?)" "0"
COMPILER_TYPE=intel
else ifeq "$(shell which gfortran >/dev/null 2>&1; echo $$?)" "0"
COMPILER_TYPE=gnu
endif
ifeq ($(COMPILER_TYPE),intel)
include Makefile_intel
else ifeq ($(COMPILER_TYPE),gnu)
include Makefile_gnu
endif
ifdef MPI
FFLAGS += -DMPI
CXXFLAGS += -DUSE_MPI
endif
# Remove command
RM = rm -rf
# Library flags
LDFLAGS += -L$(LIB_DIR)
# Export all of the necessary variables
export CC CXX FC LD LDSHARED RM AR
export CFLAGS CXXFLAGS FFLAGS LDLIBS
export EXAMPLES PROGRAMS
# make shortcuts
all: $(LIB_DIR)/libchord.a $(LIB_DIR)/libchord.so
libchord.a: $(LIB_DIR)/libchord.a
libchord.so: $(LIB_DIR)/libchord.so
examples: $(EXAMPLES)
$(EXAMPLES): % : $(BIN_DIR)/%
$(PROGRAMS): % : $(BIN_DIR)/%
# PolyChord
# ---------
# static library
$(LIB_DIR)/libchord.a:
$(MAKE) -C $(POLYCHORD_DIR) $@
# shared library
$(LIB_DIR)/libchord.so:
$(MAKE) -C $(POLYCHORD_DIR) $@
pypolychord: $(LIB_DIR)/libchord.so
@echo "======================================================================================="
@echo " now run:"
@echo ""
@echo " CC=$(CC) CXX=$(CXX) python setup.py install --user"
# Examples
# --------
$(patsubst %,$(BIN_DIR)/%,$(EXAMPLES)): $(BIN_DIR)/%: $(LIB_DIR)/libchord.a $(LIB_DIR)/lib%.a $(DRIVERS_DIR)/polychord_examples.o
$(LD) $(DRIVERS_DIR)/polychord_examples.o $(LIB_DIR)/libchord.a -o $@ $(LDFLAGS) $(LDLIBS) -l$*
$(patsubst %,$(LIB_DIR)/lib%.a,$(EXAMPLES)): $(LIB_DIR)/libchord.a
$(MAKE) -C $(EXAMPLES_DIR) $@
$(DRIVERS_DIR)/polychord_examples.o:
$(MAKE) -C $(DRIVERS_DIR) $@
# User Likelihoods
# ----------------
$(patsubst %,$(BIN_DIR)/%,$(PROGRAMS)): $(BIN_DIR)/polychord_% : $(LIB_DIR)/libchord.a $(LIB_DIR)/lib%_likelihood.a $(DRIVERS_DIR)/polychord_%.o
$(LD) $(DRIVERS_DIR)/polychord_$*.o $(LIB_DIR)/libchord.a -o $@ $(LDFLAGS) -l$*_likelihood $(LDLIBS)
$(patsubst polychord_%,$(LIB_DIR)/lib%_likelihood.a,$(PROGRAMS)): $(LIB_DIR)/lib%_likelihood.a: $(LIB_DIR)/libchord.a
$(MAKE) -C $(LIKELIHOOD_DIR)/$* $@
$(patsubst %,$(DRIVERS_DIR)/%.o,$(PROGRAMS)):
$(MAKE) -C $(DRIVERS_DIR) $@
CLEANDIRS = $(POLYCHORD_DIR) $(PYPOLYCHORD_DIR) $(LIKELIHOOD_DIR) $(BIN_DIR) $(LIB_DIR) $(DRIVERS_DIR)
.PHONY: clean veryclean $(addsuffix clean,$(CLEANDIRS)) $(addsuffix veryclean,$(CLEANDIRS))
clean: $(addsuffix clean,$(CLEANDIRS))
$(RM) *.o *.mod *.MOD
$(addsuffix clean,$(CLEANDIRS)): %clean:
$(MAKE) -C $* clean
veryclean: clean $(addsuffix veryclean,$(CLEANDIRS))
$(RM) *~ build dist pypolychord.egg-info pypolychord/*.pyc pypolychord/__pycache__ __pycache__
$(addsuffix veryclean,$(CLEANDIRS)) : %veryclean:
$(MAKE) -C $* veryclean