-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
44 lines (31 loc) · 841 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
ifeq (run, $(firstword $(MAKECMDGOALS)))
# get arguments for `make run`
RUN_ARGS := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
$(eval $(RUN_ARGS):;@:)
endif
CC = gcc
CFLAGS = -I.
CFLAGS += -Wall
SDLFLAGS = `sdl2-config --libs --cflags`
ifeq ($(shell uname), Darwin)
CFLAGS += -Wno-unused-command-line-argument
SDLFLAGS += -I/opt/homebrew/Cellar/sdl2/*/include
endif
IDIR = include
_DEPS = emulator.h display.h stack.h timers.h
DEPS = $(patsubst %, $(IDIR)/%, $(_DEPS))
BDIR = build
_OBJ = emulator.o display.o stack.o chip8.o
OBJ = $(patsubst %, $(BDIR)/%, $(_OBJ))
OUT = chip8
.PHONY: clean run test
$(BDIR)/%.o: src/%.c $(DEPS) clean
$(CC) -c -o $@ $< $(CFLAGS) $(SDLFLAGS)
$(OUT): $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(SDLFLAGS)
run:
./$(OUT) $(RUN_ARGS)
test:
./$(OUT) quirks
clean:
rm -f $(OBJ) $(OUT)