2020-01-24 03:13:32 +01:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# pull in common atmosphere configuration
|
|
|
|
#---------------------------------------------------------------------------------
|
2020-10-27 21:55:19 +01:00
|
|
|
THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
CURRENT_DIRECTORY := $(abspath $(dir $(THIS_MAKEFILE)))
|
|
|
|
include $(CURRENT_DIRECTORY)/../../libraries/config/templates/mesosphere.mk
|
2020-01-24 03:13:32 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# no real need to edit anything past this point unless you need to add additional
|
|
|
|
# rules for different file extensions
|
|
|
|
#---------------------------------------------------------------------------------
|
2020-10-27 21:55:19 +01:00
|
|
|
ifneq ($(__RECURSIVE__),1)
|
2020-01-24 03:13:32 +01:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
2020-10-27 21:55:19 +01:00
|
|
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) $(CURDIR)/include \
|
2020-01-24 03:13:32 +01:00
|
|
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
|
|
|
2020-08-11 20:22:56 +02:00
|
|
|
CFILES := $(call FIND_SOURCE_FILES,$(SOURCES),c)
|
|
|
|
CPPFILES := $(call FIND_SOURCE_FILES,$(SOURCES),cpp)
|
|
|
|
SFILES := $(call FIND_SOURCE_FILES,$(SOURCES),s)
|
2020-01-24 03:13:32 +01: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)
|
|
|
|
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
|
|
|
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(subst -,_,$(BINFILES))))
|
|
|
|
|
|
|
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
|
|
-I.
|
|
|
|
|
2020-10-27 21:55:19 +01:00
|
|
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/$(ATMOSPHERE_LIBRARY_DIR))
|
|
|
|
|
|
|
|
export TOPDIR := $(CURRENT_DIRECTORY)
|
2020-01-24 03:13:32 +01:00
|
|
|
|
2020-10-27 21:55:19 +01:00
|
|
|
OUTPUT_BASE := $(TOPDIR)/$(notdir $(TOPDIR))
|
2020-01-24 03:13:32 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
2020-10-27 21:55:19 +01:00
|
|
|
ATMOSPHERE_BUILD_CONFIGS :=
|
|
|
|
all: release
|
|
|
|
|
|
|
|
define ATMOSPHERE_ADD_TARGET
|
|
|
|
|
|
|
|
ATMOSPHERE_BUILD_CONFIGS += $(strip $1)
|
|
|
|
|
|
|
|
$(strip $1): check_libmeso_$(strip $1) $$(ATMOSPHERE_BUILD_DIR)/$(strip $1)
|
|
|
|
@$$(MAKE) __RECURSIVE__=1 OUTPUT=$$(OUTPUT_BASE)$(strip $2) $(3) \
|
|
|
|
DEPSDIR=$$(CURDIR)/$$(ATMOSPHERE_BUILD_DIR)/$(strip $1) \
|
|
|
|
LIBMESOSPHERE_NAME=mesosphere$(strip $2) \
|
|
|
|
--no-print-directory -C $$(ATMOSPHERE_BUILD_DIR)/$(strip $1) \
|
|
|
|
-f $$(THIS_MAKEFILE)
|
|
|
|
|
|
|
|
check_libmeso_$(strip $1):
|
|
|
|
@$$(MAKE) --no-print-directory -C ../../libraries/libmesosphere $(strip $1)
|
|
|
|
|
|
|
|
clean-$(strip $1):
|
|
|
|
@echo clean $(strip $1) ...
|
|
|
|
@rm -fr $$(ATMOSPHERE_BUILD_DIR)/$(strip $1) $$(OUTPUT_BASE)$(strip $2).bin $$(OUTPUT_BASE)$(strip $2).elf
|
|
|
|
|
|
|
|
endef
|
2020-01-24 03:13:32 +01:00
|
|
|
|
2020-10-27 21:55:19 +01:00
|
|
|
$(eval $(call ATMOSPHERE_ADD_TARGET, release, , \
|
|
|
|
ATMOSPHERE_BUILD_SETTINGS="" \
|
|
|
|
))
|
|
|
|
|
|
|
|
$(eval $(call ATMOSPHERE_ADD_TARGET, debug, _debug, \
|
|
|
|
ATMOSPHERE_BUILD_SETTINGS="-DMESOSPHERE_BUILD_FOR_DEBUGGING" \
|
|
|
|
))
|
|
|
|
|
|
|
|
$(eval $(call ATMOSPHERE_ADD_TARGET, audit, _audit, \
|
|
|
|
ATMOSPHERE_BUILD_SETTINGS="-DMESOSPHERE_BUILD_FOR_AUDITING" \
|
|
|
|
))
|
|
|
|
|
|
|
|
$(ATMOSPHERE_BUILD_DIR)/%:
|
|
|
|
@[ -d $@ ] || mkdir -p $@
|
2020-01-24 03:13:32 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
2020-10-27 21:55:19 +01:00
|
|
|
clean: $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS),clean-$(config))
|
|
|
|
|
|
|
|
.PHONY: all clean $(foreach config,$(ATMOSPHERE_BUILD_CONFIGS),$(config) clean-$(config))
|
2020-01-24 03:13:32 +01:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
else
|
|
|
|
|
|
|
|
DEPENDS := $(OFILES:.o=.d)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# main targets
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
$(OUTPUT).bin : $(OUTPUT).elf
|
2021-10-08 21:29:53 +02:00
|
|
|
$(OBJCOPY) -S -O binary $< $@
|
2020-01-24 03:13:32 +01:00
|
|
|
@echo built ... $(notdir $@)
|
|
|
|
|
2020-10-27 21:55:19 +01:00
|
|
|
$(OUTPUT).elf : $(OFILES)
|
|
|
|
|
|
|
|
$(OFILES) : $(ATMOSPHERE_LIBRARIES_DIR)/libmesosphere/$(ATMOSPHERE_LIBRARY_DIR)/lib$(LIBMESOSPHERE_NAME).a
|
2020-01-24 03:13:32 +01:00
|
|
|
|
|
|
|
%.elf:
|
|
|
|
@echo linking $(notdir $@)
|
|
|
|
$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
|
|
|
|
@$(NM) -CSn $@ > $(notdir $*.lst)
|
|
|
|
|
|
|
|
$(OFILES_SRC) : $(HFILES_BIN)
|
|
|
|
|
2020-08-03 08:39:58 +02:00
|
|
|
kern_libc_generic.o: CFLAGS += -fno-builtin
|
|
|
|
|
2020-01-24 03:13:32 +01:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# you need a rule like this for each extension you use as binary data
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
%.bin.o %_bin.h: %.bin
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
@echo $(notdir $<)
|
|
|
|
@$(bin2o)
|
|
|
|
|
|
|
|
-include $(DEPENDS)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
endif
|
2020-10-27 21:55:19 +01:00
|
|
|
#---------------------------------------------------------------------------------------
|