Guest User

Untitled

a guest
Jun 13th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.81 KB | None | 0 0
  1. ifeq ($(strip $(DEVKITPRO)),)
  2. $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
  3. endif
  4.  
  5. TOPDIR ?= $(CURDIR)
  6. $(info $(CURDIR))
  7. include $(DEVKITPRO)/libnx/switch_rules
  8.  
  9.  
  10. TARGET := bin/ASDF
  11. BUILD := buildSwitch
  12. SOURCES := source source/states
  13. DATA := data
  14. INCLUDES := include deps deps/HardwareInterface
  15. #ROMFS := romfs
  16.  
  17.  
  18. APP_TITLE := ASDF
  19. APP_AUTHOR := Klanc
  20. APP_VERSION := 1.0
  21. APP_TITLEID := 0100DEADB33FBABE
  22.  
  23. #---------------------------------------------------------------------------------
  24. # options for code generation
  25. #---------------------------------------------------------------------------------
  26. ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
  27.  
  28. CFLAGS := -g -O0 -ffunction-sections \
  29. $(ARCH) $(DEFINES)
  30.  
  31. CFLAGS += $(INCLUDE) -D__SWITCH__ `$(PORTLIBS)/bin/sdl2-config --cflags` `$(PORTLIBS)/bin/freetype-config --cflags` -Werror=return-type
  32.  
  33. CXXFLAGS := $(CFLAGS) -fno-exceptions -fno-rtti -std=c++17
  34.  
  35. ASFLAGS := -g $(ARCH)
  36. LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
  37.  
  38. LIBS := `$(PORTLIBS)/bin/sdl2-config --libs` -lSDL2_image -lSDL2_ttf -ljpeg -lpng -lwebp `$(PORTLIBS)/bin/freetype-config --libs` -lstdc++fs
  39.  
  40. #---------------------------------------------------------------------------------
  41. # list of directories containing libraries, this must be the top level containing
  42. # include and lib
  43. #---------------------------------------------------------------------------------
  44. LIBDIRS := $(PORTLIBS) $(LIBNX)
  45.  
  46.  
  47. #---------------------------------------------------------------------------------
  48. # no real need to edit anything past this point unless you need to add additional
  49. # rules for different file extensions
  50. #---------------------------------------------------------------------------------
  51. ifneq ($(BUILD),$(notdir $(CURDIR)))
  52. #---------------------------------------------------------------------------------
  53.  
  54. export OUTPUT := $(CURDIR)/$(TARGET)
  55. export TOPDIR := $(CURDIR)
  56.  
  57. export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  58. $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  59.  
  60. export DEPSDIR := $(CURDIR)/$(BUILD)
  61.  
  62. CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  63. CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  64. SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  65. BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  66.  
  67. #---------------------------------------------------------------------------------
  68. # use CXX for linking C++ projects, CC for standard C
  69. #---------------------------------------------------------------------------------
  70. ifeq ($(strip $(CPPFILES)),)
  71. #---------------------------------------------------------------------------------
  72. export LD := $(CC)
  73. #---------------------------------------------------------------------------------
  74. else
  75. #---------------------------------------------------------------------------------
  76. export LD := $(CXX)
  77. #---------------------------------------------------------------------------------
  78. endif
  79. #---------------------------------------------------------------------------------
  80.  
  81. export OFILES_BIN := $(addsuffix .o,$(BINFILES))
  82. export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
  83. export OFILES := $(OFILES_BIN) $(OFILES_SRC)
  84. export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
  85.  
  86. export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
  87. $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  88. -I$(CURDIR)/$(BUILD)
  89.  
  90. export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
  91.  
  92.  
  93. ifeq ($(strip $(ICON)),)
  94. icons := $(wildcard *.jpg)
  95. ifneq (,$(findstring $(TARGET).jpg,$(icons)))
  96. export APP_ICON := $(TOPDIR)/$(TARGET).jpg
  97. else
  98. ifneq (,$(findstring icon.jpg,$(icons)))
  99. export APP_ICON := $(TOPDIR)/icon.jpg
  100. endif
  101. endif
  102. else
  103. export APP_ICON := $(TOPDIR)/$(ICON)
  104. endif
  105.  
  106. ifeq ($(strip $(NO_ICON)),)
  107. export NROFLAGS += --icon=$(APP_ICON)
  108. endif
  109.  
  110. ifeq ($(strip $(NO_NACP)),)
  111. export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
  112. endif
  113.  
  114. ifneq ($(APP_TITLEID),)
  115. export NACPFLAGS += --titleid=$(APP_TITLEID)
  116. endif
  117.  
  118. ifneq ($(ROMFS),)
  119. export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
  120. endif
  121.  
  122. .PHONY: $(BUILD) clean all
  123.  
  124. #---------------------------------------------------------------------------------
  125. all: $(BUILD)
  126.  
  127. $(BUILD):
  128. @[ -d $@ ] || mkdir -p $@
  129. @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/switch.mk
  130.  
  131. #---------------------------------------------------------------------------------
  132. clean:
  133. @echo clean ...
  134. @rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
  135.  
  136.  
  137. #---------------------------------------------------------------------------------
  138. else
  139. .PHONY: all
  140.  
  141. DEPENDS := $(OFILES:.o=.d)
  142.  
  143. #---------------------------------------------------------------------------------
  144. # main targets
  145. #---------------------------------------------------------------------------------
  146. all : $(OUTPUT).pfs0 $(OUTPUT).nro
  147.  
  148. $(OUTPUT).pfs0 : $(OUTPUT).nso
  149.  
  150. $(OUTPUT).nso : $(OUTPUT).elf
  151.  
  152. ifeq ($(strip $(NO_NACP)),)
  153. $(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
  154. else
  155. $(OUTPUT).nro : $(OUTPUT).elf
  156. endif
  157.  
  158. $(OUTPUT).elf : $(OFILES)
  159.  
  160. $(OFILES_SRC) : $(HFILES_BIN)
  161.  
  162. #---------------------------------------------------------------------------------
  163. # you need a rule like this for each extension you use as binary data
  164. #---------------------------------------------------------------------------------
  165. %.bin.o %_bin.h : %.bin
  166. #---------------------------------------------------------------------------------
  167. @echo $(notdir $<)
  168. @$(bin2o)
  169.  
  170. -include $(DEPENDS)
  171.  
  172. #---------------------------------------------------------------------------------------
  173. endif
  174. #---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment