Geen omschrijving

makefile 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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_PP := $(call rwildcard,src/,*.S)
  40. ASM_SRC := $(call rwildcard,src/,*.s)
  41. C_SRC := $(call rwildcard,src/,*.c)
  42. DATA_SRC_PP := $(call rwildcard,data/,*.S)
  43. DATA_SRC := $(call rwildcard,data/,*.s)
  44. STRING := $(call rwildcard,string/$(LAN)/,*.txt)
  45. C_STRING := $(call rwildcard,string/$(LAN)/,*.c)
  46. STRING_SRC := $(STRING:%.txt=%.S)
  47. I_STRING := $(C_STRING:$.c=%.i)
  48. C_STR_OBJ := $(I_STRING:%.i=$(BLDPATH)/%.o)
  49. STRING_OBJ := $(STRING_SRC:%.S=$(BLDPATH)/%.o)
  50. ASM_OBJ_PP := $(ASM_SRC_PP:%.S=$(BLDPATH)/%.o)
  51. ASM_OBJ := $(ASM_SRC:%.s=$(BLDPATH)/%.o)
  52. C_OBJ := $(C_SRC:%.c=$(BLDPATH)/%.o)
  53. DATA_OBJ_PP := $(DATA_SRC_PP:%.S=$(BLDPATH)/%.o)
  54. DATA_OBJ := $(DATA_SRC:%.s=$(BLDPATH)/%.o)
  55. ALL_OBJ := $(C_OBJ) $(ASM_OBJ_PP) $(ASM_OBJ) $(DATA_OBJ_PP) $(DATA_OBJ)
  56. .PRECIOUS: $(STRING_SRC)
  57. $(STRINGDIR)/%.S: $(STRINGDIR)/%.txt
  58. $(STRAGB) -o $@ -i $< -t string/table.tbl -e 0xFF
  59. $(BLDPATH)/%.o: %.c $(ASSETS)
  60. $(shell mkdir -p $(dir $@))
  61. $(CC) $(CFLAGS) -c $< -o $@
  62. $(BLDPATH)/%.o: %.S
  63. $(shell mkdir -p $(dir $@))
  64. $(CC) $(CFLAGS) -c $< -o $@
  65. $(BLDPATH)/%.o: %.s
  66. $(shell mkdir -p $(dir $@))
  67. $(PREPROC) $< $(CHARMAP) > $*.i
  68. $(CC) $(CFLAGS) -c -x assembler-with-cpp $*.i -o $@
  69. $(OBJCOPY) -O binary $@ $@.bin
  70. all: rom
  71. .PHONY: rom
  72. rom: main.asm $(MAIN_OBJ)
  73. $(ARS) $<
  74. $(NM) $(BLDPATH)/linked.o -n -g --defined-only | \
  75. sed -e '{s/^/0x/g};{/.*\sA\s.*/d};{s/\sT\s/ /g}' > $(OUTPATH)/__symbols.sym
  76. @echo "*** SUCCESSFULLY BUILT PROJECT ***"
  77. $(MAIN_OBJ): $(ALL_OBJ) $(ICONS_AR) $(SPRITES) $(MUSIC_AR) $(SMPL_AR) $(VOICE_AR) $(LIST_AR) $(CRY_AR) $(STRING_OBJ)#$(B_ENGINE)
  78. $(MAKE) -f assets.makefile
  79. $(LD) $(LDFLAGS) -T $(PAGB_LINK) -T linker.ld -T bpre.sym --whole-archive -r -o $@ --start-group $^ --end-group
  80. .PHONY: $(B_ENGINE)
  81. $(B_ENGINE):
  82. $(MAKE) -C battle_engine build/linked.o
  83. .PHONY: clean
  84. clean:
  85. rm -f $(OUTPATH)/__symbols.sym $(OUTPATH)/pkmn_sots.gba
  86. rm -R -f object/*
  87. $(MAKE) -C $(dir $(MUSIC_AR)) clean
  88. $(MAKE) -C $(dir $(SMPL_AR)) clean
  89. $(MAKE) -C $(dir $(VOICE_AR)) clean
  90. $(MAKE) -C $(dir $(LIST_AR)) clean
  91. $(MAKE) -C $(dir $(CRY_AR)) clean
  92. $(MAKE) -f sprites.makefile clean
  93. $(MAKE) -f icons.makefile clean
  94. .PHONY: $(ASSETS)
  95. $(ASSETS):
  96. $(MAKE) -f assets.makefile
  97. .PHONY: $(SPRITES)
  98. $(SPRITES):
  99. $(MAKE) -f sprites.makefile
  100. .PHONY: $(ICONS_AR)
  101. $(ICONS_AR):
  102. $(MAKE) -f icons.makefile
  103. .PHONY: $(MUSIC_AR)
  104. $(MUSIC_AR):
  105. $(MAKE) -C $(dir $@) all
  106. .PHONY: $(SMPL_AR)
  107. $(SMPL_AR):
  108. $(MAKE) -C $(dir $@) all
  109. .PHONY: $(VOICE_AR)
  110. $(VOICE_AR):
  111. $(MAKE) -C $(dir $@) all
  112. .PHONY: $(LIST_AR)
  113. $(LIST_AR):
  114. $(MAKE) -C $(dir $@) all
  115. .PHONY: $(CRY_AR)
  116. $(CRY_AR):
  117. $(MAKE) -C $(dir $@) all
  118. run: rom
  119. $(VBA) "build/pkmn_sots.gba"