-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
36 lines (29 loc) · 804 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
UNAME_S := $(shell uname -s)
target := sdlarch
sources := sdlarch.c glad.c
CFLAGS := -Wall -g
ifeq ($(UNAME_S),Darwin)
LFLAGS := -static-libstdc++
else
LFLAGS := -static-libgcc
endif
LIBS :=
packages := sdl2
# do not edit from here onwards
objects := $(addprefix build/,$(sources:.c=.o))
ifneq ($(packages),)
LIBS += $(shell pkg-config --libs-only-l $(packages))
LFLAGS += $(shell pkg-config --libs-only-L --libs-only-other $(packages))
CFLAGS += $(shell pkg-config --cflags $(packages))
endif
.PHONY: all clean
all: $(target)
clean:
-rm -rf build
-rm -f $(target)
$(target): Makefile $(objects)
$(CC) $(LFLAGS) -o $@ $(objects) $(LIBS)
build/%.o: %.c Makefile
-@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -MMD -o $@ $<
-include $(addprefix build/,$(sources:.c=.d))