diff --git a/trunk/Makefile b/trunk/Makefile new file mode 100644 index 0000000..781a92e --- /dev/null +++ b/trunk/Makefile @@ -0,0 +1,36 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrFirm - build +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +include $(CTRFIRM_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = \ +# build \ + +ifdef RVCT30BIN +SUBDIRS += \ + bootrom \ + +endif # RVCT30BIN + +#---------------------------------------------------------------------------- + +include $(CTRFIRM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/trunk/bootrom/Makefile b/trunk/bootrom/Makefile new file mode 100644 index 0000000..8690b91 --- /dev/null +++ b/trunk/bootrom/Makefile @@ -0,0 +1,30 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrBrom - build +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +include $(CTRBROM_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + build \ + +#---------------------------------------------------------------------------- + +include $(CTRBROM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/trunk/bootrom/build/Makefile b/trunk/bootrom/build/Makefile new file mode 100644 index 0000000..89d4170 --- /dev/null +++ b/trunk/bootrom/build/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrBrom - build +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +include $(CTRBROM_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + $(CTRFIRM_ROOT)/build/buildsetup \ + libraries \ + +#---------------------------------------------------------------------------- + +include $(CTRBROM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/trunk/bootrom/build/buildtools/commondefs b/trunk/bootrom/build/buildtools/commondefs new file mode 100644 index 0000000..a86807f --- /dev/null +++ b/trunk/bootrom/build/buildtools/commondefs @@ -0,0 +1,354 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrBrom - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- +ifndef BROMSDK_COMMONDEFS_ +BROMSDK_COMMONDEFS_ = TRUE + +CTR_NO_STD_PCHDR = TRUE # プリコンパイルヘッダ抑止 +USE_MY_RULE_BIN = TRUE + + +EMPTY ?= +SPACE ?= $(EMPTY) $(EMPTY) + +# +# SDK Major Version +# + +BROMSDK_VERSION_MAJOR ?= 0 + +# EXO_PLATFORM = [TEG/TS] +EXO_PLATFORM ?= $(BROM_PLATFORM) + +# +# CodeGen Target +# +# BROM_PLATFORM = [TEG/TS] +# BROM_MEMSIZE = [64M/128M] +# BROM_CODEGEN = [ARM/THUMB] +# BROM_PROC = [ARM11/ARM9] +# +# BROM_PROMGEN = [TRUE/FALSE] +# BROM_TARGET = [BROM/NORFIRM/NANDFIRM/GCDFIRM/APP] +# + +BROM_PLATFORM ?= TEG +BROM_MEMSIZE ?= 128M +BROM_CODEGEN ?= THUMB +BROM_PROC ?= ARM11 +BROM_TARGET ?= BROM + +# replace TwlSDK +CTR_PLATFORM = $(BROM_PLATFORM) +CTR_MEMSIZE = $(BROM_MEMSIZE) +CTR_CODEGEN = $(BROM_CODEGEN) +CTR_PROC = $(BROM_PROC) + +# replace NitroSDK +ifndef CODEGEN_PROC +CODEGEN_PROC := $(BROM_PROC) +endif + +ifeq ($(BROM_CODEGEN),ALL) +BROM_CODEGEN_ALL ?= TRUE +override BROM_CODEGEN = ARM +endif + +ifeq ($(BROM_CODEGEN),ARM) +BROM_CODEGEN_ARCH = +else # ($(BROM_CODEGEN),THUMB) +BROM_CODEGEN_ARCH = .thumb +endif + +# +# C Compiler type +# +# CTR_CCTYPE = [CW/SNC/RVCT] +# + +# replace NitroSDK +CTR_CCTYPE := RVCT + +# +# SDK build type +# +# one of [BROM_DEBUG/BROM_RELEASE/BROM_FINALROM] +# + +ifdef BROM_DEBUG +BROM_BUILD_TYPE ?= DEBUG +BROM_BUILD_DIR ?= Debug + +else +ifdef BROM_FINALROM +BROM_BUILD_TYPE ?= FINALROM +BROM_BUILD_DIR ?= Rom + +else # BROM_RELEASE (default) +BROM_BUILD_TYPE ?= RELEASE +BROM_BUILD_DIR ?= Release + +endif +endif + +# replace TwlSDK +CTR_BUILD_TYPE ?= $(BROM_BUILD_TYPE) +CTR_BUILD_DIR ?= $(BROM_BUILD_DIR) + + +# +# PMIC Revision +# + +BROM_PMIC_REV ?= 100 + +# replace TwlSDK +CTR_PMIC_REV ?= $(BROM_PMIC_REV) + + +# +# Debugger Type +# +# one of [ISD/KMC/ARM] +# + +BROM_DEBUGGER ?= KMC + +# replace TwlSDK +CTR_DEBUGGER ?= $(BROM_DEBUGGER) + + +#---------------------------------------------------------------------------- +# BROM-SDK path settings +# + +BROM_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(CTRBROM_ROOT))) +BROM_BUILDTOOLSDIR := $(BROM_ROOT)/build/buildtools +BROM_BUILDSETUPDIR := $(BROM_ROOT)/build/buildsetup +BROM_INCDIR := $(BROM_ROOT)/include +BROM_TOOLSDIR := $(BROM_ROOT)/tools +BROM_KEYSDIR := $(BROM_ROOT)/build/keys +BROM_COMPONENTSDIR := $(BROM_ROOT)/components +BROM_ADDINS ?= $(BROM_ROOT)/add-ins + +BROM_CTRSDK_ROOT ?=$(shell cygpath -w $(CTRSDK_ROOT)) +BROM_CTRFIRM_ROOT ?=$(shell cygpath -w $(CTRFIRM_ROOT)) + +BROM_CTRFIRM_INCDIR := $(BROM_CTRFIRM_ROOT)/include +BROM_CTRFIRM_TOOLSDIR := $(BROM_CTRFIRM_ROOT)/tools + +BROM_BUILDARCH ?= $(CODEGEN_PROC)-$(BROM_PLATFORM)$(BROM_CODEGEN_ARCH) +BROM_BUILDARCH_ARM11 := ARM11-$(BROM_PLATFORM)$(BROM_CODEGEN_ARCH) +BROM_BUILDARCH_ARM9 := ARM9-$(BROM_PLATFORM)$(BROM_CODEGEN_ARCH) + +BROM_BUILDTYPE ?= $(BROM_BUILDARCH)/$(BROM_BUILD_DIR) +BROM_BUILDTYPE_ARM11 := $(BROM_BUILDARCH_ARM11)/$(BROM_BUILD_DIR) +BROM_BUILDTYPE_ARM9 := $(BROM_BUILDARCH_ARM9)/$(BROM_BUILD_DIR) + +BROM_LIBARCH := $(CODEGEN_PROC)-$(BROM_PLATFORM) +BROM_LIBTYPE := $(BROM_LIBARCH)/$(BROM_BUILD_DIR) +BROM_LIBDIR := $(BROM_ROOT)/lib/$(BROM_LIBTYPE) +BROM_LIBSYSCALLDIR := $(BROM_ROOT)/lib/$(BROM_LIBARCH)/etc +BROM_LIBSUFFIX := .brom$(BROM_CODEGEN_ARCH) + + +BROM_SPECDIR := $(BROM_INCDIR)/brom/specfiles +BROM_SPECARCH := $(BROM_LIBARCH) +ifneq ($(BROM_TARGET),BROM) +BROM_SPECARCH := $(BROM_SPECARCH)-$(BROM_TARGET) +endif +DEFAULT_BROM_LCFILE := $(BROM_SPECDIR)/$(BROM_SPECARCH).ldscript +ifndef BROM_PROMGEN +DEFAULT_BROM_LCFILE_TEMPLATE := $(BROM_SPECDIR)/$(BROM_SPECARCH)$(LCF_SUFFIX_).ldscript.template +DEFAULT_BROM_LCFILE_SPEC := $(BROM_SPECDIR)/$(BROM_SPECARCH).lsf +else # BROM_PROMGEN +DEFAULT_BROM_LCFILE_TEMPLATE := $(BROM_SPECDIR)/PROM.ldscript.template +DEFAULT_BROM_LCFILE_SPEC := $(BROM_SPECDIR)/PROM.lsf +endif # BROM_PROMGEN +DEFAULT_BROM_ROM_SPEC := $(BROM_SPECDIR)/ROM-$(CTR_PLATFORM).rsf + +BROM_LCF_MAPHDRS := $(BROM_INCDIR)/brom/hw/$(BROM_PROC)/mmap_global.h \ + $(BROM_INCDIR)/brom/hw/$(BROM_PROC)/mmap_brom.h \ + $(BROM_CTRFIRM_INCDIR)/firm/hw/$(BROM_PROC)/mmap_firm.h \ + $(BROM_CTRFIRM_INCDIR)/firm/hw/$(BROM_PROC)/mmap_wram.h \ + +ifeq ($(BROM_PROC),ARM11) +else # BROM_PROC == ARM9 +BROM_LCF_MAPHDRS += $(BROM_INCDIR)/brom/hw/$(BROM_PROC)/mmap_tcm.h +endif # BROM_PROC == ARM9 + + +# replace TwlSDK +CTR_BUILDARCH ?= $(BROM_BUILDARCH) + + +### Compiler & Linker settings + +#-include $(BROM_BUILDTOOLSDIR)/commondefs.cctype.$(CTR_CCTYPE) + +# replace NitroSDK +LCFILE_TEMPLATE ?= $(DEFAULT_BROM_LCFILE_TEMPLATE) +LCFILE_SPEC ?= $(DEFAULT_BROM_LCFILE_SPEC) +LCFILE_AUTOGEN ?= $(BINDIR)/$(notdir $(LCFILE_SPEC:.lsf=.autogen.ldscript)) +LCFILE ?= $(LCFILE_AUTOGEN) + +LDRES_FILE ?= # $(LDRES_AUTOGEN) + +LDEPENDS_LCF += $(BROM_BUILDTOOLSDIR)/commondefs $(BROM_LCF_MAPHDRS) +LDEPENDS_RES += $(BROM_BUILDTOOLSDIR)/commondefs + + +### SDK Library settings + +ifeq ($(BROM_TARGET),BROM) +ifndef BROM_PROMGEN +ifeq ($(CODEGEN_PROC),ARM11) +CRT0_O ?= crt0.o crt0_secure.o +else # CODEGEN_PROC==ARM9 +CRT0_O ?= crt0.o crt0_secure_sp.o +endif # CODEGEN_PROC==ARM9 +endif # BROM_PROMGEN +else # BROM_TARGET +CRT0_O ?= crt0_app.o +endif # BROM_TARGET + +ifdef BROM_DEF_LINK_SCATLD +CRT0_O += crt0_scat.o +endif # BROM_DEF_LINK_SCATLD + +ifeq ($(CODEGEN_PROC),ARM11) + +BROM_LIBS_BASE ?= \ + libos \ + libmi \ + libpxi \ + libsyscall \ + libswi \ + libpad \ + libpm \ + libgcd \ + libnvram \ + libacsign \ + libromsd \ + libprint_hex \ + libvlink \ + +ifdef BROM_PROFILE_TYPE +BROM_LIBS_BASE += libos.$(BROM_PROFILE_TYPE) +endif + +else # ($(CODEGEN_PROC),ARM9) + +BROM_LIBS_BASE ?= \ + libos_sp \ + libmi_sp \ + libpxi_sp \ + libswi_sp \ + libsyscall_sp \ + libpad_sp \ + libpm_sp \ + libgcd_sp \ + libnvram_sp \ + libaes_sp \ + libacsign_sp \ + libromsd_sp \ + libvlink_sp \ + +ifdef BROM_PROFILE_TYPE +BROM_LIBS_BASE += libos_sp.$(BROM_PROFILE_TYPE) +endif + +endif + +BROM_LIBS ?= $(CRT0_O) $(addsuffix $(BROM_LIBSUFFIX).a,$(BROM_LIBS_BASE)) + +BROM_LDEPENDS_DBG ?= $(CTRBROM_ROOT)/build/libraries/os/common/os_printf.c \ + +#---------------------------------------------------------------------------- +### CTR-commondefs +# +include $(CTRFIRM_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- +# MY BUILD TOOLS +# +MAKENORFIRM := $(BROM_CTRFIRM_TOOLSDIR)/bin/makenorfirm.exe +MAKENANDFIRM := $(BROM_CTRFIRM_TOOLSDIR)/bin/makenandfirm.exe +MAKEGCDFIRM := $(BROM_CTRFIRM_TOOLSDIR)/bin/makegcdfirm.exe +OPENSSL := $(BROM_CTRFIRM_TOOLSDIR)/openssl/openssl.exe + +MAKEFIRM_RSA_PRVKEY ?= $(shell cygpath -m $(BROM_CTRFIRM_TOOLSDIR))/openssl/rsa_private.der +MAKEFIRM_RSA_PUBKEY ?= $(shell cygpath -m $(BROM_CTRFIRM_TOOLSDIR))/openssl/rsa_public.der + +MAKEFIRM_FLAGS ?= + +ifneq ($(filter NORFIRM NANDFIRM GCDFIRM,$(FIRM_TARGET)),) +FIRM_STRIP_AXF := TRUE +endif + +#---------------------------------------------------------------------------- + +ifeq ($(CTR_PRIVATE),TRUE) +BROM_PRIVATE := TRUE +endif + +ifeq ($(CTR_WITH_ARM9),TRUE) +BROM_WITH_ARM9 := TRUE +endif + +#---------------------------------------------------------------------------- + +### Global Library resettings + +GINCLUDES := $(BROM_INCDIR) $(BROM_CTRFIRM_INCDIR) $(GINCLUDES) +GLIBRARY_DIRS := $(BROM_LIBDIR) $(GLIBRARY_DIRS) +GLIBRARIES := $(BROM_LIBS) \ + +# $(filter-out $(addsuffix $(CTR_LIBSUFFIX).a,$(BROM_LIBS_BASE)),$(GLIBRARIES)) + + +#---------------------------------------------------------------------------- +# CTRBROM_INSTALL_ROOT +# + +ifdef CTRBROM_INSTALL_ROOT +CTRBROM_INSTALL_ROOT_ := $(CTRBROM_INSTALL_ROOT) +else +CTRBROM_INSTALL_ROOT_ := $(CTRBROM_ROOT) +endif + +BROM_INSTALL_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(CTRBROM_INSTALL_ROOT_))) +BROM_INSTALL_INCDIR := $(BROM_INSTALL_ROOT)/include +BROM_INSTALL_TOOLSDIR := $(BROM_INSTALL_ROOT)/tools +BROM_INSTALL_LIBDIR := $(BROM_INSTALL_ROOT)/lib/$(BROM_LIBTYPE) +BROM_INSTALL_PROMDIR := $(BROM_INSTALL_TOOLSDIR)/prom +BROM_INSTALL_COMPONENTSDIR := $(BROM_INSTALL_ROOT)/components +BROM_INSTALL_ADDINS := $(BROM_INSTALL_ROOT)/add-ins + + +#---------------------------------------------------------------------------- +# Compiler flags +# +MACRO_FLAGS += -DBROM_PLATFORM_$(BROM_PLATFORM) \ + -DBROM_TARGET_$(BROM_TARGET) \ + -DBROM_KEYSDIR='$(BROM_KEYSDIR)' \ + -DMAKEFIRM_RSA_PUBKEY='$(MAKEFIRM_RSA_PUBKEY)' \ + -DBROM_ROOT='$(BROM_ROOT)' \ + + +#---------------------------------------------------------------------------- +endif # CTRBROM_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/trunk/bootrom/build/buildtools/modulerules b/trunk/bootrom/build/buildtools/modulerules new file mode 100644 index 0000000..9162e02 --- /dev/null +++ b/trunk/bootrom/build/buildtools/modulerules @@ -0,0 +1,103 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrBrom - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- +ifndef BROMSDK_MODULERULES_ + + +ifdef MAKEFIRM_ARM11 +MAKEROM_ARM11 = $(MAKEFIRM_ARM11) +endif +ifdef MAKEFIRM_ARM9 +MAKEROM_ARM9 = $(MAKEFIRM_ARM9) +endif + +#---------------------------------------------------------------------------- +### CTR-modulerules +# +include $(CTRFIRM_ROOT)/build/buildtools/modulerules + +#---------------------------------------------------------------------------- + +# +# MAKENORFIRM / MAKENANDFIRM / MAKEGCDFIRM +# + +MAKEFIRM_ARM9 ?= $(MAKEROM_ARM9) +MAKEFIRM_ARM7 ?= $(MAKEROM_ARM7) + +MAKEFIRM_DEFS += -DFIRM_ROOT='$(BROM_CTRFIRM_ROOT)' \ + -DMAKEFIRM_ARM11='$(basename $(MAKEFIRM_ARM11))' \ + -DMAKEFIRM_ARM9='$(basename $(MAKEFIRM_ARM9))' \ + -DMAKEFIRM_RSA_PRVKEY='$(MAKEFIRM_RSA_PRVKEY)' \ + +SDEPENDS_BIN += $(MAKEFIRM_RSA_PRVKEY) + +FIRM_SDEPENDS_BIN := \ + $(call eupath,$(MAKEFIRM_ARM11)) \ + $(call eupath,$(MAKEFIRM_ARM9)) \ + + +.PHONY: bromtop bromlib bromdbg + +bromtop: + @$(MAKE) -C $(CTRBROM_ROOT) + +bromlib: + @$(MAKE) -C $(CTRBROM_ROOT)/build/libraries + +bromdbg: + @$(TOUCH) $(BROM_LDEPENDS_DBG) + @$(MAKE) -C $(CTRBROM_ROOT)/build/libraries/os + @+$(REMAKE) + + +# .srl +# .nor +$(BINDIR)/%.srl $(BINDIR)/%.nor: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKENORFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .nand +$(BINDIR)/%.srl $(BINDIR)/%.nand: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKENANDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .gcd +$(BINDIR)/%.srl $(BINDIR)/%.gcd: $(FIRM_SDEPENDS_BIN) $(FIRM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) $(MAKEFILE) + $(MAKEGCDFIRM) $(MAKEFIRM_FLAGS) $(MAKEFIRM_DEFS) $(FIRM_SPEC) $@ + +# .sbin +$(BINDIR)/$(TARGET_BIN_BASENAME).sbin: $(BINDIR)/$(TARGET_BIN_BASENAME).axf $(BINDIR)/$(TARGET_BIN_BASENAME).txt + objcopy -I elf32-little -O binary $< $@ + +# $(FROMELF) --bin -o $@ $< + + +# .padbin +$(BINDIR)/$(TARGET_BIN_BASENAME).padbin: $(BINDIR)/$(TARGET_BIN_BASENAME).sbin + objcopy -I binary -O binary --pad-to $(EXO_SBIN_SIZE) --gap-fill 0x00 $< $@ + + +# .txt +$(BINDIR)/$(TARGET_BIN_BASENAME).txt: $(BINDIR)/$(TARGET_BIN_BASENAME).axf + $(FROMELF) --32x1 -cd -o $@ $< + +# .exo +$(BINDIR)/$(TARGET_BIN_BASENAME).exo: $(BINDIR)/$(TARGET_BIN_BASENAME).sbin + objcopy -I binary -O srec $< $@ + +#---------------------------------------------------------------------------- +BROMSDK_MODULERULES_ = TRUE +endif # BROMSDK_MODULERULES_ +#----- End of modulerules ----- diff --git a/trunk/bootrom/build/libraries/Makefile b/trunk/bootrom/build/libraries/Makefile new file mode 100644 index 0000000..5e65733 --- /dev/null +++ b/trunk/bootrom/build/libraries/Makefile @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrBrom - libraries +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +include $(CTRBROM_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = \ + init \ + + +#---------------------------------------------------------------------------- + +include $(CTRBROM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/trunk/bootrom/build/libraries/init/Makefile b/trunk/bootrom/build/libraries/init/Makefile new file mode 100644 index 0000000..76b0138 --- /dev/null +++ b/trunk/bootrom/build/libraries/init/Makefile @@ -0,0 +1,33 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrBrom - libraries - init +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +include $(CTRBROM_ROOT)/build/buildtools/commondefs + +#---------------------------------------------------------------------------- + +SUBDIRS = # ARM11 + +#ifdef CTR_WITH_ARM9 +SUBDIRS += ARM9 +#endif + +#---------------------------------------------------------------------------- + +include $(CTRBROM_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/trunk/build/buildsetup/Makefile b/trunk/build/buildsetup/Makefile new file mode 100644 index 0000000..5e51b07 --- /dev/null +++ b/trunk/build/buildsetup/Makefile @@ -0,0 +1,33 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: NitroSDK - buildsetup - create register map +# File: Makefile +# +# Copyright 2003-2004 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. +# +# $Log: $ +# $NoKeywords:$ +#---------------------------------------------------------------------------- + +include $(CTRFIRM_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- +ifdef NITRO_PRIVATE +SUBDIRS += # versions +endif + +SUBDIRS += ioreg ioreg_sp # fx + +#---------------------------------------------------------------------------- + +include $(CTRFIRM_ROOT)/build/buildtools/modulerules + + +#----- End of Makefile ----- diff --git a/trunk/build/buildsetup/ioreg/Makefile b/trunk/build/buildsetup/ioreg/Makefile new file mode 100644 index 0000000..20931ac --- /dev/null +++ b/trunk/build/buildsetup/ioreg/Makefile @@ -0,0 +1,65 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrBrom - buildsetup - create register map +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords:$ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +WORKDIR = ctr/hw/ARM11 +TARGET = $(WORKDIR)/ioreg.h + +CSVSRC = io_register_list.csv +SCRIPT = header_generator_ioreg.pl + +NEWDIRS = $(WORKDIR) + +#---------------------------------------------------------------------------- + +TARGET_PREFIX = $(subst .h,,$(TARGET)) +TARGET_SUBFILES = $(TARGET_PREFIX)_*.h +TARGET_TMPCSV = $(TARGET_PREFIX).csv + +# build +TARGETS = $(TARGET) $(TARGET_SUBFILES) + +# install +INSTALL_TARGETS = $(TARGETS) +INSTALL_DIR = $(CTR_INSTALL_INCDIR)/$(WORKDIR) +override DO_INSTALL = $(DO_INSTALL_WILDCARD) + +# clean/clobber +LDIRT_CLEAN = $(TARGET_TMPCSV) $(TARGETS) \ + $(firstword $(subst /, ,$(WORKDIR))) +LDIRT_CLOBBER = + +include $(CTRSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGET) + +$(TARGET): $(CSVSRC) $(SCRIPT) + $(CP) $(CSVSRC) $(TARGET_TMPCSV) + $(PERL) $(SCRIPT) $(TARGET_TMPCSV) + +#---------------------------------------------------------------------------- + +include $(CTRSDK_ROOT)/build/buildtools/modulerules + + +#----- End of Makefile ----- diff --git a/trunk/build/buildsetup/ioreg/header_generator_ioreg.pl b/trunk/build/buildsetup/ioreg/header_generator_ioreg.pl new file mode 100644 index 0000000..9cfd2b3 --- /dev/null +++ b/trunk/build/buildsetup/ioreg/header_generator_ioreg.pl @@ -0,0 +1,678 @@ +#!/usr/bin/perl -s + +############################################################################## +# +# Project: CtrSDK - header generator - +# File: header_generator_ioreg.pl +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +############################################################################## + +# +# ヘッダファイルのマクロ生成スクリプト +# +# 使用法: +# conv.pl [-v] [-dup] filename1.csv [filename2.csv ...] +# +# CSVファイルからマクロの定義が書かれているヘッダファイル +# filename1.h (filename2.h...)を出力します。 +# +# CSVファイルのフォーマットについては(SDKRoot)/docs/private/how-to-make-headers.txt +# をご覧下さい。 +# + +use Text::ParseWords; + +# +# グローバル変数 +# +$line_no = 0; +%name_hash = (); +@hash_array = (); + + + + +# +# verbose出力 +# +sub verbose { + if ($verbose_mode == 1) { + print STDERR @_; + } +} + + + + +# +# フィールドの最初と最後の空白を取り除く +# +sub trim { + my @out = @_; + for (@out) { + s/^\s+//; + s/\s+$//; + } + return @out; +} + + + + +# +# CSV解析ルーチン +# +sub parse_csv { + my @fields = quotewords(",", 0, shift @_); + @fields = trim(@fields); + + my $tmp; + # 行末の,,,,を取り除く + while(defined($tmp = pop @fields) && $tmp =~ /^$/ ) { + ; + } + push @fields, $tmp; + + return @fields; +} + + + + +# +# プリプロセッサ +# +sub preprocess { + return parse_csv(shift @_); +} + + + + +# +# マクロ名の重複チェック +# + +sub check_macro_duplicate { + my $name = shift @_; + my $condition = shift @_; + my $no = shift @_; + + if ($condition ne "") { + return 0; + } + + if (exists $name_hash{$name}) { + if ($duplicate_ok == 1) { + print STDERR "WARNING: generating duplicate macro \'$name\' in line $no\n"; + } else { + die "ERROR: duplicate macro \'$name\' in line $no"; + } + return 1; + } else { + $name_hash{$name} = 1; + return 0; + } +} + + + +# +# 解析 +# +sub analyze { + my @fields = @_; + + my $fields; + my $tmphash; + my $address, $condition, $name, $bitwidth, $rw, $category, $volatile; + $tmphash = {}; + + $address = shift @fields; + die "ERROR: Illegal address \'$address\' in line $line_no\n" unless ($address =~ /^0x[0-9A-Fa-f]+$/); + + $condition = shift @fields; + die "ERROR: Illegal condition name \'$condition\' in line $line_no\n" unless ($address =~ /^[A-Za-z0-9_()&|!]+$/); + + $name = shift @fields; + die "ERROR: Illegal macro name \'$name\' in line $line_no\n" unless ($name =~ /^[A-Za-z0-9_]+$/); + check_macro_duplicate($name, $condition, $line_no); + + + $bitwidth = shift @fields; + if ($bitwidth eq "8") { + $mask_format = "0x%02x"; + } elsif ($bitwidth eq "16") { + $mask_format = "0x%04x"; + } elsif ($bitwidth eq "32") { + $mask_format = "0x%08x"; + } elsif ($bitwidth eq "64") { + $mask_format = "0x%016x"; + } else { + die "ERROR: Illegal bitwidth \'$bitwidth\' in line $line_no\n"; + } + + + $rw = shift @fields; + $category = shift @fields; + $volatile = shift @fields; + + $tmphash->{"condition"} = $condition; + $tmphash->{"name"} = $name; + $tmphash->{"offset"} = $address; + $tmphash->{"bitwidth"} = $bitwidth; + $tmphash->{"rw"} = $rw; + if ($rw eq "r") { + $tmphash->{"const"} = "const"; + } else { + $tmphash->{"const"} = ""; + } + + $tmphash->{"category"} = $category; + + if ($volatile eq "volatile") { + $tmphash->{"volatile"} = "v"; + } elsif ($volatile eq "permanent") { + $tmphash->{"volatile"} = ""; + } else { + die "ERROR: specify volatile/permanent in line $line_no\n"; + } + + @{$tmphash->{"option"}} = splice @fields, 0; + + $tmphash->{"mask_format"} = $mask_format; + $tmphash->{"line_no"} = $line_no; + return $tmphash; +} + + +# +# 配列へ要素を追加 +# 重複があれば線形リストとしてつなげる +# +sub push_fields { + my $hash = shift @_; + my $array_num; + my $tmp_hash; + + # 既に同じ名前のものが登録されている場合はハッシュテーブルへ線形リストとして追加 + if ( exists($index_name_hash{ $hash->{"name"} }) ) { + $array_num = $index_name_hash{ $hash->{"name"} }; # 対応する配列のインデックスを取得 + # (condition eq "")のものが線形リストの最後になるよう追加 + $tmp_hash = $hash_array[ $array_num ]; + if ( $tmp_hash->{"condition"} eq "") { + $hash->{"next"} = $tmp_hash; + $hash_array[ $array_num] = $hash; + return; + } + + while ( exists($tmp_hash->{"next"}) ) { + if ($tmp_hash->{"next"}->{"condition"} eq "") { + $hash->{"next"} = $tmp_hash->{"next"}; + $tmp_hash->{"next"} = $hash; + return; + } + $tmp_hash = $tmp_hash->{"next"}; + } + $tmp_hash->{"next"} = $hash; + } else { + $array_num = @hash_array; + $index_name_hash{ $hash->{"name"} } = $array_num; + push @hash_array, $hash; + } +} + + +# +# カテゴリ情報収集 +# +sub collect_category { + my %cat_hash; + my $hash; + foreach $hash (@hash_array) { + $cat_hash{$hash->{"category"}} = 1; + } + return (keys %cat_hash); +} + +# +# 条件のマージ +# +sub merge_condition { + my $cond1 = shift @_; + my $cond2 = shift @_; + my $name = shift @_; + + my $merged_cond; + + if ( $cond1 eq "" || $cond2 eq "") { + $merged_cond = ""; + return $merged_cond; + } + + if ( "$cond1" eq "!$cond2" || "!$cond1" eq "$cond2" ) { + $merge_cond = ""; + } else { + $merged_cond = "$cond1 || $cond2"; + } + + return $merged_cond; +} + + +# +# レジスタのオフセット定義取得 +# +sub cull_register_offset_def { + my $hash = shift @_; + + my $offset_name; + my @tmp_hash; + my @def_array = (); + my $i, $k; + + $i = 0; + while ( 1 ) { + + { + $offset_name = "REG_$hash->{'name'}_OFFSET"; + $hash->{"offset_def"} = $offset_name; + $hash->{"address_def"} = "REG_$hash->{'name'}_ADDR"; + # この変数の定義は後で使用するので残しておく + $hash->{"valname_def"} = "REG_$hash->{'category'}_$hash->{'name'}"; + $hash->{"valname_def_new"} = "reg_$hash->{'category'}_$hash->{'name'}"; + } + + $tmp_hash[$i]->{"condition"} = $hash->{"condition"}; + $tmp_hash[$i]->{"name"} = $hash->{"name"}; + $tmp_hash[$i]->{"offset_def"} = $hash->{"offset_def"}; + $tmp_hash[$i]->{"offset"} = $hash->{"offset"}; + $tmp_hash[$i]->{"address_def"} = $hash->{"address_def"}; + $tmp_hash[$i]->{"valname_def"} = $hash->{"valname_def"}; + $tmp_hash[$i]->{"valname_def_new"} = $hash->{"valname_def_new"}; + + my $val = "(*($hash->{'const'} REGType$hash->{'bitwidth'}$hash->{'volatile'} *) $hash->{'address_def'})"; + + $tmp_hash[$i]->{"reg_type"} = $val; + + my $find_flg = 0; + + #reg_typeとoffsetが同じならconditionをマージ + foreach $k (@def_array) { + if ( $k->{'condition'} eq "" ) { + # 条件無しのフィールドは最後に来るはずで、先に既に存在する場合は条件設定がおかしい + print STDERR "WARNING: illegal condition in \'$k->{'name'}\'\n"; + } + + if ( ($k->{"reg_type"} eq $tmp_hash[$i]->{"reg_type"}) && ($k->{"offset"} eq $tmp_hash[$i]->{"offset"}) ) + { + $k->{'condition'} = merge_condition( $k->{'condition'}, $tmp_hash[$i]->{'condition'}, $k->{'name'} ); + $find_flg = 1; + last; + } + } + if ($find_flg == 0) { + push @def_array, $tmp_hash[$i]; + $i++; + } + + # リストにまだ残っているなら次を処理 + if (exists($hash->{"next"})) { + $hash = $hash->{"next"}; + } else { + last; + } + } + + return @def_array; +} + + +# +# アウトプット +# +sub output { + my $output_filename = shift @_; + my $category = shift @_; + + # 出力ファイルのオープン + + open OUT, ">$output_filename" or die "ERROR: Cannot create file \'$output_filename\'\n"; + my $handle = OUT; +# my $handle = STDOUT; + + my $include_guard = $output_filename; + $include_guard =~ s/[.\/]/_/g; + $include_guard = uc($include_guard). "_"; + + # + # 出力 + # + print $handle < +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definition of Register offsets, addresses and variables. + */ + + +ENDDOC + my $hash, $tmp_hash; + + foreach $hash (@hash_array) { + next if ($hash->{"category"} ne $category); + + print $handle "/* $hash->{'name'} */\n\n"; + + my @reg_array = cull_register_offset_def($hash); # 重複した項目を最適化 + my $nest_state = 0; + + foreach $tmp_hash (@reg_array) + { + if ($tmp_hash->{"condition"} ne "") { + if ($nest_state == 0) { + $nest_state = 1; + printf $handle "#if %s\n\n", $tmp_hash->{'condition'}; + } elsif ($nest_state == 1) { + printf $handle "\n#elif %s\n\n", $tmp_hash->{'condition'}; + } + } elsif ($nest_state == 1) { + printf $handle "\n#else\n\n"; + } + + printf $handle "#define %-50s %s\n", $tmp_hash->{'offset_def'}, $tmp_hash->{'offset'}; + printf $handle "#define %-50s %s\n", $tmp_hash->{"address_def"}, "(HW_REG_BASE + $tmp_hash->{'offset_def'})"; + printf $handle "#define %-50s %s\n", $tmp_hash->{"valname_def_new"}, $tmp_hash->{"reg_type"}; + + if ($nest_state == 1) { + printf $handle "// endif %s\n", $tmp_hash->{"condition"} + } + } + + printf $handle "\n"; + if ($nest_state == 1) { + printf $handle "#endif\n\n"; + } + } + + print $handle <{"category"} ne $category); + + $nest_state = 0; + + printf $handle "\n"; + print $handle "/* $hash->{'name'} */\n"; + + while ( 1 ) { + if ($hash->{"condition"} ne "") { + if ($nest_state == 0) { + $nest_state = 1; + printf $handle "#if %s\n", $hash->{'condition'}; + } elsif ($nest_state == 1) { + printf $handle "#elif %s\n", $hash->{'condition'}; + } + } elsif ($nest_state == 1) { + printf $handle "#else\n"; + } + + my $no = $hash->{"line_no"}; + + my @array = @{$hash->{"option"}}; + + my $field_macro_func = "#define $hash->{'valname_def'}_FIELD("; + my $field_macro_flag = 0; + my $field_macro_body = " (u$hash->{'bitwidth'})( \\\n"; + + my $fieldname, $fieldshift, $fieldsize; + while($fieldname = shift @array) { + my $shift_macro; + + die "ERROR: Field option not good in line $no\n" if (!defined($fieldshift = shift @array)); + die "ERROR: Field option not good in line $no\n" if (!defined($fieldsize = shift @array)); + + print $handle "\n"; + + # REG_XXX_XXXXX_SHIFTの出力 + { + my $name = "$hash->{'valname_def'}_" . $fieldname . "_SHIFT"; + check_macro_duplicate($name, $hash->{'condition'}, $no); + $shift_macro = $name; + printf $handle "#define %-50s %s\n", $name, $fieldshift; + } + + # REG_XXX_XXXXX_SIZEの出力 + { + my $name = "$hash->{'valname_def'}_" . $fieldname . "_SIZE"; + check_macro_duplicate($name, $hash->{'condition'}, $no); + printf $handle "#define %-50s %s\n", $name, $fieldsize; + } + + # REG_XXX_XXXXX_MASKの出力 + { + my $width = $hash->{"bitwidth"}; + my $mask_val = 1 << $fieldshift; + my $tmp = $mask_val; + my $i; + for ($i = 0; $i < $fieldsize - 1; $i++) { + $mask_val = $mask_val << 1; + $mask_val = $mask_val + $tmp; + } + my $name = "$hash->{'valname_def'}_" . $fieldname . "_MASK"; + check_macro_duplicate($name, $hash->{'condition'}, $no); + printf $handle "#define %-50s $hash->{'mask_format'}\n", $name, $mask_val; + } + + # REG_XXX_XXXXX_FIELDの定義の一行分を作成 + my $fn = lc($fieldname); + if ($field_macro_flag == 1) { + $field_macro_func = $field_macro_func . ", " . $fn; + $field_macro_body = $field_macro_body . " | \\\n" . " ((u32)($fn) << $shift_macro)"; + } else { + $field_macro_func = $field_macro_func . " " . $fn; + $field_macro_body = $field_macro_body . " ((u32)($fn) << $shift_macro)"; + $field_macro_flag = 1; + } + } + + if ($field_macro_flag == 1) { + # REG_XXX_XXXXX_FIELDの出力 + $field_macro_func .= " ) \\\n"; + $field_macro_func .= $field_macro_body; + print $handle "\n#ifndef SDK_ASM\n"; + print $handle $field_macro_func, ")\n"; + print $handle "#endif\n\n" + + } + if ($nest_state == 1) { + printf $handle "// endif %s\n", $hash->{"condition"}; + if ( !exists($hash->{"next"})) { + printf $handle "#endif \n\n"; + } + } + + # リストにまだ残っているなら次を表示 + if (exists($hash->{'next'})) { + $hash = $hash->{'next'}; + } else { + last; + } + } + } + + print $handle <) { + $line_no++; + $line =~ s/\"//g; + $line =~ s/\#.*//; + next if ($line =~ /^[\s,]*$/); + + @fields = preprocess($line); + push @hash_array, analyze(@fields); + } + verbose("$line_no lines read\n"); + + my @categories = collect_category(); + my $category; + my @headerfile_array = (); + + + foreach $category (@categories) { + my $output_filename = $filename; + if (($output_filename =~ s/\.csv/\.h/) == 0) { + $output_filename .= ".h"; + } + $output_filename =~ s/\.h/_$category.h/; + + push @headerfile_array, $output_filename; + + verbose("Output filename is $output_filename\n"); + output($output_filename, $category); + } + + my $master_filename = $filename; + if (($master_filename =~ s/\.csv/\.h/) == 0) { + $master_filename .= ".h"; + } + + open MASTER, ">$master_filename" or die "ERROR: Cannot create file \'$master_filename$'\n"; + + my $include_guard = $master_filename; + $include_guard =~ s/[.\/]/_/g; + $include_guard = uc($include_guard). "_"; + + print MASTER <\n" + } + + print MASTER <{"condition"} = $condition; + $tmphash->{"name"} = $name; + $tmphash->{"offset"} = $address; + $tmphash->{"bitwidth"} = $bitwidth; + $tmphash->{"rw"} = $rw; + if ($rw eq "r") { + $tmphash->{"const"} = "const"; + } else { + $tmphash->{"const"} = ""; + } + + $tmphash->{"category"} = $category; + + if ($volatile eq "volatile") { + $tmphash->{"volatile"} = "v"; + } elsif ($volatile eq "permanent") { + $tmphash->{"volatile"} = ""; + } else { + die "ERROR: specify volatile/permanent in line $line_no\n"; + } + + @{$tmphash->{"option"}} = splice @fields, 0; + + $tmphash->{"mask_format"} = $mask_format; + $tmphash->{"line_no"} = $line_no; + return $tmphash; +} + + +# +# 配列へ要素を追加 +# 重複があれば線形リストとしてつなげる +# +sub push_fields { + my $hash = shift @_; + my $array_num; + my $tmp_hash; + + # 既に同じ名前のものが登録されている場合はハッシュテーブルへ線形リストとして追加 + if ( exists($index_name_hash{ $hash->{"name"} }) ) { + $array_num = $index_name_hash{ $hash->{"name"} }; # 対応する配列のインデックスを取得 + # (condition eq "")のものが線形リストの最後になるよう追加 + $tmp_hash = $hash_array[ $array_num ]; + if ( $tmp_hash->{"condition"} eq "") { + $hash->{"next"} = $tmp_hash; + $hash_array[ $array_num] = $hash; + return; + } + + while ( exists($tmp_hash->{"next"}) ) { + if ($tmp_hash->{"next"}->{"condition"} eq "") { + $hash->{"next"} = $tmp_hash->{"next"}; + $tmp_hash->{"next"} = $hash; + return; + } + $tmp_hash = $tmp_hash->{"next"}; + } + $tmp_hash->{"next"} = $hash; + } else { + $array_num = @hash_array; + $index_name_hash{ $hash->{"name"} } = $array_num; + push @hash_array, $hash; + } +} + + +# +# カテゴリ情報収集 +# +sub collect_category { + my %cat_hash; + my $hash; + foreach $hash (@hash_array) { + $cat_hash{$hash->{"category"}} = 1; + } + return (keys %cat_hash); +} + +# +# 条件のマージ +# +sub merge_condition { + my $cond1 = shift @_; + my $cond2 = shift @_; + my $name = shift @_; + + my $merged_cond; + + if ( $cond1 eq "" || $cond2 eq "") { + $merged_cond = ""; + return $merged_cond; + } + + if ( "$cond1" eq "!$cond2" || "!$cond1" eq "$cond2" ) { + $merge_cond = ""; + } else { + $merged_cond = "$cond1 || $cond2"; + } + + return $merged_cond; +} + + + +# +# レジスタのオフセット定義取得 +# +sub cull_register_offset_def { + my $hash = shift @_; + + my $offset_name; + my @tmp_hash; + my @def_array = (); + my $i, $k; + + $i = 0; + while ( 1 ) { + + { + $offset_name = "REG_$hash->{'name'}_OFFSET"; + $hash->{"offset_def"} = $offset_name; + $hash->{"address_def"} = "REG_$hash->{'name'}_ADDR"; + # この変数の定義は後で使用するので残しておく + $hash->{"valname_def"} = "REG_$hash->{'category'}_$hash->{'name'}"; + $hash->{"valname_def_new"} = "reg_$hash->{'category'}_$hash->{'name'}"; + } + + $tmp_hash[$i]->{"condition"} = $hash->{"condition"}; + $tmp_hash[$i]->{"name"} = $hash->{"name"}; + $tmp_hash[$i]->{"offset_def"} = $hash->{"offset_def"}; + $tmp_hash[$i]->{"offset"} = $hash->{"offset"}; + $tmp_hash[$i]->{"address_def"} = $hash->{"address_def"}; + $tmp_hash[$i]->{"valname_def"} = $hash->{"valname_def"}; + $tmp_hash[$i]->{"valname_def_new"} = $hash->{"valname_def_new"}; + + my $val = "(*($hash->{'const'} REGType$hash->{'bitwidth'}$hash->{'volatile'} *) $hash->{'address_def'})"; + + $tmp_hash[$i]->{"reg_type"} = $val; + + my $find_flg = 0; + + #reg_typeとoffsetが同じならconditionをマージ + foreach $k (@def_array) { + + if ( $k->{'condition'} eq "" ) { + # 条件無しのフィールドは最後に来るはずで、先に既に存在する場合は条件設定がおかしい + print STDERR "WARNING: illegal condition in \'$k->{'name'}\'\n"; + } + + if ( ($k->{"reg_type"} eq $tmp_hash[$i]->{"reg_type"}) && ($k->{"offset"} eq $tmp_hash[$i]->{"offset"}) ) + { + $k->{'condition'} = merge_condition( $k->{'condition'}, $tmp_hash[$i]->{'condition'}, $k->{'name'} ); + $find_flg = 1; + last; + } + } + if ($find_flg == 0) { + push @def_array, $tmp_hash[$i]; + $i++; + } + + # リストにまだ残っているなら次を処理 + if (exists($hash->{"next"})) { + $hash = $hash->{"next"}; + } else { + last; + } + } + + return @def_array; +} + + +# +# アウトプット +# +sub output { + my $output_filename = shift @_; + my $category = shift @_; + + # 出力ファイルのオープン + + open OUT, ">$output_filename" or die "ERROR: Cannot create file \'$output_filename\'\n"; + my $handle = OUT; +# my $handle = STDOUT; + + my $include_guard = $output_filename; + $include_guard =~ s/[.\/]/_/g; + $include_guard = uc($include_guard). "_"; + + # + # 出力 + # + print $handle < +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definition of Register offsets, addresses and variables. + */ + + +ENDDOC + my $hash, $tmp_hash; + + foreach $hash (@hash_array) { + next if ($hash->{"category"} ne $category); + + print $handle "/* $hash->{'name'} */\n\n"; + + my @reg_array = cull_register_offset_def($hash); # 重複した項目を最適化 + my $nest_state = 0; + + foreach $tmp_hash (@reg_array) + { + if ($tmp_hash->{"condition"} ne "") { + if ($nest_state == 0) { + $nest_state = 1; + printf $handle "#if %s\n\n", $tmp_hash->{'condition'}; + } elsif ($nest_state == 1) { + printf $handle "\n#elif %s\n\n", $tmp_hash->{'condition'}; + } + } elsif ($nest_state == 1) { + printf $handle "\n#else\n\n"; + } + + printf $handle "#define %-50s %s\n", $tmp_hash->{'offset_def'}, $tmp_hash->{'offset'}; + printf $handle "#define %-50s %s\n", $tmp_hash->{"address_def"}, "(HW_REG_BASE + $tmp_hash->{'offset_def'})"; + printf $handle "#define %-50s %s\n", $tmp_hash->{"valname_def_new"}, $tmp_hash->{"reg_type"}; + + if ($nest_state == 1) { + if ( $tmp_hash->{"condition"} ne "" ) { + printf $handle "// endif %s\n", $tmp_hash->{"condition"}; + } else { + printf $handle "// endif else\n"; + } + } + } + + if ($nest_state == 1) { + printf $handle "#endif\n"; + } + printf $handle "\n"; + + } + + print $handle <{"category"} ne $category); + + $nest_state = 0; + + printf $handle "\n"; + print $handle "/* $hash->{'name'} */\n"; + + while ( 1 ) { + if ($hash->{"condition"} ne "") { + if ($nest_state == 0) { + $nest_state = 1; + printf $handle "#if %s\n", $hash->{'condition'}; + } elsif ($nest_state == 1) { + printf $handle "#elif %s\n", $hash->{'condition'}; + } + } elsif ($nest_state == 1) { + printf $handle "#else\n"; + } + + my $no = $hash->{"line_no"}; + + my @array = @{$hash->{"option"}}; + + my $field_macro_func = "#define $hash->{'valname_def'}_FIELD("; + my $field_macro_flag = 0; + my $field_macro_body = " (u$hash->{'bitwidth'})( \\\n"; + + my $fieldname, $fieldshift, $fieldsize; + while($fieldname = shift @array) { + my $shift_macro; + die "ERROR: Field option not good in line $no\n" if (!defined($fieldshift = shift @array)); + die "ERROR: Field option not good in line $no\n" if (!defined($fieldsize = shift @array)); + + print $handle "\n"; + + # REG_XXX_XXXXX_SHIFTの出力 + { + my $name = "$hash->{'valname_def'}_" . $fieldname . "_SHIFT"; + check_macro_duplicate($name, $hash->{'condition'}, $no); + $shift_macro = $name; + printf $handle "#define %-50s %s\n", $name, $fieldshift; + } + + # REG_XXX_XXXXX_SIZEの出力 + { + my $name = "$hash->{'valname_def'}_" . $fieldname . "_SIZE"; + check_macro_duplicate($name, $hash->{'condition'}, $no); + printf $handle "#define %-50s %s\n", $name, $fieldsize; + } + + # REG_XXX_XXXXX_MASKの出力 + { + my $width = $hash->{"bitwidth"}; + my $mask_val = 1 << $fieldshift; + my $tmp = $mask_val; + my $i; + for ($i = 0; $i < $fieldsize - 1; $i++) { + $mask_val = $mask_val << 1; + $mask_val = $mask_val + $tmp; + } + my $name = "$hash->{'valname_def'}_" . $fieldname . "_MASK"; + check_macro_duplicate($name, $hash->{'condition'}, $no); + printf $handle "#define %-50s $hash->{'mask_format'}\n", $name, $mask_val; + } + + # REG_XXX_XXXXX_FIELDの定義の一行分を作成 + my $fn = lc($fieldname); + if ($field_macro_flag == 1) { + $field_macro_func = $field_macro_func . ", " . $fn; + $field_macro_body = $field_macro_body . " | \\\n" . " ((u32)($fn) << $shift_macro)"; + } else { + $field_macro_func = $field_macro_func . " " . $fn; + $field_macro_body = $field_macro_body . " ((u32)($fn) << $shift_macro)"; + $field_macro_flag = 1; + } + } + + if ($field_macro_flag == 1) { + # REG_XXX_XXXXX_FIELDの出力 + $field_macro_func .= " ) \\\n"; + $field_macro_func .= $field_macro_body; + print $handle "\n#ifndef SDK_ASM\n"; + print $handle $field_macro_func, ")\n"; + print $handle "#endif\n\n" + + } + + if ($nest_state == 1) { + if ( $hash->{"condition"} ne "") { + printf $handle "// endif %s\n", $hash->{"condition"}; + } else { + printf $handle "// endif else\n"; + } + if ( !exists($hash->{"next"})) { + printf $handle "#endif \n\n"; + } + } + + # リストにまだ残っているなら次を表示 + if (exists($hash->{'next'})) { + $hash = $hash->{'next'}; + } else { + last; + } + } + } + + print $handle <) { + $line_no++; + $line =~ s/\"//g; + $line =~ s/\#.*//; + next if ($line =~ /^[\s,]*$/); + + @fields = preprocess($line); + push_fields( analyze(@fields) ); + } + verbose("$line_no lines read\n"); + + my @categories = collect_category(); + my $category; + my @headerfile_array = (); + + + foreach $category (@categories) { + my $output_filename = $filename; + if (($output_filename =~ s/\.csv/\.h/) == 0) { + $output_filename .= ".h"; + } + $output_filename =~ s/\.h/_$category.h/; + + push @headerfile_array, $output_filename; + + verbose("Output filename is $output_filename\n"); + output($output_filename, $category); + } + + my $master_filename = $filename; + if (($master_filename =~ s/\.csv/\.h/) == 0) { + $master_filename .= ".h"; + } + + open MASTER, ">$master_filename" or die "ERROR: Cannot create file \'$master_filename$'\n"; + + my $include_guard = $master_filename; + $include_guard =~ s/[.\/]/_/g; + $include_guard = uc($include_guard). "_"; + + print MASTER <\n" + } + + print MASTER < /dev/null + + +#===== End of Makefile ===== diff --git a/trunk/build/buildsetup/versions/version.h b/trunk/build/buildsetup/versions/version.h new file mode 100644 index 0000000..104ca8b --- /dev/null +++ b/trunk/build/buildsetup/versions/version.h @@ -0,0 +1,20 @@ +#ifndef CTRSDK_VERSION_H_ +#define CTRSDK_VERSION_H_ +#define SDK_VERSION_DATE 20070704 +#define SDK_VERSION_TIME 1421 +#define SDK_VERSION_MAJOR 4 +#define SDK_VERSION_MINOR 0 +#define SDK_VERSION_RELSTEP 30000 +#define SDK_BUILDVER_CW_CC 3.0 +#define SDK_BUILDVER_CW_LD 2.0 +#define SDK_BUILDNUM_CW_CC 123 +#define SDK_BUILDNUM_CW_LD 84 + +#ifndef SDK_VERSION_NUMBER +#define SDK_VERSION_NUMBER(major, minor, relstep) \ +(((major) << 24) | ((minor) << 16) | ((relstep) << 0)) +#define SDK_CURRENT_VERSION_NUMBER \ +SDK_VERSION_NUMBER(SDK_VERSION_MAJOR, SDK_VERSION_MINOR, SDK_VERSION_RELSTEP) +#endif + +#endif diff --git a/trunk/build/buildtools/@privatedefs b/trunk/build/buildtools/@privatedefs new file mode 100644 index 0000000..28f1839 --- /dev/null +++ b/trunk/build/buildtools/@privatedefs @@ -0,0 +1,21 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrFirm - @privatedefs +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, 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-07-31#$ +# $Rev: 387 $ +# $Author: terui $ +#---------------------------------------------------------------------------- + +CTR_WITH_ARM9 := TRUE + +#===== End of @privatedefs ===== diff --git a/trunk/build/buildtools/_privatedefs b/trunk/build/buildtools/_privatedefs new file mode 100644 index 0000000..a06e2b4 --- /dev/null +++ b/trunk/build/buildtools/_privatedefs @@ -0,0 +1,21 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: TwlSDK - _privatedefs +# File: Makefile +# +# Copyright 2007 Nintendo. All rights reserved. +# +# These coded insructions, 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-07-31#$ +# $Rev: 387 $ +# $Author: terui $ +#---------------------------------------------------------------------------- + +CTR_PRIVATE := TRUE + +#===== End of _privatedefs ===== diff --git a/trunk/build/buildtools/commondefs b/trunk/build/buildtools/commondefs new file mode 100644 index 0000000..c5d94a7 --- /dev/null +++ b/trunk/build/buildtools/commondefs @@ -0,0 +1,488 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - commondefs - common definitions for build system +# File: commondefs +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- +ifndef CTRSDK_COMMONDEFS_ +CTRSDK_COMMONDEFS_ = TRUE + +# +# SDK root directory +# + +CTRSDK_ROOT ?= C:/ctr_sdk + + +# +# SDK Major Version +# + +CTRSDK_VERSION_MAJOR ?= 4 + +# +# CodeGen Target +# +# CTR_PLATFORM = [TEG/TS] +# CTR_MEMSIZE = [64M/128M] +# CTR_CODEGEN = [ARM/THUMB] +# CTR_PROC = [ARM11/ARM9/ARM7] +# + +CTR_PLATFORM ?= TS +CTR_MEMSIZE ?= 64M +CTR_CODEGEN ?= ARM +CTR_PROC ?= ARM11 + +ifndef CODEGEN_PROC +CODEGEN_PROC := $(CTR_PROC) +endif + +ifeq ($(CTR_CODEGEN),ALL) +CTR_CODEGEN_ALL ?= TRUE +override CTR_CODEGEN = ARM +endif + +ifeq ($(CTR_CODEGEN),ARM) +CODEGEN_ARCH = +else # ($(CTR_CODEGEN),THUMB) +CODEGEN_ARCH = .thumb +endif +CODEGEN_CC ?= $(CTR_CODEGEN) +CODEGEN_AS ?= ARM + +TS_VERSION = $(if $(CTR_TS_VERSION),_TS$(CTR_TS_VERSION)) + +# +# C Compiler type +# +# CTR_CCTYPE = [CW/SNC] +# + +CTR_CCTYPE ?= CW + + +# +# Binary build tool switch +# + +ifeq ($(CTR_ELFTOBIN),) +CTR_MAKEROM ?= TRUE +endif + +ifeq ($(CTR_MAKEROM)$(CTR_PLATFORM),TS) +__error: + @echo "---- Stop, Don't use ELFTOBIN with CTR_PLATFORM=TS ----" + @exit 1 +endif + +# +# RomSpeedType for makerom.exe +# +# one of [MROM/1TROM/UNDEFINED] +# + +CTR_ROMSPEED ?= UNDEFINED + +# +# SDK build type +# +# one of [CTR_DEBUG/CTR_RELEASE/CTR_FINALROM] +# + +ifdef CTR_DEBUG +CTR_BUILD_TYPE ?= DEBUG +CTR_BUILD_DIR ?= Debug + +else +ifdef CTR_FINALROM +CTR_BUILD_TYPE ?= FINALROM +CTR_BUILD_DIR ?= Rom + +else # CTR_RELEASE (default) +CTR_BUILD_TYPE ?= RELEASE +CTR_BUILD_DIR ?= Release + +endif +endif + + +#---------------------------------------------------------------------------- +# Utilities +# + +EMPTY := +SPACE := $(EMPTY) $(EMPTY) + +#---------------------------------------------------------------------------- +# CTR-SDK path settings +# +-include $(CTR_BUILDTOOLSDIR)/commondefs.cygpath + +ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(CTRSDK_ROOT))) +CTR_BUILDTOOLSDIR := $(ROOT)/build/buildtools +CTR_BUILDSETUPDIR := $(ROOT)/build/buildsetup +CTR_INCDIR := $(ROOT)/include +CTR_TOOLSDIR := $(ROOT)/tools +CTR_COMPONENTSDIR := $(ROOT)/components +CTR_ADDINS ?= $(ROOT)/add-ins + +CTR_BUILDARCH ?= $(CODEGEN_PROC)-$(CTR_PLATFORM)$(CODEGEN_ARCH) +CTR_BUILDARCH_ARM11 := ARM9-$(CTR_PLATFORM)$(CODEGEN_ARCH) +CTR_BUILDARCH_ARM9 := ARM7-$(CTR_PLATFORM)$(CODEGEN_ARCH) + +CTR_BUILDTYPE ?= $(CTR_BUILDARCH)/$(CTR_BUILD_DIR) +CTR_BUILDTYPE_ARM11 := $(CTR_BUILDARCH_ARM9)/$(CTR_BUILD_DIR) +CTR_BUILDTYPE_ARM9 := $(CTR_BUILDARCH_ARM7)/$(CTR_BUILD_DIR) + +CTR_LIBARCH := $(CODEGEN_PROC)-$(CTR_PLATFORM) +CTR_LIBTYPE := $(CTR_LIBARCH)/$(CTR_BUILD_DIR) +CTR_LIBDIR := $(ROOT)/lib/$(CTR_LIBTYPE) +CTR_LIBSYSCALLDIR := $(ROOT)/lib/$(CTR_LIBARCH)/etc +CTR_LIBSUFFIX := $(CODEGEN_ARCH) + + +#---------------------------------------------------------------------------- +# CTR-SYSTEM path settings +# + +ifdef CTRSYSTEM_ROOT +CTRSYSTEM_ROOT_ := $(subst $(SPACE),\ ,$(subst \,/,$(CTRSYSTEM_ROOT))) +-include $(CTRSYSTEM_ROOT_)/build/buildtools/nnslibdefs +endif + +CTRSYSTEM_LIBDIR ?= $(ROOT)/lib/CtrSystem/$(CTR_LIBTYPE) +CTRSYSTEM_INCDIR ?= + + +#---------------------------------------------------------------------------- +# CTR-WIRELESS path settings +# +# libraries should be in +# $(ROOT)/lib/CtrWireless +# +# includes should be in +# $(ROOT)/include/nitro_wl/ARM11/*.h +# +# access by #include +# +# SDK_VERSION_WL is defined in +# + +CTRWIRELESS_VERSION ?= 2.78.00 +CTRWIRELESS_ROOT ?= $(ROOT)/add-ins/CtrWireless/Marionea-$(CTRWIRELESS_VERSION) +CTRWIRELESS_ROOT_ = $(subst $(SPACE),\ ,$(subst \,/,$(CTRWIRELESS_ROOT))) +ifneq ($(CTR_PROC),ARM9) +CTRWIRELESS_LIBDIR ?= $(ROOT)/lib/CtrWireless/$(CTR_LIBTYPE) +CTRWIRELESS_INCDIR ?= $(ROOT)/include +endif + + +#---------------------------------------------------------------------------- +# Compiler settings +# + +CTR_FORCE_BUILD ?= $(strip $(TARGET_BIN) $(TARGET_OBJ) $(TARGET_NEF) $(TARGET_LIB) $(TARGET_SIGN_BIN)) + +ifneq ($(CTR_FORCE_BUILD),) + +### module subdir src/ obj/ lib/ include/ + +DEFAULT_SRCDIR := ./src +DEFAULT_INCDIR := ./include +DEFAULT_ETCDIR := ./etc + +LCF_SUFFIX_ := $(if $(CTR_DIGEST),-C) +CTR_SPECDIR := $(CTR_INCDIR)/nitro/specfiles +DEFAULT_LCFILE := $(CTR_SPECDIR)/$(CTR_LIBARCH).lcf +DEFAULT_LCFILE_TEMPLATE := $(CTR_SPECDIR)/$(CTR_LIBARCH)$(LCF_SUFFIX_).lcf.template +DEFAULT_LCFILE_SPEC := $(CTR_SPECDIR)/$(CTR_LIBARCH).lsf +DEFAULT_ROM_SPEC := $(CTR_SPECDIR)/ROM-$(CTR_PLATFORM).rsf + +SRCDIR ?= $(DEFAULT_SRCDIR) +INCDIR ?= $(DEFAULT_INCDIR) +ETCDIR ?= $(DEFAULT_ETCDIR) +OBJDIR ?= ./obj/$(CTR_BUILDTYPE) +BINDIR ?= ./bin/$(CTR_BUILDTYPE) +LIBDIR ?= ./lib/$(CTR_BUILDTYPE) +DEPENDDIR ?= ./depend/$(CTR_BUILDTYPE) + +LIBSYSCALL_ = $(if $(LIBSYSCALL),$(LIBSYSCALL),$(CTR_LIBSYSCALLDIR)/libsyscall.a) + +### Compiler & Linker settings + +-include $(CTR_BUILDTOOLSDIR)/commondefs.cctype.$(CTR_CCTYPE) + +ifneq ($(CTR_MAKEROM),) +LCFILE_TEMPLATE ?= $(DEFAULT_LCFILE_TEMPLATE) +LCFILE_SPEC ?= $(DEFAULT_LCFILE_SPEC) +LCFILE_AUTOGEN ?= $(BINDIR)/$(notdir $(LCFILE_SPEC:.lsf=.autogen.lcf)) +LCFILE ?= $(LCFILE_AUTOGEN) +DEFAULT_LDRES_TEMPLATE := $(CTR_SPECDIR)/$(basename $(notdir $(LD))).response.template +LDRES_TEMPLATE ?= $(DEFAULT_LDRES_TEMPLATE) +LDRES_AUTOGEN ?= $(BINDIR)/$(notdir $(LCFILE_SPEC:.lsf=.autogen.response)) +LDRES_FILE ?= $(LDRES_AUTOGEN) +else +LCFILE ?= $(DEFAULT_LCFILE) +endif + +TARGETS = $(addprefix $(BINDIR)/,$(TARGET_BIN) $(TARGET_NEF) $(TARGET_SIGN_BIN)) \ + $(addprefix $(OBJDIR)/,$(TARGET_OBJ)) \ + $(addprefix $(LIBDIR)/,$(TARGET_LIB)) + +TARGET_BIN_BASENAME = $(notdir $(basename $(firstword $(TARGET_BIN) $(TARGET_NEF)))) +TARGET_NAME ?= $(TARGET_BIN_BASENAME) + +### Debugger settings + +ifndef IS_CTR_DIR +ifdef IS_IRIS_DIR +IS_CTR_DIR = $(IS_IRIS_DIR) +endif +endif + +-include $(CTR_BUILDTOOLSDIR)/commondefs.emtype.ISD + + +### SDK Library settings + +CRT0_O ?= crt0.o + +ifeq ($(CODEGEN_PROC),ARM11) + +CTR_LIBS ?= libfx$(CTR_LIBSUFFIX).a \ + libgx$(CTR_LIBSUFFIX).a \ + libos$(TS_VERSION)$(CTR_LIBSUFFIX).a \ + libmi$(CTR_LIBSUFFIX).a \ + libsnd$(CTR_LIBSUFFIX).a \ + libpxi$(CTR_LIBSUFFIX).a \ + libext$(CTR_LIBSUFFIX).a \ + libfs$(CTR_LIBSUFFIX).a \ + libdgt$(CTR_LIBSUFFIX).a \ + libcp$(CTR_LIBSUFFIX).a \ + libspi$(TS_VERSION)$(CTR_LIBSUFFIX).a \ + librtc$(CTR_LIBSUFFIX).a \ + libprc$(CTR_LIBSUFFIX).a \ + libcard$(CTR_LIBSUFFIX).a \ + libwm$(CTR_LIBSUFFIX).a \ + libwbt$(CTR_LIBSUFFIX).a \ + libmb$(CTR_LIBSUFFIX).a \ + libctrdg$(CTR_LIBSUFFIX).a \ + libmath$(CTR_LIBSUFFIX).a \ + libcht$(CTR_LIBSUFFIX).a \ + libstd$(CTR_LIBSUFFIX).a \ + libenv$(CTR_LIBSUFFIX).a \ + $(notdir $(LIBSYSCALL_)) \ + $(CRT0_O) + +ifdef CTR_PROFILE_TYPE +CTR_LIBS += libos.$(CTR_PROFILE_TYPE)$(CTR_LIBSUFFIX).a +endif + +else # ($(CODEGEN_PROC),ARM9) + +CTR_LIBS ?= libos_sp$(CTR_LIBSUFFIX).a \ + libmi_sp$(CTR_LIBSUFFIX).a \ + libsnd_sp$(CTR_LIBSUFFIX).a \ + libpxi_sp$(CTR_LIBSUFFIX).a \ + libpad_sp$(CTR_LIBSUFFIX).a \ + libexi_sp$(CTR_LIBSUFFIX).a \ + libfs_sp$(CTR_LIBSUFFIX).a \ + libcard_sp$(CTR_LIBSUFFIX).a \ + librtc_sp$(CTR_LIBSUFFIX).a \ + libspi_sp$(CTR_LIBSUFFIX).a \ + libtp_sp$(CTR_LIBSUFFIX).a \ + libnvram_sp$(CTR_LIBSUFFIX).a \ + libmic_sp$(TS_VERSION)$(CTR_LIBSUFFIX).a \ + libpm_sp$(CTR_LIBSUFFIX).a \ + libctrdg_sp$(CTR_LIBSUFFIX).a \ + libwvr_sp$(CTR_LIBSUFFIX).a \ + libstd_sp$(CTR_LIBSUFFIX).a \ + libsubpsyscall.a \ + $(CRT0_O) + +ifdef CTR_PROFILE_TYPE +CTR_LIBS += libos_sp.$(CTR_PROFILE_TYPE)$(CTR_LIBSUFFIX).a +endif + +endif + +### Global Library settings + +DEFAULT_GINCLUDES := $(INCDIR) $(SRCDIR) \ + $(CTRSYSTEM_INCDIR) $(CTRWIRELESS_INCDIR) \ + $(CTR_INCDIR) $(ISD_INCDIRS) + +DEFAULT_GLIBRARY_DIRS := $(LIBDIR) $(dir $(LIBSYSCALL_)) \ + $(CTRSYSTEM_LIBDIR) $(CTRWIRELESS_LIBDIR) \ + $(CTR_LIBDIR) $(ISD_LIBDIRS) + +DEFAULT_GLIBRARIES := $(CTRSYSTEM_LIBS) $(CTR_LIBS) $(STUBS_LIBS) $(ISD_LIBS) + +GINCLUDES ?= $(DEFAULT_GINCLUDES) +GLIBRARY_DIRS ?= $(DEFAULT_GLIBRARY_DIRS) +GLIBRARIES ?= $(DEFAULT_GLIBRARIES) + +LINCLUDES ?= +LLIBRARY_DIRS ?= +LLIBRARIES ?= +LNEWDIRS ?= + +NEWDIRS ?= $(if $(SRCS),$(OBJDIR) $(DEPENDDIR)) \ + $(if $(TARGET_LIB),$(LIBDIR)) \ + $(if $(TARGET_BIN)$(TARGET_NEF),$(BINDIR)) \ + $(LNEWDIRS) + +GDIRT_CLEAN_DIRS := ./obj ./bin ./lib ./depend +GDIRT_CLOBBER_DIRS := + +endif + +#---------------------------------------------------------------------------- +# MAKE COMMAND SETTINGS +# +# --no-print-directory: No print directory when 'change directory' +# -r no builtin rules +# -R no builtin variables +# -j do make with multi-thread (not used now) +# +MAKEFILE = $(firstword $(MAKEFILE_LIST)) +MAKEFLAGS_SHORT = $(filter -%,$(filter-out --%,$(MAKEFLAGS))) + +MAKEFLAGS += -R -r + +# Check -w option +ifeq (,$(findstring w,$(MAKEFLAGS_SHORT))) +MAKEFLAGS += --no-print-directory +endif + +# Check -k option +ifeq (,$(findstring k,$(MAKEFLAGS_SHORT))) +AND = && +else +AND = ; +endif + +# Check -s option +ifneq (,$(findstring s,$(MAKEFLAGS_SHORT))) +CTR_STDOUT = > /dev/null +endif + +#---------------------------------------------------------------------------- +# CYGWIN TOOLS +# + +CD := cd +CP := cp -rf +RM := rm -rf +MV := mv +MKDIRP := mkdir -p +SED := sed +INSTALL := install -p +TOUCH := touch +ECHO := echo +PERL := perl +OBJCOPY := objcopy -I elf32-little -O binary +REMAKE := $(MAKE) -f $(MAKEFILE) + +LEX := flex +YACC := bison -y +CC_X86 := gcc -mno-cygwin +CXX_X86 := g++ -mno-cygwin +LD_X86 := gcc -mno-cygwin +AR_X86 := ar ruc + + +#---------------------------------------------------------------------------- +# MY BUILD TOOLS +# + +MAKELCF := $(CTR_TOOLSDIR)/bin/makelcf.exe +MAKEBANNER := $(CTR_TOOLSDIR)/bin/makebanner.exe +ADDBANNER := $(CTR_TOOLSDIR)/bin/addbanner.exe +NTEXCONV := $(CTR_TOOLSDIR)/bin/ntexconv.exe +COMPSTATIC := $(CTR_TOOLSDIR)/bin/compstatic.exe +MAKEROM := $(CTR_TOOLSDIR)/bin/makerom.exe +EMUCHILD := $(CTR_TOOLSDIR)/bin/emuchild.exe +ATTACHSIGN := $(CTR_TOOLSDIR)/bin/attachsign.exe +BIN2OBJ := $(CTR_TOOLSDIR)/bin/bin2obj.exe + +MAKELCF_FLAGS ?= +MAKEBANNER_FLAGS ?= +MAKEROM_FLAGS ?= +COMPSTATIC_FLAGS ?= +DEFAULT_COMP_ARM9 ?= $(if $(findstring TEG,$(CTR_PLATFORM)),ferret,mongoose) +DEFAULT_ADDRESS_DTCM ?= $(if $(findstring TEG,$(CTR_PLATFORM)),0x02380000,0x027e0000) +DEFAULT_COMPSUFFIX ?= _LZ +DEFAULT_MAKEROM_ARM11 := $(CTR_COMPONENTSDIR)/printserver/$(CTR_BUILDTYPE_ARM9)/main.nef +DEFAULT_MAKEROM_ARM9 := $(CTR_COMPONENTSDIR)/$(DEFAULT_COMP_ARM9)/$(CTR_BUILDTYPE_ARM7)/$(DEFAULT_COMP_ARM9)_sub$(TS_VERSION).nef + +DEFAULT_MAKEROM_ROMROOT := ./files +DEFAULT_MAKEROM_ROMFILES := +DEFAULT_MAKEROM_ROMSPEED ?= $(CTR_ROMSPEED) + + +#---------------------------------------------------------------------------- +# LIST OF JUNKS for "make +# + +GDIRT_CLEAN = a.out core *~ *.bak \\\#*\\\# $(GDIRT_CLEAN_DIRS) + +GDIRT_CLOBBER = $(GDIRT_CLOBBER_DIRS) + +GDIRT_INSTALLED = $(addprefix $(INSTALL_DIR)/,$(notdir $(INSTALL_TARGETS))) + + +#---------------------------------------------------------------------------- +# CTRSDK_INSTALL_ROOT +# + +ifdef CTRSDK_INSTALL_ROOT +CTRSDK_INSTALL_ROOT_ := $(CTRSDK_INSTALL_ROOT) +else +CTRSDK_INSTALL_ROOT_ := $(CTRSDK_ROOT) +endif + +CTR_INSTALL_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(CTRSDK_INSTALL_ROOT_))) +CTR_INSTALL_INCDIR := $(CTR_INSTALL_ROOT)/include +CTR_INSTALL_TOOLSDIR := $(CTR_INSTALL_ROOT)/tools +CTR_INSTALL_LIBDIR := $(CTR_INSTALL_ROOT)/lib/$(CTR_LIBTYPE) +CTR_INSTALL_COMPONENTSDIR := $(CTR_INSTALL_ROOT)/components +CTR_INSTALL_ADDINS := $(CTR_INSTALL_ROOT)/add-ins + + +#---------------------------------------------------------------------------- +# PRIVATE FLAGS +# +-include $(CTR_BUILDTOOLSDIR)/_privatedefs +-include $(CTR_BUILDTOOLSDIR)/@privatedefs + + +#---------------------------------------------------------------------------- +# Load add-ins' commondefs +# +-include $(CTR_BUILDTOOLSDIR)/commondefs.add-ins.* + + +#---------------------------------------------------------------------------- +# DEFAULT TARGET +# +ifdef CTR_UTEST +default all: utest +else +default all: build +endif + +#---------------------------------------------------------------------------- +endif # CTRSDK_COMMONDEFS_ +#----- End of commondefs ----- diff --git a/trunk/build/buildtools/commondefs.add-ins.utest b/trunk/build/buildtools/commondefs.add-ins.utest new file mode 100644 index 0000000..331703c --- /dev/null +++ b/trunk/build/buildtools/commondefs.add-ins.utest @@ -0,0 +1,41 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - UnitTest Tool +# File: commondefs.add-ins.utest +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded insructions, 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +# +# UNIT TEST on ARM11 +# +ifeq ($(CODEGEN_PROC),ARM11) + +ELIBRARIES += libutest$(CTR_LIBSUFFIX).a + +MAKE_UTEST_MAIN = $(CTR_TOOLSDIR)/bin/make_utest_main__ +UTEST_MAIN_SRC = $(OBJDIR)/utest_main__.c +UTEST_MAIN_BIN = utest_main__.srl + +ifdef UTEST_CHECKASSERT +MACRO_FLAGS += -DSDK_CHECKASSERT +endif + +# +# UNIT TEST on ARM9 +# +else # ($(CODEGEN_PROC),ARM9) +# Not support unit test on ARM9 + +endif + +#===== End of commondefs.add-ins.utest ===== diff --git a/trunk/build/buildtools/commondefs.cctype.CW b/trunk/build/buildtools/commondefs.cctype.CW new file mode 100644 index 0000000..9911550 --- /dev/null +++ b/trunk/build/buildtools/commondefs.cctype.CW @@ -0,0 +1,510 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - buildtools - compiler dependant settings for CW +# File: commondefs.cctype.CW +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +EMPTY ?= +SPACE ?= $(EMPTY) $(EMPTY) + +#---------------------------------------------------------------------------- +CTR_STD_PCHDR ?= True + +#---------------------------------------------------------------------------- +CWFOLDER_IRIS ?= C:/Program Files/Metrowerks/CW for NINTENDO DS V1.2 +CWFOLDER_CTR ?= $(CWFOLDER_IRIS) +LM_LICENSE_FILE := $(subst /,\,$(CWFOLDER_CTR))\license.dat +CW_ROOT := $(subst $(SPACE),\ ,$(subst \,/,$(CWFOLDER_CTR))) +CW_BINDIR := $(CW_ROOT)/ARM_Tools/Command_Line_Tools +CW_ARMDIR := $(CW_ROOT)/ARM_EABI_Support + +#---------------------------------------------------------------------------- +SDK_VERINFO_CW_CC := $(CTR_BUILDTOOLSDIR)/verinfo.cw.cc +SDK_VERINFO_CW_LD := $(CTR_BUILDTOOLSDIR)/verinfo.cw.ld + +ifeq ($(MAKECMDGOALS),do-build) + +-include $(SDK_VERINFO_CW_CC) $(SDK_VERINFO_CW_LD) +#--------CW2.0beta2 以降のバージョンへの対応 +ifndef SDK_CW_BUILD_VERSION_CC +#--------SDK_CW_BUILD_VERSION_CCが定義されていない場合makeでverinfoを作成 +MAKE_VERINFO := $(shell make make-verinfo) +-include $(SDK_VERINFO_CW_CC) $(SDK_VERINFO_CW_LD) +endif + +ifeq ($(shell expr "$(SDK_CW_BUILD_VERSION_CC)" ">=" 3.0),1) +CW_MAJOR_VER ?= 2 +endif +# "__declspec(force_export)" support +ifeq ($(shell expr "$(SDK_CW_BUILD_VERSION_CC)" ">=" 3.0),1) +SDK_CW_FORCE_EXPORT_SUPPORT := yes +endif +endif +CW_MAJOR_VER ?= 1 + +######## IRIS V0.2 Hotfix 1 +######## CTR V0.3 +#CW_AVOID_STRB := -avoid_strb all,noerr +# +######## CTR V0.4 or other +CW_AVOID_STRB := -avoid_byte strb -warn_byte none +#CW_AVOID_STRB := -avoid_byte strb -warn_byte all +# + +#---------------------------------------------------------------------------- + +MWCC := $(CW_BINDIR)/mwccarm.exe +MWAS := $(CW_BINDIR)/mwasmarm.exe +MWLD := $(CW_BINDIR)/mwldarm.exe +MWAR := $(MWLD) + +CC := $(MWCC) +AS := $(MWAS) +LD := $(MWLD) +AR := $(MWAR) + +ELFTOBIN := $(CW_BINDIR)/elftobin.exe +ELFTOBIN_TYPE := $(CTR_PLATFORM)$(CODEGEN_ARCH)/$(CTR_BUILD_DIR) +ELFTOBIN_ARM11 ?= $(CTR_COMPONENTSDIR)/printserver/$(CTR_BUILDTYPE_ARM11)/printserver.nef +ELFTOBIN_ARM9 ?= $(CTR_COMPONENTSDIR)/ferret/$(CTR_BUILDTYPE_ARM9)/ferret.nef +ELFTOBIN_ROMHEADER ?= $(CTR_TOOLSDIR)/elftobin/romHeader.bin + +#---------------------------------------------------------------------------- +# Workaround flags +# SDK_CW_WARNOFF_SAFESTRB : use code32.h to wipe warning STRB out +# SDK_CW_WA_OPT4 : workaround for -O4 +# SDK_CW_WA_CONSTPOOLS : workaround for CW 'ConstantPools.c'line: 346 +# SDK_CW_WA_OPT_BLX : workaround for blxeq,blxne with opt>=2 +# SDK_CW_WA_LIBCXX : workaround for 'C++' libname in lcf +# + +#--- flags --- +ifeq ($(CTR_PLATFORM),TEG) +SDK_CW_WARNOFF_SAFESTRB := yes +else +SDK_CW_WARNOFF_SAFESTRB := +endif + +######## IRIS V0.2 Hotfix 1 +######## CTR V0.3 +######## CTR V0.4.1 +#SDK_CW_WA_OPT4 := yes +#SDK_CW_WA_CONSTPOOLS := yes +#SDK_CW_WA_OPT_BLX := yes +######## CTR V0.5 +######## CTR V0.5 + HotFix1 +######## CTR V0.6 +#SDK_CW_WA_LIBCXX := yes + +#----------------------------------- +# +ifdef SDK_CW_WA_OPT_BLX +ifdef CTR_BLXCHECKED +# workaround by pragma +MACRO_FLAGS += -DSDK_CW_WA_OPT_BLX +else +# workaround by option +SDK_CW_AVOID_ARM_ARCH5 := yes +endif +endif + +ifdef SDK_CW_WARNOFF_SAFESTRB +MACRO_FLAGS += -DSDK_CW_WARNOFF_SAFESTRB +endif + +ifdef SDK_CW_WA_OPT4 +ifeq ($(CTR_CODEGEN),ARM) +ifneq ($(CTR_BUILD_TYPE),DEBUG) +MACRO_FLAGS += -DSDK_CW_WA_OPT4 +endif +endif +endif + +ifdef SDK_CW_WA_CONSTPOOLS +ifeq ($(CTR_CODEGEN),THUMB) +ifneq ($(CTR_BUILD_TYPE),DEBUG) +MACRO_FLAGS += -DSDK_CW_WA_CONSTPOOLS +endif +endif +endif + +ifdef SDK_CW_FORCE_EXPORT_SUPPORT +MACRO_FLAGS += -DSDK_CW_FORCE_EXPORT_SUPPORT +endif + +#---------------------------------------------------------------------------- +# SDK small build + +ifdef SDK_SMALL_BUILD +MACRO_FLAGS += -DSDK_SMALL_BUILD +endif + +#---------------------------------------------------------------------------- +# Workaround flags +# SDK_TEG_WA_VBLANK : workaround TEG vblank problems +# + +ifeq ($(CTR_PLATFORM),TEG) +MACRO_FLAGS += -DSDK_TEG_WA_VBLANK +endif + + +#---------------------------------------------------------------------------- +######## IRIS V0.2 Hotfix 1 +######## CTR V0.3 +######## CTR V0.4 +#CW_LIBNAME_RULE_A := ARM +#CW_LIBNAME_RULE_T := Thumb +#CW_LIBNAME_RULE_AI := ARM_i +#CW_LIBNAME_RULE_RA := ARM_Runtime +#CW_LIBNAME_RULE_RT := Thumb_Runtime +#CW_LIBNAME_RULE_RAI := ARM_Runtime_i +######## CTR V0.5 or other +CW_LIBNAME_RULE_A := CTR_A +CW_LIBNAME_RULE_T := CTR_T +CW_LIBNAME_RULE_AI := CTR_Ai +CW_LIBNAME_RULE_RA := CTR_Runtime_A +CW_LIBNAME_RULE_RT := CTR_Runtime_T +CW_LIBNAME_RULE_RAI := CTR_Runtime_Ai +# + +CW_INCDIRS = $(CW_ARMDIR)/msl/MSL_C/MSL_ARM/Include \ + $(CW_ARMDIR)/msl/MSL_C/MSL_Common/Include \ + $(CW_ARMDIR)/msl/MSL_C/MSL_Common_Embedded/Math/Include \ + $(CW_ARMDIR)/msl/MSL_C++/MSL_ARM/Include \ + $(CW_ARMDIR)/msl/MSL_C++/MSL_Common/Include \ + $(CW_ARMDIR)/msl/MSL_Extras/MSL_Common/Include \ + $(CW_ARMDIR)/Profiler/include +#--------CW2.0beta2 以降のバージョンではRuntimeのディレクトリが変更されたため +ifeq ($(CW_MAJOR_VER),2) +CW_INCDIRS += $(CW_ARMDIR)/msl/MSL_Extras/MSL_ARM/Include +endif + +CW_CXX = $(if $(SDK_CW_WA_LIBCXX),CXX,CPP) +CW_LIBCXX_DIR = $(if $(SDK_CW_WA_LIBCXX),$(ROOT)/lib/CodeWarrior,$(CW_ARMDIR)/msl/MSL_C++/MSL_ARM/Lib) +#--------CW2.0beta2 以降のバージョンではRuntimeのディレクトリが変更されたため +ifeq ($(CW_MAJOR_VER),2) +CW_LIBDIRS ?= $(CW_ARMDIR)/msl/MSL_C/MSL_ARM/Lib \ + $(CW_LIBCXX_DIR) \ + $(CW_ARMDIR)/msl/MSL_Extras/MSL_ARM/Lib \ + $(CW_ARMDIR)/Runtime/Runtime_ARM/Runtime_CTR/Lib \ + $(CW_ARMDIR)/Mathlib/lib +endif +CW_LIBDIRS ?= $(CW_ARMDIR)/msl/MSL_C/MSL_ARM/Lib \ + $(CW_LIBCXX_DIR) \ + $(CW_ARMDIR)/msl/MSL_Extras/MSL_ARM/Lib \ + $(CW_ARMDIR)/Runtime/Lib \ + $(CW_ARMDIR)/Mathlib/lib + +ifeq ($(CODEGEN_PROC)-$(CTR_PLATFORM),ARM9-TEG) +CW_SUFFIX = _LE_strb.a +else +CW_SUFFIX = _LE.a +endif + +ifeq ($(CODEGEN_PROC),ARM9) +CW_LIBFP ?= FP_fastI_v5t_LE.a +# CW_LIBFP ?= FP_fixedI_v5t_LE.a +# CW_LIBFP ?= FP_flush0_v5t_LE.a +# CW_LIBFP ?= FP_fullI_v5t_LE.a +else +CW_LIBFP ?= FP_fastI_v4t_LE.a +# CW_LIBFP ?= FP_fixedI_v4t_LE.a +# CW_LIBFP ?= FP_flush0_v4t_LE.a +# CW_LIBFP ?= FP_fullI_v4t_LE.a +endif + +CW_LIBCXX_ARM = MSL_$(CW_CXX)_$(CW_LIBNAME_RULE_AI)$(CW_SUFFIX) + +CW_LIBS_ARM = MSL_C_$(CW_LIBNAME_RULE_AI)$(CW_SUFFIX) \ + MSL_Extras_$(CW_LIBNAME_RULE_AI)$(CW_SUFFIX) \ + $(CW_LIBCXX_ARM) \ + $(CW_LIBFP) \ + $(CW_LIBNAME_RULE_RAI)$(CW_SUFFIX) + +# Workaround for Byte Access: Don't use thumb libraries if ARM9-TEG +ifeq ($(CODEGEN_PROC)-$(CTR_PLATFORM),ARM9-TEG) + +CW_LIBCXX_THUMB = $(CW_LIBCXX_ARM) + +CW_LIBS_THUMB = $(CW_LIBS_ARM) + +else + +CW_LIBCXX_THUMB = MSL_$(CW_CXX)_$(CW_LIBNAME_RULE_T)_LE.a + +CW_LIBS_THUMB = MSL_C_$(CW_LIBNAME_RULE_T)_LE.a \ + MSL_Extras_$(CW_LIBNAME_RULE_T)_LE.a \ + $(CW_LIBCXX_THUMB) \ + $(CW_LIBFP) \ + $(CW_LIBNAME_RULE_RT)_LE.a +endif + +ifeq ($(CODEGEN_PROC),ARM11) +STUBS_LIBS += libstubscw$(CTR_LIBSUFFIX).a +else # ($(CODEGEN_PROC),ARM9) +STUBS_LIBS += libstubscw_sp$(CTR_LIBSUFFIX).a +endif + $(ECHO) "==== test"; + +#---------------------------------------------------------------------------- +# switch by codegen target +# CTR_PLATFORM TEG/TS +# CTR_MEMSIZE 64M/128M +# CODEGEN_PROC ARM11/ARM9 +# CODEGEN_CC ARM/THUMB +# CODEGEN_AS ARM/THUMB +# + +MACRO_FLAGS += -DSDK_$(CTR_PLATFORM) \ + -DSDK_$(CTR_MEMSIZE) \ + -DSDK_$(CODEGEN_PROC) + +MACRO_FLAGS_CC += -DSDK_CODE_$(CODEGEN_CC) +MACRO_FLAGS_AS += -DSDK_CODE_$(CODEGEN_AS) + + +#-------------------------------------- CODEGEN_PROC ARM11/ARM9 +ifeq ($(CODEGEN_PROC),ARM9) + +CCFLAGS_PROC := -proc $(if $(SDK_CW_AVOID_ARM_ARCH5),arm7tdmi,arm946e) +ASFLAGS_PROC := -proc arm5TE + +ifeq ($(CTR_PLATFORM),TEG) +CCFLAGS_PROC += $(CW_AVOID_STRB) +endif + +else # ($(CODEGEN_PROC),ARM7) + +CCFLAGS_PROC := -proc arm7tdmi +ASFLAGS_PROC := -proc arm4T + +endif # ($(CODEGEN_PROC)) + +#-------------------------------------- CTR_CODEGEN ARM/THUMB + +ifeq ($(CTR_CODEGEN),ARM) +CW_LIBS ?= $(CW_LIBS_ARM) +else # ($(CTR_CODEGEN),THUMB) +CW_LIBS ?= $(CW_LIBS_THUMB) +endif + + +#-------------------------------------- CODEGEN_CC ARM/THUMB + +ifeq ($(CODEGEN_CC),THUMB) +CCFLAGS_ISET := -thumb +else +CCFLAGS_ISET := -nothumb +endif + + +#-------------------------------------- CODEGEN_AS ARM/THUMB + +ifeq ($(CODEGEN_AS),THUMB) +ASFLAGS_ISET := -16 +else +ASFLAGS_ISET := -32 +endif + + +CCFLAGS_ARCH ?= $(CCFLAGS_PROC) $(CCFLAGS_ISET) -nopic -nopid -interworking +ASFLAGS_ARCH ?= $(ASFLAGS_PROC) $(ASFLAGS_ISET) +LDFLAGS_ARCH ?= $(CCFLAGS_PROC) $(CCFLAGS_ISET) -nopic -nopid -interworking +ARFLAGS_ARCH ?= + +#---------------------------------------------------------------------------- +# standard includes/libraries for CodeWarrior +# + +export MWCIncludes := $(subst \;, ,$(subst $(SPACE),;,$(CW_INCDIRS))) +export MWLibraries := $(subst \;, ,$(subst $(SPACE),;,$(CW_LIBDIRS))) +export MWLibraryFiles := $(subst \;, ,$(subst $(SPACE),;,$(CW_LIBS))) + +#---------------------------------------------------------------------------- +# switch by C Compiler CW/SNC +# + +MACRO_FLAGS += -DSDK_$(CTR_CCTYPE) + + +#---------------------------------------------------------------------------- +# switch by DEBUG/RELEASE/FINALROM +# + +MACRO_FLAGS += -DSDK_$(CTR_BUILD_TYPE) + +ifeq ($(CTR_BUILD_TYPE),DEBUG) + +CCFLAGS_OPT ?= -O0 -inline off +ASFLAGS_OPT ?= +LDFLAGS_OPT ?= +ARFLAGS_OPT ?= + +else + +CCFLAGS_OPT_O_ = -O4 -inline on,noauto + +ifeq ($(CODEGEN_PROC),ARM11) +CCFLAGS_OPT_O_ += -opt speed +else +CCFLAGS_OPT_O_ += -opt space +endif + +ifeq ($(CTR_BUILD_TYPE),FINALROM) +CCFLAGS_OPT ?= $(CCFLAGS_OPT_O_) +ASFLAGS_OPT ?= +LDFLAGS_OPT ?= +ARFLAGS_OPT ?= +else # ($(CTR_BUILD_TYPE),RELEASE) # (default) +CCFLAGS_OPT ?= $(CCFLAGS_OPT_O_) +ASFLAGS_OPT ?= +LDFLAGS_OPT ?= +ARFLAGS_OPT ?= +endif + +endif + +ifndef CTR_NO_OPT_G +CCFLAGS_OPT += -g +LDFLAGS_OPT += -g +endif + +#--------CW2.0beta2 以降のバージョンではサイズ増大問題回避のため -ipa file オプションが必須 +ifeq ($(CW_MAJOR_VER),2) +CCFLAGS_OPT += -ipa file +endif + + +#---------------------------------------------------------------------------- +# switch for code profiling +# + +ifdef CTR_PROFILE +CCFLAGS_OPT += -profile +endif + +ifdef CTR_PROFILE_TYPE +CCFLAGS_OPT += -DSDK_PROFILE_$(CTR_PROFILE_TYPE) +endif + + +#---------------------------------------------------------------------------- +# switch for anti-thread policy +# + +ifdef CTR_NO_THREAD +MACRO_FLAGS += -DSDK_NO_THREAD +endif + + +#---------------------------------------------------------------------------- +# switch for AUTOTEST/UNITTEST +# +ifdef CTR_AUTOTEST +MACRO_FLAGS += -DSDK_AUTOTEST +endif +ifdef CTR_UTEST +MACRO_FLAGS += -DSDK_UTEST +endif + +#---------------------------------------------------------------------------- +# Switch for using system call when SVC_WaitVBlankIntr +# +ifdef CTR_SVC_WAITVBLANK_COMPATIBLE +MACRO_FLAGS += -DSDK_SVC_WAITVBLANK_COMPATIBLE +endif + +#---------------------------------------------------------------------------- +# Switch for automatic PrintServer +# +ifdef CTR_ENABLE_ARM9_PRINT +MACRO_FLAGS += -DSDK_ENABLE_ARM9_PRINT +endif + + +#---------------------------------------------------------------------------- +# switch for TS board +# +# Default value of CTR_TS_VERSION is defined in +# +# CTR_TS_VERSION = [0/100/200] +# +# 0 : Prototype breadboard ~ ISD-BOX Ver.C +# 100 : ISD-BOX Ver.D +# 200 : ISD-BOX Ver.E +# +# +ifdef CTR_TS_VERSION +MACRO_FLAGS += -DSDK_TS_VERSION=$(CTR_TS_VERSION) +endif + + +#---------------------------------------------------------------------------- +# my macro flags +# +MACRO_FLAGS += $(LMACRO_FLAGS) + + +#---------------------------------------------------------------------------- +CCFLAGS_WARNING_FULL = all,cmdline,illpragmas,emptydecl,possible,unusedarg,unusedvar,unused,extracomma,pedantic,hidevirtual,implicitconv,impl_int2float,impl_float2int,impl_signedunsigned,notinlined,largeargs,structclass,padding,notused,missingreturn,unusedexpr,ptrintconv,anyptrintconv,undefmacro,filecaps,sysfilecaps,tokenpasting + +CCFLAGS_MSGSTYLE ?= -msgstyle std + +ifdef CTR_WARNING_STRICT +CCFLAGS_WARNING ?= -w $(CCFLAGS_WARNING_FULL) +else +CCFLAGS_WARNING ?= -w all +endif +LDFLAGS_WARNING ?= -w on +ARFLAGS_WARNING ?= -w on + +ifeq ($(CTRSDK_LANG),en) +CCFLAGS_ENCODING ?= -enc ascii +else +CCFLAGS_ENCODING ?= -enc SJIS +endif +CCFLAGS_CHARTYPE ?= -char signed + +CCFLAGS_MISC = $(CCFLAGS_MSGSTYLE) $(CCFLAGS_WARNING) $(CCFLAGS_ENCODING) $(CCFLAGS_CHARTYPE) +ASFLAGS_MISC = $(CCFLAGS_MSGSTYLE) +LDFLAGS_MISC = $(CCFLAGS_MSGSTYLE) $(LDFLAGS_WARNING) +ARFLAGS_MISC = $(CCFLAGS_MSGSTYLE) $(ARFLAGS_WARNING) + + +#---------------------------------------------------------------------------- + +CCFLAGS_SYS ?= -stdinc -enum int -stdkeywords off -Cpp_exceptions off +ASFLAGS_SYS ?= -nostdinc -DSDK_ASM +LDFLAGS_SYS ?= -stdlib -map closure -main _start +ARFLAGS_SYS ?= -library + + +CCFLAGS = -lang c $(CCFLAGS_ARCH) $(CCFLAGS_OPT) $(CCFLAGS_MISC) \ + $(CCFLAGS_SYS) $(MACRO_FLAGS) $(MACRO_FLAGS_CC) + +CXXFLAGS = -lang c++ $(CCFLAGS_ARCH) $(CCFLAGS_OPT) $(CCFLAGS_MISC) \ + $(CCFLAGS_SYS) $(MACRO_FLAGS) $(MACRO_FLAGS_CC) + +ASFLAGS = $(ASFLAGS_ARCH) $(ASFLAGS_OPT) $(ASFLAGS_MISC) \ + $(ASFLAGS_SYS) $(MACRO_FLAGS) $(MACRO_FLAGS_AS) + +LDFLAGS = $(LDFLAGS_ARCH) $(LDFLAGS_OPT) $(LDFLAGS_MISC) \ + $(LDFLAGS_SYS) + +ARFLAGS = $(ARFLAGS_ARCH) $(ARFLAGS_OPT) $(ARFLAGS_MISC) \ + $(ARFLAGS_SYS) + + +#----- End of commondefs.cctype.CW ----- diff --git a/trunk/build/buildtools/commondefs.cctype.RVCT b/trunk/build/buildtools/commondefs.cctype.RVCT new file mode 100644 index 0000000..985bf39 --- /dev/null +++ b/trunk/build/buildtools/commondefs.cctype.RVCT @@ -0,0 +1,321 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrFirm - buildtools - compiler dependant settings for RCVT +# File: commondefs.cctype.RVCT +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +EMPTY ?= +SPACE ?= $(EMPTY) $(EMPTY) + + +#---------------------------------------------------------------------------- +RVCT_PATH ?= $(ARMROOT)\RVCT +RVCT_ROOT = $(patsubst %/,%,$(subst $(SPACE),\ ,$(subst \,/,$(RVCT_PATH)))) +RVCT_BINDIR = $(patsubst %/,%,$(subst $(SPACE),\ ,$(subst \,/,$(RVCT30BIN)))) + + +#---------------------------------------------------------------------------- +RVCTCC := $(RVCT_BINDIR)/armcc.exe +RVCTAS := $(RVCT_BINDIR)/armasm.exe +RVCTLD := $(RVCT_BINDIR)/armlink.exe +RVCTAR := $(RVCT_BINDIR)/armar.exe +FROMELF := $(RVCT_BINDIR)/fromelf.exe +S3TOEXO := $(BROM_TOOLSDIR)/s3toexo/s3toexo.pl + +CC := $(RVCTCC) +AS := $(RVCTAS) +LD := $(RVCTLD) +AR := $(RVCTAR) + + +#---------------------------------------------------------------------------- +ifeq ($(EXO_PLATFORM),DSTEG) +EXO_SBIN_SIZE ?= 0x00008400 +else +EXO_SBIN_SIZE ?= 0x00010000 +endif + +ifeq ($(CODEGEN_PROC),ARM11) +EXO_OFFSET ?= 0x00000000 +else # ($(CODEGEN_PROC),ARM9) +EXO_OFFSET ?= EXO_SBIN_SIZE +endif + +EXO_FLAGS += --base $(EXO_OFFSET) + +#---------------------------------------------------------------------------- +# SDK small build +# +ifdef SDK_SMALL_BUILD +MACRO_FLAGS += -DSDK_SMALL_BUILD +endif + + +#---------------------------------------------------------------------------- +RVCT_INCDIRS = $(patsubst %/,%,$(subst $(SPACE),\ ,$(subst \,/,$(RVCT30INC)))) +RVCT_LIBDIRS = $(patsubst %/,%,$(subst $(SPACE),\ ,$(subst \,/,$(RVCT30LIB)))) + + +#---------------------------------------------------------------------------- +# switch by codegen target +# CTR_PLATFORM TEG/TS +# CTR_MEMSIZE 64M/128M +# CODEGEN_PROC ARM11/ARM9 +# CODEGEN_CC ARM/THUMB +# +MACRO_FLAGS += -DSDK_$(CTR_PLATFORM) \ + -DSDK_$(CTR_MEMSIZE) \ + -DSDK_$(CODEGEN_PROC) + +MACRO_FLAGS_CC += -DSDK_CODE_$(CODEGEN_CC) + + +#-------------------------------------- CODEGEN_PROC ARM11/ARM9/ARM7 +ifeq ($(CODEGEN_PROC),ARM11) +CCFLAGS_PROC := --cpu ARM11 +ASFLAGS_PROC := --cpu ARM11 +else # ($(CODEGEN_PROC),ARM9) +ifeq ($(CODEGEN_PROC),ARM9) +CCFLAGS_PROC := --cpu ARM946E-S +ASFLAGS_PROC := --cpu ARM946E-S +else # ($(CODEGEN_PROC),ARM7) +CCFLAGS_PROC := --cpu ARM7TDMI +ASFLAGS_PROC := --cpu ARM7TDMI +endif # ($(CODEGEN_PROC)) +endif # ($(CODEGEN_PROC)) + + +#-------------------------------------- CTR_CODEGEN ARM/THUMB +ifeq ($(CTR_CODEGEN),ARM) +RVCT_LIBS ?= $(RVCT_LIBS_ARM) +else # ($(CTR_CODEGEN),THUMB) +RVCT_LIBS ?= $(RVCT_LIBS_THUMB) +endif + + +#-------------------------------------- CODEGEN_CC ARM/THUMB +ifeq ($(CODEGEN_CC),THUMB) +CCFLAGS_ISET := --thumb +else +CCFLAGS_ISET := +endif + + +#-------------------------------------- CODEGEN_AS ARM/THUMB +ifeq ($(CODEGEN_AS),THUMB) +ASFLAGS_ISET := +else +ASFLAGS_ISET := +endif + +CCFLAGS_ARCH ?= $(CCFLAGS_PROC) $(CCFLAGS_ISET) +ASFLAGS_ARCH ?= $(ASFLAGS_PROC) $(ASFLAGS_ISET) +LDFLAGS_ARCH ?= +ARFLAGS_ARCH ?= + + +#---------------------------------------------------------------------------- +# switch by C Compiler CW/SNC/RVCT +# + +MACRO_FLAGS += -DSDK_$(CTR_CCTYPE) # -D__RVCT__ + + +#---------------------------------------------------------------------------- +# switch by DEBUG/RELEASE/FINALROM +# + +MACRO_FLAGS += -DSDK_$(CTR_BUILD_TYPE) -DBROM_BUILDTYPE_ARM11=$(BROM_BUILDTYPE_ARM11) -DBROM_BUILDTYPE_ARM9=$(BROM_BUILDTYPE_ARM9) + +ifeq ($(CTR_BUILD_TYPE),DEBUG) +CCFLAGS_OPT_O_ = -O0 +CCFLAGS_OPT_G_ = -g +else +ifeq ($(CTR_BUILD_TYPE),FINALROM) +CCFLAGS_OPT_O_ = -O3 -Ospace +CCFLAGS_OPT_G_ = +else # ($(CTR_BUILD_TYPE),RELEASE) # (default) +CCFLAGS_OPT_O_ = -O3 -Ospace +CCFLAGS_OPT_G_ = +endif +endif + +CCFLAGS_OPT ?= $(CCFLAGS_OPT_G_) $(CCFLAGS_OPT_O_) +ASFLAGS_OPT ?= +LDFLAGS_OPT ?= +ARFLAGS_OPT ?= + + +#---------------------------------------------------------------------------- +# switch for anti-thread policy +# +ifdef CTR_NO_THREAD +MACRO_FLAGS += -DSDK_NO_THREAD +endif + + +#---------------------------------------------------------------------------- +# switch for AUTOTEST/UNITTEST +# +ifdef CTR_AUTOTEST +MACRO_FLAGS += -DSDK_AUTOTEST +endif +ifdef CTR_UTEST +MACRO_FLAGS += -DSDK_UTEST +endif + + +#---------------------------------------------------------------------------- +# switch for TS board +# +# Default value of CTR_TS_VERSION is defined in +# +# CTR_TS_VERSION = [0/100/200] +# +# 0 : Prototype breadboard ~ ISD-BOX Ver.C +# 100 : ISD-BOX Ver.D +# 200 : ISD-BOX Ver.E +# +ifdef CTR_TS_VERSION +MACRO_FLAGS += -DSDK_TS_VERSION=$(CTR_TS_VERSION) +endif + + +#---------------------------------------------------------------------------- +# switch for anti-thread policy +# +ifdef BROM_DEF_LINK_SCATLD +MACRO_FLAGS += -DBROM_DEF_LINK_SCATLD +endif + + +#---------------------------------------------------------------------------- +# my macro flags +# +MACRO_FLAGS += $(LMACRO_FLAGS) + + +#---------------------------------------------------------------------------- +# Demote the following compiler warnings to remarks: +# +# 66: enumeration value is out of "int" range +# 108: signed bit field of length 1 +# 177: variable was declared but never referenced +# 236: controlling expression is constant +# 1256: "unsigned char" would have been promoted to "int" +# when passed through the ellipsis parameter; use the latter type instead +#A1581W: Added 2 bytes of padding at address 0x3e2 +T_CFLAGS_WARN += --diag_remark 236,177 +T_CFLAGS_WARN += --diag_suppress 66,108,1256,A1581W + +# Promote the following compiler warnings to errors: +# +# 61: integer operation result is out of range +# 68: integer conversion resulted in a change of sign +# 88: assignment in condition +# 111: statement is unreachable +# 174: expression has no effect +# 188: enumerated type mixed with another type +# 223: function "" declared implicitly +# 550: variable was set but never used +# 3017: may be used before being set +T_CFLAGS_WARN += --diag_error 68,88,111,174,188,223,3017 + +# Demote the following linker warnings to suppresses: +# +# L6314W: No section matches pattern +# L6329W: Pattern * only matches removed unused sections +T_LDFLAGS_WARN += --diag_suppress L6314W,L6329W + +ifdef BROM_PROMGEN +# L6305W: Image does not have an entry point. (Not specified or not set due to multiple choices.) +T_LDFLAGS_WARN += --diag_suppress L6305W +endif # BROM_PROMGEN + +# Promote the following linker warnings to errors: +# +# L6332W: Undefined symbol +T_LDFLAGS_WARN += --diag_error L6332W + + +CCFLAGS_WARNING ?= $(T_CFLAGS_WARN) +LDFLAGS_WARNING ?= $(T_LDFLAGS_WARN) +ARFLAGS_WARNING ?= + +ifeq ($(CTRSDK_LANG),en) +CCFLAGS_ENCODING ?= +else +CCFLAGS_ENCODING ?= --multibyte-chars +endif +CCFLAGS_CHARTYPE ?= + +CCFLAGS_MISC = $(CCFLAGS_MSGSTYLE) $(CCFLAGS_WARNING) $(CCFLAGS_ENCODING) $(CCFLAGS_CHARTYPE) +ASFLAGS_MISC = $(CCFLAGS_MSGSTYLE) +LDFLAGS_MISC = $(CCFLAGS_MSGSTYLE) $(LDFLAGS_WARNING) +ARFLAGS_MISC = $(CCFLAGS_MSGSTYLE) $(ARFLAGS_WARNING) + + +#---------------------------------------------------------------------------- +CCFLAGS_SYS ?= \ + --no_unaligned_access \ + --no_exceptions \ + --no_exceptions_unwind \ + --gnu \ + --debug \ + --split_sections \ + --apcs /interwork \ + -Ono_ldrd -Ono_memcpy --dwarf2 \ + +T_ENTRYPOINT = _start +LDFLAGS_SYS ?= \ + --callgraph --no_locals --map --mangled --symbols \ + --info=common,sizes,veneers,totals \ + --list=$(BINDIR)/realview.map \ + --locals \ + --scanlib \ + --no_exceptions \ + --exceptions_tables=nocreate \ + --datacompressor off \ + --remove \ + --pad 0xFF \ + --scatter $(LCFILE) \ + +ifndef BROM_PROMGEN +LDFLAGS_SYS += \ + --entry $(T_ENTRYPOINT) --unresolved=$(T_ENTRYPOINT) \ + +endif # BROM_PROMGEN + +# --keep '*crt0.*o(.ARM.exidx)' \ +# --info=unused \ + +ARFLAGS_SYS ?= -rcuT + +CCFLAGS = $(CCFLAGS_ARCH) $(CCFLAGS_OPT) $(CCFLAGS_MISC) \ + $(CCFLAGS_SYS) $(MACRO_FLAGS) $(MACRO_FLAGS_CC) + +CXXFLAGS = $(CCFLAGS_ARCH) $(CCFLAGS_OPT) $(CCFLAGS_MISC) \ + $(CCFLAGS_SYS) $(MACRO_FLAGS) $(MACRO_FLAGS_CC) + +ASFLAGS = $(ASFLAGS_ARCH) $(ASFLAGS_OPT) $(ASFLAGS_MISC) +# $(ASFLAGS_SYS) $(MACRO_FLAGS) $(MACRO_FLAGS_AS) + +LDFLAGS = $(LDFLAGS_ARCH) $(LDFLAGS_OPT) $(LDFLAGS_MISC) \ + $(LDFLAGS_SYS) + +ARFLAGS = $(ARFLAGS_ARCH) $(ARFLAGS_OPT) $(ARFLAGS_MISC) \ + $(ARFLAGS_SYS) + + +#----- End of commondefs.cctype.RVCT ----- diff --git a/trunk/build/buildtools/commondefs.cygpath b/trunk/build/buildtools/commondefs.cygpath new file mode 100644 index 0000000..f4f33ae --- /dev/null +++ b/trunk/build/buildtools/commondefs.cygpath @@ -0,0 +1,152 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK +# File: commondefs +# +# Copyright 2008 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:: 2008-09-29#$ +# $Rev: 8757 $ +# $Author: adachi_hiroaki $ +#---------------------------------------------------------------------------- +ifndef CTRFIRM_COMMONDEFS_CYGPATH_ +CTRFIRM_COMMONDEFS_CYGPATH_ = TRUE + +#---------------------------------------------------------------- +# +# cygpath +# + +CYGPATH ?= cygpath + +# 高速 cygpath は標準では無効 (make 3.80 では eval 関数に不具合があり動作しないため) +CYGPATH_NOCMD ?= FALSE + +# 自動判別する場合は上の定義を消す(動作未確認) +#ifndef CYGPATH_NOCMD +# +#MAKE_VERSION := $(shell $(MAKE) -v | $(HEAD) -1 | $(AWK) '{print $3}') +# +#ifndef MSYSTEM +# +#ifeq ($(shell(expr "$(MAKE_VERSION)" ">=" "3.81")),1) +#CYGPATH_NOCMD=TRUE +#else # MAKE_VERSION +#CYGPATH_NOCMD=FALSE +#endif # MAKE_VERSION +# +#endif # MSYSTEM +# +#endif # CYGPATH_NOCMD + + +# cygdrive path prefix を取得 + +ifeq ($(CYGPATH_MOUNTPOINT),) +CYGPATH_MOUNTPOINT := $(patsubst %/,%,$(dir $(shell $(CYGPATH) -u c:/))) +endif # CYGPATH_MOUNTPOINT + +ifeq ($(CYGPATH_NOCMD),TRUE) + +ifeq ($(CYGPATH_DRIVELIST),) +# 安全 +CYGPATH_DRIVELIST_ALL = $(shell DRIVES=`$(MOUNT) | $(GREP) 'type user' | $(CUT) -c1 | tr '\n' ' '` \ + && echo $${DRIVES} `echo $${DRIVES} | $(TR) '[a-z]' '[A-Z]'`) + +# 最小限で速い +CYGPATH_DRIVELIST_FAST = $(shell $(CYGPATH) -aw '$(CTRSDK_ROOT)c' \ + '$(CWFOLDER_CTR)c' \ + '$(CTRSYSTEM_ROOT)c' \ + '$(IS_CTR_DIR)c' '$(IS_TWL_DIR)c' \ + | $(CUT) -c1) + +CYGPATH_DRIVELIST := $(sort $(CYGPATH_DRIVELIST_FAST)) +#CYGPATH_DRIVELIST := $(sort $(CYGPATH_DRIVELIST_ALL)) +endif # CYGPATH_DRIVELIST + + +define cygpathm +$(strip $(eval VALUE=$(1))$(foreach DRIVE,$(CYGPATH_DRIVELIST),$(eval VALUE:=$$(patsubst $(CYGPATH_MOUNTPOINT)/$(DRIVE)/%,$(DRIVE):/%,$$(subst \,/,$$(VALUE)))))$(VALUE)) +endef # cygpathm + +define cygpathu +$(strip $(eval VALUE:=$(1))$(foreach DRIVE,$(CYGPATH_DRIVELIST),$(eval VALUE:=$$(patsubst $(DRIVE):/%,$(CYGPATH_MOUNTPOINT)/$(DRIVE)/%,$$(subst \,/,$$(VALUE)))))$(VALUE)) +endef # cygpathu + +define cygpathm_multi +$(foreach pathvar,$(1),$(call cygpathm,$(pathvar))) +endef # cygpathm_multi + +define cygpathu_multi +$(foreach pathvar,$(1),$(call cygpathu,$(pathvar))) +endef # cygpathu_multi + +define eupath +$(subst $(SPACE),\ ,$(call cygpathu,$(subst \ , ,$(1)))) +endef # eupath + +define empath +$(subst $(SPACE),\ ,$(call cygpathm,$(subst \ , ,$(1)))) +endef # empath + +else # CYGPATH_NOCMD + +define empath +$(subst $(SPACE),\ ,$(shell $(CYGPATH) -m $(subst \,\\,$(subst \ , ,$(1))))) +endef # empath + +ifdef MSYSTEM + +define eupath +$(call empath,$(1)) +endef #eupath + +define cygpathu +$(shell cygpath -m $(subst \,\\,$(subst \ , ,$(1)))) +endef + +else # MSYSTEM + +define eupath +$(subst $(SPACE),\ ,$(shell $(CYGPATH) -u $(subst \,\\,$(subst \ , ,$(1))))) +endef + +define cygpathu +$(shell cygpath -u $(subst \,\\,$(subst \ , ,$(1)))) +endef + +endif # MSYSTEM + +define cygpathm +$(shell cygpath -m $(subst \,\\,$(subst \ , ,$(1)))) +endef + +define cygpathu_multi +$(call cygpathu,$(1)) +endef + +define cygpathm_multi +$(call cygpathm,$(1)) +endef + +endif # CYGPATH_NOCMD + +export CYGPATH_MOUNTPOINT CYGPATH_DRIVELIST CYGPATH_NOCMD + +define encode_specialchar +$(subst $(SPACE),%20,$(1)) +endef + +define decode_specialchar +$(subst %20,$(SPACE),$(1)) +endef + +#---------------------------------------------------------------------------- +endif # CTRFIRM_COMMONDEFS_CYGPATH_ +#----- End of commondefs ----- diff --git a/trunk/build/buildtools/commondefs.emtype.ISD b/trunk/build/buildtools/commondefs.emtype.ISD new file mode 100644 index 0000000..fea4461 --- /dev/null +++ b/trunk/build/buildtools/commondefs.emtype.ISD @@ -0,0 +1,61 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - buildtools - debugger dependant settings for ISDbgr +# File: commondefs.emtype.ISD +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +ifdef IS_CTR_DEBUGGER_DIR + +#---------------------------------------------------------------------------- +# Setting for IS-NITRO-EMULATOR +#---------------------------------------------------------------------------- + +EMPTY ?= +SPACE ?= $(EMPTY) $(EMPTY) +CTR_ISD_ROOT := $(patsubst %/,%,$(subst $(SPACE),\ ,$(subst \,/,$(IS_CTR_DEBUGGER_DIR)))) +CTR_ISD_ROOT_NOSPACE := $(subst \,/,$(shell cygpath -d $(CTR_ISD_ROOT))) + +#---------------------------------------------------------------------------- + +ifeq ($(CODEGEN_PROC),ARM9) + +CTR_ISD_INCDIRS := $(CTR_ISD_ROOT)/Target/include/ARM9 +CTR_ISD_LIBDIRS := $(CTR_ISD_ROOT_NOSPACE)/Target/lib/ARM9-TS + +ifeq ($(CTR_CODEGEN),ARM) +CTR_ISD_LIBS := libistdmainparm.a +else # ($(CTR_CODEGEN),THUMB) +CTR_ISD_LIBS := libistdmainpthumb.a +endif + +else # ($(CODEGEN_PROC),ARM7) + +CTR_ISD_INCDIRS := $(CTR_ISD_ROOT)/Target/include/ARM7 +CTR_ISD_LIBDIRS := $(CTR_ISD_ROOT_NOSPACE)/Target/lib/ARM7-TS + +ifeq ($(CTR_CODEGEN),ARM) +CTR_ISD_LIBS := libistdsubparm.a +else # ($(CTR_CODEGEN),THUMB) +CTR_ISD_LIBS := libistdsubpthumb.a +endif + +endif + +#---------------------------------------------------------------------------- + +else + +endif + +#----- End of commondefs.emtype.ISD ----- diff --git a/trunk/build/buildtools/modulerules b/trunk/build/buildtools/modulerules new file mode 100644 index 0000000..7599c12 --- /dev/null +++ b/trunk/build/buildtools/modulerules @@ -0,0 +1,395 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - modulerules - common rules for build system +# File: modulerules +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- +ifndef CTRSDK_MODULERULES_ + +#---------------------------------------------------------------------------- +# Implicit RULES +#---------------------------------------------------------------------------- +.SUFFIXES: # Delete all suffix rules + +ifneq ($(CTR_FORCE_BUILD),) + +VPATH = $(SRCDIR) + +SSRCFILES = $(addprefix $(OBJDIR)/,$(notdir $(SRCS))) +ASRCFILES = $(addprefix $(OBJDIR)/,$(notdir $(SRCS_AUTOLOAD))) +VSRCFILES = $(addprefix $(OBJDIR)/,$(notdir $(SRCS_OVERLAY))) + +SOBJS_CC = $(filter %.o,$(SSRCFILES:.c=.o)) +SOBJS_AS = $(filter %.o,$(SSRCFILES:.s=.o)) +SOBJS_CXX = $(filter %.o,$(SSRCFILES:.cpp=.o)) +AOBJS_CC = $(filter %.o,$(ASRCFILES:.c=.o)) +AOBJS_AS = $(filter %.o,$(ASRCFILES:.s=.o)) +AOBJS_CXX = $(filter %.o,$(ASRCFILES:.cpp=.o)) +VOBJS_CC = $(filter %.o,$(VSRCFILES:.c=.o)) +VOBJS_AS = $(filter %.o,$(VSRCFILES:.s=.o)) +VOBJS_CXX = $(filter %.o,$(VSRCFILES:.cpp=.o)) + +OBJS_CC = $(SOBJS_CC) $(AOBJS_CC) $(VOBJS_CC) +OBJS_AS = $(SOBJS_AS) $(AOBJS_AS) $(VOBJS_AS) +OBJS_CXX = $(SOBJS_CXX) $(AOBJS_CXX) $(VOBJS_CXX) +OBJS_STATIC = $(SOBJS_CC) $(SOBJS_AS) $(SOBJS_CXX) $(EXT_OBJS) +OBJS_AUTOLOAD = $(AOBJS_CC) $(AOBJS_AS) $(AOBJS_CXX) $(EXT_OBJS_AUTOLOAD) +OBJS_OVERLAY = $(VOBJS_CC) $(VOBJS_AS) $(VOBJS_CXX) $(EXT_OBJS_OVERLAY) +OBJS = $(OBJS_STATIC) $(OBJS_AUTOLOAD) $(OBJS_OVERLAY) + +-include $(CTR_BUILDTOOLSDIR)/modulerules.cctype.$(CTR_CCTYPE) + +# Common Rules + +# .bin .srl +ifdef CTR_MAKEROM +# +# MAKEROM +# + +ROM_SPEC ?= $(DEFAULT_ROM_SPEC) +MAKEROM_ARM11 ?= $(DEFAULT_MAKEROM_ARM11) +MAKEROM_ARM9 ?= $(DEFAULT_MAKEROM_ARM9) +MAKEROM_ROMROOT ?= $(DEFAULT_MAKEROM_ROMROOT) +MAKEROM_ROMFILES ?= $(DEFAULT_MAKEROM_ROMFILES) +MAKEROM_ROMSPEED ?= $(DEFAULT_MAKEROM_ROMSPEED) +MAKEROM_FLAGS ?= +MAKEROM_FLAGS += $(if $(CTR_FINALROM),,-F) + +MAKEROM_DEFS = -DCTRSDK_ROOT='$(ROOT)' \ + -DTARGET_NAME='$(TARGET_NAME)' \ + -DMAKEROM_ROMROOT='$(MAKEROM_ROMROOT)' \ + -DMAKEROM_ROMFILES='$(MAKEROM_ROMFILES)' \ + -DMAKEROM_ROMSPEED='$(MAKEROM_ROMSPEED)' \ + -DBINDIR='$(BINDIR)' \ + -DCOMPDIR='$(CTR_COMPONENTSDIR)' \ + -DCOMPTYPE11='$(CTR_BUILDTYPE_ARM11)' \ + -DCOMPTYPE9='$(CTR_BUILDTYPE_ARM9)' \ + -DPROC='$(CODEGEN_PROC)' \ + -DPLATFORM='$(CTR_PLATFORM)' \ + -DCODEGEN='$(CODEGEN_ARCH)' \ + -DBUILD='$(CTR_BUILD_DIR)' \ + -DCOMPSUFFIX9='$(COMPSUFFIX)' \ + -DCOMPSUFFIX7='' + +TARGET_ROM = $(strip $(findstring .srl,$(TARGET_BIN)) \ + $(findstring .bin,$(TARGET_BIN))) + +ifneq ($(strip $(OBJS) $(LLIBRARIES)),) # any object? +ifeq ($(CODEGEN_PROC),ARM11) +SDEPENDS_BIN = $(BINDIR)/%.nef $(MAKEROM_ARM11) +MAKEROM_DEFS += -DMAKEROM_ARM11='$(basename $@)' \ + -DMAKEROM_ARM9='$(basename $(MAKEROM_ARM9))' +else # !ARM11 +SDEPENDS_BIN = $(BINDIR)/%.nef $(MAKEROM_ARM11) +MAKEROM_DEFS += -DMAKEROM_ARM11='$(basename $(MAKEROM_ARM11))' \ + -DMAKEROM_ARM9='$(basename $@)' +endif # -ARM11 +else # !OBJS !LLIBRARIES +SDEPENDS_BIN = $(MAKEROM_ARM11) $(MAKEROM_ARM7) +MAKEROM_DEFS += -DMAKEROM_ARM11='$(basename $(MAKEROM_ARM11))' \ + -DMAKEROM_ARM9='$(basename $(MAKEROM_ARM9))' +endif # -OBJS -LLIBRARIES + +ifndef USE_MY_RULE_BIN +$(BINDIR)/%.bin $(BINDIR)/%.srl: $(SDEPENDS_BIN) $(ROM_SPEC) $(LDEPENDS_BIN) $(EDEPENDS_BIN) + $(MAKEROM) $(MAKEROM_FLAGS) $(MAKEROM_DEFS) $(ROM_SPEC) $@ +endif # -USE_MY_RULE_BIN + +$(BINDIR)/$(TARGET_SIGN_BIN): $(BINDIR)/$(TARGET_BIN) + $(CTRSDK_ROOT)/tools/bin/attachsign.exe -D $(addprefix $(BINDIR)/,$(TARGET_BIN)) + +else # !CTR_MAKEROM +# +# ELFTOBIN +# +ifndef USE_MY_RULE_BIN +ifeq ($(CODEGEN_PROC),ARM11) +$(BINDIR)/%.bin $(BINDIR)/%.srl: $(BINDIR)/%.nef $(LDEPENDS_BIN) $(EDEPENDS_BIN) + $(ELFTOBIN) $< $(ELFTOBIN_ARM7) $(ELFTOBIN_ROMHEADER) -o $@ +else # !ARM11 +$(BINDIR)/%.bin $(BINDIR)/%.srl: $(BINDIR)/%.nef $(LDEPENDS_BIN) $(EDEPENDS_BIN) + $(ELFTOBIN) $(ELFTOBIN_ARM9) $< $(ELFTOBIN_ROMHEADER) -o $@ +endif # -ARM11 +endif # -USE_MY_RULE_BIN +endif # -CTR_MAKEROM + +endif # -CTR_FORCE_BUILD + +# .bnr .bsf +%.bnr: %.bsf + $(MAKEBANNER) $(MAKEBANNER_FLAGS) $< $@ + +%.nbfc %.nbfp: %.bmp + $(NTEXCONV) -no -bg -bgb -bgnc $< >/dev/null + +#---------------------------------------------------------------------------- +# MAKE TARGETS +#---------------------------------------------------------------------------- + +.PHONY: all default build install clean clobber full super-full + +BUILDCMDS = all default build + +#---------------------------------------------------------------------------- +SUBDIR_FLAGS += $(if $(CTR_CODEGEN_ALL),CTR_CODEGEN_ALL=False) + +define MAKE_SUBDIR + +$(foreach DIR,$(SUBDIRS),$(MAKE) $(SUBDIR_FLAGS) -C $(DIR) $(MAKECMDGOALS) $(AND)) true + +$(foreach FILE,$(SUBMAKES),$(MAKE) $(SUBDIR_FLAGS) -C $(dir $(FILE)) -f $(notdir $(FILE)) $(MAKECMDGOALS) $(AND)) true +endef + +ifeq ($(MAKEFILE),Makefile) +MAKEFILE_ = +else +MAKEFILE_ = /$(MAKEFILE) +endif + +define ECHO_CURDIR + $(ECHO) "==== $(CURDIR)$(MAKEFILE_)"; +endef + +define DO_INSTALL_FILES + $(INSTALL) -d $(1) $(AND) \ + $(foreach FILE, $(2), \ + if [ ! -e $(1)/$(notdir $(FILE)) -o \ + $(FILE) -nt $(1)/$(notdir $(FILE)) ]; \ + then \ + $(ECHO) " install: $(FILE) -> $(1)" $(AND) \ + $(INSTALL) $(FILE) $(1)/$(notdir $(FILE)); \ + fi $(AND) ) true +endef + +DO_INSTALL = $(call DO_INSTALL_FILES,$(INSTALL_DIR),$(INSTALL_TARGETS)) + +INSTALL_INDEX_SRC = $(firstword $(INSTALL_TARGETS)) +INSTALL_INDEX_DEST = $(INSTALL_DIR)/$(notdir $(INSTALL_INDEX_SRC)) + +define DO_INSTALL_WILDCARD + $(INSTALL) -d $(INSTALL_DIR) $(AND) \ + if [ ! -e $(INSTALL_INDEX_DEST) -o \ + $(INSTALL_INDEX_SRC) -nt $(INSTALL_INDEX_DEST) ]; \ + then \ + $(foreach FILE, $(INSTALL_TARGETS), \ + $(ECHO) " install: $(FILE) -> $(INSTALL_DIR)" $(AND) \ + $(INSTALL) $(FILE) $(INSTALL_DIR) $(AND) ) true; \ + fi +endef + +#---------------------------------------------------------------------------- +# make parallelly +#---------------------------------------------------------------------------- + +SUBDIRS_PREFIX = make-subdir-p- +SUBDIRS_PARALLEL = $(addprefix $(SUBDIRS_PREFIX),$(SUBDIRS_P)) + +$(SUBDIRS_PARALLEL):$(SUBDIRS_PREFIX)%: + $(MAKE) -C $(*F) $(MAKECMDGOALS) + +#---------------------------------------------------------------------------- +# make build +#---------------------------------------------------------------------------- +.PHONY: do-build + +build: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) +ifneq ($(strip $(NEWDIRS)),) + @$(MKDIRP) $(NEWDIRS) +endif + @+$(REMAKE) do-build +ifdef INSTALL_TARGETS + @$(DO_INSTALL) +endif +ifeq ($(CTR_CODEGEN_ALL),True) +ifeq ($(CTR_CODEGEN),ARM) + @+$(REMAKE) CTR_CODEGEN_ALL=False CTR_CODEGEN=THUMB build +endif +endif + + +#---------------------------------------------------------------------------- +# make install +#---------------------------------------------------------------------------- + +install: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) +ifdef INSTALL_TARGETS + @$(DO_INSTALL) +endif +ifeq ($(CTR_CODEGEN_ALL),True) +ifeq ($(CTR_CODEGEN),ARM) + @+$(REMAKE) CTR_CODEGEN_ALL=False CTR_CODEGEN=THUMB install +endif +endif + + +#---------------------------------------------------------------------------- +# make full +#---------------------------------------------------------------------------- + +define makefull + @echo [[[ make full $(1) $(CURDIR) ]]] + @+unset CTR_DEBUG CTR_RELEASE CTR_FINALROM CTR_CODEGEN_ALL; \ + $(foreach b,FINALROM RELEASE DEBUG, \ + $(foreach a,ARM THUMB, \ + date "+::: %Y/%m/%d %H:%M:%S $a-$b" $(AND) \ + $(REMAKE) CTR_$b=TRUE CTR_CODEGEN=$a CTR_CODEGEN_ALL=False $(1) $(AND) \ + ) \ + ) true +endef + +full: + $(call makefull,build) + +full-install: + $(call makefull,install) + +#---------------------------------------------------------------------------- +# make super-full +#---------------------------------------------------------------------------- + +define makesuperfull + @echo [[[ make super-full $(1) $(CURDIR) ]]] + @+unset CTR_DEBUG CTR_RELEASE CTR_FINALROM CTR_CODEGEN_ALL; \ + $(foreach p,TS TEG, \ + $(foreach b,FINALROM RELEASE DEBUG, \ + $(foreach a,ARM THUMB, \ + date "+::: %Y/%m/%d %H:%M:%S $a-$b" $(AND) \ + $(REMAKE) CTR_$b=TRUE CTR_PLATFORM=$p CTR_CODEGEN=$a CTR_CODEGEN_ALL=False $(1) $(AND) \ + )\ + )\ + ) true +endef + +super-full: + $(call makesuperfull,build) + +super-full-install: + $(call makesuperfull,install) + +#---------------------------------------------------------------------------- +# Autotest using IS-NITRO-EMULATOR +#---------------------------------------------------------------------------- +ifdef IS_CTR_DIR + +AUTOTESTLOG := $(ROOT)/autotest.log + +.PHONY: autotest do-autotest do-autotest-test + +autotest: + @+$(REMAKE) clobber + @+$(REMAKE) build CTR_AUTOTEST=TRUE + @$(RM) $(AUTOTESTLOG) + @+$(REMAKE) do-autotest + @$(SED) -e 's/\r//g;s/$$/\r/g;' $(AUTOTESTLOG) > $(AUTOTESTLOG).tmp + @$(MV) $(AUTOTESTLOG).tmp $(AUTOTESTLOG) + +do-autotest: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) +ifneq ($(TARGET_ROM),) + @+$(REMAKE) test-run +endif +endif + + +#---------------------------------------------------------------------------- +# make clobber & clean +#---------------------------------------------------------------------------- +.PHONY: clobber-installed + +clobber: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) + -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) $(EDIRT_CLEAN) + -$(RM) $(GDIRT_CLOBBER) $(LDIRT_CLOBBER) $(EDIRT_CLOBBER) +ifneq ($(GDIRT_INSTALLED),) +ifneq ($(CTR_FORCE_BUILD),) + $(call makefull,clobber-installed) +else + @+$(REMAKE) clobber-installed +endif +endif + +clobber-installed: + -$(RM) $(GDIRT_INSTALLED) + + +#---------------------------------------------------------------------------- + +super-clobber: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) + -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) $(EDIRT_CLEAN) + -$(RM) $(GDIRT_CLOBBER) $(LDIRT_CLOBBER) $(EDIRT_CLOBBER) +ifneq ($(GDIRT_INSTALLED),) + $(call makesuperfull,clobber-installed) +endif + + +#---------------------------------------------------------------------------- + +clean: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) + -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) $(EDIRT_CLEAN) + + +#---------------------------------------------------------------------------- +# source file dependancies +#---------------------------------------------------------------------------- + +# +# dynamic dependancy generation +# like as $(OBJDIR)/main.o: main.c +# +DEP_SRCS_ALL = $(SRCS) $(SRCS_AUTOLOAD) $(SRCS_OVERLAY) + +define RuleCtoObj +$$(OBJDIR)/$$(notdir $$(basename $(1))).o: $(1) + +endef +endif # CTRSDK_MODULERULES_ + +# Put this sentance out of include-guard to avoid $(eval xxx) limitation +$(foreach FILE,$(DEP_SRCS_ALL),$(eval $(call RuleCtoObj,$(FILE)))) + + +ifndef CTRSDK_MODULERULES_ +# +# include dependancies file +# +ifeq ($(MAKECMDGOALS),do-build) +ifdef SRCS +-include $(DEPENDDIR)/*.d +endif +endif + +#---------------------------------------------------------------------------- +# for IS-NITRO-EMULATOR +#---------------------------------------------------------------------------- +ifdef IS_CTR_DIR +-include $(CTR_BUILDTOOLSDIR)/modulerules.emtype.ISD +endif + +#---------------------------------------------------------------------------- +# Load add-ins' modulerules +#---------------------------------------------------------------------------- +-include $(CTR_BUILDTOOLSDIR)/modulerules.add-ins.* + +#---------------------------------------------------------------------------- +CTRSDK_MODULERULES_ = TRUE +endif # CTRSDK_MODULERULES_ +#----- End of modulerules ----- diff --git a/trunk/build/buildtools/modulerules.add-ins.twl b/trunk/build/buildtools/modulerules.add-ins.twl new file mode 100644 index 0000000..7780dc9 --- /dev/null +++ b/trunk/build/buildtools/modulerules.add-ins.twl @@ -0,0 +1,57 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- +ifndef TWLSDK_MODULERULES_ + +#---------------------------------------------------------------------------- +.PHONY: twltop twllib twldbg link + +link: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) + -rm $(BINDIR)/$(TARGET_BIN_BASENAME).axf $(BINDIR)/$(TARGET_BIN_BASENAME).nef + @+$(REMAKE) + +twltop: + @$(MAKE) -C $(TWLSDK_ROOT) + +twllib: + @$(MAKE) -C $(TWLSDK_ROOT)/build/buildsetup + @$(MAKE) -C $(TWLSDK_ROOT)/build/libraries + +twldbg: + @$(TOUCH) $(TWL_LDEPENDS_DBG) + @$(MAKE) -C $(TWLSDK_ROOT)/build/libraries/os + @+$(REMAKE) + +# .axf +$(BINDIR)/$(TARGET_BIN_BASENAME).axf: $(OBJS) $(LCFILE) $(MAKEFILE) $(LDEPENDS_NEF) $(EDEPENDS_NEF) $(ALIBRARIES) $(LDRES_FILE) $(CW_LIBCXX) +ifeq ($(CTR_CCTYPE),RVCT) + $(LD) $(LDFLAGS) $(LIBRARY_DIRS) -o $@ $(GLIBRARIES) $(OBJS) +else + $(LD) $(LDFLAGS) $(LIBRARY_DIRS) @$(LDRES_FILE) $(LCFILE) -o $@ +ifeq ($(TWL_PLATFORM),TS) + cp $(BINDIR)/$(TARGET_BIN_BASENAME).axf $(BINDIR)/$(TARGET_BIN_BASENAME).nef +endif +ifdef FIRM_STRIP_AXF + $(OBJCOPY) $@ $(BINDIR)/$(TARGET_BIN_BASENAME).sbin +endif +endif + +#---------------------------------------------------------------------------- +TWLSDK_MODULERULES_ = TRUE +endif # TWLSDK_MODULERULES_ +#----- End of modulerules ----- diff --git a/trunk/build/buildtools/modulerules.add-ins.twldll b/trunk/build/buildtools/modulerules.add-ins.twldll new file mode 100644 index 0000000..d3c1090 --- /dev/null +++ b/trunk/build/buildtools/modulerules.add-ins.twldll @@ -0,0 +1,53 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- +ifndef TWLDLL_MODULERULES_ + +#---------------------------------------------------------------------------- + +#MakefileでDLL_FILESを定義しておくとmake dllでstaticsymlist.cができます + +DLL_LIBS ?= $(addprefix $(TWL_LIBDIR)/,$(addsuffix $(TWL_LIBSUFFIX).a,$(DLL_FILES))) +NODBG_LIBS ?= $(addprefix $(TWL_LIBDIR)/,$(addsuffix $(TWL_LIBSUFFIX).nodbg.a,$(DLL_FILES))) +STATIC_LIBS ?= $(addprefix $(TWL_LIBDIR)/,$(TWL_LIBS)) + +.PHONY: dll + +dll: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) +ifdef DLL_FILES + $(foreach DLLFILE, $(DLL_LIBS), \ + $(TWLSDK_ROOT)/tools/stripdebug/stripdebug.exe -o $(subst .a,.nodbg.a,$(DLLFILE)) $(DLLFILE);) + + $(TWLSDK_ROOT)/tools/makelst/makelst.exe -o $(SRCDIR)/staticsymlist.c \ + -static $(STATIC_LIBS) \ + -dll $(NODBG_LIBS) +endif + + +# +# $(foreach DLLFILE, $(DLL_LIBS), \ +# $(TWLSDK_ROOT)/tools/makelst/makelst.exe -o staticsymlist.c \ +# -static $(STATIC_LIBS) \ +# -dll $(TWL_LIBDIR)/$(DLLFILE) +#) +# + +#---------------------------------------------------------------------------- +TWLDLL_MODULERULES_ = TRUE +endif # TWLDLL_MODULERULES_ +#----- End of modulerules ----- diff --git a/trunk/build/buildtools/modulerules.add-ins.utest b/trunk/build/buildtools/modulerules.add-ins.utest new file mode 100644 index 0000000..575f472 --- /dev/null +++ b/trunk/build/buildtools/modulerules.add-ins.utest @@ -0,0 +1,67 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - UnitTest Tool +# File: modulerules.add-ins.utest +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded insructions, 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +.PHONY: utest + +# +# UNIT TEST on ARM11 +# +ifeq ($(CODEGEN_PROC),ARM11) + +UTEST_MAKEOPTS = \ + SRCS="$(SRCS) $(UTEST_MAIN_SRC)" \ + LIBRARIES_UNLINK=$(TARGET_LIB) \ + TARGET_BIN=$(UTEST_MAIN_BIN) \ + TARGET_NEF= \ + TARGET_LIB= \ + TARGET_OBJ= \ + TARGET_SIGN_BIN= \ + UTEST_OBJS_TESTEE="$(OBJS)" \ + UTEST_CHECKASSERT=True \ + CTR_UTEST=True + +utest: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) +ifneq ($(strip $(TARGET_LIB)),) +ifneq ($(strip $(NEWDIRS)),) + @$(MKDIRP) $(NEWDIRS) $(BINDIR) +endif + @$(REMAKE) -s $(UTEST_MAIN_SRC) $(UTEST_MAKEOPTS) + @if [ -e $(UTEST_MAIN_SRC) ]; \ + then \ + $(REMAKE) -s do-build $(UTEST_MAKEOPTS) && \ + $(REMAKE) -s run TARGET_BIN=$(UTEST_MAIN_BIN); \ + fi +endif + +$(UTEST_MAIN_SRC): $(UTEST_OBJS_TESTEE) + @$(MAKE_UTEST_MAIN) -c $(UTEST_MAIN_SRC) $(UTEST_OBJS_TESTEE) + + +# +# UNIT TEST on ARM9 +# +else # ($(CODEGEN_PROC),ARM9) + +utest: + @ # Not support unit test on ARM9 + +endif + + +#===== End of modulerules.add-ins.utest ===== diff --git a/trunk/build/buildtools/modulerules.cctype.CW b/trunk/build/buildtools/modulerules.cctype.CW new file mode 100644 index 0000000..820fb40 --- /dev/null +++ b/trunk/build/buildtools/modulerules.cctype.CW @@ -0,0 +1,338 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - buildtools - compiler dependant settings for CodeWarrior +# File: modulerules.cctype.CW +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +AINCLUDE_DIRS = $(LINCLUDES) $(EINCLUDES) $(GINCLUDES) +ALIBRARY_DIRS = $(LLIBRARY_DIRS) $(ELIBRARY_DIRS) $(GLIBRARY_DIRS) +ALIBRARIES = $(LLIBRARIES) $(ELIBRARIES) $(GLIBRARIES) + +# +# (make version 3.80) +# +# VPATH does not support the path name included white space like "C:/Program Files" +# Please, be careful !!! +# +ifdef MSYSTEM +CTR_LIBVPATH_ = $(subst \:,\ ,$(subst $(SPACE),:,$(ALIBRARY_DIRS))) +else +CYGDRV ?= $(shell cygpath -u c:)/.. +ALIBVPATH = $(subst : ,,$(patsubst %:,$(CYGDRV)/%:,$(subst :,: ,$(ALIBRARY_DIRS)))) +endif + +vpath %.a $(ALIBVPATH) +vpath %.o $(ALIBVPATH) + +INCLUDE_DIRS = $(subst \ -I,\ ,$(addprefix -I,$(AINCLUDE_DIRS))) +LIBRARY_DIRS = $(subst \ -L,\ ,$(addprefix -L,$(ALIBRARY_DIRS))) +LIBRARIES = $(subst \ -l,\ ,$(addprefix -l,$(ALIBRARIES))) + +INCLUDES = -gccinc -I. $(INCLUDE_DIRS) + +ifdef MSYSTEM # for MinGW32 +QUOTE =' +else +QUOTE =" +endif + +#---------------------------------------------------------------------------- + +.PRECIOUS: $(OBJDIR)/%.o $(BINDIR)/%.nef $(LCFILE) $(PCHDR_H) $(PCHDR_PCH) + +# +# Generate dependency files +# +DEPEND_RULE = $(QUOTE)/ARM_EABI_Support/d;s/\\x0D//g;s/\\\\\\([^ ]\\)/\\/\\1/g;$(QUOTE) +DEPEND_RULE2 = $(QUOTE)s/^[^\\t].*: //;s/^\\t//;s/ \\\\$$//;s/\\([^ ].*\\)/\\1:/;1s/^./\\n&/;$(QUOTE) + +define MOVE_SRC_DEPEND + $(SED) -e $(DEPEND_RULE) $(*F).d > $(*F).2.d && \ + $(SED) -e $(DEPEND_RULE2) $(*F).2.d > $(*F).3.d && \ + $(CAT) $(*F).2.d $(*F).3.d > $(DEPENDDIR)/$(*F).d && \ + $(RM) $(*F).d $(*F).2.d $(*F).3.d +endef + + +ifdef CTR_STD_PCHDR +ifndef CTR_NO_STD_PCHDR + +# .mch +PCHDR_SRC = $(ROOT)/include/nitro.h +PCHDR_CACHE = $(ROOT)/cache/include + +PCHDR_C_DEFS = $(sort $(filter -DSDK_%,$(CCFLAGS))) +PCHDR_C_NODEF = $(filter-out -D%,$(CCFLAGS)) +PCHDR_C_NAME = $(subst $(SPACE),,$(subst -DSDK_,.,$(subst =,-,$(PCHDR_C_DEFS)))) +PCHDR_C_BASE = $(PCHDR_CACHE)/$(notdir $(PCHDR_SRC))$(PCHDR_C_NAME).C +PCHDR_C_MCH = $(PCHDR_C_BASE).mch +PCHDR_C_DEPEND = $(PCHDR_C_BASE).depend +PCHDR_CCFLAGS = -include $(PCHDR_C_MCH) +CCFLAGS_NOLDEF = $(PCHDR_C_DEFS) $(PCHDR_C_NODEF) + +PCHDR_CXX_DEFS = $(sort $(filter -DSDK_%,$(CXXFLAGS))) +PCHDR_CXX_NODEF = $(filter-out -D%,$(CXXFLAGS)) +PCHDR_CXX_NAME = $(subst $(SPACE),,$(subst -DSDK_,.,$(subst =,-,$(PCHDR_CXX_DEFS)))) +PCHDR_CXX_BASE = $(PCHDR_CACHE)/$(notdir $(PCHDR_SRC))$(PCHDR_CXX_NAME).CXX +PCHDR_CXX_MCH = $(PCHDR_CXX_BASE).mch +PCHDR_CXX_DEPEND= $(PCHDR_CXX_BASE).depend +PCHDR_CXXFLAGS = -include $(PCHDR_CXX_MCH) +CXXFLAGS_NOLDEF = $(PCHDR_CXX_DEFS) $(PCHDR_CXX_NODEF) + +GDIRT_CLOBBER += $(PCHDR_CACHE)/$(notdir $(PCHDR_SRC)).* + +ifeq ($(MAKECMDGOALS),do-build) + +## $(call BUILD_PCHDR,$(BASE),$(CCFLAGS)) +define BUILD_PCHDR + @$(CP) $(PCHDR_SRC) $(1).h + ($(CD) $(dir $(1).mch) && \ + $(CC) $(subst -include ,-DSDK_PCHDR_DUMMY_,$(2)) $(INCLUDES) -MD -precompile $(notdir $(1).mch) $(1).h) + @($(ECHO) $(1).mch: $(PCHDR_SRC) \\ > $(1).depend && \ + $(SED) -e '1d' -e $(DEPEND_RULE) $(1).d >> $(1).depend && $(RM) $(1).d $(1).h) +endef + +# precomipled header for C +ifneq ($(strip $(OBJS_CC)),) +-include $(PCHDR_C_DEPEND) + +$(PCHDR_C_DEPEND): $(PCHDR_C_MCH) + +$(PCHDR_C_MCH): + $(call BUILD_PCHDR,$(PCHDR_C_BASE),$(CCFLAGS_NOLDEF)) +endif + +# precomipled header for C++ +ifneq ($(strip $(OBJS_CXX)),) +-include $(PCHDR_CXX_DEPEND) + +$(PCHDR_CXX_DEPEND): $(PCHDR_CXX_MCH) + +$(PCHDR_CXX_MCH): + $(call BUILD_PCHDR,$(PCHDR_CXX_BASE),$(CXXFLAGS_NOLDEF)) +endif + +endif # do-build +endif # CTR_NO_STD_PCHDR +endif # CTR_STD_PCHDR + +# .c +$(OBJS_CC):%.o: + $(CC) $(CCFLAGS) $(INCLUDES) $(PCHDR_CCFLAGS) -c $(shell cygpath -m $<) -MD -o $@ + @$(MOVE_SRC_DEPEND) + +# .cpp +$(OBJS_CXX):%.o: + $(CC) $(CXXFLAGS) $(INCLUDES) $(PCHDR_CXXFLAGS) -c $(shell cygpath -m $<) -MD -o $@ + @$(MOVE_SRC_DEPEND) + +# .s +$(OBJS_AS):%.o: + $(AS) $(ASFLAGS) $(INCLUDES) -c $(shell cygpath -m $<) -MD -o $@ + @$(MOVE_SRC_DEPEND) + +# .lcf .par +ifdef LCFILE_SPEC + +ADDRESS_DTCM ?= $(DEFAULT_ADDRESS_DTCM) + +# exporting +GLIBRARIES_LINK = $(filter-out $(LIBRARIES_UNLINK),$(ELIBRARIES) $(GLIBRARIES)) +LLIBRARIES_LINK = $(filter-out $(LIBRARIES_UNLINK),$(LLIBRARIES)) + +MAKELCF_DEFS = -DCTRSDK_ROOT='$(ROOT)' \ + -DTARGET_NAME='$(TARGET_NAME)' \ + -DOBJS_STATIC='$(OBJS_STATIC)' \ + -DOBJS_AUTOLOAD='$(OBJS_AUTOLOAD)' \ + -DOBJS_OVERLAY='$(OBJS_OVERLAY)' \ + -DGLIBS='$(GLIBRARIES_LINK)' \ + -DLLIBS='$(LLIBRARIES_LINK)' \ + -DCW_LIBS='$(CW_LIBS)' \ + -DOBJDIR='$(OBJDIR)' \ + -DLIBDIR='$(LIBDIR)' \ + -DBINDIR='$(BINDIR)' \ + -DPROC='$(CODEGEN_PROC)' \ + -DPLATFORM='$(CTR_PLATFORM)' \ + -DCODEGEN='$(CODEGEN_ARCH)' \ + -DBUILD='$(CTR_BUILD_DIR)' \ + -DADDRESS_DTCM='$(ADDRESS_DTCM)' + +MAKELCF_FORMAT = -V$(CW_MAJOR_VER) + +MAKELCF_OPTS = $(MAKELCF_FLAGS) $(MAKELCF_DEFS) $(MAKELCF_FORMAT) + +$(LCFILE_AUTOGEN): $(LCFILE_SPEC) $(LCFILE_TEMPLATE) $(MAKEFILE) $(CTR_BUILDTOOLSDIR)/commondefs $(LDEPENDS_LCF) + $(MAKELCF) $(MAKELCF_OPTS) $< $(LCFILE_TEMPLATE) $@ + +$(LDRES_AUTOGEN): $(LCFILE_SPEC) $(LDRES_TEMPLATE) $(MAKEFILE) $(CTR_BUILDTOOLSDIR)/commondefs $(LDEPENDS_RES) + @$(MAKELCF) $(MAKELCF_OPTS) $< $(LDRES_TEMPLATE) $@ + +endif + +# compress/digest +ifeq ($(CODEGEN_PROC),ARM11) +ifdef CTR_COMPRESS +COMPSTATIC_CMDS = -11 -c +#COMPSTATIC_CMDS = -9 -c +endif +ifdef CTR_DIGEST +COMPSTATIC_CMDS += -a +endif +endif + +ifdef COMPSTATIC_CMDS +COMPSUFFIX ?= $(DEFAULT_COMPSUFFIX) +ifneq ($(COMPSUFFIX),) +COMPSTATIC_FLAGS += -e$(COMPSUFFIX) +endif +endif + + +# libcxx workaround +ifdef SDK_CW_WA_LIBCXX +CW_LIBCXX = $(CW_LIBCXX_DIR)/$(CW_LIBCXX_ARM) +$(CW_LIBCXX): $(ROOT)/build/buildsetup/libcxx/Makefile + $(MAKE) -f $< +endif + + +# .nef +ifndef USE_MY_RULE_NEF +ifneq ($(CTR_MAKEROM),) +$(BINDIR)/$(TARGET_BIN_BASENAME).nef: $(OBJS) $(LCFILE) $(MAKEFILE) $(LDEPENDS_NEF) $(EDEPENDS_NEF) $(ALIBRARIES) $(LDRES_FILE) $(CW_LIBCXX) + $(LD) $(LDFLAGS) $(LIBRARY_DIRS) @$(LDRES_FILE) $(LCFILE) -o $@ +ifdef COMPSTATIC_CMDS + $(COMPSTATIC) $(COMPSTATIC_CMDS) $(COMPSTATIC_FLAGS) -f $(BINDIR)/component.files $(CTR_STDOUT) +endif +else +$(BINDIR)/$(TARGET_BIN_BASENAME).nef: $(OBJS) $(LCFILE) $(MAKEFILE) $(LDEPENDS_NEF) $(EDEPENDS_NEF) $(ALIBRARIES) $(CW_LIBCXX) + $(LD) $(LDFLAGS) $(LIBRARY_DIRS) $(OBJS) $(LIBRARIES) $(LCFILE) -o $@ +endif +endif + +# .a +ifndef USE_MY_RULE_A +$(LIBDIR)/$(TARGET_LIB): $(OBJS) $(MAKEFILE) + $(AR) $(ARFLAGS) $(OBJS) -o $@ +endif + + +#---------------------------------------------------------------------------- +# Get SDK_CW_BUILD_VERSION SDK_CW_BUILD_NUMBER +# +# IRIS V0.2 Hotfix 1 +# SDK_CW_BUILD_VERSION_CC=2.0 +# SDK_CW_BUILD_VERSION_LD=2.0 +# SDK_CW_BUILD_NUMBER_CC=0038 +# SDK_CW_BUILD_NUMBER_LD=0050 +# +# NITRO V0.3 +# SDK_CW_BUILD_NUMBER_CC=0038 +# SDK_CW_BUILD_NUMBER_LD=0056 +# +# NITRO V0.4.1 +# SDK_CW_BUILD_NUMBER_CC=0043 +# SDK_CW_BUILD_NUMBER_LD=0057 +# +# NITRO V0.5 +# SDK_CW_BUILD_NUMBER_CC=0046 +# SDK_CW_BUILD_NUMBER_LD=0058 +# +# NITRO V0.5 + HotFix1 +# SDK_CW_BUILD_NUMBER_CC=0049 +# SDK_CW_BUILD_NUMBER_LD=0061 +# +# NITRO V0.6 +# SDK_CW_BUILD_NUMBER_CC=0050 +# SDK_CW_BUILD_NUMBER_LD=0062 +# +# NITRO V0.6.1 +# SDK_CW_BUILD_NUMBER_CC=0050 +# SDK_CW_BUILD_NUMBER_LD=0063 +# +# NITRO V0.7 +# SDK_CW_BUILD_NUMBER_CC=0050 +# SDK_CW_BUILD_NUMBER_LD=0063 +# +# NITRO V1.0 +# SDK_CW_BUILD_NUMBER_CC=0056 +# SDK_CW_BUILD_NUMBER_LD=0067 +# +# NITRO V1.0.2 +# SDK_CW_BUILD_NUMBER_CC=0068 +# SDK_CW_BUILD_NUMBER_LD=0068 +# +# NITRO V1.2 +# SDK_CW_BUILD_NUMBER_CC=0073 +# SDK_CW_BUILD_NUMBER_LD=0072 +# +# NITRO V1.2SP1 +# SDK_CW_BUILD_NUMBER_CC=0074 +# SDK_CW_BUILD_NUMBER_LD=0072 +# +# NITRO V1.2SP2+patch +# SDK_CW_BUILD_NUMBER_CC=0080 +# SDK_CW_BUILD_NUMBER_LD=0074 +# +# NITRO V1.2SP3 +# SDK_CW_BUILD_NUMBER_CC=0084 +# SDK_CW_BUILD_NUMBER_LD=0077 +# +# NITRO V1.2SP4 +# SDK_CW_BUILD_NUMBER_CC=0087 +# SDK_CW_BUILD_NUMBER_LD=7702 +# +# NITRO V2.0beta +# SDK_CW_BUILD_VERSION_CC=3.0 +# SDK_CW_BUILD_VERSION_LD=2.0 +# SDK_CW_BUILD_NUMBER_CC=0107 +# SDK_CW_BUILD_NUMBER_LD=0077 +# +# NITRO V2.0 +# SDK_CW_BUILD_NUMBER_CC=0114 +# SDK_CW_BUILD_NUMBER_LD=0082 +# +ifneq ($(findstring $(MAKECMDGOALS),do-build make-verinfo clean-verinfo),) + +.PHONY: make-verinfo +make-verinfo: $(SDK_VERINFO_CW_CC) $(SDK_VERINFO_CW_LD) + +$(SDK_VERINFO_CW_CC): $(MWCC) + @$(MWCC) -version | \ + $(SED) -e $(QUOTE)/^Version /!d;s/\(build [0-9]\{2,3\}\) /\100 /;s/^Version \([0-9.]*\).*build \([0-9]*\).*(build \([0-9]*\)).*/SDK_CW_BUILD_VERSION_CC=\1\nSDK_CW_BUILD_NUMBER_CC=\3\nSDK_CW_BUILD_NUMBER2_CC=\2/i;$(QUOTE) >$(SDK_VERINFO_CW_CC) + @$(TOUCH) -r $(MWCC) $(SDK_VERINFO_CW_CC) + +$(SDK_VERINFO_CW_LD): $(MWLD) + @$(MWLD) -version | \ + $(SED) -e $(QUOTE)/^Version /!d;s/\(build [0-9]\{2,3\}\) /\100 /;s/^Version \([0-9.]*\).*build \([0-9]*\).*(build \([0-9]*\)).*/SDK_CW_BUILD_VERSION_LD=\1\nSDK_CW_BUILD_NUMBER_LD=\3\nSDK_CW_BUILD_NUMBER2_LD=\2/i;$(QUOTE) >$(SDK_VERINFO_CW_LD) + @$(TOUCH) -r $(MWLD) $(SDK_VERINFO_CW_LD) + +endif + +.PHONY: clean-verinfo +clean-verinfo: + @$(RM) $(CTR_BUILDTOOLSDIR)/verinfo.* + + +#---------------------------------------------------------------------------- +# Check codegen bug around blxeq/blxne +# + +.PHONY: codecheck + +codecheck: + @$(ECHO) --- checking codegen --- + @$(CTR_TOOLSDIR)/bin/blxchecker + +#----- End of modulerules.cctype.CW ----- diff --git a/trunk/build/buildtools/modulerules.cctype.RVCT b/trunk/build/buildtools/modulerules.cctype.RVCT new file mode 100644 index 0000000..aa0153b --- /dev/null +++ b/trunk/build/buildtools/modulerules.cctype.RVCT @@ -0,0 +1,150 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrFirm - buildtools - compiler dependant settings for ProDG +# File: modulerules.cctype.RVCT +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +AINCLUDE_DIRS = $(LINCLUDES) $(EINCLUDES) $(GINCLUDES) $(RVCT_INCDIRS) +ALIBRARY_DIRS = $(LLIBRARY_DIRS) $(ELIBRARY_DIRS) $(GLIBRARY_DIRS) # $(RVCT_LIBDIRS) +ALIBRARIES = $(LLIBRARIES) $(ELIBRARIES) $(GLIBRARIES) + +# +# (make version 3.80) +# +# VPATH does not support the path name included white space like "C:/Program Files" +# Please, be careful !!! +# +ifdef MSYSTEM +CTR_LIBVPATH_ = $(subst \:,\ ,$(subst $(SPACE),:,$(ALIBRARY_DIRS))) +else +CYGDRV ?= $(shell cygpath -u c:)/.. +ALIBVPATH = $(subst : ,,$(patsubst %:,$(CYGDRV)/%:,$(subst :,: ,$(ALIBRARY_DIRS)))) +endif + +vpath %.a $(ALIBVPATH) +vpath %.o $(ALIBVPATH) + +INCLUDE_DIRS = $(subst \ -I,\ ,$(addprefix -I,$(AINCLUDE_DIRS))) +LIBRARY_DIRS = $(subst \ -L,\ ,$(addprefix --userlibpath ,$(ALIBRARY_DIRS))) +LIBRARIES = $(subst \ -l,\ ,$(addprefix -l,$(ALIBRARIES))) + +INCLUDES = -I. $(INCLUDE_DIRS) + +ifdef MSYSTEM # for MinGW32 +QUOTE =' +else +QUOTE =" +endif + +#---------------------------------------------------------------------------- + +.PRECIOUS: $(OBJDIR)/%.o $(BINDIR)/%.nef $(LCFILE) + +# +# Generate dependency files +# +DEPEND_RULE = $(QUOTE)s/^\(.*\)\s\(.*\)$$/&\n\2:/;$(QUOTE) + +define MOVE_SRC_DEPEND + $(SED) -e $(DEPEND_RULE) $(*F).d > $(DEPENDDIR)/$(*F).d && $(RM) $(*F).d +endef + +# .c +$(OBJS_CC):%.o: + $(CC) $(CCFLAGS) $(INCLUDES) -c $(shell cygpath -m $<) --depend_format=unix_escaped --depend $(*F).d -o $@ + @$(MOVE_SRC_DEPEND) + +# .cpp +$(OBJS_CXX):%.o: + $(CC) $(CXXFLAGS) $(INCLUDES) -c $(shell cygpath -m $<) --depend_format=unix_escaped --depend $(*F).d -o $@ + @$(MOVE_SRC_DEPEND) + +# .s +$(OBJS_AS):%.o: + $(AS) $(ASFLAGS) --depend $(*F).d -o $@ $(shell cygpath -m $<) + @$(MOVE_SRC_DEPEND) + +# .lcf .par +ifdef LCFILE_SPEC + +ADDRESS_DTCM ?= $(DEFAULT_ADDRESS_DTCM) + +# exporting +MAKELCF_DEFS = -DCTRSDK_ROOT='$(ROOT)' \ + -DTARGET_NAME='$(TARGET_NAME)' \ + -DOBJS_STATIC='$(OBJS_STATIC)' \ + -DOBJS_AUTOLOAD='$(OBJS_AUTOLOAD)' \ + -DOBJS_OVERLAY='$(OBJS_OVERLAY)' \ + -DGLIBS='$(GLIBRARIES)' \ + -DLLIBS='$(LLIBRARIES)' \ + -DCW_LIBS='$(SN_LIBS)' \ + -DOBJDIR='$(OBJDIR)' \ + -DLIBDIR='$(LIBDIR)' \ + -DBINDIR='$(BINDIR)' \ + -DPROC='$(CODEGEN_PROC)' \ + -DPLATFORM='$(CTR_PLATFORM)' \ + -DCODEGEN='$(CODEGEN_ARCH)' \ + -DBUILD='$(CTR_BUILD_DIR)' \ + -DADDRESS_DTCM='$(ADDRESS_DTCM)' + +MAKELCF_OPTS = $(MAKELCF_FLAGS) $(MAKELCF_DEFS) + + +$(LCFILE_AUTOGEN): $(LCFILE_TEMPLATE) $(MAKEFILE) $(LDEPENDS_LCF) + $(CC) $(CCFLAGS) $(INCLUDES) -E -o $(LCFILE_AUTOGEN) $(LCFILE_TEMPLATE) + +$(LDRES_AUTOGEN): $(LCFILE_SPEC) $(LDRES_TEMPLATE) $(MAKEFILE) $(LDEPENDS_RES) + $(MAKELCF) $(MAKELCF_OPTS) $< $(LDRES_TEMPLATE) $@ + +endif + + +# compress/digest +ifeq ($(CODEGEN_PROC),ARM11) +ifdef CTR_COMPRESS +COMPSTATIC_CMDS = -11 -c +#COMPSTATIC_CMDS = -9 -c +endif +ifdef CTR_DIGEST +COMPSTATIC_CMDS += -a +endif +endif + +ifdef COMPSTATIC_CMDS +COMPSUFFIX ?= $(DEFAULT_COMPSUFFIX) +ifneq ($(COMPSUFFIX),) +COMPSTATIC_FLAGS += -e$(COMPSUFFIX) +endif +endif + + +# .nef +ifndef USE_MY_RULE_NEF +$(BINDIR)/$(TARGET_BIN_BASENAME).nef: $(OBJS) $(MAKEFILE) $(LDEPENDS_NEF) $(LDRES_FILE) $(ALIBRARIES) +# $(LD) $(LDFLAGS) -T $(LCFILE) -LSF $(LCFILE_SPEC) -Map $@.xMAP $(LIBRARY_DIRS) @$(LDRES_FILE) -o $@ + $(LD) $(LDFLAGS) -T $(LCFILE) -Map $@.xMAP $(LIBRARY_DIRS) @$(LDRES_FILE) -o $@ +ifdef COMPSTATIC_CMDS + $(COMPSTATIC) $(COMPSTATIC_CMDS) $(COMPSTATIC_FLAGS) -f $(BINDIR)/component.files $(CTR_STDOUT) +endif +endif + + +# .a +ifndef USE_MY_RULE_A +$(LIBDIR)/$(TARGET_LIB): $(OBJS) $(MAKEFILE) + $(AR) $(ARFLAGS) $@ $(OBJS) +endif + + +#----- End of modulerules.cctype.RVCT ----- diff --git a/trunk/build/buildtools/modulerules.emtype.ISD b/trunk/build/buildtools/modulerules.emtype.ISD new file mode 100644 index 0000000..df253cc --- /dev/null +++ b/trunk/build/buildtools/modulerules.emtype.ISD @@ -0,0 +1,41 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - buildtools - debugger dependant settings for ISDbgr +# File: modulerules.emtype.ISD +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Run command for IS-NITRO-EMULATOR +#---------------------------------------------------------------------------- +ifneq ($(TARGET_ROM),) + +.PHONY: run test-run +run: + @if [ -e "$(ISD_NITLOAD_GCC)" ]; \ + then \ + $(ISD_NITLOAD_GCC) -p $(BINDIR)/$(firstword $(TARGET_BIN)); \ + else \ + $(ISD_NITLOAD) -p $(BINDIR)/$(firstword $(TARGET_BIN)); \ + fi + +#test-run: +# @echo ==== $(CURDIR) > $(AUTOTESTLOG).tmp +# @echo :TEST-TARGET: [$(BINDIR)/$(firstword $(TARGET_BIN))] >> $(AUTOTESTLOG).tmp +# @echo >> $(AUTOTESTLOG).tmp +# cscript $(NITRO_TOOLSDIR)/bin/runEmu.js //Nologo //T:60 $(BINDIR)/$(firstword $(TARGET_BIN)) $(AUTOTESTLOG).tmp +# @gawk '/ / || NR <= 30' $(AUTOTESTLOG).tmp >> $(AUTOTESTLOG) +# @echo >> $(AUTOTESTLOG) +endif + +#----- End of modulerules.emtype.ISD ----- diff --git a/trunk/build/buildtools/modulerules.x86 b/trunk/build/buildtools/modulerules.x86 new file mode 100644 index 0000000..e5c4a88 --- /dev/null +++ b/trunk/build/buildtools/modulerules.x86 @@ -0,0 +1,158 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - modulerules - common rules for build system +# File: modulerules.x86 +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Implicit RULES +#---------------------------------------------------------------------------- +WARNING = -Wall + +LEX = flex +YACC = bison -y + +# workaround for flex gen code to avoid warnings +%.yy.o:WARNING += -Wno-unused-label -Wno-unused-function + +ifdef DEBUG +MACROS += -DDEBUG -g +endif + +ifdef CTR_DEBUG +MACROS += -g +endif + +define COMPILE_C + $(CC_X86) $(MACROS) -DSDK_WIN32 $(WARNING) -c -I. -I$(CTR_INCDIR) $< -o $@ +endef + +define COMPILE_CXX + $(CXX_X86) $(MACROS) -DSDK_WIN32 $(WARNING) -c -I. -I$(CTR_INCDIR) $< -o $@ +endef + +%.o: %.c + $(COMPILE_C) + +%.o: %.cpp + $(COMPILE_CXX) + +%.yy.c: %.l + $(LEX) -P$(basename $<)_yy -o$@ $< + +%.tab.c: %.y + $(YACC) -d -p $(basename $<)_yy -b $(basename $<) $< + +%.tab.h: %.tab.c + +#---------------------------------------------------------------------------- +# MAKE TARGETS +#---------------------------------------------------------------------------- + +.PHONY: all default build do-build install do-install \ + clean clobber super-clobber + + +#---------------------------------------------------------------------------- + +define MAKE_SUBDIR + +$(foreach DIR,$(SUBDIRS),$(MAKE) -C $(DIR) $(MAKECMDGOALS) $(AND)) true + +$(foreach FILE,$(SUBMAKES),$(MAKE) -C $(dir $(FILE)) -f $(notdir $(FILE)) $(MAKECMDGOALS) $(AND)) true +endef + +ifeq ($(MAKEFILE),Makefile) +MAKEFILE_ = +else +MAKEFILE_ = /$(MAKEFILE) +endif + +define ECHO_CURDIR + $(ECHO) "==== $(CURDIR)$(MAKEFILE_)"; +endef + +#---------------------------------------------------------------------------- +# make build +#---------------------------------------------------------------------------- + +build: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) +ifdef TARGETS +ifdef NEWDIRS + @$(MKDIRP) $(NEWDIRS) +endif + @+$(REMAKE) do-build +ifdef INSTALL_TARGETS + @+$(REMAKE) do-install +endif +endif + + +#---------------------------------------------------------------------------- +# make install +#---------------------------------------------------------------------------- + +install: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) +ifdef INSTALL_TARGETS + @+$(REMAKE) do-install +endif + + +define DO_INSTALL + $(INSTALL) -d $(INSTALL_DIR) $(AND) \ + $(foreach FILE, $(INSTALL_TARGETS), \ + if [ ! -e $(INSTALL_DIR)/$(notdir $(FILE)) -o \ + $(FILE) -nt $(INSTALL_DIR)/$(notdir $(FILE)) ]; \ + then \ + $(ECHO) " install: $(FILE) -> $(INSTALL_DIR)" $(AND) \ + $(INSTALL) $(FILE) $(INSTALL_DIR)/$(notdir $(FILE)); \ + fi $(AND) ) true +endef + + +do-install: + @$(DO_INSTALL) + +#---------------------------------------------------------------------------- +# make do-autotest +#---------------------------------------------------------------------------- + +do-autotest: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) + + +#---------------------------------------------------------------------------- +# make clobber & clean +#---------------------------------------------------------------------------- + +super-clobber clobber: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) + -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) + -$(RM) $(GDIRT_CLOBBER) $(LDIRT_CLOBBER) + -$(RM) $(GDIRT_INSTALLED) + + +#---------------------------------------------------------------------------- + +clean: + @$(MAKE_SUBDIR) + @$(ECHO_CURDIR) + -$(RM) $(GDIRT_CLEAN) $(LDIRT_CLEAN) + + +#----- End of modulerules ----- diff --git a/trunk/build/buildtools/sdk_indent.pl b/trunk/build/buildtools/sdk_indent.pl new file mode 100644 index 0000000..1e9148d --- /dev/null +++ b/trunk/build/buildtools/sdk_indent.pl @@ -0,0 +1,80 @@ +#!/usr/bin/perl + +############################################################################## +# +# Project: CtrSDK - code formatter- +# File: sdk_indent.pl +# +# Copyright 2008 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. +# +# $Log: sdk_indent.pl,v $ +# Revision 1.2 2004/02/05 07:09:01 yasu +# change SDK prefix iris -> nitro +# +# Revision 1.1 2003/12/01 11:17:08 nishida_kenji +# 新規 +# +# $NoKeywords: $ +############################################################################## + +foreach $filename (@ARGV) { + print STDERR "processing $filename\n"; + open INFILE, "$filename" or die "cannot open infile $filename\n"; + $intext = ""; + while() { + $intext .= $_; + } + + close(INFILE); + + next if ($intext =~ m/\Wasm\W/s); #asmがあったら何もしない! + { + # intext処理部 + $intext =~ s/extern\s+\"C\"[^{]*\{/extern \"C\";/s; # extern "C" {のカッコが邪魔 + $intext =~ s/\#ifdef\s+__cplusplus\s+\}/\#ifdef __cplusplus\n\/* \} *\//s; + } + + { + # open2がおかしいのでベタに書くことにする + open OUTFILE, ">indent.tmp" or die "cannot open outfile indent.tmp\n"; + print OUTFILE $intext; + close(OUTFILE); + } + +$tpdefs = "\ +-T BOOL -T f64 -T u64 -T s64 -T f32 -T u32 -T s32 -T u16 -T s16 -T u8 -T s8 \ +-T VecFx16 -T VecFx32 -T OS_Thread -T OS_Mutex -T OS_MessageQueue -T OS_Context \ +-T MtxFx44 -T MtxFx43 -T MtxFx33 -T MtxFx22 -T LockWord -T LockByte -T G3XMiscStatus \ +-T G3DLInfo -T G3BoxTestParam -T G2OamAttr -T G2OamAffine -T fxdiv_ -T fx64Tmp_ \ +-T G2ENUM_OAM_SHAPE"; + +system "indent -bap -bbo -bli0 -bls -c60 -cd60 -cli0 -cp8 -nbfda -i4 -l120 -lc120 -lps -nbc -ncs -npsl -nsob -nut -npcs -nprs -saf -sai -saw -ss $tdefs indent.tmp"; + +open INFILE2, "indent.tmp" or die "cannot open infile indent.tmp\n"; + +$outtext = ""; +while() { + $outtext .= $_; +} + +unlink("indent.tmp"); +unlink("indent.tmp~"); + +close(INFILE2); + +{ + # outtext処理部 + $outtext =~ s/extern\s+\"C\";/extern \"C\" \{/s; # extern "C" {のカッコをつける + $outtext =~ s/\#ifdef\s+__cplusplus\s+\/\* \} \*\//\#ifdef __cplusplus\n\}/s; +} + +open OUTFILE2, ">$filename" or die "cannot open outfile $filename\n"; +print OUTFILE2 $outtext; +close(OUTFILE2); +} diff --git a/trunk/build/buildtools/template/Copyright.Header b/trunk/build/buildtools/template/Copyright.Header new file mode 100644 index 0000000..3ced904 --- /dev/null +++ b/trunk/build/buildtools/template/Copyright.Header @@ -0,0 +1,15 @@ +/*---------------------------------------------------------------------------* + Project: NitroSDK - OS - + File: XXXXXXXX.c + + Copyright 2008 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. + + $Log: $ + $NoKeywords: $ + *---------------------------------------------------------------------------*/ diff --git a/trunk/build/buildtools/template/Function.Header b/trunk/build/buildtools/template/Function.Header new file mode 100644 index 0000000..c1b77fe --- /dev/null +++ b/trunk/build/buildtools/template/Function.Header @@ -0,0 +1,12 @@ +/*---------------------------------------------------------------------------* + Name: OSExceptionInit + + Description: Performs exception initialization. + - installs the first level exception handlers + - set up exception table and common exception handler + + Arguments: installDBIntegrator if TRUE, copy OSDBIntegrator into + low memory. + + Returns: None. + *---------------------------------------------------------------------------*/ diff --git a/trunk/build/buildtools/template/Makefile.BuildSrc b/trunk/build/buildtools/template/Makefile.BuildSrc new file mode 100644 index 0000000..007dee2 --- /dev/null +++ b/trunk/build/buildtools/template/Makefile.BuildSrc @@ -0,0 +1,40 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: NitroSDK - - +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +SUBDIRS = + + +#---------------------------------------------------------------------------- + +SRCS = main.c +TARGET_BIN = main.srl + +#SRCDIR = # using default +#LCFILE = # using default + +include $(CTRSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(CTRSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/trunk/build/buildtools/template/Makefile.BuildSrc.ARM7 b/trunk/build/buildtools/template/Makefile.BuildSrc.ARM7 new file mode 100644 index 0000000..466781c --- /dev/null +++ b/trunk/build/buildtools/template/Makefile.BuildSrc.ARM7 @@ -0,0 +1,44 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: NitroSDK - - +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +SUBDIRS = + +#---------------------------------------------------------------------------- + +# Codegen for sub processer +CODEGEN_PROC = ARM9 + + +SRCS = main.c +TARGET_BIN = main.srl + + +#SRCDIR = +#LCFILE = + +include $(CTRSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +do-build: $(TARGETS) + + +include $(CTRSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/trunk/build/buildtools/template/Makefile.BuildSubdir b/trunk/build/buildtools/template/Makefile.BuildSubdir new file mode 100644 index 0000000..768e0da --- /dev/null +++ b/trunk/build/buildtools/template/Makefile.BuildSubdir @@ -0,0 +1,31 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: NitroSDK - - +# File: Makefile +# +# Copyright 2008 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +include $(CTRSDK_ROOT)/build/buildtools/commondefs + + +#---------------------------------------------------------------------------- + +SUBDIRS = + + +#---------------------------------------------------------------------------- + +include $(CTRSDK_ROOT)/build/buildtools/modulerules + + +#===== End of Makefile ===== diff --git a/trunk/build/buildtools/verinfo.cw.cc b/trunk/build/buildtools/verinfo.cw.cc new file mode 100644 index 0000000..0288c3f --- /dev/null +++ b/trunk/build/buildtools/verinfo.cw.cc @@ -0,0 +1,3 @@ +SDK_CW_BUILD_VERSION_CC=3.0 +SDK_CW_BUILD_NUMBER_CC=137 +SDK_CW_BUILD_NUMBER2_CC=13700 diff --git a/trunk/build/buildtools/verinfo.cw.ld b/trunk/build/buildtools/verinfo.cw.ld new file mode 100644 index 0000000..f8513f3 --- /dev/null +++ b/trunk/build/buildtools/verinfo.cw.ld @@ -0,0 +1,3 @@ +SDK_CW_BUILD_VERSION_LD=2.0 +SDK_CW_BUILD_NUMBER_LD=87 +SDK_CW_BUILD_NUMBER2_LD=8700 diff --git a/trunk/build/buildtools/versiondefs b/trunk/build/buildtools/versiondefs new file mode 100644 index 0000000..2100cdb --- /dev/null +++ b/trunk/build/buildtools/versiondefs @@ -0,0 +1,20 @@ +#! make -f +#---------------------------------------------------------------------------- +# Project: CtrSDK - versiondefs +# File: versiondefs +# +# Copyright 2008 Nintendo. All rights reserved. +# +# These coded insructions, 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. +# +# $Log: $ +# $NoKeywords: $ +#---------------------------------------------------------------------------- + +-include $(NITROSDK_ROOT)/include/nitro/version.h + +#===== End of versiondefs ===== diff --git a/trunk/setup b/trunk/setup new file mode 100644 index 0000000..e02ebb5 --- /dev/null +++ b/trunk/setup @@ -0,0 +1,17 @@ +#!/usr/bin/bash + +#---------------------------------------------------------------- +# This script is not for execute directly. +# Please use 'source ./setup'. +#---------------------------------------------------------------- + +export CTRFIRM_ROOT=`cygpath -m $PWD` +export CTRBROM_ROOT=$CTRFIRM_ROOT/bootrom +export CTRSDK_ROOT=$CTRFIRM_ROOT +export CYGPATH_NOCMD='TRUE' + +echo "Set CTRFIRM_ROOT: $CTRFIRM_ROOT" +echo "Set CTRBROM_ROOT: $CTRBROM_ROOT" +echo "Set CTRSDK_ROOT: $CTRSDK_ROOT" +echo "Set CYGPATH_NOCMD: $CYGPATH_NOCMD" +