Няма описание

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