Nessuna descrizione

makefile 3.7KB

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