mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-24 06:29:59 +00:00
Hotfix: Fix running make init
without -jN
(#139)
* `assembly` target * update phony * temporary cp * add todo * use @hensldm suggestion
This commit is contained in:
parent
490924df23
commit
0e3e008da4
47
Makefile
47
Makefile
@ -1,9 +1,10 @@
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
# If COMPARE is 1, check the output md5sum after building
|
||||
COMPARE ?= 1
|
||||
# If NON_MATCHING is 1, define the NON_MATCHING C flag when building
|
||||
NON_MATCHING ?= 0
|
||||
# If ORIG_COMPILER is 1, compile with QEMU_IRIX and the original compiler
|
||||
# TODO we do not support static recomp, so force this to 1
|
||||
ORIG_COMPILER ?= 0
|
||||
|
||||
ifeq ($(NON_MATCHING),1)
|
||||
@ -74,6 +75,7 @@ UNCOMPRESSED_ROM := $(MM_ROM_NAME)_uncompressed.z64
|
||||
ELF := $(MM_ROM_NAME).elf
|
||||
|
||||
SRC_DIRS := $(shell find src -type d)
|
||||
ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*")
|
||||
BASEROM_DIRS := $(shell find baserom -type d 2>/dev/null)
|
||||
COMP_DIRS := $(BASEROM_DIRS:baserom%=comp%)
|
||||
BINARY_DIRS := $(BASEROM_DIRS:baserom%=binary%)
|
||||
@ -83,20 +85,20 @@ ASSET_C_FILES := $(shell find assets/ -type f -name "*.c")
|
||||
# Instead, generate a list of assembly files based on what's listed in the linker script.
|
||||
S_FILES := $(shell grep build/asm ./linker_scripts/code_script.txt | sed 's/\s*build\///g; s/\.o(\..*)/\.asm/g')
|
||||
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
|
||||
C_O_FILES := $(C_FILES:%.c=build/%.o)
|
||||
S_O_FILES := $(S_FILES:asm/%.asm=build/asm/%.o)
|
||||
ASSET_O_FILES := $(ASSET_C_FILES:%.c=build/%.o)
|
||||
O_FILES := $(C_O_FILES) $(S_O_FILES) $(ASSET_O_FILES)
|
||||
|
||||
ASSET_BIN_DIRS := $(shell find assets/* -type d -not -path "assets/xml*")
|
||||
|
||||
## Assets binaries (PNGs, JPGs, etc)
|
||||
TEXTURE_FILES_PNG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.png))
|
||||
TEXTURE_FILES_JPG := $(foreach dir,$(ASSET_BIN_DIRS),$(wildcard $(dir)/*.jpg))
|
||||
TEXTURE_FILES_OUT := $(foreach f,$(TEXTURE_FILES_PNG:.png=.inc.c),build/$f) \
|
||||
$(foreach f,$(TEXTURE_FILES_JPG:.jpg=.jpg.inc.c),build/$f) \
|
||||
|
||||
# create build directories
|
||||
$(shell mkdir -p build/linker_scripts build/asm build/asm/boot build/asm/code build/asm/overlays $(foreach dir,$(BASEROM_DIRS) $(COMP_DIRS) $(BINARY_DIRS) $(SRC_DIRS) $(ASSET_BIN_DIRS),$(shell mkdir -p build/$(dir))))
|
||||
$(shell mkdir -p build/linker_scripts build/asm build/asm/boot build/asm/code build/asm/overlays $(foreach dir, $(COMP_DIRS) $(BINARY_DIRS) $(SRC_DIRS) $(ASSET_BIN_DIRS),$(shell mkdir -p build/$(dir))))
|
||||
|
||||
# This file defines `ROM_FILES`, `UNCOMPRESSED_ROM_FILES`, and rules for generating `.yaz0` files
|
||||
ifneq ($(MAKECMDGOALS), clean)
|
||||
@ -128,19 +130,21 @@ build/src/libultra/voice/%: CC := ./tools/preprocess.py $(CC_OLD) -- $(AS) $(ASF
|
||||
|
||||
CC := ./tools/preprocess.py $(CC) -- $(AS) $(ASFLAGS) --
|
||||
|
||||
.PHONY: all clean setup diff-init init assetclean distclean
|
||||
.PHONY: all clean setup diff-init init assetclean distclean assembly
|
||||
# make will delete any generated assembly files that are not a prerequisite for anything, so keep it from doing so
|
||||
.PRECIOUS: asm/%.asm
|
||||
.DEFAULT_GOAL := $(UNCOMPRESSED_ROM)
|
||||
|
||||
$(UNCOMPRESSED_ROM): $(TEXTURE_FILES_OUT) $(UNCOMPRESSED_ROM_FILES)
|
||||
# just using build/baserom still probably has some race condiction/dependency bug, but since
|
||||
# it is first and should be completed relatively fast, it should not occur all that often.
|
||||
$(UNCOMPRESSED_ROM): build/baserom $(TEXTURE_FILES_OUT) $(UNCOMPRESSED_ROM_FILES)
|
||||
./tools/makerom.py ./tables/dmadata_table.txt $@
|
||||
ifeq ($(COMPARE),1)
|
||||
@md5sum $(UNCOMPRESSED_ROM)
|
||||
@md5sum -c checksum_uncompressed.md5
|
||||
endif
|
||||
|
||||
$(ROM): $(ROM_FILES)
|
||||
$(ROM): build/baserom $(ROM_FILES)
|
||||
./tools/makerom.py ./tables/dmadata_table.txt $@ -c
|
||||
ifeq ($(COMPARE),1)
|
||||
@md5sum $(ROM)
|
||||
@ -173,6 +177,9 @@ build/binary/assets/scenes/%: build/code.elf
|
||||
build/binary/overlays/%: build/code.elf
|
||||
@$(OBJCOPY) --dump-section $*=$@ $< /dev/null
|
||||
|
||||
|
||||
#### ASM rules ####
|
||||
|
||||
# Use an empty sentinel file (dep) to track the directory as a dependency, and
|
||||
# emulate GNU Make's order-only dependency.
|
||||
# The `touch $@; action || rm $@` pattern ensures that the `dep` file is older
|
||||
@ -189,16 +196,21 @@ asm/disasm.dep: tables/files.txt tables/functions.txt tables/objects.txt tables/
|
||||
@touch $@
|
||||
./tools/disasm.py -d ./asm -l ./tables/files.txt -f ./tables/functions.txt -o ./tables/objects.txt -v ./tables/variables.txt -v ./tables/vrom_variables.txt || rm $@
|
||||
|
||||
|
||||
#### Main commands ####
|
||||
|
||||
## Cleaning ##
|
||||
clean:
|
||||
$(RM) -rf $(ROM) $(UNCOMPRESSED_ROM) build asm
|
||||
$(RM) -rf $(ROM) $(UNCOMPRESSED_ROM) build
|
||||
|
||||
assetclean:
|
||||
$(RM) -r $(ASSET_BIN_DIRS)
|
||||
$(RM) -r build/assets
|
||||
$(RM) -rf $(ASSET_BIN_DIRS)
|
||||
$(RM) -rf build/assets
|
||||
|
||||
distclean: assetclean clean
|
||||
$(RM) -r baserom/
|
||||
$(RM) -rf baserom/ asm/ distclean/
|
||||
|
||||
## Extraction step
|
||||
setup:
|
||||
git submodule update --init --recursive
|
||||
python3 -m pip install -r requirements.txt
|
||||
@ -206,8 +218,12 @@ setup:
|
||||
./tools/extract_rom.py $(MM_BASEROM)
|
||||
python3 extract_assets.py
|
||||
|
||||
## Assembly generation
|
||||
assembly: $(S_FILES)
|
||||
@echo "Assembly generated."
|
||||
|
||||
diff-init: all
|
||||
rm -rf expected/
|
||||
$(RM) -rf expected/
|
||||
mkdir -p expected/
|
||||
cp -r build expected/build
|
||||
cp $(UNCOMPRESSED_ROM) expected/$(UNCOMPRESSED_ROM)
|
||||
@ -216,13 +232,14 @@ diff-init: all
|
||||
init:
|
||||
$(MAKE) distclean
|
||||
$(MAKE) setup
|
||||
$(MAKE) assembly
|
||||
$(MAKE) all
|
||||
$(MAKE) diff-init
|
||||
|
||||
# Recipes
|
||||
|
||||
build/baserom/%: baserom/%
|
||||
@cp $< $@
|
||||
build/baserom:
|
||||
cp -r baserom/ build/baserom/
|
||||
|
||||
# FIXME: The process of splitting rodata changes the assembly files, so we must avoid making .o files for them until that is done.
|
||||
# The simplest way to do that is to give them an order dependency on .c files' .o files
|
||||
@ -276,7 +293,7 @@ build/linker_scripts/%.ld: linker_scripts/%.txt
|
||||
build/assets/%.d: assets/%.c
|
||||
@$(GCC) $< -Iinclude -I./ -MM -MT 'build/assets/$*.o' > $@
|
||||
|
||||
# Build C files from assets
|
||||
## Build C files from assets
|
||||
|
||||
build/%.inc.c: %.png
|
||||
$(ZAPD) btex -eh -tt $(lastword ,$(subst ., ,$(basename $<))) -i $< -o $@
|
||||
|
Loading…
Reference in New Issue
Block a user