mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-23 10:52:13 +00:00
4059dc6187
Because I was working on multiple things at once, this commit also: - Adds wrappers for/linker flags to wrap CXX exceptions to make them abort. This saves ~0x8000 of memory in every system module. - Broadly replaces lines of the pattern if (cond) { return ResultX; } with R_UNLESS(!cond, ResultX());. - Reworks the R_TRY_CATCH macros (and the result macros in general).
142 lines
5.3 KiB
Makefile
142 lines
5.3 KiB
Makefile
#---------------------------------------------------------------------------------
|
|
.SUFFIXES:
|
|
#---------------------------------------------------------------------------------
|
|
|
|
ifeq ($(strip $(DEVKITPRO)),)
|
|
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
|
endif
|
|
|
|
TOPDIR ?= $(CURDIR)
|
|
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/ams source/result source/os source/os/impl source/dd source/sf source/sf/cmif source/sf/hipc source/dmnt source/spl source/spl/smc source/updater source/patcher source/map source/rnd source/util source/sm source/cfg source/pm source/hid source/ldr source/kvdb source/boot2
|
|
DATA := data
|
|
INCLUDES := include
|
|
|
|
DEFINES := -DRESULT_ABORT_ON_ASSERT
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# options for code generation
|
|
#---------------------------------------------------------------------------------
|
|
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
|
|
|
|
CFLAGS := -g -Wall -O2 -ffunction-sections \
|
|
$(ARCH) $(DEFINES)
|
|
|
|
CFLAGS += $(INCLUDE) -D__SWITCH__
|
|
|
|
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17
|
|
|
|
ASFLAGS := -g $(ARCH)
|
|
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
|
|
|
LIBS := -lnx
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# 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. \
|
|
-iquote $(CURDIR)/include/switch/
|
|
|
|
.PHONY: clean all
|
|
|
|
#---------------------------------------------------------------------------------
|
|
all: lib/$(TARGET).a
|
|
|
|
lib:
|
|
@[ -d $@ ] || mkdir -p $@
|
|
|
|
release:
|
|
@[ -d $@ ] || mkdir -p $@
|
|
|
|
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
|
|
|
|
dist-bin: all
|
|
@tar --exclude=*~ -cjf $(TARGET).tar.bz2 include lib
|
|
|
|
dist-src:
|
|
@tar --exclude=*~ -cjf $(TARGET)-src.tar.bz2 include source Makefile
|
|
|
|
dist: dist-src dist-bin
|
|
|
|
#---------------------------------------------------------------------------------
|
|
clean:
|
|
@echo clean ...
|
|
@rm -fr release 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
|
|
#---------------------------------------------------------------------------------------
|
|
|