############################################################################### # vim:noexpandtab # Makefile for all modules # # Copyright 2010 Nintendo. All rights reserved. # # These coded instructions, statements, and computer programs contain # proprietary information of Nintendo of America Inc. and/or Nintendo # Company Ltd., and are protected by Federal copyright law. They may # not be disclosed to third parties or copied or duplicated in any form, # in whole or in part, without the prior written consent of Nintendo. # ############################################################################### ############################################################################### # # This makefile can support one library per module, and any number of # executables. # # Module must specify: # MODULE_DEPTH - depth to parent build directory using relative path (i.e. ../..) # # The library is specified by the following variables in the module makefile: # LIB := TRUE # CLIBSRCS - c sources to be included in library # CPPLIBSRCS - cpp sources to be included in library # ASMLIBSRCS - assembly sources to be included in library # # # A kernel library is specified by the following variables in the module makefile: # KERNELLIB := TRUE # CLIBSRCS - c sources to be included in library # CPPLIBSRCS - cpp sources to be included in library # ASMLIBSRCS - assembly sources to be included in library # # A loader library is specified by the following variables in the module makefile: # LOADERLIB := TRUE # CLIBSRCS - c sources to be included in library # CPPLIBSRCS - cpp sources to be included in library # ASMLIBSRCS - assembly sources to be included in library # # A kernel debugger library is specified by the following variables in the module makefile: # KDEBUGLIB := TRUE # CLIBSRCS - c sources to be included in library # CPPLIBSRCS - cpp sources to be included in library # ASMLIBSRCS - assembly sources to be included in library # # Executables and RPLs are specified by the following variables in the module makefile: # CSRCS - all c sources to be built # CPPSRCS - all cpp sources to be built # ASMSRCS - all assembly sources to be built # BINNAMES - names of all executables, with no suffix # MODULE_LIBNAMES - library names that should be linked to specifically for this module # LCF_FILE - linker command file # # RPLs can have the following additional variables # DEF_FILE - exports definition file # NOT_RPL - (TRUE/not present) specifies if the file is processed as an RPL # RPLNAME - defines the name of an RPL (this being set indicates NOT an RPX) # used to define IMPORT_LIB # BUILDING_RPL - overrides default determiniation of RPX vs RPL which is based on RPLNAME # # To show dependencies, each BINNAME should have its own rule at the # bottom of the module makefile, such as : # $(BIN_DIR)/app$(BINSUFFIX): $(OBJ_DIR)/app.o $(LIBS) # # The following pre-defined variables are relied upon: # BIN_DIR - a pointer to the binary directory of this module # BINSUFFIX - the suffix of the binary (e.g. .elf) # OBJ_DIR - a pointer to the object and dependency directory of this module # LIBS - full path to all libraries for link to module executables # this includes common and module-specific libraries # ############################################################################### ifndef MODULE_DEPTH $(error Please specify MODULE_DEPTH in $(CURDIR)/makefile) endif # # if using GCC for ARM elf, then do not use GHS build rules # ifdef ARM_ELF_GCC_VERSION USE_GHS := 0 endif # FIRST TARGET: Default to parallel build of default target include $(MODULE_DEPTH)/build/make/target_fast.mk # Module makefiles should not specify any targets before including modulerules.mk. .PHONY: default ############################################################################### ifeq ($(USE_GHS),1) ifneq ($(NOT_RPL),TRUE) ############################################################################### # RPL processing ############################################################################### ELF_TARGET_FILE = $(BIN_DIR)/$(basename $(notdir $@))$(BINSUFFIX) RPX_TARGET_FILE = $(BIN_DIR)/$(basename $(notdir $@))$(RPXSUFFIX) RPL_TARGET_FILE = $(BIN_DIR)/$(basename $(notdir $@))$(RPLSUFFIX) ifneq ($(RPLNAME),) BUILDING_RPL := 1 endif ifeq ($(BUILD_TARGET),NDEBUG) -include rplpad.mk endif ifeq ($(BUILDING_RPL),1) BINNAMES := COMMON_LIBNAMES := rpl LCF_FILE := $(RPL_LCF_FILE) ifdef MAKERPL_PAD MAKERPL_FLAGS += -checknosda $(MAKERPL_PAD) else MAKERPL_FLAGS += -checknosda endif RPL_ENTRY_SPEC ?= -e __rpl_crt else RPL_ENTRY_SPEC := -e _start ifdef MAKERPL_PAD MAKERPL_FLAGS += -f $(MAKERPL_PAD) else MAKERPL_FLAGS += -f endif endif # embed build type, sdk version and sdk revision infomations to rpx/rpl MAKERPL_FLAGS += -t BUILD_TYPE=$(BUILD_TYPE) ifeq ($(CAFE_GHS_SUPPORTS_MAKERPL_DBG_SOURCE_ROOT),TRUE) MAKERPL_FLAGS += $(DBG_SOURCE_ROOT) endif MAKERPL_TARGET_LIB ?= $(LIB_DIR)/$(basename $(notdir $@))$(LIBSUFFIX) DUMPRPL_FLAGS += -padinfo LDFLAGS += $(RPL_ENTRY_SPEC) ifneq ($(KEEP_UNUSED_FUNC),TRUE) LDFLAGS += -delete endif ifneq ($(DEF_FILE),) SPECIFY_DEF_FILE = -x $(DEF_FILE) endif EXPORT_OBJECT_NAME ?= $(OBJ_DIR)/$(basename $(notdir $@))_rpl_export.o ifeq ($(BUILD_TARGET),NDEBUG) # provide a convenient way for developers to get call stack function names with # non-shipping NDEBUG builds by exporting SUPPRESS_STRIP=TRUE ifneq ($(SUPPRESS_STRIP),TRUE) MAKERPL_FLAGS += -s endif endif ifeq ($(CAFE_FORCE_DYNAMIC),TRUE) MAKERPL_FLAGS += -d endif else ############################################################################### # *NOT* RPL ############################################################################### EXPORT_OBJECT_NAME := ELF_TARGET_FILE = $@ endif else ELF_TARGET_FILE = $@ endif ############################################################################### LIB_FILTER := $(filter $(MODULE_LIBNAMES),$(COMMON_LIBNAMES)) ifneq ($(words $(LIB_FILTER)),0) $(info MODULE_LIBNAMES: $(MODULE_LIBNAMES)) $(info COMMON_LIBNAMES: $(COMMON_LIBNAMES)) $(error MODULE_LIBNAMES duplicated with COMMON_LIBNAMES.) endif ifneq ($(INIT_STACK_SIZE), ) STACK_SIZE_OVERRIDE := -stack $(INIT_STACK_SIZE) else STACK_SIZE_OVERRIDE := endif ifeq ($(LIB),TRUE) default: headers install else ifeq ($(KERNELLIB),TRUE) default: headers install else ifeq ($(LOADERLIB),TRUE) default: headers install else ifeq ($(KDEBUGLIB),TRUE) default: headers install else ifeq ($(RPLLIB),TRUE) default: headers install else ifeq ($(IS_IOP), STARTS_WITH_IOP) default: headers install else ifeq ($(BUILD_PARALLEL), TRUE) default: headers install else default: install endif endif endif endif endif endif endif ############################################################################### # # help # ############################################################################### .PHONY: help help: $(_@)echo "------------------------------------------------------------------" ; \ echo "Usage:" ; \ echo "" ; \ echo " To build" ; \ echo " make - build debug version" ; \ echo " make NDEBUG=TRUE - build non-debug version" ; \ echo " make OS_SECURITY_LEVEL= - build security level OS with level n between 0-255"; \ echo " make default - build in serial (without parallel jobs) with compiler+linker output" ; \ echo " make clean - remove object and dependency files" ; \ echo " make clobber - return to checkout state" ; \ echo " export CAFE_MAKE_JOBS= - set maximum number of parallel jobs" ; \ echo "" ; \ echo " To build subset" ; \ echo " make -j headers - pass 1" ; \ echo " make -j install - pass 2" ; \ echo " make BINNAMES=<> - build just 1 binary (if module has multiple binaries)" ; \ echo "" ; \ echo " To run" ; \ echo " make run - build and run" ; \ echo " make rerun - just run" ; \ echo " make [re]run BINNAMES=<> - build and run just 1 binary of many (choose by name)" ; \ echo " make [re]multirun - build, run, and debug with GHS multi user interface" ; \ echo " make srun - build and run using soft launch" ; \ echo " make kernelrun - run using kernel mode" ; \ echo " make run2multi - build, run, and launch multi if crash or OSDebug()" ; \ ############################################################################### # # Paths relevant to this module # ############################################################################### # Create list of all libraries to link to the module MODULE_LIBS = $(addprefix $(LIB_DIR)/,$(addsuffix $(LIBSUFFIX), $(MODULE_LIBNAMES))) KERNEL_LIBS = $(addprefix $(KERNELLIB_DIR)/,$(addsuffix $(LIBSUFFIX), $(KERNEL_LIBNAMES))) LOADER_LIBS = $(addprefix $(LOADERLIB_DIR)/,$(addsuffix $(LIBSUFFIX), $(LOADER_LIBNAMES))) KDEBUG_LIBS = $(addprefix $(KDEBUGLIB_DIR)/,$(addsuffix $(LIBSUFFIX), $(KDEBUG_LIBNAMES))) ifeq ($(USE_GHS),1) CORE_SRC_LIB = $(addprefix $(LIB_DIR)/,$(addsuffix $(LIBSUFFIX), core_src)) CORE_DYN_LIB = $(addprefix $(LIB_DIR)/,$(addsuffix $(LIBSUFFIX), coredyn)) COS_DEF_MALLOC_LIB = $(addprefix $(LIB_DIR)/,$(addsuffix $(OBJSUFFIX),cos_def_malloc)) ifneq ($(CAFE_NO_COMMON_LIBS),TRUE) ifeq ($(BUILDING_RPL),1) ifneq ($(COS_DONT_USE_DEF_MALLOC),TRUE) COMMON_LIBS += $(COS_DEF_MALLOC_LIB) endif endif ifneq ($(RPLNAME),) ifneq ($(CAFE_RPL_USES_CORE_DYN),FALSE) CORE_LIBS = $(CORE_DYN_LIB) endif else CORE_LIBS = $(CORE_DYN_LIB) endif COMMON_LIBS += $(COMMON_DYNAMIC_LIBS) ifneq ($(RPLNAME),coredyn) # CORE_DYN_LIB is added last because we need CORE_DYN_LIB just before the # GHS libs so that it can override certain GHS symbols. LIBS = $(MODULE_LIBS) $(COMMON_LIBS) $(CORE_LIBS) else LIBS = $(OS_DYN_LIB) $(MODULE_LIBS) endif else LIBS = $(MODULE_LIBS) endif else LIBS = $(COMMON_LIBS) $(MODULE_LIBS) endif # Suffix rules .SUFFIXES: .SUFFIXES: .h .c .o .cpp .s .cp ############################################################################### # # Generate lists of objects to be built # ############################################################################### ALLCSRCS = $(CSRCS) $(CLIBSRCS) ALLCPPSRCS = $(CPPSRCS) $(CPPLIBSRCS) ALLCPSRCS = $(CPSRCS) $(CPLIBSRCS) ALLASMSRCS = $(ASMSRCS) $(ASMLIBSRCS) ifdef ASMSRCS OBJECTS += $(addprefix $(OBJ_DIR)/, $(ASMSRCS:.s=.o)) endif ifdef CSRCS OBJECTS += $(addprefix $(OBJ_DIR)/, $(CSRCS:.c=.o)) endif ifdef CPPSRCS OBJECTS += $(addprefix $(OBJ_DIR)/, $(CPPSRCS:.cpp=.o)) endif ifdef CPSRCS OBJECTS += $(addprefix $(OBJ_DIR)/, $(CPSRCS:.cp=.o)) endif ifdef ASMLIBSRCS LIBOBJECTS += $(addprefix $(OBJ_DIR)/, $(ASMLIBSRCS:.s=.o)) XLIBOBJECTS += $(ASMLIBSRCS:.s=.o) endif ifdef CLIBSRCS LIBOBJECTS += $(addprefix $(OBJ_DIR)/, $(CLIBSRCS:.c=.o)) XLIBOBJECTS += $(CLIBSRCS:.c=.o) endif ifdef CPPLIBSRCS LIBOBJECTS += $(addprefix $(OBJ_DIR)/, $(CPPLIBSRCS:.cpp=.o)) XLIBOBJECTS += $(CPPLIBSRCS:.cpp=.o) endif ifdef CPLIBSRCS LIBOBJECTS += $(addprefix $(OBJ_DIR)/, $(CPLIBSRCS:.cp=.o)) XLIBOBJECTS += $(CPLIBSRCS:.cp=.o) endif ALLOBJECTS = $(OBJECTS) $(LIBOBJECTS) ifeq ($(LIB),TRUE) # If LIBNAME isn't set, set it to the directory name ifeq ($(LIBNAME),) LIBNAME = $(notdir $(MODULE_DIR)) endif ifeq ($(USE_GHS),1) ifeq ($(filter $(LIBNAME), $(CORE_SRC_LIBNAMES)),$(LIBNAME)) TARGET_LIB = $(LIB_DIR)/core/$(LIBNAME)$(LIBSUFFIX) else TARGET_LIB = $(LIB_DIR)/$(LIBNAME)$(LIBSUFFIX) endif else TARGET_LIB = $(LIB_DIR)/$(LIBNAME)$(LIBSUFFIX) endif endif ifeq ($(KERNELLIB),TRUE) # Name of library must be same as the name of the directory LIBNAME = $(notdir $(MODULE_DIR)) TARGET_LIB = $(KERNELLIB_DIR)/$(LIBNAME)$(LIBSUFFIX) endif ifeq ($(LOADERLIB),TRUE) # Name of library must be same as the name of the directory LIBNAME = $(notdir $(MODULE_DIR)) TARGET_LIB = $(LOADERLIB_DIR)/$(LIBNAME)$(LIBSUFFIX) endif ifeq ($(KDEBUGLIB),TRUE) # Name of library must be same as the name of the directory LIBNAME = $(notdir $(MODULE_DIR)) TARGET_LIB = $(KDEBUGLIB_DIR)/$(LIBNAME)$(LIBSUFFIX) endif ifdef BINNAMES TARGET_BINS = $(addprefix $(BIN_DIR)/,$(addsuffix $(BINSUFFIX), $(BINNAMES))) ifeq ($(USE_GHS),1) ifeq ($(NOT_RPL),) # Do not make TARGET_RPXS a build target simultaneous with TARGET_BINS, # since there is only one rule that builds them both; a parallel build # would try to run that rule twice for both targets at once. TARGET_RPXS = $(addprefix $(BIN_DIR)/,$(addsuffix $(RPXSUFFIX), $(BINNAMES))) endif endif endif # We can build more than one RPLNAME (even though the name is singular), # unless you are building the import library. ifdef RPLNAME TARGET_BINS := TARGET_RPXS := TARGET_RPLS = $(addprefix $(BIN_DIR)/,$(addsuffix $(RPLSUFFIX), $(RPLNAME))) endif ############################################################################### # # include rules for header dependencies on existing object files # ############################################################################### INCLUDEDEPS=TRUE ifdef INCLUDEDEPS ifneq (,$(firstword $(ALLASMSRCS))) -include $(addprefix $(OBJ_DIR)/, $(ALLASMSRCS:.s=$(DEPSUFFIX))) endif ifneq (,$(firstword $(ALLCSRCS))) -include $(addprefix $(OBJ_DIR)/, $(ALLCSRCS:.c=$(DEPSUFFIX))) endif ifneq (,$(firstword $(ALLCPPSRCS))) -include $(addprefix $(OBJ_DIR)/, $(ALLCPPSRCS:.cpp=$(DEPSUFFIX))) endif ifneq (,$(firstword $(ALLCPSRCS))) -include $(addprefix $(OBJ_DIR)/, $(ALLCPSRCS:.cp=$(DEPSUFFIX))) endif endif ############################################################################### # # Generic make directory rules # ############################################################################### $(OBJ_DIR): $(MKDIRP) $(OBJ_DIR) $(BIN_DIR): $(MKDIRP) $(BIN_DIR) $(BIN_DIR_NO_TARGET): $(MKDIRP) $(BIN_DIR_NO_TARGET) ############################################################################### # # Generic compile rules & dependency creation # ############################################################################### CLEAN_DEPEND := sed -f "$(BUILDMAKE_ROOT)/eppccleandepend_cygwin.sed" PATH_CYGWIN_TO_DOS := sed 's_/cygdrive/\([a-zA-Z]\+\)/_\U\1:/_g' # Note: PATH_CYGWIN_TO_DOS current implementation means $CAFE_ROOT must exist # outside of CYGWIN_PATH directory. Proper implementation is using # cygpath, but need to pick out paths correctly from compiler command-line. # Take each dependency and add it as a target; see http://mad-scientist.net/make/autodep.html ADD_DEPEND := sed -f "$(BUILDMAKE_ROOT)/eppccleandepend_cygwin.sed" -f "$(BUILDMAKE_ROOT)/eppcadddepend_cygwin.sed" define CLEAN_DEPENDS $(_@)$(CLEAN_DEPEND) $(@:.o=.d) > $(@:.o=$(DEPSUFFIX)) $(_@)$(ADD_DEPEND) < $(@:.o=.d) >> $(@:.o=$(DEPSUFFIX)) endef # asm $(OBJ_DIR)/%.o: %.s $(call MOD_RULES_STEP, "\n>> Compiling $*") $(MKDIRP) $(dir $@) ifdef ASM_PREPROCESS $(CC) -E $(ASFLAGS) -D_ASSEMBLER -U__cplusplus $(INCLUDES) -c $< > $(OBJ_DIR)/$*.preprocessed.s $(AS) $(ASFLAGS) $(INCLUDES) -c $(OBJ_DIR)/$*.preprocessed.s -o $@ $(MAKE_DEPEPENDENCY_OPTION) else $(AS) $(ASFLAGS) $(INCLUDES) -c $< -o $@ $(MAKE_DEPEPENDENCY_OPTION) endif $(CLEAN_DEPENDS) # c $(OBJ_DIR)/%.o: %.c $(call MOD_RULES_STEP,"\n>> Compiling $*") $(MKDIRP) $(dir $@) $(CC) $(CCFLAGS) -D_LANGUAGE_C $(INCLUDES) $(PREFIX_FILE) $(COMPILE) $< -o $@ $(MAKE_DEPEPENDENCY_OPTION) $(CLEAN_DEPENDS) # cpp $(OBJ_DIR)/%.o: %.cpp $(call MOD_RULES_STEP,"\n>> Compiling $*") $(MKDIRP) $(dir $@) $(CC) $(CCFLAGS) $(CXXFLAGS) $(INCLUDES) $(PREFIX_FILE) $(COMPILE) $< -o $@ $(MAKE_DEPEPENDENCY_OPTION) $(CLEAN_DEPENDS) # cp $(OBJ_DIR)/%.o: %.cp $(call MOD_RULES_STEP,"\n>> Compiling $*") $(MKDIRP) $(dir $@) $(CC) $(CCFLAGS) $(INCLUDES) $(PREFIX_FILE) $(COMPILE) $< -o $@ $(MAKE_DEPEPENDENCY_OPTION) $(CLEAN_DEPENDS) ############################################################################### # # Generic linking rules # # linker command file is always used for EOS applications # user can override if there are special requirements # ############################################################################### LCFFLAGS := ifdef LCF_FILE DOS_LCF_FILE := $(shell cygpath -m "$(LCF_FILE)") LCFFLAGS := $(SPECIFY_LCF_OPTION) $(DOS_LCF_FILE) endif ifdef REL_LCF_FILE REL_LCF_FILE := $(shell cygpath -m "$(REL_LCF_FILE)") REL_LDFLAGS += $(SPECIFY_LCF_OPTION) $(REL_LCF_FILE) endif ifdef PREREL_LCF_FILE PREREL_LCF_FILE := $(shell cygpath -m "$(PREREL_LCF_FILE)") PREREL_LDFLAGS += $(SPECIFY_LCF_OPTION) $(PREREL_LCF_FILE) endif # elf - static library creation $(TARGET_LIB): $(LIBOBJECTS) $(call MOD_RULES_STEP,"\n>> Creating Library \"$(notdir $@)\" <-- $(notdir $?)") $(MKDIRP) $(dir $@) ifdef INSTALL_OBJ_TO_LIB_DIR cp -p $(LIBOBJECTS) $(LIB_DIR) endif ifndef INSTALL_OBJ_TO_LIB_DIR ifdef COMPILER_REQUIRES_DOS_ARGUMENTS ifdef OBJ_SEARCH_PATHS $(AR) $(shell echo '$(ARFLAGS) -o $(TARGET_LIB) $(notdir $(LIBOBJECTS))' | $(PATH_CYGWIN_TO_DOS)) else ifeq ($(USE_OBJ_DIR),FALSE) $(AR) $(shell echo '$(ARFLAGS) -o $(TARGET_LIB) $(LIBOBJECTS)' | $(PATH_CYGWIN_TO_DOS)) else ( cd $(OBJ_DIR); $(AR) $(shell echo '$(ARFLAGS) -o $(TARGET_LIB) $(XLIBOBJECTS)' | $(PATH_CYGWIN_TO_DOS)) ) endif endif else ifdef OBJ_SEARCH_PATHS $(AR) $(notdir $(LIBOBJECTS)) $(ARFLAGS) -o $(TARGET_LIB) else $(AR) $(LIBOBJECTS) $(ARFLAGS) -o $(TARGET_LIB) endif endif endif # elf, rpx/rpl linking ifneq ($(USE_PREPRPL_IMPORT_LIB),TRUE) ifeq ($(USE_GHS),1) $(BIN_DIR)/%$(RPLSUFFIX) $(BIN_DIR)/%$(RPXSUFFIX) $(BIN_DIR)/%$(BINSUFFIX): else $(BIN_DIR)/%$(BINSUFFIX): endif # USE_GHS==1 $(MKDIRP) $(dir $@) ifeq ($(USE_GHS),1) ifneq ($(NOT_RPL),TRUE) ifeq ($(BUILDING_RPL),1) $(call MOD_RULES_STEP,"\n>> Create RPL \"$(basename $(notdir $@))\" <-- $(notdir $?)") else $(call MOD_RULES_STEP,"\n>> Create RPX \"$(basename $(notdir $@))\" <-- $(notdir $?)") endif else $(call MOD_RULES_STEP,"\n>> Create \"$(notdir $@)\" <-- $(notdir $?)") endif ifneq ($(NOT_RPL),TRUE) $(MKDIRP) $(dir $(EXPORT_OBJECT_NAME)) ; \ $(PREPRPL) $(shell echo '$(SPECIFY_DEF_FILE) $(RPL_ENTRY_SPEC) $(PREPRPL_FLAGS) -o $(EXPORT_OBJECT_NAME) $(filter-out %.def %.lcf,$^)' | $(PATH_CYGWIN_TO_DOS)) endif # NOT_RPL!=TRUE else $(call MOD_RULES_STEP,"\n>> Linking ELF \"$(subst $(BIN_DIR)/,,$@)\" <-- $(notdir $?)") endif # USE_GHS==1 ifdef COMPILER_REQUIRES_DOS_ARGUMENTS ifdef OBJ_SEARCH_PATHS $(LD) $(shell echo '$(EXPORT_OBJECT_NAME) $(notdir $(filter-out %.def %.lcf,$+)) $(LDFLAGS) $(LCFFLAGS) -o $(ELF_TARGET_FILE)' | $(PATH_CYGWIN_TO_DOS)) else $(LD) $(shell echo '$(EXPORT_OBJECT_NAME) $(filter-out %.def %.lcf,$^) $(LDFLAGS) $(LCFFLAGS) -o $(ELF_TARGET_FILE)' | $(PATH_CYGWIN_TO_DOS)) endif # OBJ_SEARCH_PATHS else ifdef OBJ_SEARCH_PATHS $(LD) $(EXPORT_OBJECT_NAME) $(notdir $(filter-out %.def %.lcf,$+)) $(LDFLAGS) $(LCFFLAGS) -o $(ELF_TARGET_FILE) else $(LD) $(EXPORT_OBJECT_NAME) $(filter-out %.def %.lcf,$+) $(LDFLAGS) $(LCFFLAGS) -o $(ELF_TARGET_FILE) endif # OBJ_SEARCH_PATHS endif # COMPILER_REQUIRES_DOS_ARGUMENTS ifeq ($(USE_GHS),1) ifneq ($(NOT_RPL),TRUE) $(MAKERPL) $(shell echo '$(ELF_TARGET_FILE) $(STACK_SIZE_OVERRIDE) $(MAKERPL_FLAGS) -l $(MAKERPL_TARGET_LIB)' | $(PATH_CYGWIN_TO_DOS)) ifeq ($(RPLLIMITS),TRUE) ifeq ($(BUILDING_RPL),1) $(DUMPRPL) $(shell echo '$(RPL_TARGET_FILE) $(DUMPRPL_FLAGS)' | $(PATH_CYGWIN_TO_DOS)) > $(BIN_DIR)/rpllimits.txt else $(DUMPRPL) $(shell echo '$(RPX_TARGET_FILE) $(DUMPRPL_FLAGS)' | $(PATH_CYGWIN_TO_DOS)) > $(BIN_DIR)/rpllimits.txt endif endif endif # NOT_RPL!=TRUE endif # USE_GHS==1 endif # USE_PREPRPL_IMPORT_LIB!=TRUE ############################################################################### # # import library # # NOTE: special rules as in this case the RPL/RPX build step must depend on the # export object file, but that messes up the default rule for building ELF ############################################################################### ifeq ($(BUILDING_RPL),1) ifeq ($(USE_PREPRPL_IMPORT_LIB),TRUE) ifneq ($(RPLNAME),) ifneq ($(words $(RPLNAME)),1) $(error More than one RPLNAME not allowed.) endif IMPORT_LIB := $(LIB_DIR)/$(RPLNAME).a $(IMPORT_LIB): $(OBJ_DIR)/$(RPLNAME)_rpl_export.o $(OBJ_DIR)/$(RPLNAME)_rpl_export.o: $(DEF_FILE) $(MKDIRP) $(OBJ_DIR) $(LIB_DIR) $(PREPRPL) -q -x $< $(PREPRPL_FLAGS) -o $(shell echo '$(OBJ_DIR)/$(RPLNAME)_rpl_export.o -l $(IMPORT_LIB)' | $(PATH_CYGWIN_TO_DOS)) -r $(RPLNAME) else # This rule is to allow multiple RPLs build in the same makefile # Note this form should not be used on System RPLs because # it does not define IMPORT_LIB and does not install # the import library when installing the headers # useful for building tests $(OBJ_DIR)/%_rpl_export.o $(LIB_DIR)/%.a: %.def $(MKDIRP) $(OBJ_DIR) $(LIB_DIR) $(PREPRPL) -q -x $< $(PREPRPL_FLAGS) -o $(shell echo '$(OBJ_DIR)/$*_rpl_export.o -l $(LIB_DIR)/$*.a' | $(PATH_CYGWIN_TO_DOS)) -r $* endif # RPLNAME!="" #rpx/rpl linking # NOTE: adding the %_rpl_export.o adds the export object to the $+/$^ variables # also $+/$^ includes the dependencies from any other rules for the .rpx/rpl # need to filter out the .def file (to allow us to track .def dependencies) $(BIN_DIR)/%$(RPLSUFFIX) $(BIN_DIR)/%$(RPXSUFFIX): $(OBJ_DIR)/%_rpl_export.o $(MKDIRP) $(dir $@) $(dir $(EXPORT_OBJECT_NAME)) $(call MOD_RULES_TOOL,"\n>> Linking RPX/RPL \"$(subst $(BIN_DIR)/,,$@)\" <-- $(notdir $?)") ifdef COMPILER_REQUIRES_DOS_ARGUMENTS ifdef OBJ_SEARCH_PATHS $(LD) $(shell echo '$(notdir $(filter-out %.def %.lcf,$+)) $(LDFLAGS) $(LCFFLAGS) -o $(ELF_TARGET_FILE)' | $(PATH_CYGWIN_TO_DOS)) else $(LD) $(shell echo '$(filter-out %.def %.lcf,$^) $(LDFLAGS) $(LCFFLAGS) -o $(ELF_TARGET_FILE)' | $(PATH_CYGWIN_TO_DOS)) endif else ifdef OBJ_SEARCH_PATHS $(LD) $(notdir $(filter-out %.def %.lcf,$+)) $(LDFLAGS) $(LCFFLAGS) -o $(ELF_TARGET_FILE) else $(LD) $(filter-out %.def %.lcf,$+) $(LDFLAGS) $(LCFFLAGS) -o $(ELF_TARGET_FILE) endif endif # COMPILER_REQUIRES_DOS_ARGUMENTS $(MAKERPL) $(shell echo '$(ELF_TARGET_FILE) $(STACK_SIZE_OVERRIDE) $(MAKERPL_FLAGS) -f -nolib' | $(PATH_CYGWIN_TO_DOS)) ifeq ($(RPLLIMITS),TRUE) ifeq ($(BUILDING_RPL),1) $(DUMPRPL) $(shell echo '$(RPL_TARGET_FILE) $(DUMPRPL_FLAGS)' | $(PATH_CYGWIN_TO_DOS)) > $(BIN_DIR)/rpllimits.txt else $(DUMPRPL) $(shell echo '$(RPX_TARGET_FILE) $(DUMPRPL_FLAGS)' | $(PATH_CYGWIN_TO_DOS)) > $(BIN_DIR)/rpllimits.txt endif endif else # from USE_PREPRPL_IMPORT_LIB==TRUE IMPORT_LIB := $(IMPORT_LIB): endif # USE_PREPRPL_IMPORT_LIB==TRUE endif # BUILDING_RPL==1 ############################################################################### # # headers # ############################################################################### .PHONY: headers print_module_header print_module_headers: $(call MOD_RULES_PHASE, "Installing headers $(MODULE_PATH_FROM_SRC)") HEADER_DIR := headers HEADERS := $(shell if [ -d $(HEADER_DIR) ] ; then find $(HEADER_DIR) -iname "*.h" -type f | sed 's;^$(HEADER_DIR);$(INCLUDE_DIR);g' ; fi) $(INCLUDE_DIR)/%: $(HEADER_DIR)/% $(MACRO_INSTALL_FILE) $< $@ headers: print_module_headers $(HEADERS) $(MODULE_HEADERS) $(IMPORT_LIB) ############################################################################### # # install # ############################################################################### .PHONY: print_module_install install print_module_install: $(call MOD_RULES_PHASE,"Building/Installing $(MODULE_PATH_FROM_SRC) $(BUILD_TYPE) $(MODULE_COMMENT)") # TARGET_RPXS removed from here to prevent issues with parallel build install: print_module_install $(OBJECTS) $(TARGET_LIB) $(TARGET_BINS) $(TARGET_RPLS) ############################################################################### # # run / rerun # # "make run" builds/installs then runs # "make rerun" just runs # ############################################################################### .PHONY: run rerun rerun_binary debug_binary run: install rerun # Determine which binary to run ifeq ($(words $(BINNAMES)), 0) # No binaries or rpl in this module rerun: $(_@)echo "Nothing to run" else ifeq ($(words $(BINNAMES)), 1) # Only 1 binary in this module rerun: $(_@)$(MAKE) rerun_binary RUN_BINARY=$(TARGET_RPXS) else # Multiple binaries in this module. Ask user which one # TODO: Automate which binary if user specifies number or binary name rerun: $(_@)echo "Choose which binary to run:" ; \ PS3='number? ' ; \ select n in $(notdir $(TARGET_RPXS)) ; do \ if [[ -n $$n ]] ; then \ $(MAKE) rerun_binary RUN_BINARY="$(dir $(firstword $(TARGET_RPXS)))$$n" ; \ fi ; \ break ; \ done endif endif .PHONY: multirun remultirun gdbrun regdbrun gdbtuirun regdbtuirun srun resrun bgrun run2multi # run the binary using kernelmode kernelrun: $(_@)$(MAKE) run DEBUG_RUN="-K" bgrun: $(_@)$(MAKE) run DEBUG_RUN="-g 0x100" rwrun: $(_@)$(MAKE) run DEBUG_RUN="-g 0x40000000" shrun: $(_@)$(MAKE) run MACRO_RUN_OPTIONS="-n" erun: $(_@)$(MAKE) run MACRO_RUN_OPTIONS="-g 0x00008000" multirun: $(_@)$(MAKE) run MULTI_DEBUG=1 DEBUG_RUN="-d multi" multishrun: $(_@)$(MAKE) run MULTI_DEBUG=1 DEBUG_RUN="-d multi" MACRO_RUN_OPTIONS="-n" remultirun: $(_@)$(MAKE) rerun MULTI_DEBUG=1 DEBUG_RUN="-d multi" gdbrun: $(_@)$(MAKE) run DEBUG_RUN="-d gdb" regdbrun: $(_@)$(MAKE) rerun DEBUG_RUN="-d gdb" gdbtuirun: $(_@)$(MAKE) run DEBUG_RUN="-d gdbtui" regdbtuirun: $(_@)$(MAKE) rerun DEBUG_RUN="-d gdbtui" srun: $(_@)$(MAKE) run MACRO_RUN_OPTIONS="-s" resrun: $(_@)$(MAKE) rerun MACRO_RUN_OPTIONS="-s" run2multi: $(_@)$(MAKE) run MULTI_DEBUG=1 DEBUG_RUN="-R -d multi" # Run the binary (depends on the os, as defined in commondefs..*.mk") ifeq ($(MULTI_DEBUG),1) MULTI_DEBUG_BINARY = -k $(BIN_DIR)/$(basename $(notdir $(RUN_BINARY)))$(BINSUFFIX) endif ifeq ($(BUILD_TARGET), DEBUG) OS_VER_OPTION=-b endif ifeq ($(BUILD_TARGET), FDEBUG) OS_VER_OPTION=-u endif ifeq ($(BUILD_TARGET), OS_SECURITY_LEVEL) OS_VER_OPTION=-C endif rerun_binary: $(_@)if [ ! -e $(RUN_BINARY) ] ; then \ echo "Can't find $(RUN_BINARY)" ; \ exit 1 ; \ fi ; \ echo "------------------------------------------------------------------" $(MACRO_RUN) ############################################################################### # # import # ############################################################################### .PHONY: import import_binary # Determine which binary to run ifeq ($(words $(BINNAMES)), 0) # No binaries or rpl in this module import: $(_@)echo "Nothing to import" else ifeq ($(words $(BINNAMES)), 1) # Only 1 binary in this module import: $(MAKE) import_binary IMPORT_BINARY=$(TARGET_RPXS) else # Multiple binaries in this module. Ask user which one # TODO: Automate which binary if user specifies number or binary name import: $(_@)echo "Choose which binary to import:" ; \ PS3='number? ' ; \ select n in $(notdir $(TARGET_RPXS)) ; do \ if [[ -n $$n ]] ; then \ $(MAKE) import_binary IMPORT_BINARY="$(dir $(firstword $(TARGET_RPXS)))$$n" ; \ fi ; \ break ; \ done endif endif import_binary: $(_@)if [ -z "$(IMPORT_BINARY)" ] ; then \ echo "Can't find $(IMPORT_BINARY)" ; \ exit 1 ; \ fi ; \ if [ -z "$(IMPORT_TID)" ] ; then \ echo "Please call make import IMPORT_TID=" ; \ exit 1 ; \ fi ; \ echo "------------------------------------------------------------------" cafeinstall $(IMPORT_BINARY) $(IMPORT_TID) ############################################################################### # # clean # ############################################################################### .PHONY: print_module_clean cleanobj cleandis cleanuser clean print_module_clean: $(_@)echo "------------------------------------------------------------------" ; \ echo "Cleaning $(MODULE_PATH_FROM_SRC)" cleanobj: ifneq ($(TOP_CLOBBER_DONE),TRUE) rm -Rf $(dir $(OBJ_DIR)) endif cleanuser: ifdef CLEANFILES rm -Rf $(CLEANFILES) endif clean: print_module_clean cleanobj cleanuser ############################################################################### # # clobber # ############################################################################### .PHONY: call_cafestop print_module_clobber clobber # release FSEmul's locks in CAFE_CONTENT_DIR if FSEmul is still running call_cafestop: ifneq ($(TOP_CLOBBER_DONE),TRUE) $(_@)if [ -f "$(CAFE_ROOT)/system/bin/tool/cafestop" -a -n "`ps | grep FSEmul`" ]; then \ echo "Releasing file locks..." ; \ $(CAFE_ROOT)/system/bin/tool/cafestop ; \ fi endif print_module_clobber: $(_@)echo "------------------------------------------------------------------" ; \ echo "Clobbering $(MODULE_PATH_FROM_SRC) $(MODULE_COMMENT)" clobber: clean print_module_clobber call_cafestop ifneq ($(TOP_CLOBBER_DONE),TRUE) ifeq ($(LIB),TRUE) rm -Rf $(dir $(LIB_DIR))DEBUG/$(LIBNAME)$(LIBSUFFIX) rm -Rf $(dir $(LIB_DIR))NDEBUG/$(LIBNAME)$(LIBSUFFIX) ifdef INSTALL_OBJ_TO_LIB_DIR rm -Rf $(dir $(LIB_DIR))DEBUG/$(LIBNAME)$(OBJSUFFIX) rm -Rf $(dir $(LIB_DIR))NDEBUG/$(LIBNAME)$(OBJSUFFIX) endif # INSTALL_OBJ_TO_LIB_DIR else ifeq ($(KERNELLIB),TRUE) rm -Rf $(dir $(KERNELLIB_DIR))DEBUG/$(LIBNAME)$(LIBSUFFIX) rm -Rf $(dir $(KERNELLIB_DIR))NDEBUG/$(LIBNAME)$(LIBSUFFIX) else ifeq ($(LOADERLIB),TRUE) rm -Rf $(dir $(LOADERLIB_DIR))DEBUG/$(LIBNAME)$(LIBSUFFIX) rm -Rf $(dir $(LOADERLIB_DIR))NDEBUG/$(LIBNAME)$(LIBSUFFIX) else ifeq ($(KDEBUGLIB),TRUE) rm -Rf $(dir $(KDEBUGLIB_DIR))DEBUG/$(LIBNAME)$(LIBSUFFIX) rm -Rf $(dir $(KDEBUGLIB_DIR))NDEBUG/$(LIBNAME)$(LIBSUFFIX) else rm -Rf $(dir $(BIN_DIR)) endif # ($(KDEBUGLIB),TRUE) endif # ($(LOADERLIB),TRUE) endif # ($(KERNELLIB),TRUE) endif # ($(LIB),TRUE) $(_@)if [ -d $(HEADER_DIR) ] ; then \ echo "rm -f $(HEADERS)" ; \ rm -Rf $(HEADERS) ; \ fi $(_@)if [ -n "$(MODULE_HEADERS)" ] ; then \ echo "rm -f $(MODULE_HEADERS)" ; \ rm -f $(MODULE_HEADERS) ; \ fi endif # ($(TOP_CLOBBER_DONE),TRUE)