81 lines
1.5 KiB
Makefile
81 lines
1.5 KiB
Makefile
CFLAGS = -Isaturn
|
|
|
|
OPT ?= -Og
|
|
LIB = ./saturn
|
|
|
|
SRC = main.o input.o gen/maps.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,2bpp,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 LINK_BINARY
|
|
@mkdir -p $(dir $@)
|
|
ln -sf $(shell realpath --relative-to="$(dir $@)" $<) $@
|
|
endef
|
|
|
|
GEN_PYTHON_SOURCE = $(wildcard tools/source/*.py) $(wildcard tools/generate/*.py)
|
|
|
|
define RUN_GENERATE
|
|
@mkdir -p ./gen
|
|
PYTHONPATH=./tools python -m generate ./pokered ./gen ./res
|
|
endef
|
|
|
|
gen/%.cpp: $(GEN_PYTHON_SOURCE)
|
|
$(RUN_GENERATE)
|
|
|
|
gen/%.hpp: $(GEN_PYTHON_SOURCE)
|
|
$(RUN_GENERATE)
|
|
|
|
generated: $(GENERATED)
|
|
|
|
res/%.2bpp: pokered/%.png
|
|
@mkdir -p $(dir $@)
|
|
python tools/png_to_nbpp.py $< 2 $@
|
|
|
|
%.2bpp.h:
|
|
$(BUILD_BINARY_H)
|
|
|
|
%.2bpp.o: %.2bpp %.2bpp.h
|
|
$(BUILD_BINARY_O)
|
|
|
|
res/%.blk: pokered/%.blk
|
|
$(LINK_BINARY)
|
|
|
|
%.blk.h:
|
|
$(BUILD_BINARY_H)
|
|
|
|
%.blk.o: %.blk %.blk.h
|
|
$(BUILD_BINARY_O)
|
|
|
|
res/%.bst: pokered/%.bst
|
|
$(LINK_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
|