Advertisement
Guest User

Untitled

a guest
Sep 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 7.50 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. TARGET      :=  $(notdir $(CURDIR))
  34. BUILD       :=  build
  35. SOURCES     :=  engine/common engine/common/imagelib engine/common/soundlib engine/common/soundlib/libmpg engine/client engine/client/vgui engine/server engine/platform/switch engine/platform/sdl
  36. DATA        :=  data
  37. INCLUDES    :=  include engine engine/platform/sdl engine/common engine/common/imagelib engine/common/soundlib engine/common/stb common engine/server engine/client engine/client/vgui pm_shared
  38. EXEFS_SRC   :=  exefs_src
  39. #ROMFS  :=  romfs
  40.  
  41. #---------------------------------------------------------------------------------
  42. # options for code generation
  43. #---------------------------------------------------------------------------------
  44. ARCH    :=  -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
  45.  
  46. CFLAGS  :=  -g -Wall -O2 -ffunction-sections  \
  47.             $(ARCH) $(DEFINES)
  48.  
  49. CFLAGS  +=  $(INCLUDE) -D__SWITCH__ -DXASH_SDL -DXASH_DLL_LOADER -DSINGLE_BINARY -DXASHSDL_MAIN -DXASH_NO_ASYNC_NS_RESOLVE
  50.  
  51. CXXFLAGS    := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 -static-libstdc++ -static-libgcc
  52.  
  53. ASFLAGS :=  -g $(ARCH)
  54. LDFLAGS =   -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
  55.  
  56. LIBS    := -lnx -lm -lSDL2 -lmpg123 -lglad -lEGL -lglapi -ldrm_nouveau
  57.  
  58. #---------------------------------------------------------------------------------
  59. # list of directories containing libraries, this must be the top level containing
  60. # include and lib
  61. #---------------------------------------------------------------------------------
  62. LIBDIRS := $(PORTLIBS) $(LIBNX)
  63.  
  64.  
  65. #---------------------------------------------------------------------------------
  66. # no real need to edit anything past this point unless you need to add additional
  67. # rules for different file extensions
  68. #---------------------------------------------------------------------------------
  69. ifneq ($(BUILD),$(notdir $(CURDIR)))
  70. #---------------------------------------------------------------------------------
  71.  
  72. export OUTPUT   :=  $(CURDIR)/$(TARGET)
  73. export TOPDIR   :=  $(CURDIR)
  74.  
  75. export VPATH    :=  $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  76.             $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  77.  
  78. export DEPSDIR  :=  $(CURDIR)/$(BUILD)
  79.  
  80. CFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  81. CPPFILES    :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  82. SFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  83. BINFILES    :=  $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  84.  
  85. #---------------------------------------------------------------------------------
  86. # use CXX for linking C++ projects, CC for standard C
  87. #---------------------------------------------------------------------------------
  88. ifeq ($(strip $(CPPFILES)),)
  89. #---------------------------------------------------------------------------------
  90.     export LD   :=  $(CC)
  91. #---------------------------------------------------------------------------------
  92. else
  93. #---------------------------------------------------------------------------------
  94.     export LD   :=  $(CXX)
  95. #---------------------------------------------------------------------------------
  96. endif
  97. #---------------------------------------------------------------------------------
  98.  
  99. export OFILES_BIN   :=  $(addsuffix .o,$(BINFILES))
  100. export OFILES_SRC   :=  $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
  101. export OFILES   :=  $(OFILES_BIN) $(OFILES_SRC)
  102. export HFILES_BIN   :=  $(addsuffix .h,$(subst .,_,$(BINFILES)))
  103.  
  104. export INCLUDE  :=  $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
  105.             $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  106.             -I$(CURDIR)/$(BUILD)
  107.  
  108. export LIBPATHS :=  $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
  109.  
  110. export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
  111.  
  112. ifeq ($(strip $(ICON)),)
  113.     icons := $(wildcard *.jpg)
  114.     ifneq (,$(findstring $(TARGET).jpg,$(icons)))
  115.         export APP_ICON := $(TOPDIR)/$(TARGET).jpg
  116.     else
  117.         ifneq (,$(findstring icon.jpg,$(icons)))
  118.             export APP_ICON := $(TOPDIR)/icon.jpg
  119.         endif
  120.     endif
  121. else
  122.     export APP_ICON := $(TOPDIR)/$(ICON)
  123. endif
  124.  
  125. ifeq ($(strip $(NO_ICON)),)
  126.     export NROFLAGS += --icon=$(APP_ICON)
  127. endif
  128.  
  129. ifeq ($(strip $(NO_NACP)),)
  130.     export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
  131. endif
  132.  
  133. ifneq ($(APP_TITLEID),)
  134.     export NACPFLAGS += --titleid=$(APP_TITLEID)
  135. endif
  136.  
  137. ifneq ($(ROMFS),)
  138.     export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
  139. endif
  140.  
  141. .PHONY: $(BUILD) clean all
  142.  
  143. #---------------------------------------------------------------------------------
  144. all: $(BUILD)
  145.  
  146. $(BUILD):
  147.     @[ -d $@ ] || mkdir -p $@
  148.     @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
  149.  
  150. #---------------------------------------------------------------------------------
  151. clean:
  152.     @echo clean ...
  153.     @rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
  154.  
  155.  
  156. #---------------------------------------------------------------------------------
  157. else
  158. .PHONY: all
  159.  
  160. DEPENDS :=  $(OFILES:.o=.d)
  161.  
  162. #---------------------------------------------------------------------------------
  163. # main targets
  164. #---------------------------------------------------------------------------------
  165. all :   $(OUTPUT).pfs0 $(OUTPUT).nro
  166.  
  167. $(OUTPUT).pfs0  :   $(OUTPUT).nso
  168.  
  169. $(OUTPUT).nso   :   $(OUTPUT).elf
  170.  
  171. ifeq ($(strip $(NO_NACP)),)
  172. $(OUTPUT).nro   :   $(OUTPUT).elf $(OUTPUT).nacp
  173. else
  174. $(OUTPUT).nro   :   $(OUTPUT).elf
  175. endif
  176.  
  177. $(OUTPUT).elf   :   $(OFILES)
  178.  
  179. $(OFILES_SRC)   : $(HFILES_BIN)
  180.  
  181. #---------------------------------------------------------------------------------
  182. # you need a rule like this for each extension you use as binary data
  183. #---------------------------------------------------------------------------------
  184. %.bin.o %_bin.h :   %.bin
  185. #---------------------------------------------------------------------------------
  186.     @echo $(notdir $<)
  187.     @$(bin2o)
  188.  
  189. -include $(DEPENDS)
  190.  
  191. #---------------------------------------------------------------------------------------
  192. endif
  193. #---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement