-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
65 lines (49 loc) · 1.82 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
# Disables built-in rules (e.g. how to make .o from .c)
.SUFFIXES:
.PHONY: default clean debug release
default: release
COMMON_FLAGS := -Wall -Wno-unused-variable -Wno-unused-function
LINK_FLAGS := -lm -lpthread
DEBUG_FLAGS := -g -Og
RELEASE_FLAGS := -DNDEBUG=1 -s -flto
RELEASE_ENC_FLAGS := -Ofast
RELEASE_OTHER_FLAGS := -Os
ENC_SRC := $(wildcard src/enc/*.c) $(wildcard src/enc/lzo/*.c) $(wildcard src/enc/ucl/comp/*.c) $(wildcard src/enc/apultra/*.c)
STB_SRC := $(wildcard src/stb/*.c)
MAIN_SRC := $(wildcard src/*.c)
ENC_HDR := $(wildcard src/enc/*.h) $(wildcard src/enc/lzo/*.h) $(wildcard src/enc/ucl/comp/*.h) $(wildcard src/enc/apultra/*.h)
STB_HDR := $(wildcard src/stb/*.h)
MAIN_HDR := $(wildcard src/*.h)
ENC_OBJ := $(addprefix build/,$(ENC_SRC:%.c=%.o))
STB_OBJ := $(addprefix build/,$(STB_SRC:%.c=%.o))
MAIN_OBJ := $(addprefix build/,$(MAIN_SRC:%.c=%.o))
PLATFORM := $(shell uname)
ifeq ($(PLATFORM),Linux)
CC := gcc
EXECUTABLE := zzrtl
else
CC := i686-w64-mingw32.static-gcc
EXECUTABLE := zzrtl.exe
endif
debug: CCFLAGS_ENC := $(COMMON_FLAGS) $(DEBUG_FLAGS)
debug: CCFLAGS_OTHER := $(COMMON_FLAGS) $(DEBUG_FLAGS)
debug: $(EXECUTABLE)
release: CCFLAGS_ENC := $(COMMON_FLAGS) $(RELEASE_FLAGS) $(RELEASE_ENC_FLAGS)
release: CCFLAGS_OTHER := $(COMMON_FLAGS) $(RELEASE_FLAGS) $(RELEASE_OTHER_FLAGS)
release: $(EXECUTABLE)
build/src/enc/%.o: src/enc/%.c $(ENC_HDR)
@mkdir -p build/src/enc
@mkdir -p build/src/enc/lzo
@mkdir -p build/src/enc/ucl/comp
@mkdir -p build/src/enc/apultra
$(CC) $(CCFLAGS_ENC) -c $< -o $@
build/src/stb/%.o: src/stb/%.c $(STB_HDR)
mkdir -p build/src/stb
$(CC) $(CCFLAGS_OTHER) -c $< -o $@
build/src/%.o: src/%.c $(MAIN_HDR)
mkdir -p build/src
$(CC) $(CCFLAGS_OTHER) -c $< -o $@
$(EXECUTABLE): $(ENC_OBJ) $(STB_OBJ) $(MAIN_OBJ)
$(CC) -o $@ $^ $(LINK_FLAGS)
clean:
rm -rf build/ o/ bin/ $(EXECUTABLE)