Nav apraksta

makefile 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 := -mthumb -mthumb-interwork -g -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -O3 -std=c99 -Wall -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. .PRECIOUS: $(STRING_SRC)
  47. $(STRINGDIR)/%.S: $(STRINGDIR)/%.txt
  48. $(STRAGB) -o $@ -i $< -t string/table.tbl -e 0xFF
  49. $(BLDPATH)/%.o: %.c $(ASSETS)
  50. $(shell mkdir -p $(dir $@))
  51. $(CC) $(CFLAGS) -c $< -o $@
  52. $(BLDPATH)/%.o: %.S
  53. $(shell mkdir -p $(dir $@))
  54. $(CC) $(CFLAGS) -c $< -o $@
  55. $(BLDPATH)/%.o: %.s
  56. $(shell mkdir -p $(dir $@))
  57. $(AS) $(ASFLAGS) $< -o $@
  58. all: rom
  59. .PHONY: rom
  60. rom: main.asm $(MAIN_OBJ)
  61. $(ARS) $<
  62. $(NM) $(BLDPATH)/linked.o -n -g --defined-only | \
  63. sed -e '{s/^/0x/g};{/.*\sA\s.*/d};{s/\sT\s/ /g}' > $(OUTPATH)/__symbols.sym
  64. @echo "*** SUCCESSFULLY BUILT PROJECT ***"
  65. $(MAIN_OBJ): $(ALL_OBJ) $(ICONS_AR) $(SPRITES) $(DYN_OVER) $(MUSIC_AR) $(SMPL_AR) $(VOICE_AR) $(LIST_AR) $(CRY_AR) $(STRING_OBJ)
  66. $(MAKE) -f assets.makefile
  67. $(LD) $(LDFLAGS) -T linker.ld -T bpre.sym --whole-archive -r -o $@ --start-group $^ --end-group
  68. $(LD) $(LDFLAGS) -T linker.ld -T bpre.sym -o object/debug.o object/linked.o
  69. .PHONY: clean
  70. clean:
  71. rm -R -f build/*
  72. rm -R -f object/*
  73. $(MAKE) -C $(dir $(MUSIC_AR)) clean
  74. $(MAKE) -C $(dir $(SMPL_AR)) clean
  75. $(MAKE) -C $(dir $(VOICE_AR)) clean
  76. $(MAKE) -C $(dir $(LIST_AR)) clean
  77. $(MAKE) -C $(dir $(CRY_AR)) clean
  78. $(MAKE) -f sprites.makefile clean
  79. $(MAKE) -f icons.makefile clean
  80. .PHONY: $(ASSETS)
  81. $(ASSETS):
  82. $(MAKE) -f assets.makefile
  83. .PHONY: $(SPRITES)
  84. $(SPRITES):
  85. $(MAKE) -f sprites.makefile
  86. .PHONY: $(ICONS_AR)
  87. $(ICONS_AR):
  88. $(MAKE) -f icons.makefile
  89. .PHONY: $(MUSIC_AR)
  90. $(MUSIC_AR):
  91. $(MAKE) -C $(dir $@) all
  92. .PHONY: $(SMPL_AR)
  93. $(SMPL_AR):
  94. $(MAKE) -C $(dir $@) all
  95. .PHONY: $(VOICE_AR)
  96. $(VOICE_AR):
  97. $(MAKE) -C $(dir $@) all
  98. .PHONY: $(LIST_AR)
  99. $(LIST_AR):
  100. $(MAKE) -C $(dir $@) all
  101. .PHONY: $(CRY_AR)
  102. $(CRY_AR):
  103. $(MAKE) -C $(dir $@) all