-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
59 lines (48 loc) · 1.3 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
# based on http://voidptr.io/blog/2017/01/21/GameBoy.html
rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
ASM := rgbasm
LINKER := rgblink
FIX := rgbfix
BUILD_DIR := build
SRC_DIR := src
SRC_ASM :=
INC_DIR := inc/
ASMFLAGS := -p0
FIXFLAGS := -O -f gh
FIX16 := 0
DX := 0
ifeq ($(FIX16),0)
ifeq ($(DX),0)
FIX16 := 2
DX := 1
endif
endif
ifneq ($(FIX16),0)
PROJECT_NAME := fb2k_16
SRC_ASM += $(SRC_DIR)/16.asm
ifeq ($(FIX16),2)
ASMFLAGS += -D _FIX16_FULL
endif
endif
ifneq ($(DX),0)
PROJECT_NAME = fb2k_dx
SRC_ASM += $(SRC_DIR)/dx.asm
ifeq ($(DX),2)
ASMFLAGS += -D _USE_GDMA
endif
endif
OUTPUT := $(BUILD_DIR)/$(PROJECT_NAME)
OBJ_FILES := $(addprefix $(BUILD_DIR)/obj/, $(SRC_ASM:src/%.asm=%.obj))
OBJ_DIRS := $(sort $(addprefix $(BUILD_DIR)/obj/, $(dir $(SRC_ASM:src/%.asm=%.obj))))
LINKERFLAGS := -m $(OUTPUT).map -n $(OUTPUT).sym -d
.PHONY: all clean
all: build
build: $(OBJ_FILES)
$(LINKER) -O fb2k.gb -o $(OUTPUT).gb $(LINKERFLAGS) $(OBJ_FILES)
$(FIX) $(FIXFLAGS) $(OUTPUT).gb
$(BUILD_DIR)/obj/%.obj : src/%.asm | $(OBJ_DIRS)
$(ASM) -o $@ $(ASMFLAGS) $<
$(OBJ_DIRS):
mkdir -p $@
clean:
rm -rf $(BUILD_DIR)