diff options
author | Bad Diode <bd@badd10de.dev> | 2022-10-20 10:10:27 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2022-10-20 10:10:27 +0200 |
commit | 42dcdb3a98a957974225b5f699c02891db176c55 (patch) | |
tree | ad5d35e9c7d0a167cea19cb8faa7a90ca29b20ab /Makefile | |
parent | e577c73974aefb0d78ff8d731e002c47d9804326 (diff) | |
download | uxn64-42dcdb3a98a957974225b5f699c02891db176c55.tar.gz uxn64-42dcdb3a98a957974225b5f699c02891db176c55.zip |
Add custom uxn rom selection via Makefile
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -16,6 +16,8 @@ BUILD_DIR := build | |||
16 | SRC_MAIN := $(SRC_DIR)/main.c $(SRC_DIR)/entry.s | 16 | SRC_MAIN := $(SRC_DIR)/main.c $(SRC_DIR)/entry.s |
17 | SRC_LN := $(SRC_DIR)/linker.ld | 17 | SRC_LN := $(SRC_DIR)/linker.ld |
18 | SRC_OBJ := | 18 | SRC_OBJ := |
19 | UXN_ROM_C := $(BUILD_DIR)/rom.c | ||
20 | UXN_ROM := $(SRC_DIR)/uxn/bin/screen.rom | ||
19 | OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC_OBJ)) | 21 | OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC_OBJ)) |
20 | WATCH_SRC := $(shell find $(SRC_DIR) \ | 22 | WATCH_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") |
25 | INC_DIRS := $(shell find $(SRC_DIR) -type d) | 27 | INC_DIRS := $(shell find $(SRC_DIR) -type d) |
28 | INC_DIRS += $(BUILD_DIR) | ||
26 | INC_DIRS += $(LIBULTRA_INC) | 29 | INC_DIRS += $(LIBULTRA_INC) |
27 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) | 30 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) |
28 | 31 | ||
@@ -31,6 +34,9 @@ TARGET := uxn64 | |||
31 | ELF := $(BUILD_DIR)/$(TARGET).elf | 34 | ELF := $(BUILD_DIR)/$(TARGET).elf |
32 | BIN := $(BUILD_DIR)/$(TARGET).n64 | 35 | BIN := $(BUILD_DIR)/$(TARGET).n64 |
33 | 36 | ||
37 | # Target tools. | ||
38 | TOOLS_BIN2CARR := tools/bin2carr/build/bin2carr | ||
39 | |||
34 | # Main compilation tool paths. | 40 | # Main compilation tool paths. |
35 | CC := $(SDK_BIN)/mips32-elf-gcc | 41 | CC := $(SDK_BIN)/mips32-elf-gcc |
36 | LD := $(SDK_BIN)/mips32-elf-ld | 42 | LD := $(SDK_BIN)/mips32-elf-ld |
@@ -52,8 +58,6 @@ RELEASE_CFLAGS := -O2 -DNDEBUG -D_FINALROM | |||
52 | DEBUG_CFLAGS := -O0 -DDEBUG -D_FINALROM | 58 | DEBUG_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 | ||
57 | DEBUG ?= 0 | 61 | DEBUG ?= 0 |
58 | ifeq ($(DEBUG), 1) | 62 | ifeq ($(DEBUG), 1) |
59 | CFLAGS += $(DEBUG_CFLAGS) | 63 | CFLAGS += $(DEBUG_CFLAGS) |
@@ -63,13 +67,23 @@ endif | |||
63 | 67 | ||
64 | main: $(BIN) | 68 | main: $(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. |
74 | run: $(BIN) | 88 | run: $(BIN) |
75 | $(EMULATOR) $(BIN) | 89 | $(EMULATOR) $(BIN) |