GameBoy (Color) port of the GTA San Andreas arcade game Duality
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Adapted from GBDK-2020 examples
  2. ifndef GBDK_HOME
  3. GBDK_HOME = ../../../
  4. endif
  5. BIN := duality.gb
  6. SRC_DIR := src
  7. BUILD_DIR := build
  8. DATA_DIR := data
  9. SRCS := $(wildcard $(SRC_DIR)/*.c)
  10. OBJS := $(SRCS:%.c=$(BUILD_DIR)/%.o)
  11. ASSETS := $(wildcard $(DATA_DIR)/*.png)
  12. SPRITES := $(ASSETS:%.png=$(BUILD_DIR)/%.c)
  13. OBJS += $(SPRITES:%.c=%.o)
  14. LCC := $(GBDK_HOME)/bin/lcc
  15. PNGA := $(GBDK_HOME)/bin/png2asset
  16. GB_EMU := gearboy
  17. LCCFLAGS := -Wa-l -Wl-m -Wm"-yn Duality" -I$(BUILD_DIR)/$(DATA_DIR)
  18. EMUFLAGS := $(BIN)
  19. ifndef GBDK_RELEASE
  20. LCCFLAGS += -debug -Wa-j -Wa-y -Wa-s -Wl-j -Wl-y -Wl-u -Wm-yS
  21. EMUFLAGS += $(BUILD_DIR)/$(BIN:.gb=.sym)
  22. BUILD_TYPE = Debug
  23. else
  24. BUILD_TYPE = Release
  25. endif
  26. $(info BUILD_TYPE is $(BUILD_TYPE))
  27. .PHONY: all run $(BIN) clean compile_commands.json
  28. all: $(BIN)
  29. compile_commands.json:
  30. @echo "Cleaning old build"
  31. @make clean
  32. @echo "Preparing bear.cfg"
  33. @echo '{"compilation":{"compilers_to_recognize":[{"executable":"$(GBDK_HOME)/bin/sdcc","flags_to_add":[""],"flags_to_remove":[""]}]}}' > bear.cfg
  34. @echo "Running full build within bear"
  35. @bear --config bear.cfg -- make -j4
  36. @rm -rf bear.cfg
  37. run: $(BIN)
  38. @echo Emulating $<
  39. @$(GB_EMU) $(EMUFLAGS)
  40. .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
  41. $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h: $(DATA_DIR)/%.png
  42. @mkdir -p $(@D)
  43. $(if $(findstring _map,$<), \
  44. @echo "Converting map $<" && \
  45. $(PNGA) $< -o $@ -spr8x8 -map \
  46. , \
  47. @echo "Converting tile $<" && \
  48. $(PNGA) $< -o $@ -spr8x8 \
  49. )
  50. $(BUILD_DIR)/%.o: %.c
  51. @mkdir -p $(@D)
  52. @echo Compiling $<
  53. @$(LCC) $(LCCFLAGS) -c -o $@ $<
  54. $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
  55. @mkdir -p $(@D)
  56. @echo Compiling $<
  57. @$(LCC) $(LCCFLAGS) -c -o $@ $<
  58. $(BUILD_DIR)/%.o: %.s
  59. @mkdir -p $(@D)
  60. @echo Assembling $<
  61. @$(LCC) $(LCCFLAGS) -c -o $@ $<
  62. $(BUILD_DIR)/$(BIN): $(OBJS)
  63. @echo Linking $@
  64. @$(LCC) $(LCCFLAGS) -o $@ $(OBJS)
  65. $(BIN): $(BUILD_DIR)/$(BIN)
  66. @cp $< $@
  67. clean:
  68. rm -rf $(BUILD_DIR) $(BIN)