2019-12-12 14:29:37 +00:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# pull in common atmosphere configuration
|
|
|
|
#---------------------------------------------------------------------------------
|
2020-10-27 20:55:19 +00:00
|
|
|
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
CURRENT_DIRECTORY := $(abspath $(dir $(THIS_MAKEFILE)))
|
|
|
|
include $(CURRENT_DIRECTORY)/../config/common.mk
|
2019-12-12 14:29:37 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# options for code generation
|
|
|
|
#---------------------------------------------------------------------------------
|
2020-10-27 20:55:19 +00:00
|
|
|
PRECOMPILED_HEADERS := include/mesosphere.hpp
|
2020-02-19 09:22:51 +00:00
|
|
|
|
2019-12-12 14:29:37 +00:00
|
|
|
DEFINES := $(ATMOSPHERE_DEFINES) -DATMOSPHERE_IS_MESOSPHERE
|
2020-12-02 01:34:09 +00:00
|
|
|
SETTINGS := $(ATMOSPHERE_SETTINGS) -Os -mgeneral-regs-only -ffixed-x18 -Wextra -Werror -fno-non-call-exceptions
|
2019-12-12 14:29:37 +00:00
|
|
|
CFLAGS := $(ATMOSPHERE_CFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE)
|
2020-01-31 12:47:08 +00:00
|
|
|
CXXFLAGS := $(CFLAGS) $(ATMOSPHERE_CXXFLAGS) -fno-use-cxa-atexit -flto
|
2020-08-01 03:48:22 +01:00
|
|
|
ASFLAGS := $(ATMOSPHERE_ASFLAGS) $(SETTINGS) $(DEFINES) $(INCLUDE)
|
2019-12-12 14:29:37 +00:00
|
|
|
|
2020-12-29 20:36:26 +00:00
|
|
|
SOURCES += $(foreach v,$(call ALL_SOURCE_DIRS,../libvapours/source),$(if $(findstring ../libvapours/source/sdmmc,$v),,$v))
|
2020-02-23 14:51:32 +00:00
|
|
|
|
2019-12-12 14:29:37 +00:00
|
|
|
LIBS :=
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# list of directories containing libraries, this must be the top level containing
|
|
|
|
# include and lib
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
LIBDIRS := $(ATMOSPHERE_LIBRARIES_DIR)/libvapours
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# no real need to edit anything past this point unless you need to add additional
|
|
|
|
# rules for different file extensions
|
|
|
|
#---------------------------------------------------------------------------------
|
2020-10-27 20:55:19 +00:00
|
|
|
ifneq ($(__RECURSIVE__),1)
|
2019-12-12 14:29:37 +00:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
2020-02-19 09:22:51 +00:00
|
|
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(CURDIR)/include \
|
2019-12-12 14:29:37 +00:00
|
|
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
|
|
|
2020-08-11 19:22:56 +01:00
|
|
|
CFILES := $(call FIND_SOURCE_FILES,$(SOURCES),c)
|
|
|
|
CPPFILES := $(call FIND_SOURCE_FILES,$(SOURCES),cpp)
|
|
|
|
SFILES := $(call FIND_SOURCE_FILES,$(SOURCES),s)
|
2019-12-12 14:29:37 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# 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)
|
2020-10-27 20:55:19 +00:00
|
|
|
export GCH_DIRS := $(PRECOMPILED_HEADERS:.hpp=.hpp.gch)
|
2019-12-12 14:29:37 +00:00
|
|
|
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
2019-12-17 22:16:08 +00:00
|
|
|
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
2019-12-12 14:29:37 +00:00
|
|
|
|
|
|
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
|
|
-I.
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
2020-10-27 20:55:19 +00:00
|
|
|
ATMOSPHERE_BUILD_CONFIGS :=
|
|
|
|
all: release
|
2019-12-12 14:29:37 +00:00
|
|
|
|
2020-10-27 20:55:19 +00:00
|
|
|
define ATMOSPHERE_ADD_TARGET
|
|
|
|
|
|
|
|
ATMOSPHERE_BUILD_CONFIGS += $(strip $1)
|
|
|
|
|
|
|
|
$(strip $1): $$(ATMOSPHERE_LIBRARY_DIR)/$(strip $2)
|
|
|
|
|
|
|
|
$$(ATMOSPHERE_LIBRARY_DIR)/$(strip $2) : $$(ATMOSPHERE_LIBRARY_DIR) $$(ATMOSPHERE_BUILD_DIR)/$(strip $1) $$(SOURCES) $$(INCLUDES) $$(GCH_DIRS)
|
|
|
|
@$$(MAKE) __RECURSIVE__=1 OUTPUT=$$(CURDIR)/$$@ $(3) \
|
|
|
|
ATMOSPHERE_GCH_IDENTIFIER="$$(ATMOSPHERE_BOARD_NAME)_$$(ATMOSPHERE_ARCH_NAME)_$(strip $1)" \
|
|
|
|
DEPSDIR=$$(CURDIR)/$$(ATMOSPHERE_BUILD_DIR)/$(strip $1) \
|
|
|
|
--no-print-directory -C $$(ATMOSPHERE_BUILD_DIR)/$(strip $1) \
|
|
|
|
-f $$(THIS_MAKEFILE)
|
|
|
|
|
|
|
|
clean-$(strip $1):
|
|
|
|
@echo clean $(strip $1) ...
|
|
|
|
@rm -fr $$(ATMOSPHERE_BUILD_DIR)/$(strip $1) $$(ATMOSPHERE_LIBRARY_DIR)/$(strip $2)
|
|
|
|
@rm -fr $$(foreach hdr,$$(GCH_DIRS),$$(hdr)/$$(ATMOSPHERE_BOARD_NAME)_$$(ATMOSPHERE_ARCH_NAME)_$(strip $1))
|
|
|
|
@for i in $$(GCH_DIRS) $$(ATMOSPHERE_BUILD_DIR) $$(ATMOSPHERE_LIBRARY_DIR); do [ -d $$$$i ] && rmdir --ignore-fail-on-non-empty $$$$i || true; done
|
|
|
|
|
|
|
|
endef
|
2019-12-12 14:29:37 +00:00
|
|
|
|
2020-10-27 20:55:19 +00:00
|
|
|
$(eval $(call ATMOSPHERE_ADD_TARGET, release, $(TARGET).a, \
|
|
|
|
ATMOSPHERE_BUILD_SETTINGS="" \
|
|
|
|
))
|
2019-12-12 14:29:37 +00:00
|
|
|
|
2020-10-27 20:55:19 +00:00
|
|
|
$(eval $(call ATMOSPHERE_ADD_TARGET, debug, $(TARGET)_debug.a, \
|
|
|
|
ATMOSPHERE_BUILD_SETTINGS="-DMESOSPHERE_BUILD_FOR_DEBUGGING" \
|
|
|
|
))
|
2019-12-12 14:29:37 +00:00
|
|
|
|
2020-10-27 20:55:19 +00:00
|
|
|
$(eval $(call ATMOSPHERE_ADD_TARGET, audit, $(TARGET)_audit.a, \
|
|
|
|
ATMOSPHERE_BUILD_SETTINGS="-DMESOSPHERE_BUILD_FOR_AUDITING" \
|
|
|
|
))
|
2019-12-12 14:29:37 +00:00
|
|
|
|
2020-10-27 20:55:19 +00:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-include $(ATMOSPHERE_BOARD_NAME)_$(ATMOSPHERE_ARCH_NAME).mk
|
|
|
|
|
|
|
|
ALL_GCH_IDENTIFIERS := $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS),$(ATMOSPHERE_BOARD_NAME)_$(ATMOSPHERE_ARCH_NAME)_$(config))
|
|
|
|
ALL_GCH_FILES := $(foreach hdr,$(PRECOMPILED_HEADERS:.hpp=.hpp.gch),$(foreach id,$(ALL_GCH_IDENTIFIERS),$(hdr)/$(id)))
|
|
|
|
|
|
|
|
.PHONY: clean all $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS),$(config) clean-$(config))
|
|
|
|
|
|
|
|
$(ATMOSPHERE_LIBRARY_DIR) $(GCH_DIRS):
|
|
|
|
@[ -d $@ ] || mkdir -p $@
|
|
|
|
|
|
|
|
$(ATMOSPHERE_BUILD_DIR)/%:
|
|
|
|
@[ -d $@ ] || mkdir -p $@
|
2019-12-12 14:29:37 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
clean:
|
|
|
|
@echo clean ...
|
2020-10-27 20:55:19 +00:00
|
|
|
@rm -fr $(ATMOSPHERE_BUILD_DIR) $(ATMOSPHERE_LIBRARY_DIR) *.bz2 $(ALL_GCH_FILES)
|
|
|
|
@for i in $(GCH_DIRS); do [ -d $$i ] && rmdir --ignore-fail-on-non-empty $$i || true; done
|
2019-12-12 14:29:37 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
else
|
|
|
|
|
2020-10-27 20:55:19 +00:00
|
|
|
GCH_FILES := $(foreach hdr,$(PRECOMPILED_HEADERS:.hpp=.hpp.gch),$(CURRENT_DIRECTORY)/$(hdr)/$(ATMOSPHERE_GCH_IDENTIFIER))
|
|
|
|
DEPENDS := $(OFILES:.o=.d) $(foreach hdr,$(GCH_FILES),$(notdir $(patsubst %.hpp.gch/,%.d,$(dir $(hdr)))))
|
2019-12-12 14:29:37 +00:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# main targets
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
$(OUTPUT) : $(OFILES)
|
|
|
|
|
2020-02-19 09:22:51 +00:00
|
|
|
$(filter-out kern_svc_tables.o, $(OFILES)) : $(GCH_FILES)
|
|
|
|
|
2019-12-17 22:16:08 +00:00
|
|
|
$(OFILES_SRC) : $(HFILES_BIN)
|
2019-12-12 14:29:37 +00:00
|
|
|
|
2020-05-11 23:02:10 +01:00
|
|
|
kern_libc_generic.o: CFLAGS += -fno-builtin
|
|
|
|
|
2019-12-12 14:29:37 +00:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
%_bin.h %.bin.o : %.bin
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
@echo $(notdir $<)
|
|
|
|
@$(bin2o)
|
|
|
|
|
|
|
|
|
|
|
|
-include $(DEPENDS)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
endif
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
|