-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (37 loc) · 1.2 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
GCC = g++
LD = $(GCC)
TARGET = build/TestSudoku
LIBRARY = build/libSudokuSolver.so
DEBUGEXE = build/debug
SOURCES_LIB = $(wildcard src/*.cpp)
INCLUDE_LIB = include
INCLUDE_LIB_ARG = $(foreach d, $(INCLUDE_LIB), -I$d)
OBJECTS_LIB = $(SOURCES_LIB:.cpp=.o)
all: CSHAREDFLAGS = -std=c++11 -c -fPIC $(INCLUDE_LIB_ARG)
debug: CSHAREDFLAGS = -std=c++11 -c -g $(INCLUDE_LIB_ARG)
LDSHAREDFLAGS = -shared
SOURCES_TEST = $(wildcard test/*.cpp)
INCLUDE_TEST = test $(INCLUDE_LIB)
INCLUDE_TEST_ARG = $(foreach d, $(INCLUDE_TEST), -I$d)
OBJECTS_TEST = $(SOURCES_TEST:.cpp=.o)
all: CFLAGS = -std=c++11 -c -Wall $(INCLUDE_TEST_ARG)
debug: CFLAGS = -std=c++11 -c -Wall -g $(INCLUDE_TEST_ARG)
LDFLAGS = -Lbuild -lSudokuSolver -lstdc++
LDDEBUGFLAGS = -lstdc++ -g -gdwarf-3
all: $(LIBRARY) $(TARGET)
debug: $(DEBUGEXE)
src/%.o: src/%.cpp
$(GCC) $(CSHAREDFLAGS) $< -o $@
$(OBJECTS_TEST): $(SOURCES_TEST)
$(GCC) $(CFLAGS) $^ -o $@
$(LIBRARY): $(OBJECTS_LIB)
mkdir -p build
$(LD) -o $@ $^ $(LDSHAREDFLAGS)
$(TARGET): $(OBJECTS_TEST)
$(LD) -o $@ $^ $(LDFLAGS)
$(DEBUGEXE): $(OBJECTS_LIB) $(OBJECTS_TEST)
$(LD) -o $@ $^ $(LDDEBUGFLAGS)
cl:
rm $(OBJECTS)
clean:
rm $(TARGET) $(LIBRARY) $(DEBUGEXE) $(OBJECTS_LIB) $(OBJECTS_TEST)