blob: 9b2c9d7b8aef91322cd7c3dca4a4fe1479bf958c (
plain)
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
|
CC ?= gcc
SRCDIR ?= src
OBJDIR ?= obj
LIBS = $(shell pkg-config --libs SDL2) -Wl,-rpath,./SDL/build/ $(shell pkg-config --libs cglm)
INCS = -ISDL/build/include/SDL2 -ISDL/build/include-config-/SDL2
CFLAGS ?= -D_FORTIFY_SOURCE=2 -Wall -Werror -Wno-error=unused-variable -g -Og
CFLAGS += -std=gnu11 -fms-extensions -flto $(shell pkg-config --cflags cglm)
APP_SOURCES = $(shell find $(SRCDIR) -name "*.c")
APP_OBJS = $(APP_SOURCES:%.c=$(OBJDIR)/%.o)
APP_DEPS = $(APP_OBJS:%.o=%.d)
-include $(APP_DEPS)
# We don't really need to run the tests for bear to record them
compile_commands.json: clean Makefile $(APP_SOURCES)
@rm -f "$@"
bear -- make main
main: $(APP_OBJS)
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(APP_OBJS) $(LIBS)
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCS) -MMD -o $@ -c $<
clean:
@rm -rf $(OBJDIR)
@rm -f main
.DEFAULT_GOAL := all
all: main
|