138 lines
2.9 KiB
Makefile
138 lines
2.9 KiB
Makefile
CFLAGS = -Isaturn
|
|
|
|
OPT ?= -O3
|
|
LIB = ./saturn
|
|
|
|
GEN_PYTHON_SOURCE = $(wildcard tools/source/*.py) $(wildcard tools/generate/*.py)
|
|
|
|
GEN_HEADERS =
|
|
GEN_HEADERS += gen/maps.hpp
|
|
GEN_HEADERS += gen/tilesets.hpp
|
|
GEN_HEADERS += gen/sprites.hpp
|
|
GEN_HEADERS += gen/collision_tile_ids.hpp
|
|
GEN_HEADERS += gen/text.hpp
|
|
GEN_HEADERS += gen/text_pointers.hpp
|
|
GEN_HEADERS += gen/pokemon/moves.hpp
|
|
GEN_HEADERS += gen/pokemon/types.hpp
|
|
GEN_HEADERS += gen/pokemon/pokemon_enum.inc.hpp
|
|
|
|
GEN_SRC =
|
|
GEN_SRC += gen/maps.cpp
|
|
GEN_SRC += gen/map_objects.cpp
|
|
GEN_SRC += gen/sprites.cpp
|
|
GEN_SRC += gen/tilesets.cpp
|
|
GEN_SRC += gen/collision_tile_ids.cpp
|
|
GEN_SRC += gen/text.cpp
|
|
GEN_SRC += gen/text_pointers.cpp
|
|
GEN_SRC += gen/pokemon/moves.cpp
|
|
GEN_SRC += gen/pokemon/pokemon.cpp
|
|
|
|
SRC =
|
|
SRC += $(GEN_SRC)
|
|
SRC += main.cpp
|
|
SRC += input.cpp
|
|
SRC += vram.cpp
|
|
SRC += font.cpp
|
|
SRC += graphic.cpp
|
|
SRC += menu.cpp
|
|
|
|
DEP = $(patsubst %.cpp,%.cpp.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/)
|
|
GFX_SPRITES = $(call res_png,2bpp,pokered/gfx/sprites/)
|
|
GFX_POKEMON = $(call res_png,2bpp,pokered/gfx/pokemon/front/) $(call res_png,2bpp,pokered/gfx/pokemon/back/)
|
|
MAPS_BLOCKS = $(call res,blk,pokered/maps/)
|
|
FONTS = res/font.2bpp.o
|
|
|
|
GENERATED_SRC = $(GFX_TILESETS) $(GFX_BLOCKSETS) $(GFX_SPRITES) $(GFX_POKEMON) $(MAPS_BLOCKS) $(GEN_SRC) $(FONTS)
|
|
GENERATED = $(GENERATED_SRC) $(GEN_HEADERS)
|
|
|
|
OBJ = $(patsubst %.cpp,%.o,$(SRC) $(GENERATED_SRC))
|
|
|
|
all: main.cue
|
|
|
|
include $(LIB)/common.mk
|
|
-include $(DEP)
|
|
|
|
define LINK_BINARY
|
|
@mkdir -p $(dir $@)
|
|
ln -sf $(shell realpath --relative-to="$(dir $@)" $<) $@
|
|
endef
|
|
|
|
define RUN_GENERATE
|
|
@mkdir -p ./gen
|
|
PYTHONPATH=./tools python -m generate ./pokered ./gen ./res
|
|
endef
|
|
|
|
gen/%.hpp: $(GEN_PYTHON_SOURCE)
|
|
$(RUN_GENERATE) $@
|
|
|
|
gen/%.cpp: $(GEN_PYTHON_SOURCE)
|
|
$(RUN_GENERATE) $@
|
|
|
|
define PNG_TO_2BPP
|
|
@mkdir -p $(dir $@)
|
|
python tools/png_to_nbpp.py 2 $@ $<
|
|
endef
|
|
|
|
define PNG_TO_2BPP_SPRITE
|
|
@mkdir -p $(dir $@)
|
|
python tools/png_to_nbpp_sprite.py 2 $@ $<
|
|
endef
|
|
|
|
res/%.2bpp: derived/%.png
|
|
$(PNG_TO_2BPP)
|
|
|
|
res/%.2bpp: pokered/%.png
|
|
$(PNG_TO_2BPP)
|
|
|
|
res/.1bpp: pokered/%.png
|
|
@mkdir -p $(dir $@)
|
|
python tools/png_to_nbpp.py 1 $@ $<
|
|
|
|
res/gfx/sprites/%.2bpp: pokered/gfx/sprites/%.png
|
|
$(PNG_TO_2BPP_SPRITE)
|
|
|
|
res/gfx/pokemon/%.2bpp: pokered/gfx/pokemon/%.png
|
|
$(PNG_TO_2BPP_SPRITE)
|
|
|
|
%.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) $(LIBGCC)
|
|
|
|
clean: clean-sh
|
|
clean-sh:
|
|
rm -rf res gen
|
|
|
|
generated: $(GENERATED)
|
|
|
|
PHONY: generated
|