2018-10-26 02:29:41 +00:00
|
|
|
# TODO think about how to split this up
|
|
|
|
|
|
|
|
MIPS_BINUTILS := mips-linux-gnu-
|
|
|
|
|
|
|
|
AS := $(MIPS_BINUTILS)as
|
|
|
|
LD := $(MIPS_BINUTILS)ld
|
|
|
|
|
2018-11-14 04:10:59 +00:00
|
|
|
#QEMU_IRIX := ~/irixemu/mips-linux-user/qemu-mips
|
|
|
|
QEMU_IRIX := ~/qemu-irix
|
2018-12-06 19:47:07 +00:00
|
|
|
IRIX_71_ROOT := ./ido/71/
|
2018-11-17 08:16:20 +00:00
|
|
|
IRIX_62_ROOT := ./ido/62/
|
2018-12-06 19:47:07 +00:00
|
|
|
IRIX_53_ROOT := ./ido/53_patched/
|
2018-10-26 02:29:41 +00:00
|
|
|
|
|
|
|
CFLAGS := -G 0 -non_shared -Xfullwarn -Xcpluscomm
|
2018-11-14 04:10:59 +00:00
|
|
|
ASFLAGS := -march=vr4300 -32
|
2018-10-26 02:29:41 +00:00
|
|
|
|
|
|
|
MIPS_VERSION := -mips2
|
|
|
|
OPTIMIZATION := -O2 -g3
|
|
|
|
|
|
|
|
build/src/libultra/os/%: OPTIMIZATION := -O1
|
|
|
|
build/src/libultra/io/%: OPTIMIZATION := -O2
|
|
|
|
build/src/libultra/libc/%: OPTIMIZATION := -O2
|
2018-11-17 08:16:20 +00:00
|
|
|
build/src/libultra/gu/%: OPTIMIZATION := -O2
|
|
|
|
build/src/libultra/%: CC := $(QEMU_IRIX) -L $(IRIX_53_ROOT) $(IRIX_53_ROOT)/usr/bin/cc
|
|
|
|
build/src/libultra/%: CFLAGS := $(CFLAGS) -Wab,-r4300_mul
|
2018-11-14 04:10:59 +00:00
|
|
|
build/src/boot_O1/%: OPTIMIZATION := -O1
|
2018-10-29 04:12:21 +00:00
|
|
|
build/src/boot_O2_g3/%: OPTIMIZATION := -O2 -g3
|
2019-03-07 03:48:32 +00:00
|
|
|
build/src/code/%: CFLAGS := $(CFLAGS) -Wab,-r4300_mul
|
|
|
|
test.txt: OPTIMIZATION := -O2 -g3
|
|
|
|
test.txt: CC := $(QEMU_IRIX) -L $(IRIX_71_ROOT) $(IRIX_71_ROOT)/usr/bin/cc
|
2018-11-17 08:16:20 +00:00
|
|
|
test.txt: CFLAGS := $(CFLAGS) -Wab,-r4300_mul
|
|
|
|
|
2018-12-06 19:47:07 +00:00
|
|
|
CC := $(QEMU_IRIX) -L $(IRIX_71_ROOT) $(IRIX_71_ROOT)/usr/bin/cc
|
2018-10-26 02:29:41 +00:00
|
|
|
|
2018-11-14 04:10:59 +00:00
|
|
|
test.txt: CC := python3 preprocess.py $(CC) -- $(AS) $(ASFLAGS) --
|
|
|
|
build/src/boot_O2_g3/%: CC := python3 preprocess.py $(CC) -- $(AS) $(ASFLAGS) --
|
2019-03-07 03:48:32 +00:00
|
|
|
build/src/code/%: CC := python3 preprocess.py $(CC) -- $(AS) $(ASFLAGS) --
|
2018-11-14 04:10:59 +00:00
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
BASEROM_FILES := $(wildcard baserom/*)
|
2019-04-12 02:12:49 +00:00
|
|
|
# Exclude dmadata, it will be generated right before packing the rom
|
|
|
|
BASEROM_FILES := $(subst baserom/dmadata ,,$(BASEROM_FILES))
|
|
|
|
BASEROM_BUILD_FILES := $(BASEROM_FILES:baserom/%=build/baserom/%)
|
|
|
|
|
|
|
|
DECOMP_FILES := $(wildcard decomp/*)
|
|
|
|
COMP_FILES := $(DECOMP_FILES:decomp/%=build/comp/%.yaz0)
|
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
S_FILES := $(wildcard asm/*)
|
|
|
|
S_O_FILES = $(S_FILES:asm/%.asm=build/asm/%.o)
|
2018-11-14 04:10:59 +00:00
|
|
|
C_FILES := $(wildcard src/libultra/*) \
|
2018-10-29 04:12:21 +00:00
|
|
|
$(wildcard src/libultra/os/*) \
|
|
|
|
$(wildcard src/libultra/io/*) \
|
|
|
|
$(wildcard src/libultra/libc/*) \
|
2018-11-17 08:16:20 +00:00
|
|
|
$(wildcard src/libultra/gu/*) \
|
2018-10-29 04:12:21 +00:00
|
|
|
$(wildcard src/code/*) \
|
2018-11-14 04:10:59 +00:00
|
|
|
$(wildcard src/boot_O2_g3/*) \
|
|
|
|
$(wildcard src/boot_O1/*)
|
2018-10-26 02:29:41 +00:00
|
|
|
C_O_FILES = $(C_FILES:src/%.c=build/src/%.o)
|
2019-04-11 04:58:55 +00:00
|
|
|
ROM_FILES := $(shell cat makerom_files.txt)
|
2018-10-28 08:32:16 +00:00
|
|
|
|
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
ROM := rom.z64
|
|
|
|
|
|
|
|
# make build directories
|
|
|
|
$(shell mkdir -p build/asm)
|
|
|
|
$(shell mkdir -p build/baserom)
|
2019-04-11 04:58:55 +00:00
|
|
|
$(shell mkdir -p build/comp)
|
2018-10-26 02:29:41 +00:00
|
|
|
$(shell mkdir -p build/src)
|
|
|
|
$(shell mkdir -p build/src/libultra)
|
|
|
|
$(shell mkdir -p build/src/libultra/os)
|
|
|
|
$(shell mkdir -p build/src/libultra/io)
|
|
|
|
$(shell mkdir -p build/src/libultra/libc)
|
2018-11-17 08:16:20 +00:00
|
|
|
$(shell mkdir -p build/src/libultra/gu)
|
2018-10-26 02:29:41 +00:00
|
|
|
$(shell mkdir -p build/src/code)
|
2018-10-29 04:12:21 +00:00
|
|
|
$(shell mkdir -p build/src/boot_O2_g3)
|
2018-11-14 04:10:59 +00:00
|
|
|
$(shell mkdir -p build/src/boot_O1)
|
2018-10-26 02:29:41 +00:00
|
|
|
|
2019-04-16 02:01:57 +00:00
|
|
|
check: $(ROM)
|
2018-10-26 02:29:41 +00:00
|
|
|
@md5sum -c checksum.md5
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2019-04-11 04:58:55 +00:00
|
|
|
$(ROM): $(ROM_FILES)
|
|
|
|
@python3 makerom.py
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
boot.bin: code.elf
|
|
|
|
$(MIPS_BINUTILS)objcopy --dump-section boot=$@ $<
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
code.bin: code.elf
|
|
|
|
$(MIPS_BINUTILS)objcopy --dump-section code=$@ $<
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
code.elf: $(S_O_FILES) $(C_O_FILES) codescript.txt undef.txt
|
|
|
|
$(LD) -T codescript.txt -T undef.txt --no-check-sections --accept-unknown-input-arch -o $@
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
test.txt: build/src/test.o
|
2018-11-09 03:02:45 +00:00
|
|
|
$(MIPS_BINUTILS)objdump -d -z --adjust-vma=0x80080790 $< > test.txt
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
clean:
|
2019-04-11 04:58:55 +00:00
|
|
|
rm $(ROM) code.elf code.bin boot.bin -r build
|
2018-10-26 02:29:41 +00:00
|
|
|
|
2019-04-12 02:12:49 +00:00
|
|
|
build/baserom/dmadata: $(COMP_FILES) $(BASEROM_BUILD_FILES)
|
|
|
|
python3 dmadata.py
|
|
|
|
|
2019-04-12 05:09:21 +00:00
|
|
|
build/baserom/boot: boot.bin
|
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
build/comp/code.yaz0: code.bin
|
|
|
|
python3 yaz0.py -i $< -o $@
|
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
# Recipes
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2019-04-11 04:58:55 +00:00
|
|
|
build/baserom/%: baserom/%
|
|
|
|
cp $< $@
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
build/asm/%.o: asm/%.asm
|
2018-11-14 04:10:59 +00:00
|
|
|
$(AS) $(ASFLAGS) $^ -o $@
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2018-10-26 02:29:41 +00:00
|
|
|
build/src/%.o: src/%.c include/*
|
2018-11-14 04:10:59 +00:00
|
|
|
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTIMIZATION) -Iinclude -o $@ $<
|
2018-10-28 08:32:16 +00:00
|
|
|
|
2019-04-11 04:58:55 +00:00
|
|
|
build/comp/%.yaz0: decomp/%
|
|
|
|
python3 yaz0.py -i $< -o $@
|
|
|
|
|