説明なし

makefile 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. VBA := vba
  10. LAN := de
  11. STRAGB := string2agb
  12. export PATH := $(realpath ../tools):$(PATH)
  13. DEFINES := -DBPRE -DSOFTWARE_VERSION=0
  14. ASFLAGS := -mthumb
  15. CFLAGS := -mthumb -mthumb-interwork -g -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -O3 -std=c99 -Wall -Wextra -Wunreachable-code -Isrc/include $(DEFINES)
  16. GRITFLAGS := -ftc -fa
  17. LDFLAGS := -z muldefs
  18. BLDPATH := object
  19. OUTPATH := build
  20. SOURCEDIR := src
  21. STRINGDIR := string
  22. MAIN_OBJ := $(BLDPATH)/linked.o
  23. SPRITES := $(BLDPATH)/pkmn_sprites.o
  24. ICONS_AR := $(BLDPATH)/pkmn_icons.a
  25. DYN_OVER := built/dynamic_overworld.o
  26. SND_ROOT := sots-private/sound
  27. MUSIC_AR := $(SND_ROOT)/Music/music.a
  28. SMPL_AR := $(SND_ROOT)/Samples/sample.a
  29. VOICE_AR := $(SND_ROOT)/Voicegroup/voice.a
  30. LIST_AR := $(SND_ROOT)/Songtable/songlist.a
  31. CRY_AR := $(SND_ROOT)/Crys/cry.a
  32. rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
  33. ASM_SRC_PP := $(call rwildcard,src/,*.S)
  34. ASM_SRC := $(call rwildcard,src/,*.s)
  35. C_SRC := $(call rwildcard,src/,*.c)
  36. DATA_SRC_PP := $(call rwildcard,data/,*.S)
  37. DATA_SRC := $(call rwildcard,data/,*.s)
  38. STRING := $(call rwildcard,string/$(LAN)/,*.txt)
  39. STRING_SRC := $(STRING:%.txt=%.S)
  40. STRING_OBJ := $(STRING_SRC:%.S=$(BLDPATH)/%.o)
  41. ASM_OBJ_PP := $(ASM_SRC_PP:%.S=$(BLDPATH)/%.o)
  42. ASM_OBJ := $(ASM_SRC:%.s=$(BLDPATH)/%.o)
  43. C_OBJ := $(C_SRC:%.c=$(BLDPATH)/%.o)
  44. DATA_OBJ_PP := $(DATA_SRC_PP:%.S=$(BLDPATH)/%.o)
  45. DATA_OBJ := $(DATA_SRC:%.s=$(BLDPATH)/%.o)
  46. ALL_OBJ := $(C_OBJ) $(ASM_OBJ_PP) $(ASM_OBJ) $(DATA_OBJ_PP) $(DATA_OBJ)
  47. .PRECIOUS: $(STRING_SRC)
  48. $(STRINGDIR)/%.S: $(STRINGDIR)/%.txt
  49. $(STRAGB) -o $@ -i $< -t string/table.tbl -e 0xFF
  50. $(BLDPATH)/%.o: %.c $(ASSETS)
  51. $(shell mkdir -p $(dir $@))
  52. $(CC) $(CFLAGS) -c $< -o $@
  53. $(BLDPATH)/%.o: %.S
  54. $(shell mkdir -p $(dir $@))
  55. $(CC) $(CFLAGS) -c $< -o $@
  56. $(BLDPATH)/%.o: %.s
  57. $(shell mkdir -p $(dir $@))
  58. $(AS) $(ASFLAGS) $< -o $@
  59. all: rom
  60. .PHONY: rom
  61. rom: main.asm $(MAIN_OBJ)
  62. $(ARS) $<
  63. $(NM) $(BLDPATH)/linked.o -n -g --defined-only | \
  64. sed -e '{s/^/0x/g};{/.*\sA\s.*/d};{s/\sT\s/ /g}' > $(OUTPATH)/__symbols.sym
  65. @echo "*** SUCCESSFULLY BUILT PROJECT ***"
  66. $(MAIN_OBJ): $(ALL_OBJ) $(ICONS_AR) $(SPRITES) $(MUSIC_AR) $(SMPL_AR) $(VOICE_AR) $(LIST_AR) $(CRY_AR) $(STRING_OBJ) $(DYN_OVER)
  67. $(MAKE) -f assets.makefile
  68. $(LD) $(LDFLAGS) -T linker.ld -T bpre.sym --whole-archive -r -o $@ --start-group $^ --end-group
  69. $(LD) $(LDFLAGS) -T linker.ld -T bpre.sym -o object/debug.o object/linked.o
  70. .PHONY: clean
  71. clean:
  72. rm -f $(OUTPATH)/__symbols.sym $(OUTPATH)/pkmn_sots.gba
  73. rm -R -f object/*
  74. $(MAKE) -C $(dir $(MUSIC_AR)) clean
  75. $(MAKE) -C $(dir $(SMPL_AR)) clean
  76. $(MAKE) -C $(dir $(VOICE_AR)) clean
  77. $(MAKE) -C $(dir $(LIST_AR)) clean
  78. $(MAKE) -C $(dir $(CRY_AR)) clean
  79. $(MAKE) -f sprites.makefile clean
  80. $(MAKE) -f icons.makefile clean
  81. .PHONY: $(ASSETS)
  82. $(ASSETS):
  83. $(MAKE) -f assets.makefile
  84. .PHONY: $(SPRITES)
  85. $(SPRITES):
  86. $(MAKE) -f sprites.makefile
  87. .PHONY: $(ICONS_AR)
  88. $(ICONS_AR):
  89. $(MAKE) -f icons.makefile
  90. .PHONY: $(MUSIC_AR)
  91. $(MUSIC_AR):
  92. $(MAKE) -C $(dir $@) all
  93. .PHONY: $(SMPL_AR)
  94. $(SMPL_AR):
  95. $(MAKE) -C $(dir $@) all
  96. .PHONY: $(VOICE_AR)
  97. $(VOICE_AR):
  98. $(MAKE) -C $(dir $@) all
  99. .PHONY: $(LIST_AR)
  100. $(LIST_AR):
  101. $(MAKE) -C $(dir $@) all
  102. .PHONY: $(CRY_AR)
  103. $(CRY_AR):
  104. $(MAKE) -C $(dir $@) all
  105. run: rom
  106. $(VBA) "build/pkmn_sots.gba"