GameBoy (Color) port of the GTA San Andreas arcade game Duality
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Makefile 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # Adapted from GBDK-2020 examples
  2. #
  3. # Copyright (C) 2025 Thomas Buck <thomas@xythobuz.de>
  4. #
  5. # https://gbdk.org/docs/api/docs_toolchain_settings.html
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # See <http://www.gnu.org/licenses/>.
  18. ifndef GBDK_HOME
  19. GBDK_HOME = ../../../
  20. endif
  21. BIN := duality.gb
  22. SRC_DIR := src
  23. BUILD_DIR := build
  24. DATA_DIR := data
  25. SRCS := $(wildcard $(SRC_DIR)/*.c)
  26. OBJS := $(SRCS:%.c=$(BUILD_DIR)/%.o)
  27. ASSETS := $(wildcard $(DATA_DIR)/*.png)
  28. SPRITES := $(ASSETS:%.png=$(BUILD_DIR)/%.c)
  29. OBJS += $(SPRITES:%.c=%.o)
  30. LCC := $(GBDK_HOME)/bin/lcc
  31. PNGA := $(GBDK_HOME)/bin/png2asset
  32. ROMU := $(GBDK_HOME)/bin/romusage
  33. GB_EMU := gearboy
  34. LCCFLAGS := -Wa-l -Wl-m -Wp-MMD
  35. LCCFLAGS += -I$(BUILD_DIR)/$(DATA_DIR)
  36. LCCFLAGS += -Wm"-yn Duality" -Wm-yt0x1A -Wm-yoA -Wm-ya16 -Wm-yc
  37. LCCFLAGS += -autobank -Wb-ext=.rel -Wb-v -Wf-bo255
  38. EMUFLAGS := $(BIN)
  39. ifndef GBDK_RELEASE
  40. LCCFLAGS += -debug -DDEBUG -Wa-j -Wa-y -Wa-s -Wl-j -Wl-y -Wl-u -Wm-yS
  41. EMUFLAGS += $(BUILD_DIR)/$(BIN:.gb=.sym)
  42. BUILD_TYPE = Debug
  43. else
  44. BUILD_TYPE = Release
  45. endif
  46. $(info BUILD_TYPE is $(BUILD_TYPE))
  47. # TODO this is not working. why?!
  48. #DEPS=$(OBJS:%.o=%.d)
  49. #-include $(DEPS)
  50. .PHONY: all run clean compile_commands.json usage
  51. .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
  52. all: $(BIN)
  53. compile_commands.json:
  54. @echo "Cleaning old build"
  55. @make clean
  56. @echo "Preparing bear.cfg"
  57. @echo '{"compilation":{"compilers_to_recognize":[{"executable":"$(GBDK_HOME)/bin/sdcc","flags_to_add":[""],"flags_to_remove":[""]}]}}' > bear.cfg
  58. @echo "Running full build within bear"
  59. @bear --config bear.cfg -- make -j4
  60. @rm -rf bear.cfg
  61. usage: $(BUILD_DIR)/$(BIN)
  62. @echo Analyzing $<
  63. @$(ROMU) $(BUILD_DIR)/$(BIN:%.gb=%.map)
  64. run: $(BIN)
  65. @echo Emulating $<
  66. @$(GB_EMU) $(EMUFLAGS)
  67. $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h: $(DATA_DIR)/%.png
  68. @mkdir -p $(@D)
  69. $(if $(findstring _map,$<), \
  70. @echo "Converting map $<" && \
  71. $(PNGA) $< -o $@ -spr8x8 -map -use_map_attributes -noflip \
  72. ,$(if $(findstring _fnt,$<), \
  73. @echo "Converting font $<" && \
  74. $(PNGA) $< -o $@ -spr8x8 -sw 16 -sh 16 -map -noflip \
  75. , \
  76. @echo "Converting tile $<" && \
  77. $(PNGA) $< -o $@ -spr8x8 \
  78. ))
  79. $(BUILD_DIR)/%.o: %.c $(SPRITES)
  80. @mkdir -p $(@D)
  81. @echo Compiling Code $<
  82. $(eval BAFLAG = $(shell echo "$<" | sed -n 's/.*\.ba\([0-9]\+\).*/\-Wf-ba\1/p'))
  83. @$(LCC) $(LCCFLAGS) $(BAFLAG) -c -o $@ $<
  84. $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c $(SPRITES)
  85. @mkdir -p $(@D)
  86. @echo Compiling Asset $<
  87. @$(LCC) $(LCCFLAGS) -c -o $@ $<
  88. $(BUILD_DIR)/%.o: %.s $(SPRITES)
  89. @mkdir -p $(@D)
  90. @echo Assembling $<
  91. @$(LCC) $(LCCFLAGS) -c -o $@ $<
  92. $(BUILD_DIR)/$(BIN): $(OBJS)
  93. @echo Linking $@
  94. @$(LCC) $(LCCFLAGS) -o $@ $(OBJS)
  95. $(BIN): $(BUILD_DIR)/$(BIN)
  96. @cp $< $@
  97. @make usage
  98. clean:
  99. rm -rf $(BUILD_DIR) $(BIN)