-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
54 lines (39 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
46
47
48
49
50
51
52
53
54
SRC_DIR = src
INC_DIR = include
BUILD_DIR = build
#list all source files in SRC_DIR
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
SRC_FILES += $(wildcard $(SRC_DIR)/*/*.cpp)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRC_FILES))
# XBraid location
BRAID_INC_DIR = xbraid/braid
BRAID_LIB_FILE = xbraid/braid/libbraid.a
# set inc dir
INC = -I$(INC_DIR) -I$(BRAID_INC_DIR)
# set compiler flags
CXX_FLAGS = -g -Wall -pedantic -lm -Wno-write-strings -Wno-delete-non-virtual-dtor -std=c++11
# set compiler
CC = mpicc
CXX = mpicxx
# Default: Build all (main and xbraid)
all: $(BRAID_LIB_FILE) main
# link main
main: $(OBJ_FILES)
$(CXX) $(CXX_FLAGS) -o $@ $(OBJ_FILES) $(BRAID_LIB_FILE)
# build src files
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
@mkdir -p $(@D)
$(CXX) $(CXX_FLAGS) -c $< -o $@ $(INC)
@$(CXX) $(CXX_FLAGS) -MM $< -MP -MT $@ -MF $(@:.o=.d) $(INC)
# Build xbraid
$(BRAID_LIB_FILE):
cd xbraid; make braid
.PHONY: all $(BRAID_LIB_FILE) clean cleanall
clean:
rm -fr $(BUILD_DIR)
rm -f main
cleanall:
make clean
rm -f $(BRAID_LIB_FILE)
# include the dependency files
-include $(OBJ_FILES:.o=.d)