-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (31 loc) · 901 Bytes
/
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
CC := gcc
TARGET := main
SRCDIR := src/
OBJDIR := build/
SRC := $(wildcard $(SRCDIR)*.c)
OBJ := $(patsubst $(SRCDIR)%.c, $(OBJDIR)%.o, $(SRC))
CFLAGS := -Wall -Wextra -O2 -std=c99 $(shell pkgconf --cflags sdl2 cglm)
CPPFLAGS := -Iinclude/ -Iinclude/glad/
LDFLAGS := $(shell pkgconf --libs sdl2 cglm)
UNAME := $(shell uname -s)
ifeq ($(UNAME), Linux)
CFLAGS += $(shell pkgconf --cflags opengl)
LDFLAGS += -lm $(shell pkgconf --libs opengl)
endif
ifeq ($(UNAME), Darwin)
CFLAGS += -march=armv8.6-a+simd
LDFLAGS += -framework OpenGL
endif
all: $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
$(OBJDIR)%.o: $(SRCDIR)%.c | $(OBJDIR)
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJDIR):
mkdir -p -v $(OBJDIR)
clean:
rm -r build
debug: CFLAGS += -fsanitize=address -ggdb
debug: LDFLAGS += -static-libasan ; ASAN_OPTIONS=detect_leaks=1
debug: $(TARGET)
.PHONY: clean