-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (56 loc) · 1.59 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
# Command-line parameter to switch gdb on/off
# Use with -B to force a rebuild
GDB =
# Subdirectories with header files
INCLUDES = graph util test
# Default compiler and linker flags
override CXXFLAGS += -Wall $(MODE) -std=c++1y -frounding-math -fopenmp
override LDFLAGS += -lCGAL -lgmp -lboost_graph -lboost_thread -lboost_unit_test_framework -fopenmp -lrt
# Automatically find all sources and use implicit make rules
SRCS = $(shell find * -name \*.cpp)
OBJS = $(SRCS:.cpp=.o)
DEPS = $(OBJS:.o=.d)
EXEC = $(OBJS:.o=.exe)
RM = rm -f
# Using target-specific variables would be nicer,
# but they force you to build the whole source tree
ifeq ($(GDB), off)
MODE = -O4 -DNDEBUG
else
ifeq ($(GDB), on)
MODE = -O0 -g -ggdb
else
ifeq ($(GDB), prof)
MODE = -O2 -g -fno-omit-frame-pointer -DNDEBUG -fno-inline-functions\
-fno-inline-functions-called-once -fno-optimize-sibling-calls
else
MODE = -O2 -g
endif
endif
endif
.PHONY: all clean cleanall cleanobjs rules
all: $(EXEC)
# Use .exe suffix for easier integration with Git
%.exe : %.o
$(CXX) -o $@ $< $(LDFLAGS)
cleanall: clean
$(RM) **/*~ *.dot
clean: cleanobjs
$(RM) $(EXEC)
cleanobjs:
$(RM) $(OBJS) $(DEPS)
# Files, flags and rules for auto dependencies
.PRECIOUS: %.d %.o
override CXXFLAGS += -MP -MMD $(INCLUDES:%=-I%)
-include $(DEPS)
# Show variables for Makefile debugging
rules:
@echo SRCS = $(SRCS)
@echo EXEC = $(EXEC)
@echo OBJS = $(OBJS)
@echo DEPS = $(DEPS)
@echo PWD = $(PWD)
@echo CC = `$(CC) --version | head -n 1`
@echo CXX = `$(CXX) --version | head -n 1`
@echo CXXFLAGS = $(CXXFLAGS)
@echo LDFLAGS = $(LDFLAGS)