SHARE
TWEET

Untitled

a guest Aug 15th, 2018 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. #
  20. # NO_ICON: if set to anything, do not use icon.
  21. # NO_NACP: if set to anything, no .nacp file is generated.
  22. # APP_TITLE is the name of the app stored in the .nacp file (Optional)
  23. # APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
  24. # APP_VERSION is the version of the app stored in the .nacp file (Optional)
  25. # APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
  26. # ICON is the filename of the icon (.jpg), relative to the project folder.
  27. #   If not set, it attempts to use one of the following (in this order):
  28. #     - <Project name>.jpg
  29. #     - icon.jpgK
  30. #     - <libnx folder>/default_icon.jpg
  31. #---------------------------------------------------------------------------------
  32. TARGET      :=  paint
  33. BUILD       :=  build
  34. SOURCES     :=  .
  35. INCLUDES    :=  .
  36. #DATA       :=  data
  37. EXEFS_SRC   :=  exefs_src
  38.  
  39. APP_TITLE   := Paint
  40. APP_AUTHOR  := 730
  41. APP_VERSION     := 1.0
  42. #ICON       := res/icon.jpg
  43. #APP_TITLEID := is the titleID of the app stored in the .nacp file (Optional)
  44.  
  45. #---------------------------------------------------------------------------------
  46. # options for code generation
  47. #---------------------------------------------------------------------------------
  48. ARCH    :=  -march=armv8-a -mtp=soft -fPIE
  49.  
  50. CFLAGS  :=  -g -Wall -O2 \
  51.             -ffast-math \
  52.             $(ARCH) $(DEFINES)
  53.  
  54. CFLAGS  +=  $(INCLUDE) -DSWITCH -D__LIBNX__ -DNOSTYLUS -DUSE_FILE32API -DNOCURL
  55.  
  56.  
  57. CXXFLAGS    := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
  58.  
  59. ASFLAGS :=  -g $(ARCH)
  60. LDFLAGS =   -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
  61.  
  62. LIBS    :=-lSDL2 -lm -lnx
  63.  
  64. #---------------------------------------------------------------------------------
  65. # list of directories containing libraries, this must be the top level containing
  66. # include and lib
  67. #---------------------------------------------------------------------------------
  68. LIBDIRS := $(PORTLIBS) $(LIBNX)
  69.  
  70.  
  71. #---------------------------------------------------------------------------------
  72. # no real need to edit anything past this point unless you need to add additional
  73. # rules for different file extensions
  74. #---------------------------------------------------------------------------------
  75. ifneq ($(BUILD),$(notdir $(CURDIR)))
  76. #---------------------------------------------------------------------------------
  77.  
  78. export OUTPUT   :=  $(CURDIR)/$(TARGET)
  79. export TOPDIR   :=  $(CURDIR)
  80.  
  81. export VPATH    :=  $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  82.             $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  83.  
  84. export DEPSDIR  :=  $(CURDIR)/$(BUILD)
  85.  
  86. CFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  87. CPPFILES    :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  88. SFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  89. BINFILES    :=  $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  90.  
  91. #---------------------------------------------------------------------------------
  92. # use CXX for linking C++ projects, CC for standard C
  93. #---------------------------------------------------------------------------------
  94. ifeq ($(strip $(CPPFILES)),)
  95. #---------------------------------------------------------------------------------
  96.     export LD   :=  $(CC)
  97. #---------------------------------------------------------------------------------
  98. else
  99. #---------------------------------------------------------------------------------
  100.     export LD   :=  $(CXX)
  101. #---------------------------------------------------------------------------------
  102. endif
  103. #---------------------------------------------------------------------------------
  104.  
  105. export OFILES   :=  $(addsuffix .o,$(BINFILES)) \
  106.             $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
  107.  
  108. export INCLUDE  :=  $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
  109.             $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  110.             $(foreach dir,$(LIBDIRS),-I$(dir)/include/SDL) \
  111.             -I$(CURDIR)/$(BUILD)
  112.  
  113. export LIBPATHS :=  $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
  114.  
  115. export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
  116.  
  117. ifeq ($(strip $(ICON)),)
  118.     icons := $(wildcard *.jpg)
  119.     ifneq (,$(findstring $(TARGET).jpg,$(icons)))
  120.         export APP_ICON := $(TOPDIR)/$(TARGET).jpg
  121.     else
  122.         ifneq (,$(findstring icon.jpg,$(icons)))
  123.             export APP_ICON := $(TOPDIR)/icon.jpg
  124.         endif
  125.     endif
  126. else
  127.     export APP_ICON := $(TOPDIR)/$(ICON)
  128. endif
  129.  
  130. ifeq ($(strip $(NO_ICON)),)
  131.     export NROFLAGS += --icon=$(APP_ICON)
  132. endif
  133.  
  134. ifeq ($(strip $(NO_NACP)),)
  135.     export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
  136. endif
  137.  
  138. ifneq ($(APP_TITLEID),)
  139.     export NACPFLAGS += --titleid=$(APP_TITLEID)
  140. endif
  141.  
  142. .PHONY: $(BUILD) clean all
  143.  
  144. #---------------------------------------------------------------------------------
  145. all: $(BUILD)
  146.  
  147. $(BUILD):
  148.     @[ -d $@ ] || mkdir -p $@
  149.     @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.libnx
  150.  
  151. #---------------------------------------------------------------------------------
  152. clean:
  153.     @echo clean ...
  154.     @rm -fr $(BUILD) $(TARGET).pfs0 $(TARGET).nso $(TARGET).nro $(TARGET).nacp $(TARGET).elf
  155.  
  156.  
  157. #---------------------------------------------------------------------------------
  158. else
  159. .PHONY: all
  160.  
  161. DEPENDS :=  $(OFILES:.o=.d)
  162.  
  163. #---------------------------------------------------------------------------------
  164. # main targets
  165. #---------------------------------------------------------------------------------
  166. all :   $(OUTPUT).pfs0 $(OUTPUT).nro
  167.  
  168. $(OUTPUT).pfs0  :   $(OUTPUT).nso
  169.  
  170. $(OUTPUT).nso   :   $(OUTPUT).elf
  171.  
  172. ifeq ($(strip $(NO_NACP)),)
  173. $(OUTPUT).nro   :   $(OUTPUT).elf $(OUTPUT).nacp
  174. else
  175. $(OUTPUT).nro   :   $(OUTPUT).elf
  176. endif
  177.  
  178. $(OUTPUT).elf   :   $(OFILES)
  179.  
  180. #---------------------------------------------------------------------------------
  181. # you need a rule like this for each extension you use as binary data
  182. #---------------------------------------------------------------------------------
  183. %.bin.o :   %.bin
  184. #---------------------------------------------------------------------------------
  185.     @echo $(notdir $<)
  186.     @$(bin2o)
  187.  
  188. -include $(DEPENDS)
  189.  
  190. #---------------------------------------------------------------------------------------
  191. endif
  192. #---------------------------------------------------------------------------------------
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top