CFLAGS = -Isaturn OPT ?= -Og LIB = ./saturn SRC = main.o DEP = $(patsubst %.o,%.d,$(SRC)) res = $(subst pokered/,res/,$(patsubst %.$(1),%.$(1).o,$(wildcard $(2)*.$(1)))) res_png = $(subst pokered/,res/,$(patsubst %.png,%.$(1).o,$(wildcard $(2)*.png))) GFX_TILESETS = $(call res_png,4bpp,pokered/gfx/tilesets/) GFX_BLOCKSETS = $(call res,bst,pokered/gfx/blocksets/) MAPS_BLOCKS = $(call res,blk,pokered/maps/) GENERATED = $(GFX_TILESETS) $(GFX_BLOCKSETS) $(MAPS_BLOCKS) OBJ = $(SRC) $(GENERATED) all: main.cue include $(LIB)/common.mk -include $(DEP) define COPY_BINARY @mkdir -p $(dir $@) cp -a $< $@ endef generated: $(GENERATED) res/%.4bpp: pokered/%.png @mkdir -p $(dir $@) python tools/png_to_4bpp.py $< $@ %.4bpp.h: $(BUILD_BINARY_H) %.4bpp.o: %.4bpp %.4bpp.h $(BUILD_BINARY_O) res/%.blk: pokered/%.blk $(COPY_BINARY) %.blk.h: $(BUILD_BINARY_H) %.blk.o: %.blk %.blk.h $(BUILD_BINARY_O) res/%.bst: pokered/%.bst $(COPY_BINARY) %.bst.h: $(BUILD_BINARY_H) %.bst.o: %.bst %.bst.h $(BUILD_BINARY_O) %.o: | $(GFX_TILESETS) main.elf: $(OBJ) clean: clean-sh clean-sh: rm -rf res PHONY: generated-headers