From 1d1d50494efa09a0d7607047b7209eb0d9c6e493 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 17 Oct 2022 08:12:08 +1000 Subject: [PATCH] Make some tweaks and fixes for the build system for Ubuntu --- Makefile | 2 +- README.md | 6 ++++-- tools/mkrom/Makefile | 2 +- tools/mkrom/map.c | 8 ++------ tools/mkrom/pack.c | 2 +- tools/mkrom/piracy.c | 12 ++++++++++-- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 1d822df8c..e8920628e 100644 --- a/Makefile +++ b/Makefile @@ -784,4 +784,4 @@ allclean: rm -rf build/* codeclean: - find $(B_DIR)/{game,inflate,lib} -name '*.o' -delete + find $(B_DIR)/game $(B_DIR)/inflate $(B_DIR)/lib -name '*.o' -delete diff --git a/README.md b/README.md index dc805ce1d..8fcc1080f 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,13 @@ The ntsc-1.0 and ntsc-final versions are fully decompiled, but a small handful o For Arch Linux: * Install these packages: `binutils fakeroot gcc make python vim` -* Install from AUR: `armips` and a mips binutils package of your choice (eg. `mips-elf-binutils`) +* Install from AUR: `armips` +* Install from AUR: a MIPS binutils package of your choice (eg. `mips-elf-binutils`) +* Install from AUR: a MIPS gcc package of your choice (eg. `mips-elf-gcc`) For Debian and Ubuntu: -* Install these packages: `binutils-mips-linux-gnu build-essential libc6-dev-i386 libcapstone3 libcapstone-dev make` +* Install these packages: `binutils-mips-linux-gnu build-essential gcc-mips-linux-gnu libc6-dev-i386 libcapstone-dev make` * Compile and install `armips` ## ROM Versions diff --git a/tools/mkrom/Makefile b/tools/mkrom/Makefile index a7b513304..d0169a242 100644 --- a/tools/mkrom/Makefile +++ b/tools/mkrom/Makefile @@ -4,4 +4,4 @@ C_FILES = $(wildcard *.c) gcc -O3 %< -o $@ mkrom: $(C_FILES) - gcc -O3 $(C_FILES) -o mkrom + gcc -Wno-unused-result -O3 $(C_FILES) -o mkrom diff --git a/tools/mkrom/map.c b/tools/mkrom/map.c index 82fb57ef4..8d69001d2 100644 --- a/tools/mkrom/map.c +++ b/tools/mkrom/map.c @@ -41,9 +41,7 @@ bool map_get_function_rompos(char *funcname, uint32_t *start, uint32_t *end) fseek(state.mapfd, 0, SEEK_SET); - while (!feof(state.mapfd)) { - fgets(line, 1024, state.mapfd); - + while (fgets(line, 1024, state.mapfd)) { if (lookingforend) { ptr = line; @@ -116,9 +114,7 @@ bool map_get_segment_rompos(char *segname, uint32_t *start, uint32_t *end) // Find lines like this: // " 0x0000000000001050 _libzipSegmentRomStart = __rompos" - while (!feof(state.mapfd)) { - fgets(line, 1024, state.mapfd); - + while (fgets(line, 1024, state.mapfd)) { if (!found_start && strstr(line, startstring)) { char *ptr = strstr(line, "0x"); diff --git a/tools/mkrom/pack.c b/tools/mkrom/pack.c index 8425e783b..08215b6c1 100644 --- a/tools/mkrom/pack.c +++ b/tools/mkrom/pack.c @@ -5,7 +5,7 @@ extern struct state state; -static void copy(char *segname, uint8_t *payload, size_t len, char *constname) +static void copy(char *segname, uint8_t *payload, uint32_t len, char *constname) { uint32_t start; uint32_t end; diff --git a/tools/mkrom/piracy.c b/tools/mkrom/piracy.c index 27f0e21f2..03c6d0ad8 100644 --- a/tools/mkrom/piracy.c +++ b/tools/mkrom/piracy.c @@ -42,7 +42,11 @@ static uint32_t calc_sum(char *sumfunc, Algo algo) uint32_t offset; if (!map_get_function_rompos(sumfunc, &start, &end)) { - fprintf(stderr, "Unable to find function \"%s\" in map file\n", sumfunc); + fprintf(stderr, "Unable to find function \"%s\" in map file.\n", sumfunc); + fprintf(stderr, "If a piracy function has been renamed then you may need to rebuild mkrom:\n"); + fprintf(stderr, "\n"); + fprintf(stderr, " make -C tools/mkrom\n"); + fprintf(stderr, "\n"); exit(1); } @@ -99,7 +103,11 @@ static void write_sum(char *patchfunc, uint32_t sum) uint32_t end; if (!map_get_function_rompos(patchfunc, &start, &end)) { - fprintf(stderr, "Unable to find function \"%s\" in map file\n", patchfunc); + fprintf(stderr, "Unable to find function \"%s\" in map file.\n", patchfunc); + fprintf(stderr, "If a piracy function has been renamed then you may need to rebuild mkrom:\n"); + fprintf(stderr, "\n"); + fprintf(stderr, " make -C tools/mkrom\n"); + fprintf(stderr, "\n"); exit(1); }