-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (35 loc) · 1.07 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
# yeah non-idiomatic i know
.PHONY: all tidy clean debug-tidy asm-debug
NIM_BUILD_DIR:= _nimbuild
ASM_BUILD_DIR:= _asmbuild
NIM_SRC := nim_src
ASM_SRC := $(wildcard asm/*.asm)
NIM_FLAGS := --mm:none --os:standalone -d:danger --threads:off
NIM := nim
ROM_NAME := Rebrickd
NIM_ENTRY_FILE := $(NIM_SRC)/$(ROM_NAME).nim
GBDK_HOME := ../gbdk/
GBDK_BIN := $(GBDK_HOME)bin/
LCC := $(GBDK_BIN)lcc
LCC_FLAGS := -Iinclude -Wl-m -Wl-j -Wm-yS
SDAS := $(GBDK_BIN)sdasgb
SDAS_FLAGS := -pogn -plosgffw
all: $(ROM_NAME).gb
asm-debug: $(ASM_BUILD_DIR)
$(ROM_NAME).gb: $(NIM_BUILD_DIR)
$(LCC) $(LCC_FLAGS) -o $@ $(wildcard $(NIM_BUILD_DIR)/*.c) $(ASM_SRC)
$(ASM_BUILD_DIR): $(NIM_BUILD_DIR)
mkdir -p $@
$(LCC) $(LCC_FLAGS) -S $(wildcard $(NIM_BUILD_DIR)/*.c) $(ASM_SRC)
for i in *.asm; do mv $$i $@; done
touch $@
$(NIM_BUILD_DIR): $(NIM_ENTRY_FILE) $(shell find $(NIM_SRC) -type f -name '*.nim')
$(NIM) c -c $(NIM_FLAGS) --nimcache:$(NIM_BUILD_DIR) $<
touch $@
debug-tidy:
rm -f *.asm
tidy:
rm -rf $(NIM_BUILD_DIR) $(ASM_BUILD_DIR)
rm -f *.map *.sym *.noi *.asm
clean: tidy
rm -f *.gb