-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
48 lines (34 loc) · 833 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
42
43
44
45
46
47
CC = gcc
CFLAGS = -lSDL2 -Wextra -Wall -std=c99 -Iinclude
OUT = emul
#ROM = Metal_Gear.nes
ROM = castleva.nes
src = $(wildcard src/*.c)
hdr = $(wildcard include/*.h)
obj = $(subst src, build, $(src:.c=.o))
dep = $(subst src, build, $(src:.c=.d))
all: $(OUT)
debug: CFLAGS += -DDEBUG
debug: clean make $(OUT) test
test: $(OUT)
./$(OUT) $(ROM)
$(OUT): $(obj)
$(CC) $(CFLAGS) -o $@ $^
build/%.o: src/%.c build/%.d
$(CC) $(CFLAGS) -c -o $@ $<
make: $(dep)
build/%.d: src/%.c
# ./makedeps.awk -v inc=include -v build=build $< > $@
$(CC) $(CFLAGS) -MM $< | sed -e "s/^[^ \t]\+\.o:/build\/&/" > $@
clean:
rm -rf $(OUT)
rm -rf $(obj)
fullclean: clean
rm -rf $(dep)
.PHONY: fullclean clean debug test make
.SECONDARY: $(dep)
ifneq "$(MAKECMDGOALS)" "clean"
ifneq "$(MAKECMDGOALS)" "fullclean"
-include $(dep)
endif
endif