Advertisement
Guest User

Untitled

a guest
Jun 10th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 5.49 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. include $(DEVKITPRO)/libnx/switch_rules
  10.  
  11. #---------------------------------------------------------------------------------
  12. # TARGET is the name of the output
  13. # SOURCES is a list of directories containing source code
  14. # DATA is a list of directories containing data files
  15. # INCLUDES is a list of directories containing header files
  16. #---------------------------------------------------------------------------------
  17. TARGET      :=  $(notdir $(CURDIR))
  18. SOURCES     :=  source source/app source/gl source/imgui source/2d
  19. DATA        :=  data
  20. INCLUDES    :=  include
  21.  
  22. #---------------------------------------------------------------------------------
  23. # options for code generation
  24. #---------------------------------------------------------------------------------
  25. ARCH    :=  -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
  26.  
  27. CFLAGS  :=  -g -Wall -Werror \
  28.             -ffunction-sections \
  29.             -fdata-sections \
  30.             -Wno-unknown-pragmas \
  31.             $(ARCH) \
  32.             $(BUILD_CFLAGS)
  33.  
  34. CFLAGS  +=  $(INCLUDE) $(DEBUGFLAG) -D__SWITCH__ -DIMGUI_IMPL_OPENGL_LOADER_GLAD -DIMGUI_INCLUDE_IMGUI_USER_H \
  35.             -D_GLIBCXX_USE_C99_MATH_TR1 -D_LDBL_EQ_DBL -DGLM_FORCE_PURE
  36.  
  37. CXXFLAGS    := $(CFLAGS) -fno-rtti -fno-exceptions
  38.  
  39. ASFLAGS :=  -g $(ARCH)
  40.  
  41. #---------------------------------------------------------------------------------
  42. # list of directories containing libraries, this must be the top level containing
  43. # include and lib
  44. #---------------------------------------------------------------------------------
  45. LIBDIRS := $(PORTLIBS) $(LIBNX)
  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 VPATH    :=  $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
  55.             $(foreach dir,$(DATA),$(CURDIR)/$(dir))
  56.  
  57. CFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
  58. CPPFILES    :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
  59. SFILES      :=  $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
  60. BINFILES    :=  $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
  61.  
  62. #---------------------------------------------------------------------------------
  63. # use CXX for linking C++ projects, CC for standard C
  64. #---------------------------------------------------------------------------------
  65. ifeq ($(strip $(CPPFILES)),)
  66. #---------------------------------------------------------------------------------
  67.     export LD   :=  $(CC)
  68. #---------------------------------------------------------------------------------
  69. else
  70. #---------------------------------------------------------------------------------
  71.     export LD   :=  $(CXX)
  72. #---------------------------------------------------------------------------------
  73. endif
  74. #---------------------------------------------------------------------------------
  75.  
  76. export OFILES_BIN   :=  $(addsuffix .o,$(BINFILES))
  77. export OFILES_SRC   :=  $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
  78. export OFILES   :=  $(OFILES_BIN) $(OFILES_SRC)
  79. export HFILES   :=  $(addsuffix .h,$(subst .,_,$(BINFILES)))
  80.  
  81. export INCLUDE  :=  $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
  82.             $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
  83.             -I$(CURDIR)/$(BUILD)
  84.  
  85. .PHONY: clean all
  86.  
  87. #---------------------------------------------------------------------------------
  88. all: lib/lib$(TARGET).a lib/lib$(TARGET)d.a
  89.  
  90. lib:
  91.     @[ -d $@ ] || mkdir -p $@
  92.  
  93. release:
  94.     @[ -d $@ ] || mkdir -p $@
  95.  
  96. debug:
  97.     @[ -d $@ ] || mkdir -p $@
  98.  
  99. lib/lib$(TARGET).a : lib release $(SOURCES) $(INCLUDES)
  100.     @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
  101.     BUILD_CFLAGS="-DNDEBUG=1 -O2" \
  102.     DEPSDIR=$(CURDIR)/release \
  103.     --no-print-directory -C release \
  104.     -f $(CURDIR)/Makefile
  105.  
  106. lib/lib$(TARGET)d.a : lib debug $(SOURCES) $(INCLUDES)
  107.     @$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
  108.     BUILD_CFLAGS="-DDEBUG=1 -Og" \
  109.     DEPSDIR=$(CURDIR)/debug \
  110.     --no-print-directory -C debug \
  111.     -f $(CURDIR)/Makefile
  112.  
  113. dist-bin: all
  114.     @tar --exclude=*~ -cjf lib$(TARGET).tar.bz2 include lib
  115.  
  116. dist-src:
  117.     @tar --exclude=*~ -cjf lib$(TARGET)-src.tar.bz2 include source Makefile
  118.  
  119. dist: dist-src dist-bin
  120.  
  121. #---------------------------------------------------------------------------------
  122. clean:
  123.     @echo clean ...
  124.     @rm -fr release debug lib *.bz2
  125.  
  126. #---------------------------------------------------------------------------------
  127. else
  128.  
  129. DEPENDS :=  $(OFILES:.o=.d)
  130.  
  131. #---------------------------------------------------------------------------------
  132. # main targets
  133. #---------------------------------------------------------------------------------
  134. $(OUTPUT)   :   $(OFILES)
  135.  
  136. $(OFILES_SRC)   : $(HFILES)
  137.  
  138. #---------------------------------------------------------------------------------
  139. %_bin.h %.bin.o :   %.bin
  140. #---------------------------------------------------------------------------------
  141.     @echo $(notdir $<)
  142.     @$(bin2o)
  143.  
  144.  
  145. -include $(DEPENDS)
  146.  
  147. #---------------------------------------------------------------------------------------
  148. endif
  149. #---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement