diff --git a/build/buildtools/commondefs b/build/buildtools/commondefs new file mode 100644 index 00000000..f8ea3c53 --- /dev/null +++ b/build/buildtools/commondefs @@ -0,0 +1,44 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2007 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. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_IPL_COMMONDEFS_ +TWL_IPL_COMMONDEFS_ = TRUE + +#FIRM_USE_PRODUCT_KEYS = TRUE +#SYSM_BUILD_FOR_DEBUGGER = TRUE +SYSM_DEV_WHITELIST_CHECK_SKIP ?= TRUE + +ifeq ($(TARGET_FIRM),SYSTEMMENU) +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs.sysmenu +else +include $(TWL_IPL_RED_ROOT)/build/buildtools/commondefs.firm +endif + +ifdef FIRM_USE_PRODUCT_KEYS +MACRO_FLAGS += -DFIRM_USE_PRODUCT_KEYS=$(FIRM_USE_PRODUCT_KEYS) +endif + +ifneq ($(TWL_IPL_RED_PRIVATE_ROOT),) +TWL_KEYSDIR := $(TWL_IPL_RED_PRIVATE_ROOT)/keys +TWL_IPL_RED_PRIVATE_TOOLSDIR = $(call eupath,$(TWL_IPL_RED_PRIVATE_ROOT)/tools) +endif + +MAKEROM_FLAGS += -s + +#---------------------------------------------------------------------------- +endif # TWL_IPL_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/build/buildtools/commondefs.firm b/build/buildtools/commondefs.firm new file mode 100644 index 00000000..894e01db --- /dev/null +++ b/build/buildtools/commondefs.firm @@ -0,0 +1,137 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2007 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. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWLFIRM_COMMONDEFS_ +TWLFIRM_COMMONDEFS_ = TRUE + +EMPTY ?= +SPACE ?= $(EMPTY) $(EMPTY) + +TARGET_BIN ?= $(TARGET_FIRM_BIN) + +# +# change default variables for product +# +override TARGET_PLATFORM := TWL +override TWL_ARCHGEN := LIMITED +override TWL_CODEGEN := ARM +override TWL_MEMSIZE := 16M + +#---------------------------------------------------------------------------- +### TWL-commondefs +# +include $(TWLSDK_ROOT)/build/buildtools/commondefs +include $(TWLSDK_ROOT)/build/libraries/reboot/commondefs.reboot + +#---------------------------------------------------------------------------- +# TWL-FIRM path settings +# + +FIRM_ROOT := $(call eupath,$(TWL_IPL_RED_ROOT)) +FIRM_BUILDTOOLSDIR := $(FIRM_ROOT)/build/buildtools +FIRM_BUILDSETUPDIR := $(FIRM_ROOT)/build/buildsetup +FIRM_INCDIR := $(FIRM_ROOT)/include +FIRM_TOOLSDIR := $(FIRM_ROOT)/tools +FIRM_COMPONENTSDIR := $(FIRM_ROOT)/components +FIRM_ADDINS ?= $(FIRM_ROOT)/add-ins + +FIRM_LIBDIR = $(FIRM_ROOT)/lib/$(TWL_LIBTYPE) +FIRM_LIBSUFFIX = .firm$(ARCHGEN_TYPE)$(CODEGEN_ARCH) + +FIRM_SPECDIR := $(FIRM_INCDIR)/firm/specfiles +FIRM_LSFARCH = $(TWL_LIBARCH)-FIRM +FIRM_LCFARCH = $(FIRM_LSFARCH) +DEFAULT_FIRM_LCFILE = $(FIRM_SPECDIR)/$(FIRM_LCFARCH).lcf +DEFAULT_FIRM_LCFILE_TEMPLATE = $(FIRM_SPECDIR)/$(FIRM_LCFARCH).lcf.template +DEFAULT_FIRM_LCFILE_SPEC = $(FIRM_SPECDIR)/$(FIRM_LSFARCH).lsf +DEFAULT_FIRM_ROM_SPEC = $(FIRM_SPECDIR)/ROM-$(TWL_PLATFORM)-FIRM.rsf + +### Compiler & Linker settings + +# replace NitroSDK +DEFAULT_LCFILE_TEMPLATE = $(DEFAULT_FIRM_LCFILE_TEMPLATE) +DEFAULT_LCFILE_SPEC = $(DEFAULT_FIRM_LCFILE_SPEC) +DEFAULT_ROM_SPEC = $(DEFAULT_FIRM_ROM_SPEC) + +LDEPENDS_LCF += $(FIRM_BUILDTOOLSDIR)/commondefs +LDEPENDS_RES += $(FIRM_BUILDTOOLSDIR)/commondefs + +### SDK Library settings + +ifeq ($(CODEGEN_PROC),ARM9) + +FIRM_LIBS_BASE ?= \ + libos \ + libpxi \ + libfs \ + libfatfs \ + libmi \ + +else # ($(CODEGEN_PROC),ARM7) + +FIRM_LIBS_BASE ?= \ + libos_sp \ + libpxi_sp \ + libfs_sp \ + libaes_sp \ + libpm_sp \ + libnvram_sp \ + +endif + +FIRM_LIBS ?= $(addsuffix $(FIRM_LIBSUFFIX).a,$(FIRM_LIBS_BASE)) + +#---------------------------------------------------------------------------- +# MY BUILD TOOLS +# +MAKENORFIRM = $(TWL_IPL_RED_PRIVATE_TOOLSDIR)/bin/makenorfirm.exe +MAKENANDFIRM = $(TWL_IPL_RED_PRIVATE_TOOLSDIR)/bin/makenandfirm.exe +MAKEGCDFIRM = $(TWL_IPL_RED_PRIVATE_TOOLSDIR)/bin/makegcdfirm.exe +NTEXCONV := $(ROOT)/tools/bin/ntexconv.exe +MAKEBANNER := $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +MAKEFIRM_FLAGS ?= + +#---------------------------------------------------------------------------- + +### Global Library resettings + +GINCLUDES := $(FIRM_INCDIR) $(GINCLUDES) +GLIBRARY_DIRS := $(FIRM_LIBDIR) $(GLIBRARY_DIRS) +GLIBRARIES := $(FIRM_LIBS) $(GLIBRARIES) + +#---------------------------------------------------------------------------- +# TWLFIRM_INSTALL_ROOT +# + +ifdef TWLFIRM_INSTALL_ROOT +TWLFIRM_INSTALL_ROOT_ := $(TWLFIRM_INSTALL_ROOT) +else +TWLFIRM_INSTALL_ROOT_ := $(TWL_IPL_RED_ROOT) +endif + +FIRM_INSTALL_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWLFIRM_INSTALL_ROOT_))) +FIRM_INSTALL_INCDIR := $(FIRM_INSTALL_ROOT)/include +FIRM_INSTALL_TOOLSDIR := $(FIRM_INSTALL_ROOT)/tools +FIRM_INSTALL_LIBDIR = $(FIRM_INSTALL_ROOT)/lib/$(TWL_LIBTYPE) +FIRM_INSTALL_PROMDIR := $(FIRM_INSTALL_TOOLSDIR)/prom +FIRM_INSTALL_COMPONENTSDIR := $(FIRM_INSTALL_ROOT)/components +FIRM_INSTALL_ADDINS := $(FIRM_INSTALL_ROOT)/add-ins + +#---------------------------------------------------------------------------- +endif # TWLFIRM_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/build/buildtools/commondefs.sysmenu b/build/buildtools/commondefs.sysmenu new file mode 100644 index 00000000..137a1bde --- /dev/null +++ b/build/buildtools/commondefs.sysmenu @@ -0,0 +1,119 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2007 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. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_SYSMENU_COMMONDEFS_ +TWL_SYSMENU_COMMONDEFS_ = TRUE + +NITRO_NO_STD_PCHDR = TRUE # プリコンパイルヘッダ抑止 + +EMPTY ?= +SPACE ?= $(EMPTY) $(EMPTY) + +define toLower +$(shell echo $(1) | tr '[A-Z]' '[a-z]' ) +endef # toLower + +# デフォルトのCODEGENを指定(他のcommondefsの前で指定しておかないとダメ) +TARGET_CODEGEN ?= THUMB + +#---------------------------------------------------------------------------- +### TWL-commondefs +# +#include $(TWLSDK_ROOT)/build/buildtools/commondefs +include $(NITROSYSTEM_ROOT)/build/buildtools/commondefs + +# TwlSDK の TWLSYSTEM_* -> NITROSYSTEM_* 変更暫定対策 +# NitroSystemパッチが更新されれば不要のはず +NITROSYSTEM_INCDIR ?= $(TWLSYSTEM_INCDIR) +NITROSYSTEM_LIBDIR ?= $(TWLSYSTEM_LIBDIR) +NITROSYSTEM_LIBS ?= $(TWLSYSTEM_LIBS) + +#---------------------------------------------------------------------------- +# TWL-SYSTEM-MENU path settings +# + +#SYSMENU_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWL_IPL_RED_ROOT))) +SYSMENU_ROOT := $(call eupath,$(TWL_IPL_RED_ROOT)) + +SYSMENU_BUILDTOOLSDIR := $(SYSMENU_ROOT)/build/buildtools +SYSMENU_INCDIR := $(SYSMENU_ROOT)/include \ + $(ROOT)/build/libraries/spi/ARM9/include \ + $(ROOT)/build/libraries/os/common/include \ + $(ROOT)/build/libraries/mb/common/include +SYSMENU_TOOLSDIR := $(SYSMENU_ROOT)/tools +SYSMENU_COMPONENTSDIR := $(SYSMENU_ROOT)/components + +SYSMENU_ROM_HEADER_DIR = $(SYSMENU_ROOT)/RomHeader + + +LDEPENDS_LCF += $(SYSMENU_BUILDTOOLSDIR)/commondefs.sysmenu +LDEPENDS_RES += $(SYSMENU_BUILDTOOLSDIR)/commondefs.sysmenu + + +ifneq ($(TARGET_TAD),) +TARGETS += $(TARGET_TAD) +endif + +#---------------------------------------------------------------------------- +### SYSTEM_MENU Library settings + +SYSMENU_LIBDIR := $(SYSMENU_ROOT)/lib/$(TWL_LIBTYPE) + +#---------------------------------------------------------------------------- +# MY BUILD TOOLS +# +OPENSSL := $(SYSMENU_TOOLSDIR)/openssl/openssl.exe +NTEXCONV := $(ROOT)/tools/bin/ntexconv.exe +MAKEBANNER := $(TWL_TOOLSDIR)/bin/makebanner.TWL.exe + +MAKESYSMENU_RSA_PRVKEY ?= $(SYSMENU_TOOLSDIR)/openssl/rsa_private.der +MAKESYSMENU_RSA_PUBKEY ?= $(SYSMENU_TOOLSDIR)/openssl/rsa_public.der + +#---------------------------------------------------------------------------- + +### Global Library resettings + +GINCLUDES := $(SYSMENU_INCDIR) $(GINCLUDES) +ifneq ($(ES_ROOT),) +GINCLUDES += $(ES_ROOT)/twl/include +endif +GLIBRARY_DIRS := $(SYSMENU_LIBDIR) $(GLIBRARY_DIRS) + +#---------------------------------------------------------------------------- +# TWLSYSMENU_INSTALL_ROOT +# +SYSMENU_INSTALL_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(TWL_IPL_RED_ROOT))) +SYSMENU_INSTALL_INCDIR := $(SYSMENU_INSTALL_ROOT)/include +SYSMENU_INSTALL_TOOLSDIR := $(SYSMENU_INSTALL_ROOT)/tools +SYSMENU_INSTALL_LIBDIR := $(SYSMENU_INSTALL_ROOT)/lib/$(TWL_LIBTYPE) +SYSMENU_INSTALL_COMPONENTSDIR := $(SYSMENU_INSTALL_ROOT)/components +SDK_NMENU_DATADIR = $(ROOT)/build/tools/TwlNMenu/data + +#---------------------------------------------------------------------------- + +ifeq ($(SYSM_BUILD_FOR_DEBUGGER),TRUE) +MACRO_FLAGS += -DSYSM_BUILD_FOR_DEBUGGER +endif + +#---------------------------------------------------------------------------- +# ARM7コンポーネントにARMビルドを使用する + +TWL_BUILDTYPE_ARM7 := $(subst $(CODEGEN_ARCH),,$(TWL_BUILDTYPE_ARM7)) + +#---------------------------------------------------------------------------- +endif # TWL_SYSMENU_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/build/buildtools/modulerules b/build/buildtools/modulerules new file mode 100644 index 00000000..3d246a4a --- /dev/null +++ b/build/buildtools/modulerules @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2007 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. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_IPL_MODULERULES_ + +#---------------------------------------------------------------------------- +### TWL-modulerules +# + +ifeq ($(TARGET_FIRM),SYSTEMMENU) +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules.sysmenu +else +include $(TWL_IPL_RED_ROOT)/build/buildtools/modulerules.firm +endif + + +#---------------------------------------------------------------------------- +TWL_IPL_MODULERULES_ = TRUE +endif # TWL_IPL_MODULERULES_ +#----- End of modulerules ----- diff --git a/build/buildtools/modulerules.firm b/build/buildtools/modulerules.firm new file mode 100644 index 00000000..1014ed4d --- /dev/null +++ b/build/buildtools/modulerules.firm @@ -0,0 +1,92 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlFirm - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2007 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. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWLFIRM_MODULERULES_ + +#---------------------------------------------------------------------------- +### TWL-modulerules +# +include $(TWLSDK_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +# +# MAKEROM for IS-TWL-DEBUGGER +# +ifeq ($(filter $(MAKEROM_FLAGS),-F),) +MAKEROM_FLAGS += -F +endif + +# +# MAKENORFIRM / MAKENANDFIRM / MAKEGCDFIRM +# +MAKEFIRM_ARM7 ?= ARM7/bin/$(TWL_BUILDTYPE_ARM7)/main.tef +MAKEFIRM_ARM9 ?= ARM9/bin/$(TWL_BUILDTYPE_ARM9)/main.tef +MAKEFIRM_RSA_PRVKEY ?= $(TWL_KEYSDIR)/rsa/pubkey_nor.der + +MAKEFIRM_ARM7_M := $(call empath,$(MAKEFIRM_ARM7)) +MAKEFIRM_ARM9_M := $(call empath,$(MAKEFIRM_ARM9)) +MAKEFIRM_RSA_PRVKEY_M := $(call empath,$(MAKEFIRM_RSA_PRVKEY)) + +MAKEFIRM_DEFS += -DFIRM_ROOT='$(FIRM_ROOT)' \ + -DMAKEFIRM_ARM9='$(basename $(MAKEFIRM_ARM9_M))' \ + -DMAKEFIRM_ARM7='$(basename $(MAKEFIRM_ARM7_M))' \ + -DMAKEFIRM_RSA_PRVKEY='$(MAKEFIRM_RSA_PRVKEY_M)' \ + +ifdef TWL_KEYSDIR +ifeq ($(TWL_IPL_RED_PRIVATE_ROOT),) +MAKEGCDFIRM_FLAGS += -t'$(TWLSDK_ROOT)/tools/bin/rom_header.template.sbin' +else +MAKEGCDFIRM_FLAGS += -t'$(TWL_KEYSDIR)/blowfish/gcdfirm_header_twlj.template.sbin' +endif +else +MAKEGCDFIRM_FLAGS += -t'$(FIRM_ROOT)/build/tools/makegcdfirm/gcdfirm_header_twlj.template.sbin' +endif + +FIRM_SDEPENDS_BIN := \ + $(call eupath,$(MAKEFIRM_ARM9)) \ + $(call eupath,$(MAKEFIRM_ARM7)) + + +.PHONY: firmtop firmlib + +firmtop: + @$(MAKE) -C $(TWL_IPL_RED_ROOT)/build + +firmlib: + @$(MAKE) -C $(TWL_IPL_RED_ROOT)/build/libraries + +# .nor +$(BINDIR)/%.nor: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKENORFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .nand +$(BINDIR)/%.nand: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKENANDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .gcd +$(BINDIR)/%.gcd: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKEGCDFIRM) $(MAKEFIRM_FLAGS) $(MAKEGCDFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .rbin +$(BINDIR)/$(TARGET_BIN_BASENAME).rbin: $(OBJS) + objcopy -I elf32-little -O binary $< $@ + +#---------------------------------------------------------------------------- +TWLFIRM_MODULERULES_ = TRUE +endif # TWLFIRM_MODULERULES_ +#----- End of modulerules ----- diff --git a/build/buildtools/modulerules.sysmenu b/build/buildtools/modulerules.sysmenu new file mode 100644 index 00000000..9ee0a948 --- /dev/null +++ b/build/buildtools/modulerules.sysmenu @@ -0,0 +1,34 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlIPL - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2007 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. +# +# $Date:: 2007-09-06$ +# $Rev$ +# $Author$ +#---------------------------------------------------------------------------- +ifndef TWL_SYSMENU_MODULERULES_ + +#---------------------------------------------------------------------------- +### TWL-modulerules +# +#include $(TWLSDK_ROOT)/build/buildtools/modulerules +include $(NITROSYSTEM_ROOT)/build/buildtools/modulerules + + +# .rbin +$(BINDIR)/$(TARGET_BIN_BASENAME).rbin: $(OBJS) + objcopy -I elf32-little -O binary $< $@ + +#---------------------------------------------------------------------------- +TWL_SYSMENU_MODULERULES_ = TRUE +endif # TWL_SYSMENU_MODULERULES_ +#----- End of modulerules -----