-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (78 loc) · 1.98 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
CC = cc
CFLAGS = -Wall -Wextra -Wshadow -O2 -g -pipe
CFLAGS += -Iinclude $(shell sdl2-config --cflags)
LDFLAGS = $(shell sdl2-config --libs) -lSDL2_ttf -lm
VERSION_GIT_H = include/version_git.h
VERSION_GIT = $(strip $(shell cat $(VERSION_GIT_H) 2>/dev/null))
HEAD_COMMIT = $(strip $(shell git describe --always --tags --abbrev=10))
SRC = logger.c \
xalloc.c \
main.c \
emulator_utils.c \
emulator_events.c \
emulator.c \
cpu_view.c \
mmu_view.c \
gb_system.c \
cartridge.c \
timer.c \
joypad.c \
serial.c \
cpu/interrupts.c \
cpu/cpu.c \
cpu/opcodes.c \
cpu/opcodes/control.c \
cpu/opcodes/ld.c \
cpu/opcodes/jumps.c \
cpu/opcodes/calls.c \
cpu/opcodes/rotate.c \
cpu/opcodes/swap.c \
cpu/opcodes/shifts.c \
cpu/opcodes/bit.c \
cpu/opcodes/res.c \
cpu/opcodes/set.c \
cpu/opcodes/alu/add.c \
cpu/opcodes/alu/adc.c \
cpu/opcodes/alu/sub.c \
cpu/opcodes/alu/sbc.c \
cpu/opcodes/alu/and.c \
cpu/opcodes/alu/xor.c \
cpu/opcodes/alu/or.c \
cpu/opcodes/alu/cp.c \
cpu/opcodes/alu/inc.c \
cpu/opcodes/alu/dec.c \
mmu/rombanks.c \
mmu/rambanks.c \
mmu/mmu.c \
mmu/mmu_internal.c \
mmu/mbc1.c \
mmu/mbc3.c \
mmu/mbc5.c \
ppu/ppu.c \
ppu/lcd_regs.c \
apu/apu.c \
apu/sound_regs.c
OBJ = $(SRC:%.c=obj/%.o)
DEP = $(OBJ:.o=.d)
BIN = gameboy
ifdef WINDOWS
CFLAGS += -DSDL_MAIN_HANDLED
endif
ifdef WINDOWS_NOCONSOLE
LDFLAGS += -Wl,-subsystem,windows
endif
.PHONY: all update_version_git clean
all: update_version_git $(BIN)
update_version_git:
ifneq ($(findstring $(HEAD_COMMIT), $(VERSION_GIT)), $(HEAD_COMMIT))
@echo Updating $(VERSION_GIT_H) with commit hash $(HEAD_COMMIT)
@echo "#define GAMEBOY_COMMIT_HASH \"$(HEAD_COMMIT)\"" > $(VERSION_GIT_H)
endif
clean:
rm -rf obj
obj/%.o: src/%.c
@mkdir -p $(shell dirname $@)
$(CC) -MMD $(CFLAGS) -o $@ -c $<
$(BIN): $(OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
-include $(DEP)