From 084a57082dfe8c40315776e5da9df72aa6377e0f Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 12 Dec 2020 21:54:19 +1000 Subject: [PATCH] Add support for simultaneous build jobs (make -j) --- Makefile | 14 ++++---------- README.md | 15 ++++++++++----- ld/zero.ld | 4 ++-- tools/mkrawobject | 7 +++---- tools/mksimpleelf | 7 +++++++ 5 files changed, 26 insertions(+), 21 deletions(-) create mode 100755 tools/mksimpleelf diff --git a/Makefile b/Makefile index e46c51629..7acbae562 100644 --- a/Makefile +++ b/Makefile @@ -196,7 +196,7 @@ SEGMENT_FILES := \ $(B_DIR)/segments/mpstringsI.bin \ $(B_DIR)/segments/textureconfig.bin -test: $(SEGMENT_FILES) $(ASSET_FILES) +test: rom $(SEGMENT_FILES) $(ASSET_FILES) @md5sum --quiet -c checksums.$(ROMID).md5 $(B_DIR)/segments/%.bin: $(B_DIR)/stage2.bin @@ -259,9 +259,7 @@ src/files/bgdata/bg_%_tiles.o: src/files/bgdata/bg_%_tiles.s $(B_DIR)/files/bgdata/bg_%_tiles.elf: src/files/bgdata/bg_%_tiles.o @mkdir -p $(B_DIR)/files/bgdata - cp $< build/zero.tmp.o - $(TOOLCHAIN)-ld -T ld/zero.ld -o $@ - rm -f build/zero.tmp.o + TOOLCHAIN=$(TOOLCHAIN) tools/mksimpleelf $< $@ # Chrs $(B_DIR)/files/C%Z: $(E_DIR)/files/C%Z @@ -279,9 +277,7 @@ $(B_DIR)/files/lang/L%.o: src/files/lang/$(ROMID)/%.c $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc -c $(CFLAGS) $< -o $@ -O2 $(B_DIR)/files/L%.elf: $(B_DIR)/files/lang/L%.o - cp $< build/zero.tmp.o - $(TOOLCHAIN)-ld -T ld/zero.ld -o $@ - rm -f build/zero.tmp.o + TOOLCHAIN=$(TOOLCHAIN) tools/mksimpleelf $< $@ $(B_DIR)/files/L%E: $(B_DIR)/files/L%E.bin tools/rarezip $< > $@ @@ -305,9 +301,7 @@ $(B_DIR)/files/P%Z: $(E_DIR)/files/P%Z # Stage setups $(B_DIR)/files/U%.elf: $(B_DIR)/files/setup/%.o @mkdir -p $(B_DIR)/files - cp $< build/zero.tmp.o - $(TOOLCHAIN)-ld -T ld/zero.ld -o $@ - rm -f build/zero.tmp.o + TOOLCHAIN=$(TOOLCHAIN) tools/mksimpleelf $< $@ # General target to convert any finalised file into a raw object for ld $(B_DIR)/files/%.o: $(B_DIR)/files/% diff --git a/README.md b/README.md index 33f51a488..f8529aae4 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,14 @@ See the [Perfect Dark Decompilation Status Page](https://ryandwyer.gitlab.io/pds ## Installation Requirements -* make -* mips build tools (Debian/Ubuntu: binutils-mips-linux-gnu, Arch: mips64-elf-binutils from AUR) -* Python 3 +For Arch Linux: + +* Install these packages: `binutils fakeroot gcc make python vim` +* Install from AUR: `mips64-elf-binutils` + +For Debian and Ubuntu: + +* Install these packages: `binutils-mips-linux-gnu make` ## ROM Versions @@ -38,10 +43,10 @@ Before you do anything you need an existing ROM to extract assets from. ## Compiling -* Run `make rom` to build the ROM. The ROM will be written to `build/ntsc-final/pd.z64`. +* Run `make -j` to build the ROM. The ROM will be written to `build/ntsc-final/pd.z64`. ## How do I know the built files are matching? -Run `make` followed by `make test`. If `make test` produces no output then all compiled segments are matching. +Run `make` followed by `make test`. If `make test` produces no output then the compiled project is matching. You can also md5sum your base ROM with the built ROM and check they have the same hash: `md5sum pd.ntsc-final.z64 build/ntsc-final/pd.z64`. diff --git a/ld/zero.ld b/ld/zero.ld index faddffe8f..b36cf243f 100644 --- a/ld/zero.ld +++ b/ld/zero.ld @@ -4,11 +4,11 @@ OUTPUT_ARCH (mips) SECTIONS { .data 0x00000000 : AT(0x0000) { - build/zero.tmp.o (.data); + __FILE__ (.data); } .rodata : AT(SIZEOF(.data)) { - build/zero.tmp.o (.rodata); + __FILE__ (.rodata); } /DISCARD/ : { diff --git a/tools/mkrawobject b/tools/mkrawobject index fce1ceae4..d4c511846 100755 --- a/tools/mkrawobject +++ b/tools/mkrawobject @@ -2,9 +2,8 @@ set -e -echo -e "\n.data\n.incbin \"$1\"\n.balign 0x10" > build/$ROMID/file.s +echo -e "\n.data\n.incbin \"$1\"\n.balign 0x10" > build/$ROMID/file-$$.s -$TOOLCHAIN-as -mabi=32 -mips2 -I src/include -EB -o "$2" build/$ROMID/file.s - -rm -f build/$ROMID/file.s +$TOOLCHAIN-as -mabi=32 -mips2 -I src/include -EB -o "$2" build/$ROMID/file-$$.s +rm -f build/$ROMID/file-$$.s diff --git a/tools/mksimpleelf b/tools/mksimpleelf new file mode 100755 index 000000000..67f6e6363 --- /dev/null +++ b/tools/mksimpleelf @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +sed "s|__FILE__|$1|g" ld/zero.ld >> build/zero-$$.ld +$TOOLCHAIN-ld -T build/zero-$$.ld -o "$2" +rm -f build/zero-$$.ld