Advertisement
Guest User

Untitled

a guest
Jun 10th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 8.58 KB | None | 0 0
  1. #---------------------------------------------------------------------------------
  2. .SUFFIXES:
  3. #---------------------------------------------------------------------------------
  4.  
  5. ifeq ($(strip $(DEVKITPRO)),)
  6. $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
  7. endif
  8.  
  9. TOPDIR ?= $(CURDIR)
  10. include $(DEVKITPRO)/libnx/switch_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. # EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm".
  19. # ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
  20. #
  21. # NO_ICON: if set to anything, do not use icon.
  22. # NO_NACP: if set to anything, no .nacp file is generated.
  23. # APP_TITLE is the name of the app stored in the .nacp file (Optional)
  24. # APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
  25. # APP_VERSION is the version of the app stored in the .nacp file (Optional)
  26. # APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
  27. # ICON is the filename of the icon (.jpg), relative to the project folder.
  28. #   If not set, it attempts to use one of the following (in this order):
  29. #     - <Project name>.jpg
  30. #     - icon.jpg
  31. #     - <libnx folder>/default_icon.jpg
  32. #---------------------------------------------------------------------------------
  33. APP_AUTHOR  :=  romain337 / !!M
  34. APP_TITLE   :=  Fake 1
  35. TARGET      :=  $(notdir $(CURDIR))
  36. DATA        :=  data
  37. EXEFS_SRC   :=  exefs_src
  38. SWITCH_IP   :=  192.168.1.18
  39. #ROMFS  :=  romfs
  40. BUILD       :=  build
  41. INCLUDES    :=  include
  42. SOURCES     :=  source \
  43.                 source/shader \
  44.                 source/screen \
  45.                 source/audio
  46.  
  47. #---------------------------------------------------------------------------------
  48. # options for code generation
  49. #---------------------------------------------------------------------------------
  50. ARCH    :=  -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
  51.  
  52. CFLAGS  :=  -g -Wall -Wno-unknown-pragmas -O2 -ffunction-sections \
  53.             $(ARCH) $(DEFINES)
  54.  
  55. # The following line works around an issue in newlib that produces a compilation
  56. # error in glm. It will be removed as soon as this issue is resolved.
  57. CFLAGS  +=  -D_GLIBCXX_USE_C99_MATH_TR1 -D_LDBL_EQ_DBL -DGLM_FORCE_PURE
  58.  
  59. CFLAGS  +=  $(INCLUDE) ${DEBUGFLAG} -D__SWITCH__ -DSTBI_ONLY_PNG -DSTB_IMAGE_IMPLEMENTATION \
  60.             -DIMGUI_IMPL_OPENGL_LOADER_GLAD -DIMGUI_INCLUDE_IMGUI_USER_H
  61.  
  62. CXXFLAGS    := $(CFLAGS) -fno-rtti -fno-exceptions
  63.  
  64. ASFLAGS :=  -g $(ARCH)
  65. LDFLAGS =   -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
  66.  
  67. LIBS    := -lglad -lEGL -lglapi -ldrm_nouveau -lnotswitchd -ljansson -lmikmod -lnx
  68.  
  69. #---------------------------------------------------------------------------------
  70. # list of directories containing libraries, this must be the top level containing
  71. # include and lib
  72. #---------------------------------------------------------------------------------
  73. LIBDIRS := $(PORTLIBS) $(LIBNX)
  74.  
  75.  
  76. #---------------------------------------------------------------------------------
  77. # no real need to edit anything past this point unless you need to add additional
  78. # rules for different file extensions
  79. #---------------------------------------------------------------------------------
  80. ifneq ($(BUILD),$(notdir $(CURDIR)))
  81. #---------------------------------------------------------------------------------
  82.  
  83. export OUTPUT   :=  $(CURDIR)/$(TARGET)
  84. export TOPDIR   :=  $(CURDIR)
  85.  
  86. export VPATH    :=  $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  87.             $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  88.  
  89. export DEPSDIR  :=  $(CURDIR)/$(BUILD)
  90.  
  91. CFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  92. CPPFILES    :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  93. SFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  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. export OFILES_BIN   :=  $(addsuffix .o,$(BINFILES))
  111. export OFILES_SRC   :=  $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
  112. export OFILES   :=  $(OFILES_BIN) $(OFILES_SRC)
  113. export HFILES_BIN   :=  $(addsuffix .h,$(subst .,_,$(BINFILES)))
  114.  
  115. export INCLUDE  :=  $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
  116.             $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  117.             -I$(CURDIR)/$(BUILD)
  118.  
  119. export LIBPATHS :=  $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
  120.  
  121. export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
  122.  
  123. ifeq ($(strip $(ICON)),)
  124.     icons := $(wildcard *.jpg)
  125.     ifneq (,$(findstring $(TARGET).jpg,$(icons)))
  126.         export APP_ICON := $(TOPDIR)/$(TARGET).jpg
  127.     else
  128.         ifneq (,$(findstring icon.jpg,$(icons)))
  129.             export APP_ICON := $(TOPDIR)/icon.jpg
  130.         endif
  131.     endif
  132. else
  133.     export APP_ICON := $(TOPDIR)/$(ICON)
  134. endif
  135.  
  136. ifeq ($(strip $(NO_ICON)),)
  137.     export NROFLAGS += --icon=$(APP_ICON)
  138. endif
  139.  
  140. ifeq ($(strip $(NO_NACP)),)
  141.     export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
  142. endif
  143.  
  144. ifneq ($(APP_TITLEID),)
  145.     export NACPFLAGS += --titleid=$(APP_TITLEID)
  146. endif
  147.  
  148. ifneq ($(ROMFS),)
  149.     export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
  150. endif
  151.  
  152. .PHONY: $(BUILD) clean all
  153.  
  154. #---------------------------------------------------------------------------------
  155. all: $(BUILD)
  156.  
  157. $(BUILD):
  158.     @[ -d $@ ] || mkdir -p $@
  159.     @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
  160.  
  161. #---------------------------------------------------------------------------------
  162. clean:
  163.     @echo clean ...
  164.     @rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
  165.  
  166. #---------------------------------------------------------------------------------
  167. run:
  168.     @echo run ...
  169.     @nxlink --address $(SWITCH_IP) $(TARGET).nro
  170.  
  171. #---------------------------------------------------------------------------------
  172. else
  173. .PHONY: all
  174.  
  175. DEPENDS :=  $(OFILES:.o=.d)
  176.  
  177. #---------------------------------------------------------------------------------
  178. # main targets
  179. #---------------------------------------------------------------------------------
  180. all :   $(OUTPUT).pfs0 $(OUTPUT).nro
  181.  
  182. $(OUTPUT).pfs0  :   $(OUTPUT).nso
  183.  
  184. $(OUTPUT).nso   :   $(OUTPUT).elf
  185.  
  186. ifeq ($(strip $(NO_NACP)),)
  187. $(OUTPUT).nro   :   $(OUTPUT).elf $(OUTPUT).nacp
  188. else
  189. $(OUTPUT).nro   :   $(OUTPUT).elf
  190. endif
  191.  
  192. $(OUTPUT).elf   :   $(OFILES)
  193.  
  194. $(OFILES_SRC)   : $(HFILES_BIN)
  195.  
  196. #---------------------------------------------------------------------------------
  197. # you need a rule like this for each extension you use as binary data
  198. #---------------------------------------------------------------------------------
  199. %.bin.o %_bin.h :   %.bin
  200. #---------------------------------------------------------------------------------
  201.     @echo $(notdir $<)
  202.     @$(bin2o)
  203. #---------------------------------------------------------------------------------
  204. %.png.o %_png.h :   %.png
  205. #---------------------------------------------------------------------------------
  206.     @echo $(notdir $<)
  207.     @$(bin2o)
  208. #---------------------------------------------------------------------------------
  209. %.json.o %_json.h : %.json
  210. #---------------------------------------------------------------------------------
  211.     @echo $(notdir $<)
  212.     @$(bin2o)
  213. #---------------------------------------------------------------------------------
  214. %.xm.o %_xm.h : %.xm
  215. #---------------------------------------------------------------------------------
  216.     @echo $(notdir $<)
  217.     @$(bin2o)
  218. #---------------------------------------------------------------------------------
  219. %.mod.o %_mod.h :   %.mod
  220. #---------------------------------------------------------------------------------
  221.     @echo $(notdir $<)
  222.     @$(bin2o)
  223.  
  224. -include $(DEPENDS)
  225.  
  226. #---------------------------------------------------------------------------------------
  227. endif
  228. #---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement