aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile27
1 files changed, 14 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 100c861..8da65eb 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,9 @@ LIBGBA += $(LIBGBA_DIR)/lib/libmm.a
15SRC_DIR := src 15SRC_DIR := src
16BUILD_DIR := build 16BUILD_DIR := build
17SRC_MAIN := $(SRC_DIR)/main.c 17SRC_MAIN := $(SRC_DIR)/main.c
18ROM := $(BUILD_DIR)/rom.c 18UXN_ROM := roms/dvd.rom
19ROM_SRC := roms/dvd.rom 19ROM_FILE := $(BUILD_DIR)/uxn.rom
20ROM_OBJ := $(BUILD_DIR)/rom.o
20ASM_FILES := $(wildcard $(SRC_DIR)/*.s) 21ASM_FILES := $(wildcard $(SRC_DIR)/*.s)
21WATCH_SRC := $(shell find $(SRC_DIR) -name *.c -or -name *.s -or -name *.h) 22WATCH_SRC := $(shell find $(SRC_DIR) -name *.c -or -name *.s -or -name *.h)
22INC_DIRS := $(shell find $(SRC_DIR) -type d) 23INC_DIRS := $(shell find $(SRC_DIR) -type d)
@@ -29,16 +30,13 @@ TARGET := uxngba
29ELF := $(BUILD_DIR)/$(TARGET).elf 30ELF := $(BUILD_DIR)/$(TARGET).elf
30BIN := $(BUILD_DIR)/$(TARGET).gba 31BIN := $(BUILD_DIR)/$(TARGET).gba
31 32
32# Target tools.
33TOOLS_BIN2CARR := tools/bin2carr/build/bin2carr
34
35# Compiler and linker configuration. 33# Compiler and linker configuration.
36CC := $(DEVKITBIN)/arm-none-eabi-gcc 34CC := $(DEVKITBIN)/arm-none-eabi-gcc
37OBJCOPY := $(DEVKITBIN)/arm-none-eabi-objcopy 35OBJCOPY := $(DEVKITBIN)/arm-none-eabi-objcopy
38ARCH := -mthumb -mthumb-interwork 36ARCH := -mthumb -mthumb-interwork
39SPECS := -specs=gba.specs 37SPECS := -specs=gba.specs
40CONFIG := 38CONFIG :=
41CFLAGS := -Wall -Wextra -pedantic -Wno-incompatible-pointer-types 39CFLAGS := -Wall -Wextra -pedantic -Wno-incompatible-pointer-types -Wno-unused-variable -Wno-unused-function -Wno-unused-parameter
42CFLAGS += -fno-strict-aliasing 40CFLAGS += -fno-strict-aliasing
43CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) 41CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH)
44CFLAGS += $(INC_FLAGS) 42CFLAGS += $(INC_FLAGS)
@@ -62,17 +60,23 @@ endif
62 60
63main: $(BUILD_DIR) $(ROM) $(BIN) 61main: $(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.
86clean: 90clean:
87 rm -rf $(BUILD_DIR) 91 rm -rf $(BUILD_DIR)
88
89$(TOOLS_BIN2CARR):
90 make -C tools/bin2carr