説明なし

makefile 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. AS := @arm-none-eabi-as
  2. LD := @arm-none-eabi-ld
  3. OBJCOPY := @arm-none-eabi-objcopy
  4. GRIT := @grit
  5. CC := @arm-none-eabi-gcc
  6. ARS := @armips
  7. MAKE := make
  8. NM := @arm-none-eabi-nm
  9. PREPROC := @preproc
  10. VBA := vba
  11. LAN := de
  12. STRAGB := string2agb
  13. export PATH := $(realpath ../tools):$(PATH)
  14. PAGB_MAIN := g3headers
  15. PAGB_INCLUDE := $(PAGB_MAIN)/build/include/
  16. PAGB_LINK := $(PAGB_MAIN)/build/linker/BPRE.ld
  17. AUTO_ASSET_ROOT := sots-private/assets/images
  18. CHARMAP := charmap.txt
  19. DEFINES := -DBPRE -DSOFTWARE_VERSION=0
  20. ASFLAGS := -mthumb
  21. CFLAGS := -mthumb -mthumb-interwork -g -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -Og -std=c11 -Wall -Wextra -Wunreachable-code -I$(PAGB_INCLUDE) -Isrc/include -fdiagnostics-color $(DEFINES)
  22. GRITFLAGS := -ftc -fa
  23. LDFLAGS := -z muldefs
  24. BLDPATH := object
  25. OUTPATH := build
  26. SOURCEDIR := src
  27. STRINGDIR := string
  28. MAIN_OBJ := $(BLDPATH)/linked.o
  29. B_ENGINE := battle_engine/build/linked.o
  30. SPRITES := $(BLDPATH)/pkmn_sprites.o
  31. ICONS_AR := $(BLDPATH)/pkmn_icons.a
  32. DYN_OVER := built/dynamic_overworld.o
  33. SND_ROOT := sots-private/sound
  34. MUSIC_AR := $(SND_ROOT)/Music/music.a
  35. SMPL_AR := $(SND_ROOT)/Samples/sample.a
  36. VOICE_AR := $(SND_ROOT)/Voicegroup/voice.a
  37. LIST_AR := $(SND_ROOT)/Songtable/songlist.a
  38. CRY_AR := $(SND_ROOT)/Crys/cry.a
  39. rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
  40. IMAGES=$(call rwildcard,$(AUTO_ASSET_ROOT),*.png)
  41. GEN_SRC := $(IMAGES:$(AUTO_ASSET_ROOT)/%.png=generated_image/%.c)
  42. ASM_SRC := $(call rwildcard,src/,*.s)
  43. C_SRC := $(call rwildcard,src/,*.c)
  44. DATA_SRC := $(call rwildcard,data/,*.s)
  45. STRING := $(call rwildcard,string/$(LAN)/,*.txt)
  46. STRING_SRC := $(STRING:%.txt=%.s)
  47. GEN_OBJ := $(GEN_SRC:%.c=$(BLDPATH)/%.o)
  48. STRING_OBJ := $(STRING_SRC:%.s=$(BLDPATH)/%.o)
  49. ASM_OBJ := $(ASM_SRC:%.s=$(BLDPATH)/%.o)
  50. C_OBJ := $(C_SRC:%.c=$(BLDPATH)/%.o)
  51. DATA_OBJ := $(DATA_SRC:%.s=$(BLDPATH)/%.o)
  52. ALL_OBJ := $(C_OBJ) $(ASM_OBJ) $(DATA_OBJ) $(GEN_OBJ) $(STRING_OBJ)
  53. .PRECIOUS: $(STRING_SRC)
  54. $(STRINGDIR)/%.s: $(STRINGDIR)/%.txt
  55. $(STRAGB) -o $@ -i $< -t string/table.tbl -e 0xFF
  56. $(BLDPATH)/%.o: %.c $(ASSETS)
  57. @echo -e "\e[32mCompiling $<\e[0m"
  58. $(shell mkdir -p $(dir $@))
  59. $(CC) $(CFLAGS) -c $< -o $@
  60. $(BLDPATH)/%.o: %.s
  61. @echo -e "\e[32mAssembling $<\e[0m"
  62. $(shell mkdir -p $(dir $@))
  63. $(PREPROC) $< $(CHARMAP) > $*.i
  64. $(CC) $(CFLAGS) -c -x assembler-with-cpp $*.i -o $@
  65. @rm -f $*.i
  66. generated_image/%.c: $(AUTO_ASSET_ROOT)/%.png $(AUTO_ASSET_ROOT)/%.grit
  67. @echo -e "\e[34mProcessing image $<\e[0m"
  68. $(shell mkdir -p $(dir $@))
  69. $(GRIT) $< -o $@ -ftc -ff $(<:%.png=%.grit)
  70. generated_image/%.c: $(AUTO_ASSET_ROOT)/%.png
  71. @echo -e "\e[34mProcessing image $< (using directory grit file)\e[0m"
  72. $(shell mkdir -p $(dir $@))
  73. $(GRIT) $< -o $@ -ftc -ff $(<D)/$(notdir $(<D)).grit
  74. all: rom
  75. .PHONY: rom
  76. rom: main.asm $(MAIN_OBJ)
  77. $(ARS) $<
  78. $(NM) $(BLDPATH)/linked.o -n -g --defined-only | \
  79. sed -e '{s/^/0x/g};{/.*\sA\s.*/d};{s/\sT\s/ /g}' > $(OUTPATH)/__symbols.sym
  80. @echo "*** SUCCESSFULLY BUILT PROJECT ***"
  81. $(MAIN_OBJ): $(ALL_OBJ) $(ICONS_AR) $(SPRITES) $(MUSIC_AR) $(SMPL_AR) $(VOICE_AR) $(LIST_AR) $(CRY_AR) $()#$(B_ENGINE)
  82. $(MAKE) -f assets.makefile
  83. $(LD) $(LDFLAGS) -T $(PAGB_LINK) -T linker.ld -T bpre.sym --whole-archive -r -o $@ --start-group $^ --end-group
  84. .PHONY: $(B_ENGINE)
  85. $(B_ENGINE):
  86. $(MAKE) -C battle_engine build/linked.o
  87. .PHONY: clean
  88. clean:
  89. rm -f $(OUTPATH)/__symbols.sym $(OUTPATH)/pkmn_sots.gba
  90. rm -R -f object/*
  91. $(MAKE) -C $(dir $(MUSIC_AR)) clean
  92. $(MAKE) -C $(dir $(SMPL_AR)) clean
  93. $(MAKE) -C $(dir $(VOICE_AR)) clean
  94. $(MAKE) -C $(dir $(LIST_AR)) clean
  95. $(MAKE) -C $(dir $(CRY_AR)) clean
  96. $(MAKE) -f sprites.makefile clean
  97. $(MAKE) -f icons.makefile clean
  98. .PHONY: $(ASSETS)
  99. $(ASSETS):
  100. $(MAKE) -f assets.makefile
  101. .PHONY: $(SPRITES)
  102. $(SPRITES):
  103. $(MAKE) -f sprites.makefile
  104. .PHONY: $(ICONS_AR)
  105. $(ICONS_AR):
  106. $(MAKE) -f icons.makefile
  107. .PHONY: $(MUSIC_AR)
  108. $(MUSIC_AR):
  109. $(MAKE) -C $(dir $@) all
  110. .PHONY: $(SMPL_AR)
  111. $(SMPL_AR):
  112. $(MAKE) -C $(dir $@) all
  113. .PHONY: $(VOICE_AR)
  114. $(VOICE_AR):
  115. $(MAKE) -C $(dir $@) all
  116. .PHONY: $(LIST_AR)
  117. $(LIST_AR):
  118. $(MAKE) -C $(dir $@) all
  119. .PHONY: $(CRY_AR)
  120. $(CRY_AR):
  121. $(MAKE) -C $(dir $@) all
  122. run: rom
  123. $(VBA) "build/pkmn_sots.gba"