forked from LostArtefacts/TRX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (58 loc) · 1.95 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
71
72
73
CC=i686-w64-mingw32-gcc
PYTHON=python3
WINDRES=i686-w64-mingw32-windres
LDFLAGS=-ldbghelp -lwinmm -ldsound -lddraw -ldinput8 -ldxguid
CFLAGS=-Wall -Isrc
VERSION = $(shell git describe --abbrev=7 --tags master)
CWD = $(shell pwd)
C_FILES = $(shell find src/ -type f -name '*.c')
H_FILES = $(shell find src/ -type f -name '*.h')
O_FILES = $(patsubst src/%.c, build/src/%.o, $(C_FILES))
TEST_C_FILES = $(shell find test/ -type f -name '*.c')
TEST_H_FILES = $(shell find test/ -type f -name '*.h')
TEST_O_FILES = $(patsubst test/%.c, build/test/%.o, $(TEST_C_FILES))
HOST_USER_UID = $(shell id -u)
HOST_USER_GID = $(shell id -g)
# building
build: $(O_FILES) autogenerated
$(CC) $(CFLAGS) $(O_FILES) build/version.res $(LDFLAGS) -static -shared -o build/Tomb1Main.dll
debug: CFLAGS += -DDEBUG -g
debug: build
test: $(O_FILES) $(TEST_O_FILES)
$(CC) $(CFLAGS) $(O_FILES) $(TEST_O_FILES) $(LDFLAGS) -o build/test.exe
chmod +x build/test.exe
build/test.exe
autogenerated: autogenerated_version autogenerated_c
@:
autogenerated_c:
$(PYTHON) scripts/generate_init
autogenerated_version:
sed s/{version}/$(VERSION)/g src/version.rc >build/version.rc
$(WINDRES) build/version.rc -O coff -o build/version.res
# physical files
build/src/%.o: src/%.c
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -c "$<" -o "$@"
build/test/%.o: test/%.c
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -c "$<" -o "$@"
# misc tasks
clean:
find build -type f -iname '*.o' -delete
find build -type f -iname '*.dll' -delete
rm -f build/version.res build/version.rc
find . -type d -empty -delete
lint: $(C_FILES)
clang-format -i $(C_FILES) $(H_FILES) $(TEST_C_FILES) $(TEST_H_FILES)
docs:
scripts/render_progress
# docker builds
docker:
docker build -t tomb1main .
docker_build: docker
docker run --rm \
--user $(HOST_USER_UID):$(HOST_USER_GID) \
-v $(CWD)/.git:/app/.git \
-v $(CWD)/build:/app/build \
tomb1main
.PHONY: clean build docker docker_build lint docs test autogenerated_c autogenerated_version autogenerated