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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. ROMU := $(GBDK_HOME)/bin/romusage
  17. GB_EMU := gearboy
  18. LCCFLAGS := -Wa-l -Wl-m -Wm"-yn Duality" -I$(BUILD_DIR)/$(DATA_DIR) -Wm-yc
  19. EMUFLAGS := $(BIN)
  20. ifndef GBDK_RELEASE
  21. LCCFLAGS += -debug -DDEBUG -Wa-j -Wa-y -Wa-s -Wl-j -Wl-y -Wl-u -Wm-yS
  22. EMUFLAGS += $(BUILD_DIR)/$(BIN:.gb=.sym)
  23. BUILD_TYPE = Debug
  24. else
  25. BUILD_TYPE = Release
  26. endif
  27. $(info BUILD_TYPE is $(BUILD_TYPE))
  28. .PHONY: all run $(BIN) clean compile_commands.json usage
  29. all: $(BIN)
  30. compile_commands.json:
  31. @echo "Cleaning old build"
  32. @make clean
  33. @echo "Preparing bear.cfg"
  34. @echo '{"compilation":{"compilers_to_recognize":[{"executable":"$(GBDK_HOME)/bin/sdcc","flags_to_add":[""],"flags_to_remove":[""]}]}}' > bear.cfg
  35. @echo "Running full build within bear"
  36. @bear --config bear.cfg -- make -j4
  37. @rm -rf bear.cfg
  38. usage: $(BUILD_DIR)/$(BIN)
  39. @echo Analyzing $<
  40. @$(ROMU) $(BUILD_DIR)/$(BIN:%.gb=%.map)
  41. run: $(BIN)
  42. @echo Emulating $<
  43. @$(GB_EMU) $(EMUFLAGS)
  44. .PRECIOUS: $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h
  45. $(BUILD_DIR)/$(DATA_DIR)/%.c $(BUILD_DIR)/$(DATA_DIR)/%.h: $(DATA_DIR)/%.png
  46. @mkdir -p $(@D)
  47. $(if $(findstring _map,$<), \
  48. @echo "Converting map $<" && \
  49. $(PNGA) $< -o $@ -spr8x8 -map -use_map_attributes -noflip \
  50. , \
  51. @echo "Converting tile $<" && \
  52. $(PNGA) $< -o $@ -spr8x8 \
  53. )
  54. $(BUILD_DIR)/%.o: %.c $(SPRITES)
  55. @mkdir -p $(@D)
  56. @echo Compiling $<
  57. @$(LCC) $(LCCFLAGS) -c -o $@ $<
  58. $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c
  59. @mkdir -p $(@D)
  60. @echo Compiling $<
  61. @$(LCC) $(LCCFLAGS) -c -o $@ $<
  62. $(BUILD_DIR)/%.o: %.s
  63. @mkdir -p $(@D)
  64. @echo Assembling $<
  65. @$(LCC) $(LCCFLAGS) -c -o $@ $<
  66. $(BUILD_DIR)/$(BIN): $(OBJS)
  67. @echo Linking $@
  68. @$(LCC) $(LCCFLAGS) -o $@ $(OBJS)
  69. $(BIN): $(BUILD_DIR)/$(BIN) usage
  70. @cp $< $@
  71. clean:
  72. rm -rf $(BUILD_DIR) $(BIN)