aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2022-10-19 10:00:42 +0200
committerBad Diode <bd@badd10de.dev>2022-10-19 10:00:42 +0200
commit0702260e53a18dacfae58582da8a4d518c3c41ee (patch)
tree51e35f761f6e23fd4f9ce54cfa3d119e2e4bdc64 /Makefile
parent219029f317e20a5248735d7f7bf6bb88ecb95d28 (diff)
downloaduxn64-0702260e53a18dacfae58582da8a4d518c3c41ee.tar.gz
uxn64-0702260e53a18dacfae58582da8a4d518c3c41ee.zip
Replace `spicy` with linker scripts
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 16 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 5250c36..f402bd2 100644
--- a/Makefile
+++ b/Makefile
@@ -12,11 +12,15 @@ LIBULTRA := $(LIBULTRA_DIR)/usr/lib/libgultra.a
12# Source code location and files to watch for changes. 12# Source code location and files to watch for changes.
13SRC_DIR := src 13SRC_DIR := src
14BUILD_DIR := build 14BUILD_DIR := build
15SRC_MAIN := $(SRC_DIR)/main.c 15SRC_MAIN := $(SRC_DIR)/main.c $(SRC_DIR)/entry.s
16SRC_LN := $(SRC_DIR)/linker.ld
16SRC_OBJ := 17SRC_OBJ :=
17OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC_OBJ)) 18OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC_OBJ))
18 19WATCH_SRC := $(shell find $(SRC_DIR) \
19WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h") 20 -name "*.c" -or \
21 -name "*.s" -or \
22 -name "*.h" -or \
23 -name "**.ld")
20INC_DIRS := $(shell find $(SRC_DIR) -type d) 24INC_DIRS := $(shell find $(SRC_DIR) -type d)
21INC_DIRS += $(LIBULTRA_INC) 25INC_DIRS += $(LIBULTRA_INC)
22INC_FLAGS := $(addprefix -I,$(INC_DIRS)) 26INC_FLAGS := $(addprefix -I,$(INC_DIRS))
@@ -31,8 +35,8 @@ CC := $(SDK_BIN)/mips32-elf-gcc
31LD := $(SDK_BIN)/mips32-elf-ld 35LD := $(SDK_BIN)/mips32-elf-ld
32AS := $(SDK_BIN)/mips32-elf-as 36AS := $(SDK_BIN)/mips32-elf-as
33OBJDUMP := $(SDK_BIN)/mips32-elf-objdump 37OBJDUMP := $(SDK_BIN)/mips32-elf-objdump
38OBJCOPY := $(SDK_BIN)/mips32-elf-objcopy
34# TODO: Replace with internal tools to avoid dependencies. 39# TODO: Replace with internal tools to avoid dependencies.
35SPICY := $(SDK_BIN)/spicy
36MAKEMASK := $(SDK_BIN)/makemask 40MAKEMASK := $(SDK_BIN)/makemask
37 41
38# Compiler and linker configuration. 42# Compiler and linker configuration.
@@ -40,8 +44,8 @@ CFLAGS := -Wall -Wextra -pedantic
40CFLAGS += -mabi=32 -mfix4300 44CFLAGS += -mabi=32 -mfix4300
41CFLAGS += -ffreestanding -G 0 45CFLAGS += -ffreestanding -G 0
42CFLAGS += $(INC_FLAGS) 46CFLAGS += $(INC_FLAGS)
43CFLAGS += -DF3DEX_GBI_2 -nostdlib -r 47CFLAGS += -DF3DEX_GBI_2
44LDFLAGS := -nostdlib -r 48LDFLAGS := -nostdlib
45LDLIBS := $(LIBULTRA) $(SDK_BASE)/lib/gcc/mips32-elf/13.0.0/libgcc.a 49LDLIBS := $(LIBULTRA) $(SDK_BASE)/lib/gcc/mips32-elf/13.0.0/libgcc.a
46RELEASE_CFLAGS := -O2 -DNDEBUG -D_FINALROM 50RELEASE_CFLAGS := -O2 -DNDEBUG -D_FINALROM
47DEBUG_CFLAGS := -O0 -DDEBUG -D_FINALROM 51DEBUG_CFLAGS := -O0 -DDEBUG -D_FINALROM
@@ -59,15 +63,10 @@ endif
59main: $(BIN) 63main: $(BIN)
60 64
61$(ELF): $(SRC_MAIN) $(WATCH_SRC) | $(BUILD_DIR) 65$(ELF): $(SRC_MAIN) $(WATCH_SRC) | $(BUILD_DIR)
62 $(CC) $(CFLAGS) $(LDFLAGS) -o $(ELF) $(SRC_MAIN) $(LDLIBS) 66 $(CC) $(CFLAGS) $(LDFLAGS) -o $(ELF) -T $(SRC_LN) $(SRC_MAIN) $(LDLIBS)
63 67
64$(BIN): $(ELF) $(OBJECTS) $(WATCH_SRC) | $(BUILD_DIR) 68$(BIN): $(ELF) $(OBJECTS) $(WATCH_SRC) | $(BUILD_DIR)
65 $(SPICY) -r $@ $(SRC_DIR)/spec \ 69 $(OBJCOPY) -O binary $< $@
66 --as_command="$(SDK_BIN)/mips32-elf-as" \
67 --cpp_command="$(SDK_BIN)/mips32-elf-gcc" \
68 --ld_command="$(SDK_BIN)/mips32-elf-ld" \
69 --objcopy_command="$(SDK_BIN)/mips32-elf-objcopy"
70 rm a.out
71 $(MAKEMASK) $(BIN) 70 $(MAKEMASK) $(BIN)
72 71
73# Test the output .n64 in an emulator. 72# Test the output .n64 in an emulator.
@@ -86,3 +85,7 @@ $(BUILD_DIR):
86# Inference rules for C files. 85# Inference rules for C files.
87$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR) 86$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
88 $(CC) $(CFLAGS) $< -o $@ 87 $(CC) $(CFLAGS) $< -o $@
88
89# Inference rules for assembly files.
90$(BUILD_DIR)/%.o: $(SRC_DIR)/%.s | $(BUILD_DIR)
91 $(AS) $(AFLAGS) -o $@ -c $<