diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -15,8 +15,9 @@ LIBGBA += $(LIBGBA_DIR)/lib/libmm.a | |||
15 | SRC_DIR := src | 15 | SRC_DIR := src |
16 | BUILD_DIR := build | 16 | BUILD_DIR := build |
17 | SRC_MAIN := $(SRC_DIR)/main.c | 17 | SRC_MAIN := $(SRC_DIR)/main.c |
18 | ROM := $(BUILD_DIR)/rom.c | 18 | UXN_ROM := roms/dvd.rom |
19 | ROM_SRC := roms/dvd.rom | 19 | ROM_FILE := $(BUILD_DIR)/uxn.rom |
20 | ROM_OBJ := $(BUILD_DIR)/rom.o | ||
20 | ASM_FILES := $(wildcard $(SRC_DIR)/*.s) | 21 | ASM_FILES := $(wildcard $(SRC_DIR)/*.s) |
21 | WATCH_SRC := $(shell find $(SRC_DIR) -name *.c -or -name *.s -or -name *.h) | 22 | WATCH_SRC := $(shell find $(SRC_DIR) -name *.c -or -name *.s -or -name *.h) |
22 | INC_DIRS := $(shell find $(SRC_DIR) -type d) | 23 | INC_DIRS := $(shell find $(SRC_DIR) -type d) |
@@ -29,16 +30,13 @@ TARGET := uxngba | |||
29 | ELF := $(BUILD_DIR)/$(TARGET).elf | 30 | ELF := $(BUILD_DIR)/$(TARGET).elf |
30 | BIN := $(BUILD_DIR)/$(TARGET).gba | 31 | BIN := $(BUILD_DIR)/$(TARGET).gba |
31 | 32 | ||
32 | # Target tools. | ||
33 | TOOLS_BIN2CARR := tools/bin2carr/build/bin2carr | ||
34 | |||
35 | # Compiler and linker configuration. | 33 | # Compiler and linker configuration. |
36 | CC := $(DEVKITBIN)/arm-none-eabi-gcc | 34 | CC := $(DEVKITBIN)/arm-none-eabi-gcc |
37 | OBJCOPY := $(DEVKITBIN)/arm-none-eabi-objcopy | 35 | OBJCOPY := $(DEVKITBIN)/arm-none-eabi-objcopy |
38 | ARCH := -mthumb -mthumb-interwork | 36 | ARCH := -mthumb -mthumb-interwork |
39 | SPECS := -specs=gba.specs | 37 | SPECS := -specs=gba.specs |
40 | CONFIG := | 38 | CONFIG := |
41 | CFLAGS := -Wall -Wextra -pedantic -Wno-incompatible-pointer-types | 39 | CFLAGS := -Wall -Wextra -pedantic -Wno-incompatible-pointer-types -Wno-unused-variable -Wno-unused-function -Wno-unused-parameter |
42 | CFLAGS += -fno-strict-aliasing | 40 | CFLAGS += -fno-strict-aliasing |
43 | CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) | 41 | CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) |
44 | CFLAGS += $(INC_FLAGS) | 42 | CFLAGS += $(INC_FLAGS) |
@@ -62,17 +60,23 @@ endif | |||
62 | 60 | ||
63 | main: $(BUILD_DIR) $(ROM) $(BIN) | 61 | main: $(BUILD_DIR) $(ROM) $(BIN) |
64 | 62 | ||
65 | $(ROM): $(TOOLS_BIN2CARR) | 63 | # Creates the rom object file from the given UXN_ROM. |
66 | ./tools/bin2carr/build/bin2carr -n uxn_rom -e u16 -o $(ROM) $(ROM_SRC) | 64 | $(ROM_FILE): |
65 | cp $(UXN_ROM) $(ROM_FILE) | ||
66 | |||
67 | $(ROM_OBJ): $(ROM_FILE) | ||
68 | $(OBJCOPY) --rename-section .data=.rodata \ | ||
69 | -I binary -O elf32-littlearm $(ROM_FILE) $(ROM_OBJ) | ||
67 | 70 | ||
68 | # Strip and fix header to create final .gba file. | 71 | # Strip and fix header to create final .gba file. |
69 | $(BIN): $(ELF) | 72 | $(BIN): $(ELF) |
70 | $(OBJCOPY) -v -O binary $(ELF) $(BIN) | 73 | $(OBJCOPY) -v -O binary $(ELF) $(BIN) |
71 | $(DEVKITTOOLS)/gbafix $(BIN) | 74 | $(DEVKITTOOLS)/gbafix $(BIN) |
75 | rm $(ROM_FILE) | ||
72 | 76 | ||
73 | # Link files. | 77 | # Link files. |
74 | $(ELF): $(SRC_MAIN) $(WATCH_SRC) | 78 | $(ELF): $(SRC_MAIN) $(WATCH_SRC) $(ROM_OBJ) | $(BUILD_DIR) |
75 | $(CC) $(CFLAGS) $(LDFLAGS) -o $(ELF) $(SRC_MAIN) $(ASM_FILES) $(LDLIBS) | 79 | $(CC) $(CFLAGS) $(LDFLAGS) -o $(ELF) $(SRC_MAIN) $(ASM_FILES) $(LDLIBS) $(ROM_OBJ) |
76 | 80 | ||
77 | # Create build directory if needed. | 81 | # Create build directory if needed. |
78 | $(BUILD_DIR): | 82 | $(BUILD_DIR): |
@@ -85,6 +89,3 @@ run: main | |||
85 | # Remove build directory. | 89 | # Remove build directory. |
86 | clean: | 90 | clean: |
87 | rm -rf $(BUILD_DIR) | 91 | rm -rf $(BUILD_DIR) |
88 | |||
89 | $(TOOLS_BIN2CARR): | ||
90 | make -C tools/bin2carr | ||