Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #---------------------------------------------------------------------------------
- .SUFFIXES:
- #---------------------------------------------------------------------------------
- ifeq ($(strip $(DEVKITPRO)),)
- $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
- endif
- include $(DEVKITPRO)/libnx/switch_rules
- #---------------------------------------------------------------------------------
- # TARGET is the name of the output
- # SOURCES is a list of directories containing source code
- # DATA is a list of directories containing data files
- # INCLUDES is a list of directories containing header files
- #---------------------------------------------------------------------------------
- TARGET := $(notdir $(CURDIR))
- SOURCES := source source/app source/gl source/imgui source/2d
- DATA := data
- INCLUDES := include
- #---------------------------------------------------------------------------------
- # options for code generation
- #---------------------------------------------------------------------------------
- ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec
- CFLAGS := -g -Wall -Werror \
- -ffunction-sections \
- -fdata-sections \
- -Wno-unknown-pragmas \
- $(ARCH) \
- $(BUILD_CFLAGS)
- CFLAGS += $(INCLUDE) $(DEBUGFLAG) -D__SWITCH__ -DIMGUI_IMPL_OPENGL_LOADER_GLAD -DIMGUI_INCLUDE_IMGUI_USER_H \
- -D_GLIBCXX_USE_C99_MATH_TR1 -D_LDBL_EQ_DBL -DGLM_FORCE_PURE
- CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
- ASFLAGS := -g $(ARCH)
- #---------------------------------------------------------------------------------
- # list of directories containing libraries, this must be the top level containing
- # include and lib
- #---------------------------------------------------------------------------------
- LIBDIRS := $(PORTLIBS) $(LIBNX)
- #---------------------------------------------------------------------------------
- # no real need to edit anything past this point unless you need to add additional
- # rules for different file extensions
- #---------------------------------------------------------------------------------
- ifneq ($(BUILD),$(notdir $(CURDIR)))
- #---------------------------------------------------------------------------------
- export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
- $(foreach dir,$(DATA),$(CURDIR)/$(dir))
- CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
- CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
- SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
- BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
- #---------------------------------------------------------------------------------
- # use CXX for linking C++ projects, CC for standard C
- #---------------------------------------------------------------------------------
- ifeq ($(strip $(CPPFILES)),)
- #---------------------------------------------------------------------------------
- export LD := $(CC)
- #---------------------------------------------------------------------------------
- else
- #---------------------------------------------------------------------------------
- export LD := $(CXX)
- #---------------------------------------------------------------------------------
- endif
- #---------------------------------------------------------------------------------
- export OFILES_BIN := $(addsuffix .o,$(BINFILES))
- export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
- export OFILES := $(OFILES_BIN) $(OFILES_SRC)
- export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES)))
- export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
- $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
- -I$(CURDIR)/$(BUILD)
- .PHONY: clean all
- #---------------------------------------------------------------------------------
- all: lib/lib$(TARGET).a lib/lib$(TARGET)d.a
- lib:
- @[ -d $@ ] || mkdir -p $@
- release:
- @[ -d $@ ] || mkdir -p $@
- debug:
- @[ -d $@ ] || mkdir -p $@
- lib/lib$(TARGET).a : lib release $(SOURCES) $(INCLUDES)
- @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
- BUILD_CFLAGS="-DNDEBUG=1 -O2" \
- DEPSDIR=$(CURDIR)/release \
- --no-print-directory -C release \
- -f $(CURDIR)/Makefile
- lib/lib$(TARGET)d.a : lib debug $(SOURCES) $(INCLUDES)
- @$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
- BUILD_CFLAGS="-DDEBUG=1 -Og" \
- DEPSDIR=$(CURDIR)/debug \
- --no-print-directory -C debug \
- -f $(CURDIR)/Makefile
- dist-bin: all
- @tar --exclude=*~ -cjf lib$(TARGET).tar.bz2 include lib
- dist-src:
- @tar --exclude=*~ -cjf lib$(TARGET)-src.tar.bz2 include source Makefile
- dist: dist-src dist-bin
- #---------------------------------------------------------------------------------
- clean:
- @echo clean ...
- @rm -fr release debug lib *.bz2
- #---------------------------------------------------------------------------------
- else
- DEPENDS := $(OFILES:.o=.d)
- #---------------------------------------------------------------------------------
- # main targets
- #---------------------------------------------------------------------------------
- $(OUTPUT) : $(OFILES)
- $(OFILES_SRC) : $(HFILES)
- #---------------------------------------------------------------------------------
- %_bin.h %.bin.o : %.bin
- #---------------------------------------------------------------------------------
- @echo $(notdir $<)
- @$(bin2o)
- -include $(DEPENDS)
- #---------------------------------------------------------------------------------------
- endif
- #---------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement