설명 없음

makefile 3.6KB

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