mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-18 05:33:05 +00:00
87ec045a98
This was tested using `https://github.com/node-dot-cpp/alloc-test` plus a few other by-hand tests. It seems to work for the case we care about (sysmodules without thread cache-ing). External users are advised to build with assertions on and contact SciresM if you find issues. This is a lot of code to have gotten right in one go, and it was written mostly after midnight while sick, so there are probably un-noticed issues.
142 lines
6.3 KiB
Makefile
142 lines
6.3 KiB
Makefile
#---------------------------------------------------------------------------------
|
|
# pull in common atmosphere configuration
|
|
#---------------------------------------------------------------------------------
|
|
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../config/common.mk
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# pull in switch rules
|
|
#---------------------------------------------------------------------------------
|
|
ifeq ($(strip $(DEVKITPRO)),)
|
|
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
|
|
endif
|
|
|
|
include $(DEVKITPRO)/libnx/switch_rules
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# options for code generation
|
|
#---------------------------------------------------------------------------------
|
|
DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_STRATOSPHERE -D_GNU_SOURCE
|
|
SETTINGS := $(ATMOSPHERE_SETTINGS) -O2
|
|
CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE)
|
|
CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -flto
|
|
ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS)
|
|
|
|
LDFLAGS := -specs=$(DEVKITPRO)/libnx/switch.specs $(SETTINGS) -Wl,-Map,$(notdir $*.map)
|
|
|
|
SOURCES += $(call ALL_SOURCE_DIRS,../libvapours/source)
|
|
|
|
LIBS := -lnx
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# list of directories containing libraries, this must be the top level containing
|
|
# include and lib
|
|
#---------------------------------------------------------------------------------
|
|
LIBDIRS := $(PORTLIBS) $(LIBNX) $(ATMOSPHERE_LIBRARIES_DIR)/libvapours
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# 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),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \
|
|
$(notdir $(wildcard $(dir)/*.c))))
|
|
CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c)))
|
|
CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c)))
|
|
CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c)))
|
|
|
|
CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \
|
|
$(notdir $(wildcard $(dir)/*.cpp))))
|
|
CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp)))
|
|
CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp)))
|
|
CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp)))
|
|
|
|
SFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \
|
|
$(notdir $(wildcard $(dir)/*.s))))
|
|
SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s)))
|
|
SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s)))
|
|
SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s)))
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# 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_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
|
|
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
-I.
|
|
|
|
.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)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
%_bin.h %.bin.o : %.bin
|
|
#---------------------------------------------------------------------------------
|
|
@echo $(notdir $<)
|
|
@$(bin2o)
|
|
|
|
|
|
-include $(DEPENDS)
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
endif
|
|
#---------------------------------------------------------------------------------------
|
|
|