-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (52 loc) · 1.08 KB
/
Makefile
File metadata and controls
70 lines (52 loc) · 1.08 KB
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
# Build system for Natevolve Ark library
# Settings
## Project
PROJNAME := natevolve
OBJNAME := lib$(PROJNAME).a
SRC := $(wildcard src/*.cpp)
OBJS := $(subst src/,obj/,$(subst .cpp,.o,$(SRC)))
HFILES := $(wildcard include/*.hpp)
## Test
ifeq ($(OS), Windows_NT)
TESTOBJ := test.exe
else
TESTOBJ := test.bin
endif
TESTSRC := $(wildcard test/*.cpp)
TESTOBJS := $(subst test/,test/obj/,$(subst .cpp,.o,$(TESTSRC)))
## Compiler
CPPC := g++
CPPFLAGS := -std=c++17 -O2 -Wall -Werror -Iinclude
LD := g++
LDFLAGS := -L. -l$(PROJNAME)
# Targets
## Helper
.PHONY: all
all: $(OBJNAME)
.PHONY: test
test: $(TESTOBJ)
.PHONY: clean
clean:
rm -rf obj/
rm -rf test/obj/
rm -rf $(OBJNAME)
rm -rf $(TESTOBJ)
## Main
obj/%.o: src/%.cpp $(HFILES)
ifeq ($(OS), Windows_NT)
-mkdir obj
else
mkdir -p obj
endif
$(CPPC) -o $@ $(CPPFLAGS) -c $<
$(OBJNAME): $(OBJS)
ar rcs $@ $(OBJS)
test/obj/%.o: test/%.cpp $(HFILES)
ifeq ($(OS), Windows_NT)
-mkdir test\obj
else
mkdir -p test/obj
endif
$(CPPC) -o $@ $(CPPFLAGS) -c $<
$(TESTOBJ): $(OBJNAME) $(TESTOBJS)
$(LD) -o $@ $(TESTOBJS) $(LDFLAGS)