Nav apraksta

makefile 3.7KB

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