aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-10-20 10:10:27 +0200
committerBad Diode <bd@badd10de.dev>2022-10-20 10:10:27 +0200
commit42dcdb3a98a957974225b5f699c02891db176c55 (patch)
treead5d35e9c7d0a167cea19cb8faa7a90ca29b20ab /Makefile
parente577c73974aefb0d78ff8d731e002c47d9804326 (diff)
downloaduxn64-42dcdb3a98a957974225b5f699c02891db176c55.tar.gz
uxn64-42dcdb3a98a957974225b5f699c02891db176c55.zip
Add custom uxn rom selection via Makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 17 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 2016e10..f69dd8d 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,8 @@ BUILD_DIR := build
16SRC_MAIN := $(SRC_DIR)/main.c $(SRC_DIR)/entry.s 16SRC_MAIN := $(SRC_DIR)/main.c $(SRC_DIR)/entry.s
17SRC_LN := $(SRC_DIR)/linker.ld 17SRC_LN := $(SRC_DIR)/linker.ld
18SRC_OBJ := 18SRC_OBJ :=
19UXN_ROM_C := $(BUILD_DIR)/rom.c
20UXN_ROM := $(SRC_DIR)/uxn/bin/screen.rom
19OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC_OBJ)) 21OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC_OBJ))
20WATCH_SRC := $(shell find $(SRC_DIR) \ 22WATCH_SRC := $(shell find $(SRC_DIR) \
21 -name "*.c" -or \ 23 -name "*.c" -or \
@@ -23,6 +25,7 @@ WATCH_SRC := $(shell find $(SRC_DIR) \
23 -name "*.h" -or \ 25 -name "*.h" -or \
24 -name "**.ld") 26 -name "**.ld")
25INC_DIRS := $(shell find $(SRC_DIR) -type d) 27INC_DIRS := $(shell find $(SRC_DIR) -type d)
28INC_DIRS += $(BUILD_DIR)
26INC_DIRS += $(LIBULTRA_INC) 29INC_DIRS += $(LIBULTRA_INC)
27INC_FLAGS := $(addprefix -I,$(INC_DIRS)) 30INC_FLAGS := $(addprefix -I,$(INC_DIRS))
28 31
@@ -31,6 +34,9 @@ TARGET := uxn64
31ELF := $(BUILD_DIR)/$(TARGET).elf 34ELF := $(BUILD_DIR)/$(TARGET).elf
32BIN := $(BUILD_DIR)/$(TARGET).n64 35BIN := $(BUILD_DIR)/$(TARGET).n64
33 36
37# Target tools.
38TOOLS_BIN2CARR := tools/bin2carr/build/bin2carr
39
34# Main compilation tool paths. 40# Main compilation tool paths.
35CC := $(SDK_BIN)/mips32-elf-gcc 41CC := $(SDK_BIN)/mips32-elf-gcc
36LD := $(SDK_BIN)/mips32-elf-ld 42LD := $(SDK_BIN)/mips32-elf-ld
@@ -52,8 +58,6 @@ RELEASE_CFLAGS := -O2 -DNDEBUG -D_FINALROM
52DEBUG_CFLAGS := -O0 -DDEBUG -D_FINALROM 58DEBUG_CFLAGS := -O0 -DDEBUG -D_FINALROM
53 59
54# Setup debug/release builds. 60# Setup debug/release builds.
55# make clean && make <target> DEBUG=0
56# make clean && make <target> DEBUG=1
57DEBUG ?= 0 61DEBUG ?= 0
58ifeq ($(DEBUG), 1) 62ifeq ($(DEBUG), 1)
59 CFLAGS += $(DEBUG_CFLAGS) 63 CFLAGS += $(DEBUG_CFLAGS)
@@ -63,13 +67,23 @@ endif
63 67
64main: $(BIN) 68main: $(BIN)
65 69
66$(ELF): $(SRC_MAIN) $(WATCH_SRC) | $(BUILD_DIR) 70# Compile the elf file.
71$(ELF): $(SRC_MAIN) $(UXN_ROM_C) $(WATCH_SRC) | $(BUILD_DIR)
67 $(CC) $(CFLAGS) $(LDFLAGS) -o $(ELF) -T $(SRC_LN) $(SRC_MAIN) $(LDLIBS) 72 $(CC) $(CFLAGS) $(LDFLAGS) -o $(ELF) -T $(SRC_LN) $(SRC_MAIN) $(LDLIBS)
68 73
74# Create the valid .n64 rom from the elf file.
69$(BIN): $(ELF) $(OBJECTS) $(WATCH_SRC) | $(BUILD_DIR) 75$(BIN): $(ELF) $(OBJECTS) $(WATCH_SRC) | $(BUILD_DIR)
70 $(OBJCOPY) -O binary $< $@ 76 $(OBJCOPY) -O binary $< $@
71 $(MAKEMASK) $(BIN) 77 $(MAKEMASK) $(BIN)
72 78
79# Build the uxn rom's C file.
80$(UXN_ROM_C): $(TOOLS_BIN2CARR) | $(BUILD_DIR)
81 ./$(TOOLS_BIN2CARR) -n uxn_rom -e u8 -o $(UXN_ROM_C) $(UXN_ROM)
82
83# Build the tools.
84$(TOOLS_BIN2CARR):
85 make -C tools/bin2carr
86
73# Test the output .n64 in an emulator. 87# Test the output .n64 in an emulator.
74run: $(BIN) 88run: $(BIN)
75 $(EMULATOR) $(BIN) 89 $(EMULATOR) $(BIN)