############################################################################### # vim:noexpandtab # previous line for VI users to keep the tabs (important for make) # # Global Green Hills PPC definitions for build system # # Copyright (C) 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. # ############################################################################### # NOTE: Modules should include commondefs.mk before including this file # Do a quick check for safety ifndef INCLUDE_DIR $(error error: Please include commondefs.mk before including this file in $(CURDIR)/makefile) endif ifneq ($(TOOLCHAIN),ghs) $(error error: TOOLCHAIN not set to ghs but USE_GHS set to 1. ) endif # GHS toolchain requires TMP environment variable or cryptic permissions errors can occur ifndef TMP $(error error: Please define TMP environment variable. For example, remove "unset TMP" in ~/.bashrc) endif ifndef CAFE_GHS_VERSION $(error error: CAFE_GHS_VERSION not set. cafe.bat sets this environment variable.) endif include $(BUILD_MAKE_PATH)/ghs_version_check.mk ######################################################################## # # Global libraries # ######################################################################## # IMPORTANT: ONLY ADD LIBRARIES HERE IF *ALL* BINARIES ARE REQUIRED TO LINK! # Module's makefile can also specify libraries to link with MODULE_LIBNAMES COMMON_DYNAMIC_LIBNAMES := nsyshid nlibcurl nsysnet nn_nets2 nsysccr nsysuvd gx2 avm tcl tve dc snd_core snd_user uvc uvd camera h264 dmae nn_acp nn_save vpad vpadbase proc_ui nn_ac padscore COMMON_DYNAMIC_LIBS = $(addprefix $(LIB_DIR)/,$(addsuffix $(LIBSUFFIX), $(COMMON_DYNAMIC_LIBNAMES))) COMMON_LIBNAMES := pad gfd mtx demo gx2ut nn_util nn_crypto COMMON_LIBS = $(addprefix $(LIB_DIR)/,$(addsuffix $(LIBSUFFIX), $(COMMON_LIBNAMES))) ######################################################################## # # Switches for modulerules.mk # ######################################################################## # tell modulerules.mk to convert paths to mixed-style path COMPILER_REQUIRES_DOS_ARGUMENTS := TRUE # COS builds pre-process assembler # ASM_PREPROCESS := TRUE # GHS uses C compiler to process assembler the ASM_PREPROCESS step is not needed # OBJ_SEARCH_PATH is defined later to clean up paths in the command-line ######################################################################## # # Green Hills Multi # ######################################################################## CC := $(GHS_ROOT)/ccppc.exe CXX := $(GHS_ROOT)/cxppc.exe AS := $(GHS_ROOT)/ccppc.exe LD := $(GHS_ROOT)/cxppc.exe AR := $(GHS_ROOT)/ccppc.exe LIBRARIAN := $(GHS_ROOT)/ax.exe ######################################################################## # # Nintendo RPL tools # ######################################################################## PREPRPL = $(TOOL_DIR)/preprpl$(TOOL_USED_ON_ARCH) MAKERPL = $(TOOL_DIR)/makerpl$(TOOL_USED_ON_ARCH) DUMPRPL = $(TOOL_DIR)/dumprpl ######################################################################## # # Includes # ######################################################################## # -I adds path to include list # Don't use := assignment for INCLUDES since LINCLUDES or GINCLUDES # may be defined in the module later ifeq ($(CAFE_NO_SYSTEM_INCLUDES),TRUE) INCLUDES = -I. \ $(addprefix -I$(space),$(LINCLUDES)) \ $(addprefix -I$(space),$(GINCLUDES)) else INCLUDES = -I. \ -I$(INCLUDE_DIR_DOS) \ $(addprefix -I$(space),$(LINCLUDES)) \ $(addprefix -I$(space),$(GINCLUDES)) endif ######################################################################## # # Root path to file debugger will look at (avoid full paths) # ######################################################################## DBG_SOURCE_ROOT = -dbg_source_root $(shell cygpath -m $(SYSTEM_ROOT)) ######################################################################## # # Libraries (don't hide from command-line view) # ######################################################################## LIB_SEARCH_PATHS = $(LIB_DIR) # common debug related flags # _DEBUG is our symbol for saying "debug version". The absence of NDEBUG # can also be used by code. # NDEBUG is our symbol for saying "no debug version". The absence of _DEBUG # can also be used by code. ifdef DEBUG DEBUGFLAGS := -D_DEBUG else DEBUGFLAGS := -DNDEBUG endif SPECIFY_LCF_OPTION := MAKE_DEPEPENDENCY_OPTION := -MD # override the default DEPSUFFIX DEPSUFFIX := .dep DEPINPUTSUFFIX := .d # PPC RiscWatch boot flags (e.g., diable L1i, L1d, or L2). Default value is # 0=none. Note that bit 0 is used by debugger/gdb. This PPC_BS_FLAGS value # is or'ed with "-g" arg to caferun. PPC_RW_FLAGS := 0 # PPC Waikiki output flag, setting PPC_WAIKIKI_CONSOLE=-W # tells caferun that COS should send printf output to the Waikiki port PPC_WAIKIKI_CONSOLE := ######################################################################## # # OPTIMIZATION FLAGS # ######################################################################## # enable general optimizations # can override to something else # make CC_OPTIMIZATION_FLAGS=-Osize ifndef CC_OPTIMIZATION_FLAGS ifeq ($(BUILD_TYPE), FDEBUG) CC_OPTIMIZATION_FLAGS := -Onone else CC_OPTIMIZATION_FLAGS := -Ogeneral endif endif # start with blank for LD stuff LD_OPTIMIZATION_FLAGS := # cross-module inlining #LD_OPTIMIZATION_FLAGS := -OI # linker optimizations #LD_OPTIMIZATION_FLAGS += -Olink # linker optimizations #LD_OPTIMIZATION_FLAGS += -Owholeprogram # agressively pursue optimizations #LD_OPTIMIZATION_FLAGS += -Omax ######################################################################## # # DEFINES # ######################################################################## DEFINES := $(DEBUGFLAGS) # Platform Type DEFINES += -DNDEV=1 -DCAFE=2 DEFINES += -DPLATFORM=CAFE ifdef EPPC DEFINES += -DEPPC endif # Don't use := assignment below (especially for LDFLAGS) # Flag to defeat cos security ifeq ($(COS_SECURITY_ENABLED), FALSE) DEFINES += -DCOS_SECURITY_ENABLED=0 else DEFINES += -DCOS_SECURITY_ENABLED=1 endif # Enabling of debug startup to allow one to JTAG debug kernel startup ifeq ($(IOS_DEBUG_STARTUP), TRUE) DEFINES += -DIOS_DEBUG_STARTUP_STATE=TRUE else DEFINES += -DIOS_DEBUG_STARTUP_STATE=FALSE endif ######################################################################## # # FLAGS # ######################################################################## ifdef EXCEPTIONS_ON CCEXCEPTIONS := --exceptions else CCEXCEPTIONS := --no_exceptions endif ifdef IMPORT_TID EMULATION := -t$(IMPORT_TID) endif ifdef CAFE_SDK CCFLAGS_DEBUG := else CCFLAGS_DEBUG := -G ifdef DWARFDEBUG CCFLAGS_DEBUG += -dual_debug endif endif ifeq ($(KERNEL),TRUE) # Kernel uses GCC-mode which is more permissive than C99, but no C++ DUAL_FLAGS = -cpu=espresso -sda=none RELPROG_CAFE = else ifeq ($(LOADER),TRUE) DUAL_FLAGS = -cpu=espresso -sda=none RELPROG_CAFE = else ifeq ($(KDEBUG),TRUE) DUAL_FLAGS = -cpu=espresso -sda=none RELPROG_CAFE = else DUAL_FLAGS = $(CCEXCEPTIONS) --g++ --link_once_templates -cpu=espresso RELPROG_CAFE = -relprog_cafe ifeq ($(LIB),TRUE) DUAL_FLAGS += -sda=none else ifneq ($(RPLNAME),) DUAL_FLAGS += -sda=none else # default for RPX is to not build with small data sections # define RPX_CONFIG_SDA in your RPX makefile to a custom setting for sda ifneq ($(RPX_CONFIG_SDA),) DUAL_FLAGS += $(RPX_CONFIG_SDA) else DUAL_FLAGS += -sda=none endif endif endif endif endif endif DUAL_FLAGS += $(DBG_SOURCE_ROOT) $(CC_OPTIMIZATION_FLAGS) $(CCFLAGS_DEBUG) ifeq ($(KERNEL),TRUE) # All Kernel modules must treat warnings as errors CCFLAGS_NO_DASH_C = $(DEFINES) $(CCONLYFLAGS) -no_ansi_alias --quit_after_warnings --no_commons -gcc -kanji=shiftjis -only_explicit_reg_use $(DUAL_FLAGS) CCFLAGS = $(CCFLAGS_NO_DASH_C) -c else ifeq ($(LOADER),TRUE) CCFLAGS = $(DEFINES) $(CCONLYFLAGS) -no_ansi_alias --quit_after_warnings -c --no_commons -gcc -kanji=shiftjis -only_explicit_reg_use $(DUAL_FLAGS) else ifeq ($(KDEBUG),TRUE) CCFLAGS = $(DEFINES) $(CCONLYFLAGS) -no_ansi_alias --quit_after_warnings -c --no_commons -gcc -kanji=shiftjis -only_explicit_reg_use $(DUAL_FLAGS) else CCFLAGS = $(DEFINES) $(CCONLYFLAGS) -c --no_commons -c99 -kanji=shiftjis -only_explicit_reg_use $(DUAL_FLAGS) CCFLAGS += --quit_after_warnings endif endif endif ASFLAGS = $(DEFINES) -cpu=espresso $(DUAL_FLAGS) -D_ASSEMBLER -U__cplusplus -preprocess_assembly_files ARFLAGS = -archive ONE_LD_PATH = -L$(space)$(one_path_arg) LDFLAGS = \ $(LD_OPTIMIZATION_FLAGS) \ $(RELPROG_CAFE) \ -lnk=-nosegments_always_executable -nostartfile $(DUAL_FLAGS) \ $(foreach one_path_arg, $(LIB_SEARCH_PATHS), $(ONE_LD_PATH)) \ -Mn -Mu -map=$(empty)$(BIN_DIR)/$(basename $(notdir $@)).map ######################################################################## # # LCF_FILE # ######################################################################## LCF_FILE ?= $(INCLUDE_DIR)/cafe/eppc.Cafe.ld RPL_LCF_FILE ?= $(INCLUDE_DIR)/cafe/eppc.Cafe.rpl.ld ######################################################################## # # MACRO_RUN # ######################################################################## # Command used to execute a binary with cos # RUN_BINARY is defined by modulerules as the path to the executable. define MACRO_RUN caferun $(MACRO_RUN_OPTIONS) $(EMULATION) $(OS_VER_OPTION) $(PPC_WAIKIKI_CONSOLE) -w $(PPC_RW_FLAGS) $(DEBUG_RUN) $(USER_RUN) $(MULTI_DEBUG_BINARY) $(RUN_BINARY) $(RUN_ARGS) endef ######################################################################## # # FIND MACROS # ######################################################################## # NOTE: It's important that the results of these macros be assigned to # a variable using the := assignment for optimization. # Finds all c source files at the module directory define FIND_C_SRCS $(wildcard *.c) endef # Finds all c source files recursively within the module define FIND_C_SRCS_RECURSIVE $(subst ./,,$(shell find -iname "*.c")) endef # Finds all cpp source files at the module directory define FIND_CPP_SRCS $(wildcard *.cpp) endef # Finds all cpp source files recursively within the module define FIND_CPP_SRCS_RECURSIVE $(subst ./,,$(shell find -iname "*.cpp")) endef # Finds all asm source files at the module directory define FIND_ASM_SRCS $(wildcard *.s) endef # Finds all asm source files recursively within the module define FIND_ASM_SRCS_RECURSIVE $(subst ./,,$(shell find -iname "*.s")) endef