Makefile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. MD5 := md5sum -c
  2. pokered_obj := audio_red.o main_red.o text_red.o wram_red.o
  3. pokeblue_obj := audio_blue.o main_blue.o text_blue.o wram_blue.o
  4. .SUFFIXES:
  5. .SECONDEXPANSION:
  6. .PRECIOUS:
  7. .SECONDARY:
  8. .PHONY: all clean red blue compare tools
  9. roms := pokered.gbc pokeblue.gbc
  10. all: $(roms)
  11. red: pokered.gbc
  12. blue: pokeblue.gbc
  13. # For contributors to make sure a change didn't affect the contents of the rom.
  14. compare: red blue
  15. @$(MD5) roms.md5
  16. clean:
  17. rm -f $(roms) $(pokered_obj) $(pokeblue_obj) $(roms:.gbc=.sym)
  18. find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} +
  19. $(MAKE) clean -C tools/
  20. tools:
  21. $(MAKE) -C tools/
  22. # Build tools when building the rom.
  23. # This has to happen before the rules are processed, since that's when scan_includes is run.
  24. ifeq (,$(filter clean tools,$(MAKECMDGOALS)))
  25. $(info $(shell $(MAKE) -C tools))
  26. endif
  27. %.asm: ;
  28. %_red.o: dep = $(shell tools/scan_includes $(@D)/$*.asm)
  29. $(pokered_obj): %_red.o: %.asm $$(dep)
  30. rgbasm -D _RED -h -o $@ $*.asm
  31. %_blue.o: dep = $(shell tools/scan_includes $(@D)/$*.asm)
  32. $(pokeblue_obj): %_blue.o: %.asm $$(dep)
  33. rgbasm -D _BLUE -h -o $@ $*.asm
  34. pokered_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON RED"
  35. pokeblue_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON BLUE"
  36. %.gbc: $$(%_obj)
  37. rgblink -d -n $*.sym -l pokered.link -o $@ $^
  38. rgbfix $($*_opt) $@
  39. sort $*.sym -o $*.sym
  40. gfx/blue/intro_purin_1.2bpp: rgbgfx += -h
  41. gfx/blue/intro_purin_2.2bpp: rgbgfx += -h
  42. gfx/blue/intro_purin_3.2bpp: rgbgfx += -h
  43. gfx/red/intro_nido_1.2bpp: rgbgfx += -h
  44. gfx/red/intro_nido_2.2bpp: rgbgfx += -h
  45. gfx/red/intro_nido_3.2bpp: rgbgfx += -h
  46. gfx/game_boy.2bpp: tools/gfx += --remove-duplicates
  47. gfx/theend.2bpp: tools/gfx += --interleave --png=$<
  48. gfx/tilesets/%.2bpp: tools/gfx += --trim-whitespace
  49. %.png: ;
  50. %.2bpp: %.png
  51. rgbgfx $(rgbgfx) -o $@ $<
  52. $(if $(tools/gfx),\
  53. tools/gfx $(tools/gfx) -o $@ $@)
  54. %.1bpp: %.png
  55. rgbgfx -d1 $(rgbgfx) -o $@ $<
  56. $(if $(tools/gfx),\
  57. tools/gfx $(tools/gfx) -d1 -o $@ $@)
  58. %.pic: %.2bpp
  59. tools/pkmncompress $< $@