summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile36
1 files changed, 28 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index f24d501..442c85d 100644
--- a/Makefile
+++ b/Makefile
@@ -111,9 +111,10 @@ ASM_PROC_FLAGS := --input-enc=utf-8 --output-enc=euc-jp --convert-statics=globa
SPLAT ?= python3 -m splat split
SPLAT_YAML ?= $(TARGET).$(VERSION).yaml
+PIGMENT ?=tools/pigment64/pigment64
-IINC := -Iinclude -Isrc -Ibin/$(VERSION) -I.
+IINC := -Iinclude -Isrc -Iassets/$(VERSION) -I. -I$(BUILD_DIR)
IINC += -Ilib/ultralib/include -Ilib/ultralib/include/PR -Ilib/ultralib/include/ido
ifeq ($(KEEP_MDEBUG),0)
@@ -181,19 +182,23 @@ endif
#### Files ####
-$(shell mkdir -p asm/$(VERSION) bin linker_scripts/$(VERSION)/auto)
+$(shell mkdir -p asm/$(VERSION) assets/$(VERSION) linker_scripts/$(VERSION)/auto)
SRC_DIRS := $(shell find src -type d)
ASM_DIRS := $(shell find asm/$(VERSION) -type d -not -path "asm/$(VERSION)/nonmatchings/*" -not -path "asm/$(VERSION)/lib/*")
-BIN_DIRS := $(shell find bin -type d)
+ASSET_DIRS := $(shell find assets/$(VERSION) -type d)
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c))
S_FILES := $(foreach dir,$(ASM_DIRS) $(SRC_DIRS),$(wildcard $(dir)/*.s))
-BIN_FILES := $(foreach dir,$(BIN_DIRS),$(wildcard $(dir)/*.bin))
+BIN_FILES := $(foreach dir,$(ASSET_DIRS),$(wildcard $(dir)/*.bin))
O_FILES := $(foreach f,$(C_FILES:.c=.o),$(BUILD_DIR)/$f) \
$(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \
$(foreach f,$(BIN_FILES:.bin=.o),$(BUILD_DIR)/$f)
+ASSET_PNGS := $(foreach dir,$(ASSET_DIRS),$(wildcard $(dir)/*.png))
+ASSET_BINS := $(foreach f,$(ASSET_PNGS:.png=.bin),$(BUILD_DIR)/$f)
+ASSET_INC_C := $(foreach f,$(ASSET_PNGS:.png=.inc.c),$(BUILD_DIR)/$f)
+
LIBULTRA_DIRS := $(shell find lib/ultralib/src -type d \
-not -path "lib/ultralib/src/audio" \
-not -path "lib/ultralib/src/error" \
@@ -217,7 +222,7 @@ DEP_FILES := $(O_FILES:.o=.d) \
$(O_FILES:.o=.asmproc.d)
# create build directories
-$(shell mkdir -p $(BUILD_DIR)/linker_scripts/$(VERSION) $(BUILD_DIR)/linker_scripts/$(VERSION)/auto $(foreach dir,$(SRC_DIRS) $(ASM_DIRS) $(BIN_DIRS),$(BUILD_DIR)/$(dir)))
+$(shell mkdir -p $(BUILD_DIR)/linker_scripts/$(VERSION) $(BUILD_DIR)/linker_scripts/$(VERSION)/auto $(foreach dir,$(SRC_DIRS) $(ASM_DIRS) $(ASSET_DIRS),$(BUILD_DIR)/$(dir)))
# directory flags
@@ -253,13 +258,13 @@ ifneq ($(COMPARE),0)
endif
clean:
- $(RM) -r $(BUILD_DIR)/asm $(BUILD_DIR)/bin $(BUILD_DIR)/src $(ROM) $(ROMC) $(ELF)
+ $(RM) -r $(BUILD_DIR)/asm $(BUILD_DIR)/assets $(BUILD_DIR)/src $(ROM) $(ROMC) $(ELF)
libclean:
$(MAKE) -C lib clean
distclean: clean
- $(RM) -r $(BUILD_DIR) asm/ bin/ .splat/
+ $(RM) -r $(BUILD_DIR) asm/ assets/ .splat/
$(RM) -r linker_scripts/$(VERSION)/auto $(LD_SCRIPT)
$(MAKE) -C tools distclean
$(MAKE) -C lib distclean
@@ -269,7 +274,7 @@ setup:
python3 tools/decompress_baserom.py
extract:
- $(RM) -r asm/$(VERSION) bin/$(VERSION)
+ $(RM) -r asm/$(VERSION) assets/$(VERSION)
$(CAT) yamls/$(VERSION)/header.yaml yamls/$(VERSION)/makerom.yaml yamls/$(VERSION)/boot.yaml yamls/$(VERSION)/code.yaml yamls/$(VERSION)/overlays.yaml yamls/$(VERSION)/assets.yaml > $(SPLAT_YAML)
$(SPLAT) $(SPLAT_FLAGS) $(SPLAT_YAML)
@@ -332,6 +337,21 @@ ifneq ($(PERMUTER), 1)
$(error Library files has not been built, please run `$(MAKE) lib` first)
endif
+# Build C files from assets
+$(BUILD_DIR)/%.bin: %.png
+# file names are formatted as <file name>.<image format>.png
+# The <image format> part is passed into pigment's format argument
+ $(PIGMENT) to-bin -f $(subst .,,$(suffix $*)) -o $@ $<
+
+%.inc.c: %.bin
+# The C name argument uses just the <file name> part, with .<image format>.bin removed
+ python3 tools/bin_inc_c.py $< $@ $(basename $(basename $(notdir $<)))
+
+# Add these as a dependency for .o files
+asset_files: $(ASSET_INC_C)
+$(O_FILES): | asset_files
+.PHONY: asset_files
+
-include $(DEP_FILES)
# Print target for debugging