-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
155 lines (128 loc) · 5.84 KB
/
Copy pathmakefile
File metadata and controls
155 lines (128 loc) · 5.84 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# - CONFIGURABLE PARAMETERS - #
SHELL = /bin/sh
srcdir = ./src
testdir = ./test
builddir = ./build
includedir = ./include
depsdir = $(builddir)/deps
testdepsdir = $(builddir)/test_deps
AR = ar
CC = gcc
CFLAGS = -Wall -Wextra -Wvla -std=gnu17 -pedantic
CFLAGS += -fsanitize=address,undefined -fno-omit-frame-pointer
LDFLAGS = -lm
CDEBUG = -g -O3 -D 'SERVER_ADDR="0.0.0.0"' -D SERVER_PORT=9999
# END OF CONFIGURABLE PARAMETERS #
ALL_CFLAGS = $(CFLAGS) $(shell pkg-config --cflags sdl2 jansson) $(CDEBUG)
ALL_LDFLAGS = $(LDFLAGS) $(shell pkg-config --libs sdl2 jansson)
# - TARGETS - #
CLIENT_SRC = audio/mixer.c audio/emitter.c blockmap.c bsp.c byte_reader.c color.c \
engine.c events.c flat.c game_states.c \
geometry.c header.c keybindings.c linedef.c lump.c main.c map_renderer.c node.c \
patch.c player.c remote.c sector.c segment.c segment_handler.c sidedef.c sound.c subsector.c \
textarea.c texture.c thing.c timer.c util.c vertex.c wad_data.c weapons.c lift.c door.c drawseg.c vssprite.c player_animation.c spawnpoints.c \
ui/def.c ui/module.c ui/common.c ui/label.c ui/button.c ui/image.c ui/textbox.c ui/event_handler.c ui/feed.c shared.c \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/component/*.c)) \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/event/*.c)) \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/system/client/*.c))
CLIENT_OBJ = $(CLIENT_SRC:%.c=%.o)
CLIENT_LIB = libnet.a libevent.a libecs.a libcollection.a
CLIENT_LDFLAGS = -lSDL2 -lSDL2_ttf -lSDL2_image -lSDL2_mixer -lSDL2_net
SERVER_SRC = server.c \
blockmap.c byte_reader.c color.c door.c flat.c geometry.c header.c lift.c \
linedef.c lump.c node.c patch.c sector.c segment.c sidedef.c sound.c \
subsector.c texture.c thing.c util.c vertex.c wad_data.c drawseg.c vssprite.c spawnpoints.c \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/server/*.c)) \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/event/*.c)) \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/system/server/*.c)) \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/component/*.c))
SERVER_OBJ = $(SERVER_SRC:%.c=%.o)
SERVER_LIB = libnet.a libevent.a libecs.a libcollection.a
SERVER_LDFLAGS = -lSDL2 -lSDL2_net
LIBNET_SRC = net/util.c net/tracked_connection.c net/packet/client.c net/packet/server.c
LIBNET_OBJ = $(LIBNET_SRC:%.c=%.o)
LIBNET_LIB =
LIBEVENT_SRC = event/event.c \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/event/server_*.c)) \
$(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/event/client_*.c))
LIBEVENT_OBJ = $(LIBEVENT_SRC:%.c=%.o)
LIBEVENT_LIB =
LIBCOLLECTION_SRC = $(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/collection/*.c))
LIBCOLLECTION_OBJ = $(LIBCOLLECTION_SRC:%.c=%.o)
LIBCOLLECTION_TEST_SRC = $(patsubst $(testdir)/%, %, $(wildcard $(testdir)/collection/*.c))
LIBCOLLECTION_TEST_OBJ = $(LIBCOLLECTION_TEST_SRC:%.c=%.o)
LIBCOLLECTION_LIB =
LIBCOLLECTION_LDFLAGS =
LIBECS_SRC = $(patsubst $(srcdir)/%, %, $(wildcard $(srcdir)/ecs/*.c))
LIBECS_OBJ = $(LIBECS_SRC:%.c=%.o)
LIBECS_TEST_SRC = $(patsubst $(testdir)/%, %, $(wildcard $(testdir)/ecs/*.c))
LIBECS_TEST_OBJ = $(LIBECS_TEST_SRC:%.c=%.o)
LIBECS_LIB = libcollection.a
# - END OF TARGETS - #
.PHONY: all clean test before_build run_server run_client build_server build_client test test_collection \
test_ecs doc open_doc
all: $(builddir)/server $(builddir)/client
# helper targets
run_server: build_server
$(builddir)/server 9999
run_client: build_client
$(builddir)/client
test: test_collection test_ecs
test_collection: $(builddir)/test_collection
@$(builddir)/test_collection
test_ecs: $(builddir)/test_ecs
@$(builddir)/test_ecs
build_client: $(builddir)/client
build_server: $(builddir)/server
# server - build + link target
$(builddir)/server: $(addprefix $(depsdir)/, $(SERVER_OBJ)) $(addprefix $(depsdir)/, $(SERVER_LIB)) | before_build
@echo "Building server..."
$(CC) $(ALL_CFLAGS) -o $@ $^ $(ALL_LDFLAGS) $(SERVER_LDFLAGS)
# client - build + link target
$(builddir)/client: $(addprefix $(depsdir)/, $(CLIENT_OBJ)) $(addprefix $(depsdir)/, $(CLIENT_LIB)) | before_build
@echo "Building client..."
$(CC) $(ALL_CFLAGS) -o $@ $^ $(ALL_LDFLAGS) $(CLIENT_LDFLAGS)
# libnet - build archive target
$(depsdir)/libnet.a: $(addprefix $(depsdir)/, $(LIBNET_OBJ)) $(addprefix $(depsdir)/, $(LIBNET_LIB)) | before_build
@echo "Building libnet..."
$(AR) rcs $@ $^
# libevent - build archive target
$(depsdir)/libevent.a: $(addprefix $(depsdir)/, $(LIBEVENT_OBJ)) $(addprefix $(depsdir)/, $(LIBEVENT_LIB)) | before_build
@echo "Building libevent..."
$(AR) rcs $@ $^
# libcollection - build archive target
$(depsdir)/libcollection.a: $(addprefix $(depsdir)/, $(LIBCOLLECTION_OBJ)) $(addprefix $(depsdir)/, $(LIBCOLLECTION_LIB)) | before_build
@echo "Building libcollection..."
$(AR) rcs $@ $^
# libcollection - test target
$(builddir)/test_collection: $(addprefix $(testdepsdir)/, $(LIBCOLLECTION_TEST_OBJ)) $(addprefix $(depsdir)/, $(LIBCOLLECTION_LIB)) $(depsdir)/libcollection.a | before_build
@echo "Building test_collection..."
$(CC) $(ALL_CFLAGS) -o $@ $^ $(ALL_LDFLAGS) $(LIBCOLLECTION_LDFLAGS)
# libecs - build archive target
$(depsdir)/libecs.a: $(addprefix $(depsdir)/, $(LIBECS_OBJ)) | before_build
@echo "Building libecs..."
$(AR) rcs $@ $^
# libecs - test target
$(builddir)/test_ecs: $(addprefix $(testdepsdir)/, $(LIBECS_TEST_OBJ)) $(depsdir)/libecs.a $(addprefix $(depsdir)/, $(LIBECS_LIB)) | before_build
@echo "Building test_ecs..."
$(CC) $(ALL_CFLAGS) -o $@ $^ $(ALL_LDFLAGS)
# compilation target
$(depsdir)/%.o: $(srcdir)/%.c | before_build
@mkdir -p $(dir $@)
@echo "Compiling $<..."
$(CC) $(ALL_CFLAGS) -c -o $@ $<
# compilation target for tests
$(testdepsdir)/%.o: $(testdir)/%.c | before_build
@mkdir -p $(dir $@)
@echo "Compiling $<..."
$(CC) $(ALL_CFLAGS) -c -o $@ $<
# other targets
before_build:
@mkdir -p $(builddir)
@mkdir -p $(depsdir)
clean:
-rm -rf $(builddir)
doc:
doxygen
open_doc: doc
xdg-open ./build/doc/html/index.html