Advertisement
Guest User

Untitled

a guest
Jul 12th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.09 KB | None | 0 0
  1. #---------------------------------------------------------------------------------
  2. .SUFFIXES:
  3. #---------------------------------------------------------------------------------
  4.  
  5. ifeq ($(strip $(DEVKITARM)),)
  6. $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
  7. endif
  8.  
  9. TOPDIR ?= $(CURDIR)
  10. include $(DEVKITARM)/3ds_rules
  11.  
  12. #---------------------------------------------------------------------------------
  13. # TARGET is the name of the output
  14. # BUILD is the directory where object files & intermediate files will be placed
  15. # SOURCES is a list of directories containing source code
  16. # DATA is a list of directories containing data files
  17. # INCLUDES is a list of directories containing header files
  18. # GRAPHICS is a list of directories containing graphics files
  19. # GFXBUILD is the directory where converted graphics files will be placed
  20. # If set to $(BUILD), it will statically link in the converted
  21. # files as if they were data files.
  22. #
  23. # NO_SMDH: if set to anything, no SMDH file is generated.
  24. # ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
  25. # APP_TITLE is the name of the app stored in the SMDH file (Optional)
  26. # APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
  27. # APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
  28. # ICON is the filename of the icon (.png), relative to the project folder.
  29. # If not set, it attempts to use one of the following (in this order):
  30. # - <Project name>.png
  31. # - icon.png
  32. # - <libctru folder>/default_icon.png
  33. #---------------------------------------------------------------------------------
  34. TARGET := $(notdir $(CURDIR))
  35. BUILD := build
  36. SOURCES := source
  37. DATA := data
  38. INCLUDES := include
  39. GRAPHICS := gfx
  40. GFXBUILD := $(BUILD)
  41. APP_TITLE := ROMFree3DS
  42. APP_DESCRIPTION := Alternative FreeShop (ported from original PC tool)
  43. APP_AUTHOR := Dontwait00, Kiron
  44. #ROMFS := romfs
  45. #GFXBUILD := $(ROMFS)/gfx
  46.  
  47. #---------------------------------------------------------------------------------
  48. # options for code generation
  49. #---------------------------------------------------------------------------------
  50. ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
  51.  
  52. CFLAGS := -g -Wall -O2 -mword-relocations \
  53. -fomit-frame-pointer -ffunction-sections \
  54. $(ARCH)
  55.  
  56. CFLAGS += $(INCLUDE) -DARM11 -D_3DS
  57.  
  58. CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
  59.  
  60. ASFLAGS := -g $(ARCH)
  61. LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
  62.  
  63. LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lz -lctru -lm
  64.  
  65. #---------------------------------------------------------------------------------
  66. # list of directories containing libraries, this must be the top level containing
  67. # include and lib
  68. #---------------------------------------------------------------------------------
  69. LIBDIRS := $(CTRULIB) $(PORTLIBS)
  70.  
  71.  
  72. #---------------------------------------------------------------------------------
  73. # no real need to edit anything past this point unless you need to add additional
  74. # rules for different file extensions
  75. #---------------------------------------------------------------------------------
  76. ifneq ($(BUILD),$(notdir $(CURDIR)))
  77. #---------------------------------------------------------------------------------
  78.  
  79. export OUTPUT := $(CURDIR)/$(TARGET)
  80. export TOPDIR := $(CURDIR)
  81.  
  82. export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  83. $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
  84. $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  85.  
  86. export DEPSDIR := $(CURDIR)/$(BUILD)
  87.  
  88. CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  89. CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  90. SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  91. PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
  92. SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
  93. GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
  94. BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  95.  
  96. #---------------------------------------------------------------------------------
  97. # use CXX for linking C++ projects, CC for standard C
  98. #---------------------------------------------------------------------------------
  99. ifeq ($(strip $(CPPFILES)),)
  100. #---------------------------------------------------------------------------------
  101. export LD := $(CC)
  102. #---------------------------------------------------------------------------------
  103. else
  104. #---------------------------------------------------------------------------------
  105. export LD := $(CXX)
  106. #---------------------------------------------------------------------------------
  107. endif
  108. #---------------------------------------------------------------------------------
  109.  
  110. #---------------------------------------------------------------------------------
  111. ifeq ($(GFXBUILD),$(BUILD))
  112. #---------------------------------------------------------------------------------
  113. export T3XFILES := $(GFXFILES:.t3s=.t3x)
  114. #---------------------------------------------------------------------------------
  115. else
  116. #---------------------------------------------------------------------------------
  117. export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
  118. export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
  119. #---------------------------------------------------------------------------------
  120. endif
  121. #---------------------------------------------------------------------------------
  122.  
  123. export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
  124.  
  125. export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
  126. $(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
  127. $(addsuffix .o,$(T3XFILES))
  128.  
  129. export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
  130.  
  131. export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
  132. $(addsuffix .h,$(subst .,_,$(BINFILES))) \
  133. $(GFXFILES:.t3s=.h)
  134.  
  135. export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
  136. $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  137. -I$(CURDIR)/$(BUILD)
  138.  
  139. export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
  140.  
  141. export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
  142.  
  143. ifeq ($(strip $(ICON)),)
  144. icons := $(wildcard *.png)
  145. ifneq (,$(findstring $(TARGET).png,$(icons)))
  146. export APP_ICON := $(TOPDIR)/$(TARGET).png
  147. else
  148. ifneq (,$(findstring icon.png,$(icons)))
  149. export APP_ICON := $(TOPDIR)/icon.png
  150. endif
  151. endif
  152. else
  153. export APP_ICON := $(TOPDIR)/$(ICON)
  154. endif
  155.  
  156. ifeq ($(strip $(NO_SMDH)),)
  157. export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
  158. endif
  159.  
  160. ifneq ($(ROMFS),)
  161. export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
  162. endif
  163.  
  164. .PHONY: all clean
  165.  
  166. #---------------------------------------------------------------------------------
  167. all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
  168. @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
  169.  
  170. $(BUILD):
  171. @mkdir -p $@
  172.  
  173. ifneq ($(GFXBUILD),$(BUILD))
  174. $(GFXBUILD):
  175. @mkdir -p $@
  176. endif
  177.  
  178. ifneq ($(DEPSDIR),$(BUILD))
  179. $(DEPSDIR):
  180. @mkdir -p $@
  181. endif
  182.  
  183. #---------------------------------------------------------------------------------
  184. clean:
  185. @echo clean ...
  186. @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf $(GFXBUILD)
  187.  
  188. #---------------------------------------------------------------------------------
  189. $(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
  190. #---------------------------------------------------------------------------------
  191. @echo $(notdir $<)
  192. @tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
  193.  
  194. #---------------------------------------------------------------------------------
  195. else
  196.  
  197. #---------------------------------------------------------------------------------
  198. # main targets
  199. #---------------------------------------------------------------------------------
  200. $(OUTPUT).3dsx : $(OUTPUT).elf $(_3DSXDEPS)
  201.  
  202. $(OFILES_SOURCES) : $(HFILES)
  203.  
  204. $(OUTPUT).elf : $(OFILES)
  205.  
  206. #---------------------------------------------------------------------------------
  207. # you need a rule like this for each extension you use as binary data
  208. #---------------------------------------------------------------------------------
  209. %.bin.o %_bin.h : %.bin
  210. #---------------------------------------------------------------------------------
  211. @echo $(notdir $<)
  212. @$(bin2o)
  213.  
  214. #---------------------------------------------------------------------------------
  215. .PRECIOUS : %.t3x
  216. #---------------------------------------------------------------------------------
  217. %.t3x.o %_t3x.h : %.t3x
  218. #---------------------------------------------------------------------------------
  219. @echo $(notdir $<)
  220. @$(bin2o)
  221.  
  222. #---------------------------------------------------------------------------------
  223. # rules for assembling GPU shaders
  224. #---------------------------------------------------------------------------------
  225. define shader-as
  226. $(eval CURBIN := $*.shbin)
  227. $(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
  228. echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
  229. echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
  230. echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
  231. echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
  232. picasso -o $(CURBIN) $1
  233. bin2s $(CURBIN) | $(AS) -o $*.shbin.o
  234. endef
  235.  
  236. %.shbin.o %_shbin.h : %.v.pica %.g.pica
  237. @echo $(notdir $^)
  238. @$(call shader-as,$^)
  239.  
  240. %.shbin.o %_shbin.h : %.v.pica
  241. @echo $(notdir $<)
  242. @$(call shader-as,$<)
  243.  
  244. %.shbin.o %_shbin.h : %.shlist
  245. @echo $(notdir $<)
  246. @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
  247.  
  248. #---------------------------------------------------------------------------------
  249. %.t3x %.h : %.t3s
  250. #---------------------------------------------------------------------------------
  251. @echo $(notdir $<)
  252. @tex3ds -i $< -H $*.h -d $*.d -o $*.t3x
  253.  
  254. -include $(DEPSDIR)/*.d
  255.  
  256. #---------------------------------------------------------------------------------------
  257. endif
  258. #---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement