Chip 8 emulator made using gint
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

195 lines
4.6 KiB

  1. #! /usr/bin/make -f
  2. # Default Makefile for fxSDK add-ins. This file was probably copied there by
  3. # the [fxsdk] program.
  4. #---
  5. #
  6. # Configuration
  7. #
  8. include project.cfg
  9. # Compiler flags
  10. CFLAGSFX := $(CFLAGS) $(CFLAGS_FX) $(INCLUDE)
  11. CFLAGSCG := $(CFLAGS) $(CFLAGS_CG) $(INCLUDE)
  12. # Linker flags
  13. LDFLAGSFX := $(LDFLAGS) $(LDFLAGS_FX)
  14. LDFLAGSCG := $(LDFLAGS) $(LDFLAGS_CG)
  15. # Dependency list generation flags
  16. depflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
  17. # ELF to binary flags
  18. BINFLAGS := -R .bss -R .gint_bss
  19. # G1A and G3A generation flags
  20. NAME_G1A ?= $(NAME)
  21. NAME_G3A ?= $(NAME)
  22. G1AF := -i "$(ICON_FX)" -n "$(NAME_G1A)" --internal="$(INTERNAL)"
  23. G3AF := -n basic:"$(NAME_G3A)" -i uns:"$(ICON_CG_UNS)" -i sel:"$(ICON_CG_SEL)"
  24. ifeq "$(TOOLCHAIN_FX)" ""
  25. TOOLCHAIN_FX := sh3eb-elf
  26. endif
  27. ifeq "$(TOOLCHAIN_CG)" ""
  28. TOOLCHAIN_CG := sh4eb-elf
  29. endif
  30. # fxconv flags
  31. FXCONVFX := --fx --toolchain=$(TOOLCHAIN_FX)
  32. FXCONVCG := --cg --toolchain=$(TOOLCHAIN_CG)
  33. #
  34. # File listings
  35. #
  36. NULL :=
  37. TARGET := $(subst $(NULL) $(NULL),-,$(NAME))
  38. ifeq "$(TARGET_FX)" ""
  39. TARGET_FX := $(TARGET).g1a
  40. endif
  41. ifeq "$(TARGET_CG)" ""
  42. TARGET_CG := $(TARGET).g3a
  43. endif
  44. ELF_FX := build-fx/$(shell basename -s .g1a $(TARGET_FX)).elf
  45. BIN_FX := $(ELF_FX:.elf=.bin)
  46. ELF_CG := build-cg/$(shell basename -s .g3a $(TARGET_CG)).elf
  47. BIN_CG := $(ELF_CG:.elf=.bin)
  48. # Source files
  49. src := $(wildcard src/*.[csS] \
  50. src/*/*.[csS] \
  51. src/*/*/*.[csS] \
  52. src/*/*/*/*.[csS])
  53. assets-fx := $(wildcard assets-fx/*/*)
  54. assets-cg := $(wildcard assets-cg/*/*)
  55. # Object files
  56. obj-fx := $(src:%=build-fx/%.o) \
  57. $(assets-fx:assets-fx/%=build-fx/assets/%.o)
  58. obj-cg := $(src:%=build-cg/%.o) \
  59. $(assets-cg:assets-cg/%=build-cg/assets/%.o)
  60. # Additional dependencies
  61. deps-fx := $(ICON_FX)
  62. deps-cg := $(ICON_CG_UNS) $(ICON_CG_SEL)
  63. # All targets
  64. all :=
  65. ifneq "$(wildcard build-fx)" ""
  66. all += all-fx
  67. endif
  68. ifneq "$(wildcard build-cg)" ""
  69. all += all-cg
  70. endif
  71. #
  72. # Build rules
  73. #
  74. all: $(all)
  75. all-fx: $(TARGET_FX)
  76. all-cg: $(TARGET_CG)
  77. $(TARGET_FX): $(obj-fx) $(deps-fx)
  78. @ mkdir -p $(dir $@)
  79. $(TOOLCHAIN_FX)-gcc -o $(ELF_FX) $(obj-fx) $(CFLAGSFX) $(LDFLAGSFX)
  80. $(TOOLCHAIN_FX)-objcopy -O binary $(BINFLAGS) $(ELF_FX) $(BIN_FX)
  81. fxg1a $(BIN_FX) -o $@ $(G1AF)
  82. $(TARGET_CG): $(obj-cg) $(deps-cg)
  83. @ mkdir -p $(dir $@)
  84. $(TOOLCHAIN_CG)-gcc -o $(ELF_CG) $(obj-cg) $(CFLAGSCG) $(LDFLAGSCG)
  85. $(TOOLCHAIN_CG)-objcopy -O binary $(BINFLAGS) $(ELF_CG) $(BIN_CG)
  86. mkg3a $(G3AF) $(BIN_CG) $@
  87. # C sources
  88. build-fx/%.c.o: %.c
  89. @ mkdir -p $(dir $@)
  90. $(TOOLCHAIN_FX)-gcc -c $< -o $@ $(CFLAGSFX) $(depflags)
  91. build-cg/%.c.o: %.c
  92. @ mkdir -p $(dir $@)
  93. $(TOOLCHAIN_CG)-gcc -c $< -o $@ $(CFLAGSCG) $(depflags)
  94. # Assembler sources
  95. build-fx/%.s.o: %.s
  96. @ mkdir -p $(dir $@)
  97. $(TOOLCHAIN_FX)-gcc -c $< -o $@
  98. build-cg/%.s.o: %.s
  99. @ mkdir -p $(dir $@)
  100. $(TOOLCHAIN_CG)-gcc -c $< -o $@
  101. # Preprocessed assembler sources
  102. build-fx/%.S.o: %.S
  103. @ mkdir -p $(dir $@)
  104. $(TOOLCHAIN_FX)-gcc -c $< -o $@ $(INCLUDE)
  105. build-cg/%.S.o: %.S
  106. @ mkdir -p $(dir $@)
  107. $(TOOLCHAIN_CG)-gcc -c $< -o $@ $(INCLUDE)
  108. # Images
  109. build-fx/assets/img/%.o: assets-fx/img/%
  110. @ mkdir -p $(dir $@)
  111. fxconv -i $< -o $@ $(FXCONVFX) name:img_$(basename $*) $(IMG.$*)
  112. build-cg/assets/img/%.o: assets-cg/img/%
  113. @ mkdir -p $(dir $@)
  114. fxconv -i $< -o $@ $(FXCONVCG) name:img_$(basename $*) $(IMG.$*)
  115. # Fonts
  116. build-fx/assets/fonts/%.o: assets-fx/fonts/%
  117. @ mkdir -p $(dir $@)
  118. fxconv -f $< -o $@ $(FXCONVFX) name:font_$(basename $*) $(FONT.$*)
  119. build-cg/assets/fonts/%.o: assets-cg/fonts/%
  120. @ mkdir -p $(dir $@)
  121. fxconv -f $< -o $@ $(FXCONVCG) name:font_$(basename $*) $(FONT.$*)
  122. # Binaries
  123. build-fx/assets/bin/%.o: assets-fx/bin/%
  124. @ mkdir -p $(dir $@)
  125. fxconv -b $< -o $@ $(FXCONVFX) name:bin_$(basename $*) $(BIN.$*)
  126. build-cg/assets/bin/%.o: assets-cg/bin/%
  127. @ mkdir -p $(dir $@)
  128. fxconv -b $< -o $@ $(FXCONVCG) name:bin_$(basename $*) $(BIN.$*)
  129. #
  130. # Cleaning and utilities
  131. #
  132. # Dependency information
  133. -include $(shell find build* -name *.d 2> /dev/null)
  134. build-fx/%.d: ;
  135. build-cg/%.d: ;
  136. .PRECIOUS: build-fx build-cg build-fx/%.d build-cg/%.d %/
  137. clean-fx:
  138. @ rm -rf build-fx/
  139. clean-cg:
  140. @ rm -rf build-cg/
  141. distclean-fx: clean-fx
  142. @ rm -f $(TARGET_FX)
  143. distclean-cg: clean-cg
  144. @ rm -f $(TARGET_CG)
  145. clean: clean-fx clean-cg
  146. distclean: distclean-fx distclean-cg
  147. install-fx: $(TARGET_FX)
  148. p7 send -f $<
  149. install-cg: $(TARGET_CG)
  150. @ while [[ ! -h /dev/Prizm1 ]]; do sleep 0.25; done
  151. @ while ! mount /dev/Prizm1; do sleep 0.25; done
  152. @ rm -f /mnt/prizm/$<
  153. @ cp $< /mnt/prizm
  154. @ umount /dev/Prizm1
  155. @- eject /dev/Prizm1
  156. .PHONY: all all-fx all-cg clean distclean install-fx install-cg