1############################################################################### 2# vim:noexpandtab 3# previous line for VI users to keep the tabs (important for make) 4# 5# Global Green Hills PPC definitions for build system 6# 7# Copyright (C) Nintendo. All rights reserved. 8# 9# These coded instructions, statements, and computer programs contain 10# proprietary information of Nintendo of America Inc. and/or Nintendo 11# Company Ltd., and are protected by Federal copyright law. They may 12# not be disclosed to third parties or copied or duplicated in any form, 13# in whole or in part, without the prior written consent of Nintendo. 14# 15############################################################################### 16 17# NOTE: Modules should include commondefs.mk before including this file 18# Do a quick check for safety 19ifndef INCLUDE_DIR 20 $(error error: Please include commondefs.mk before including this file in $(CURDIR)/makefile) 21endif 22 23ifneq ($(TOOLCHAIN),ghs) 24 $(error error: TOOLCHAIN not set to ghs but USE_GHS set to 1. ) 25endif 26 27# GHS toolchain requires TMP environment variable or cryptic permissions errors can occur 28ifndef TMP 29 $(error error: Please define TMP environment variable. For example, remove "unset TMP" in ~/.bashrc) 30endif 31 32ifndef CAFE_GHS_VERSION 33 $(error error: CAFE_GHS_VERSION not set. cafe.bat sets this environment variable.) 34endif 35 36include $(BUILD_MAKE_PATH)/ghs_version_check.mk 37 38######################################################################## 39# 40# Global libraries 41# 42######################################################################## 43 44# IMPORTANT: ONLY ADD LIBRARIES HERE IF *ALL* BINARIES ARE REQUIRED TO LINK! 45# Module's makefile can also specify libraries to link with MODULE_LIBNAMES 46 47COMMON_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 48 49COMMON_DYNAMIC_LIBS = $(addprefix $(LIB_DIR)/,$(addsuffix $(LIBSUFFIX), $(COMMON_DYNAMIC_LIBNAMES))) 50 51COMMON_LIBNAMES := pad gfd mtx demo gx2ut nn_util nn_crypto 52COMMON_LIBS = $(addprefix $(LIB_DIR)/,$(addsuffix $(LIBSUFFIX), $(COMMON_LIBNAMES))) 53 54######################################################################## 55# 56# Switches for modulerules.mk 57# 58######################################################################## 59 60# tell modulerules.mk to convert paths to mixed-style path 61COMPILER_REQUIRES_DOS_ARGUMENTS := TRUE 62 63# COS builds pre-process assembler 64# ASM_PREPROCESS := TRUE 65# GHS uses C compiler to process assembler the ASM_PREPROCESS step is not needed 66 67# OBJ_SEARCH_PATH is defined later to clean up paths in the command-line 68 69######################################################################## 70# 71# Green Hills Multi 72# 73######################################################################## 74 75CC := $(GHS_ROOT)/ccppc.exe 76CXX := $(GHS_ROOT)/cxppc.exe 77AS := $(GHS_ROOT)/ccppc.exe 78LD := $(GHS_ROOT)/cxppc.exe 79AR := $(GHS_ROOT)/ccppc.exe 80LIBRARIAN := $(GHS_ROOT)/ax.exe 81 82######################################################################## 83# 84# Nintendo RPL tools 85# 86######################################################################## 87PREPRPL = $(TOOL_DIR)/preprpl$(TOOL_USED_ON_ARCH) 88MAKERPL = $(TOOL_DIR)/makerpl$(TOOL_USED_ON_ARCH) 89DUMPRPL = $(TOOL_DIR)/dumprpl 90 91######################################################################## 92# 93# Includes 94# 95######################################################################## 96 97# -I adds path to include list 98# Don't use := assignment for INCLUDES since LINCLUDES or GINCLUDES 99# may be defined in the module later 100 101ifeq ($(CAFE_NO_SYSTEM_INCLUDES),TRUE) 102INCLUDES = -I. \ 103 $(addprefix -I$(space),$(LINCLUDES)) \ 104 $(addprefix -I$(space),$(GINCLUDES)) 105else 106INCLUDES = -I. \ 107 -I$(INCLUDE_DIR_DOS) \ 108 $(addprefix -I$(space),$(LINCLUDES)) \ 109 $(addprefix -I$(space),$(GINCLUDES)) 110endif 111 112 113######################################################################## 114# 115# Root path to file debugger will look at (avoid full paths) 116# 117######################################################################## 118 119DBG_SOURCE_ROOT = -dbg_source_root $(shell cygpath -m $(SYSTEM_ROOT)) 120 121######################################################################## 122# 123# Libraries (don't hide from command-line view) 124# 125######################################################################## 126 127LIB_SEARCH_PATHS = $(LIB_DIR) 128 129# common debug related flags 130# _DEBUG is our symbol for saying "debug version". The absence of NDEBUG 131# can also be used by code. 132# NDEBUG is our symbol for saying "no debug version". The absence of _DEBUG 133# can also be used by code. 134ifdef DEBUG 135 DEBUGFLAGS := -D_DEBUG 136else 137 DEBUGFLAGS := -DNDEBUG 138endif 139 140SPECIFY_LCF_OPTION := 141 142MAKE_DEPEPENDENCY_OPTION := -MD 143# override the default DEPSUFFIX 144DEPSUFFIX := .dep 145DEPINPUTSUFFIX := .d 146 147# PPC RiscWatch boot flags (e.g., diable L1i, L1d, or L2). Default value is 148# 0=none. Note that bit 0 is used by debugger/gdb. This PPC_BS_FLAGS value 149# is or'ed with "-g" arg to caferun. 150PPC_RW_FLAGS := 0 151 152# PPC Waikiki output flag, setting PPC_WAIKIKI_CONSOLE=-W 153# tells caferun that COS should send printf output to the Waikiki port 154PPC_WAIKIKI_CONSOLE := 155 156######################################################################## 157# 158# OPTIMIZATION FLAGS 159# 160######################################################################## 161 162# enable general optimizations 163# can override to something else 164# make CC_OPTIMIZATION_FLAGS=-Osize 165 166ifndef CC_OPTIMIZATION_FLAGS 167ifeq ($(BUILD_TYPE), FDEBUG) 168 CC_OPTIMIZATION_FLAGS := -Onone 169else 170 CC_OPTIMIZATION_FLAGS := -Ogeneral 171endif 172endif 173 174# start with blank for LD stuff 175LD_OPTIMIZATION_FLAGS := 176 177# cross-module inlining 178#LD_OPTIMIZATION_FLAGS := -OI 179 180# linker optimizations 181#LD_OPTIMIZATION_FLAGS += -Olink 182 183# linker optimizations 184#LD_OPTIMIZATION_FLAGS += -Owholeprogram 185 186# agressively pursue optimizations 187#LD_OPTIMIZATION_FLAGS += -Omax 188 189######################################################################## 190# 191# DEFINES 192# 193######################################################################## 194 195DEFINES := $(DEBUGFLAGS) 196 197# Platform Type 198DEFINES += -DNDEV=1 -DCAFE=2 199DEFINES += -DPLATFORM=CAFE 200 201ifdef EPPC 202 DEFINES += -DEPPC 203endif 204 205# Don't use := assignment below (especially for LDFLAGS) 206 207# Flag to defeat cos security 208ifeq ($(COS_SECURITY_ENABLED), FALSE) 209 DEFINES += -DCOS_SECURITY_ENABLED=0 210else 211 DEFINES += -DCOS_SECURITY_ENABLED=1 212endif 213 214# Enabling of debug startup to allow one to JTAG debug kernel startup 215ifeq ($(IOS_DEBUG_STARTUP), TRUE) 216 DEFINES += -DIOS_DEBUG_STARTUP_STATE=TRUE 217else 218 DEFINES += -DIOS_DEBUG_STARTUP_STATE=FALSE 219endif 220 221######################################################################## 222# 223# FLAGS 224# 225######################################################################## 226 227ifdef EXCEPTIONS_ON 228 CCEXCEPTIONS := --exceptions 229else 230 CCEXCEPTIONS := --no_exceptions 231endif 232 233ifdef IMPORT_TID 234 EMULATION := -t$(IMPORT_TID) 235endif 236 237ifdef CAFE_SDK 238 CCFLAGS_DEBUG := 239else 240CCFLAGS_DEBUG := -G 241ifdef DWARFDEBUG 242CCFLAGS_DEBUG += -dual_debug 243endif 244endif 245 246ifeq ($(KERNEL),TRUE) 247# Kernel uses GCC-mode which is more permissive than C99, but no C++ 248 DUAL_FLAGS = -cpu=espresso -sda=none 249 RELPROG_CAFE = 250else 251 ifeq ($(LOADER),TRUE) 252 DUAL_FLAGS = -cpu=espresso -sda=none 253 RELPROG_CAFE = 254 else 255 ifeq ($(KDEBUG),TRUE) 256 DUAL_FLAGS = -cpu=espresso -sda=none 257 RELPROG_CAFE = 258 else 259 DUAL_FLAGS = $(CCEXCEPTIONS) --g++ --link_once_templates -cpu=espresso 260 RELPROG_CAFE = -relprog_cafe 261 ifeq ($(LIB),TRUE) 262 DUAL_FLAGS += -sda=none 263 else 264 ifneq ($(RPLNAME),) 265 DUAL_FLAGS += -sda=none 266 else 267 # default for RPX is to not build with small data sections 268 # define RPX_CONFIG_SDA in your RPX makefile to a custom setting for sda 269 ifneq ($(RPX_CONFIG_SDA),) 270 DUAL_FLAGS += $(RPX_CONFIG_SDA) 271 else 272 DUAL_FLAGS += -sda=none 273 endif 274 endif 275 endif 276 endif 277 endif 278endif 279 280DUAL_FLAGS += $(DBG_SOURCE_ROOT) $(CC_OPTIMIZATION_FLAGS) $(CCFLAGS_DEBUG) 281 282ifeq ($(KERNEL),TRUE) 283 284# All Kernel modules must treat warnings as errors 285 286CCFLAGS_NO_DASH_C = $(DEFINES) $(CCONLYFLAGS) -no_ansi_alias --quit_after_warnings --no_commons -gcc -kanji=shiftjis -only_explicit_reg_use $(DUAL_FLAGS) 287CCFLAGS = $(CCFLAGS_NO_DASH_C) -c 288else 289ifeq ($(LOADER),TRUE) 290CCFLAGS = $(DEFINES) $(CCONLYFLAGS) -no_ansi_alias --quit_after_warnings -c --no_commons -gcc -kanji=shiftjis -only_explicit_reg_use $(DUAL_FLAGS) 291else 292ifeq ($(KDEBUG),TRUE) 293CCFLAGS = $(DEFINES) $(CCONLYFLAGS) -no_ansi_alias --quit_after_warnings -c --no_commons -gcc -kanji=shiftjis -only_explicit_reg_use $(DUAL_FLAGS) 294else 295CCFLAGS = $(DEFINES) $(CCONLYFLAGS) -c --no_commons -c99 -kanji=shiftjis -only_explicit_reg_use $(DUAL_FLAGS) 296CCFLAGS += --quit_after_warnings 297endif 298endif 299endif 300 301ASFLAGS = $(DEFINES) -cpu=espresso $(DUAL_FLAGS) -D_ASSEMBLER -U__cplusplus -preprocess_assembly_files 302ARFLAGS = -archive 303 304ONE_LD_PATH = -L$(space)$(one_path_arg) 305LDFLAGS = \ 306 $(LD_OPTIMIZATION_FLAGS) \ 307 $(RELPROG_CAFE) \ 308 -lnk=-nosegments_always_executable -nostartfile $(DUAL_FLAGS) \ 309 $(foreach one_path_arg, $(LIB_SEARCH_PATHS), $(ONE_LD_PATH)) \ 310 -Mn -Mu -map=$(empty)$(BIN_DIR)/$(basename $(notdir $@)).map 311 312######################################################################## 313# 314# LCF_FILE 315# 316######################################################################## 317LCF_FILE ?= $(INCLUDE_DIR)/cafe/eppc.Cafe.ld 318RPL_LCF_FILE ?= $(INCLUDE_DIR)/cafe/eppc.Cafe.rpl.ld 319 320######################################################################## 321# 322# MACRO_RUN 323# 324######################################################################## 325 326# Command used to execute a binary with cos 327# RUN_BINARY is defined by modulerules as the path to the executable. 328define MACRO_RUN 329 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) 330endef 331 332######################################################################## 333# 334# FIND MACROS 335# 336######################################################################## 337 338# NOTE: It's important that the results of these macros be assigned to 339# a variable using the := assignment for optimization. 340 341# Finds all c source files at the module directory 342define FIND_C_SRCS 343 $(wildcard *.c) 344endef 345 346# Finds all c source files recursively within the module 347define FIND_C_SRCS_RECURSIVE 348 $(subst ./,,$(shell find -iname "*.c")) 349endef 350 351# Finds all cpp source files at the module directory 352define FIND_CPP_SRCS 353 $(wildcard *.cpp) 354endef 355 356# Finds all cpp source files recursively within the module 357define FIND_CPP_SRCS_RECURSIVE 358 $(subst ./,,$(shell find -iname "*.cpp")) 359endef 360 361# Finds all asm source files at the module directory 362define FIND_ASM_SRCS 363 $(wildcard *.s) 364endef 365 366# Finds all asm source files recursively within the module 367define FIND_ASM_SRCS_RECURSIVE 368 $(subst ./,,$(shell find -iname "*.s")) 369endef 370