説明なし

makefile 3.1KB

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