###############################################################################
# vim:noexpandtab
#
# Global common 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.
#
###############################################################################
# This file contains common definitions that exist across the build
ifndef OS_SECURITY_LEVEL
OS_SECURITY_LEVEL = 0
endif
empty :=
space := $(empty) $(empty)
comma := ,
COMPILE_WARNINGS_AS_ERRORS := TRUE
CFLAGS := --Werror
_@=@
#
# Message handling, if $(_@) != @ don't print noisy messages
#
ifeq ($(_@), @)
MOD_RULES_PHASE=@echo -e "------------------------------------------------------------------\n" $(1)
MOD_RULES_STEP=@echo -e $(1)
else
MOD_RULES_PHASE=
MOD_RULES_STEP=
endif
###############################################################################
#
# Environment variables
#
# All environment variables use UNIX-style paths. Paths are converted to
# mixed mode where required.
#
###############################################################################
# Assumes these are already set properly as UNIX-style environment variables
#
# CAFE_ROOT - path to cafe tree
# ENV_BIN - path to environment tools
# PLATFORM - hardware name
###############################################################################
#
# Common constants
#
###############################################################################
SYSTEM_ROOT := $(CAFE_ROOT)/system
BUILD_ROOT := $(SYSTEM_ROOT)/src
INCLUDE_DIR := $(SYSTEM_ROOT)/include
INCLUDE_DIR_DOS := $(shell cygpath -m $(INCLUDE_DIR))
BIN_ROOT := $(SYSTEM_ROOT)/bin
LIB_ROOT := $(SYSTEM_ROOT)/lib
OBJ_ROOT := $(SYSTEM_ROOT)/obj
TOOL_DIR := $(BIN_ROOT)/tool
BUILDMAKE_ROOT := $(BUILD_ROOT)/build/make
###############################################################################
#
# choose tool desired architecture for tools that support 32 or 64 bits
#
###############################################################################
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
TOOL_USED_ON_ARCH := 64
else
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
# cygwin is lying to us
TOOL_USED_ON_ARCH := 64
else
TOOL_USED_ON_ARCH := 32
endif
endif
###############################################################################
#
# Base Paths for a module
#
# (should be called from current directory, or make -C
, not make -f)
#
###############################################################################
# CURDIR is set by makefile.
MODULE_DIR := $(CURDIR)
# Get the path from src.
# Remove the full path to src from the full path to module directory ignoring case
# Use semicolon as separator so don't think any character in CAFE_ROOT is a delimiter
#
# DONE - Replaced this call to the shell with an internal make command
# to do replacement. Do this to speed up the build
#
#MODULE_PATH_FROM_SRC ?= $(shell echo "$(MODULE_DIR)" | sed "s;\($(BUILD_ROOT)/\);;i")
MODULE_PATH_FROM_SRC ?= $(subst $(BUILD_ROOT)/,,$(MODULE_DIR))
###############################################################################
#
# BUILD_TYPE flag (FDEBUG, DEBUG, NDEBUG, OS_SECURITY_LEVEL)
#
###############################################################################
# For keeping backward compatibility
ifeq ($(NDEBUG), TRUE)
BUILD_TYPE := NDEBUG
endif
ifeq ($(NDEBUG), FALSE)
BUILD_TYPE := DEBUG
endif
ifneq ($(OS_SECURITY_LEVEL), 0)
BUILD_TYPE := OS_SECURITY_LEVEL
endif
###################################
# Default for any ppc modules
# - BUILD_TYPE : DEBUG
###################################
ifeq ($(NDEBUG), )
ifeq ($(BUILD_TYPE), )
BUILD_TYPE := DEBUG
endif
endif
###################################
# Default for any ppc modules
# - SUPPRESS_STRIP : FALSE
###################################
ifeq ($(SUPPRESS_STRIP), )
SUPPRESS_STRIP := FALSE
endif
###################################
# Override build for any iop modules
# - If BUILD_TYPE=DEBUG|NDEBUG|OS_SECURITY_LEVEL -> NDEBUG
# - If BUILD_TYPE=FDEBUG -> DEBUG
###################################
IS_IOP := $(patsubst iop%,STARTS_WITH_IOP,$(MODULE_PATH_FROM_SRC))
ifeq ($(IS_IOP), STARTS_WITH_IOP)
ifeq ($(BUILD_TYPE), FDEBUG)
override BUILD_TYPE := DEBUG
else
override BUILD_TYPE := NDEBUG
endif
endif
###################################
# FDEBUG
# - Defines : DEBUG
# - Opt Lib : off
# - Debug Info : generated
###################################
ifeq ($(BUILD_TYPE), FDEBUG)
DEBUG := TRUE
NDEBUG := FALSE
BUILD_TARGET := FDEBUG
else
###################################
# DEBUG
# - Defines : DEBUG
# - Opt Lib : on
# - Debug Info : stripped
###################################
ifeq ($(BUILD_TYPE), DEBUG)
DEBUG := TRUE
NDEBUG :=
BUILD_TARGET := DEBUG
else
###################################
# NDEBUG
# - Defines : NDEBUG
# - Opt Lib : on
# - Debug Info : stripped
###################################
ifeq ($(BUILD_TYPE), NDEBUG)
DEBUG :=
NDEBUG := TRUE
BUILD_TARGET := NDEBUG
else
###################################
# OS_SECURITY_LEVEL
# - Defines : NDEBUG
# - Opt Lib : on
# - Debug Info : stripped
###################################
ifeq ($(BUILD_TYPE), OS_SECURITY_LEVEL)
DEBUG :=
NDEBUG := TRUE
BUILD_TARGET := OS_SECURITY_LEVEL
else
$(error error: Unknown BUILD_TYPE. BUILD_TYPE should be OS_SECURITY_LEVEL, FDEBUG, DEBUG, or NDEBUG.)
endif
endif
endif
endif
###############################################################################
#
# Generic Paths relevant to a module
#
# (should be called from current directory, or make -C , not make -f)
#
###############################################################################
# Binaries and libraries for a specific platform
BIN_DIR_NO_TARGET := $(MODULE_DEPTH)/../bin/$(TOOLCHAIN)/$(PLATFORM)/$(MODULE_PATH_FROM_SRC)
LIB_DIR_NO_TARGET := $(LIB_ROOT)/$(TOOLCHAIN)/$(PLATFORM)
BIN_DIR := $(BIN_DIR_NO_TARGET)/$(BUILD_TARGET)
LIB_DIR := $(LIB_DIR_NO_TARGET)/$(BUILD_TARGET)
KERNELLIB_DIR := $(LIB_ROOT)/$(TOOLCHAIN)/$(PLATFORM)/kernel/$(BUILD_TARGET)
LOADERLIB_DIR := $(LIB_ROOT)/$(TOOLCHAIN)/$(PLATFORM)/loader/$(BUILD_TARGET)
KDEBUGLIB_DIR := $(LIB_ROOT)/$(TOOLCHAIN)/$(PLATFORM)/kdebug/$(BUILD_TARGET)
# Binaries and libraries for all platforms
BIN_DIR_ALL := $(BIN_ROOT)/all/$(MODULE_PATH_FROM_SRC)/$(BUILD_TARGET)
LIB_DIR_ALL := $(LIB_ROOT)/all/$(BUILD_TARGET)
# OBJ_DIR must be relative to match dependency file generation
# So don't use OBJ_ROOT (manually make sure these directories match paths)
# Don't forget that OBJ_SEARCH_PATH is separately defined in commondefs.cos.??.mk
OBJ_DIR := $(MODULE_DEPTH)/../obj/$(TOOLCHAIN)/$(PLATFORM)/$(MODULE_PATH_FROM_SRC)/$(BUILD_TARGET)
###############################################################################
#
# PLATFORM and TOOLCHAIN
#
###############################################################################
ifeq ($(TOOLCHAIN), ghs)
VALID_TOOLCHAIN := TRUE
endif
ifneq ($(VALID_TOOLCHAIN),TRUE)
$(error Please specify supported TOOLCHAIN environment variable)
endif
ifeq ($(PLATFORM), cafe)
EPPC := TRUE
VALID_PLATFORM := TRUE
endif
ifneq ($(VALID_PLATFORM),TRUE)
$(error Please specify supported PLATFORM environment variable)
endif
# Set parameters for the architecture target
GTX_OPTIONS += -gpu 2
GSH_OPTIONS += -gpu 2
########################################################################
#
# Suffixes
#
########################################################################
LIBSUFFIX := .a
OBJSUFFIX := .o
BINSUFFIX := .elf
RPLSUFFIX := .rpl
RPXSUFFIX := .rpx
LCFSUFFIX := .lcf
LSTSUFFIX := .lst
WADSUFFIX := .wad
MCHSUFFIX := .mch
LZ77SUFFIX := .lz7
DEPSUFFIX := .dep
###############################################################################
#
# MACROS
#
###############################################################################
MKDIRP := mkdir -p
# Usage: $(MACRO_INSTALL_FILE)
# Install file as read and execute-only,
# to prevent mistakes for modifying installed headers.
define MACRO_INSTALL_FILE
install -Dpv -m ugo=rx
endef
# Usage: $(MACRO_INSTALL_PREBUILTOBJ)
# Install object file and remove debug info references.
# Remove write permissions to prevent mistakes for modifying objects.
define MACRO_INSTALL_PREBUILTOBJ
install -Dpv -m ugo=rw $< $@
gstripdbg $(shell cygpath -m $@)
chmod a-w $@
endef
###############################################################################
#
# Other configuration settings
# This section is only for Nintendo internal use.
#
###############################################################################