/
Makefile
46 lines (35 loc) · 1.12 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
# Compiler settings
CPP = g++
# Optimized
CFLAGS = -fPIC -O3 -Wall -Wextra -ansi -pedantic -DNDEBUG -Wno-unused-parameter
# Directory structure
SRC_DIR = src
INCLUDE_DIR = include
BUILD_DIR = lib
# Filenames
FILENAMES = CommandLineOptions Level LikelihoodType Model Options RandomNumberGenerator Utils
SOURCES = $(foreach f, $(FILENAMES), $(SRC_DIR)/$(f).cpp)
OBJECTS = $(foreach f, $(FILENAMES), $(SRC_DIR)/$(f).o)
LIB_NAME = libdnest3
# Examples
EXAMPLE_DIR = Examples
EXAMPLES = SpikeSlab FitSine HarlemShake
# The default build rule
.cpp.o:
$(CPP) $(CFLAGS) -I$(INCLUDE_DIR) -o $*.o -c $*.cpp
default: examples
# Build the library
libdnest3: $(OBJECTS)
mkdir -p $(BUILD_DIR)
ar rcs $(BUILD_DIR)/$(LIB_NAME).a $(OBJECTS)
shared: $(OBJECTS)
mkdir -p $(BUILD_DIR)
$(CPP) -shared $(CLIBS) -o $(BUILD_DIR)/$(LIB_NAME).so $(OBJECTS)
# Build the examples
examples: shared force_look
$(foreach e, $(EXAMPLES), (echo "Building $(e):"; cd $(EXAMPLE_DIR)/$(e); $(MAKE) $(MFLAGS));)
clean:
rm -f $(OBJECTS) $(LIB_NAME) *.pyc $(INCLUDE_DIR)/*.gch
$(foreach e, $(EXAMPLES), (cd $(EXAMPLE_DIR)/$(e); $(MAKE) clean);)
force_look:
true