Subject: New crosscompile kit
To: None <port-sh3@netbsd.org>
From: SAITOH Masanobu <masanobu@iij.ad.jp>
List: port-dreamcast
Date: 02/26/2001 19:07:50
 I made new patches for binutils-2.9.1.0.25 and egcs-1.1.2:

	ftp://ftp.netbsd.org/pub/NetBSD/arch/sh3/crosskit/20010226/shcrosskit20010226-1.tgz


 XXX THIS PATCH WAS MADE FROM MY WORKING DIRECTORY. THERE ARE SOME PROBLEMS:

		1) ELF is fixed not to leading underscore
			(cvs tree's version is automatically selected
			 by __LEADING_UNDERSCORE which defined in
			 both sh3/include/cdefs.h and sh3/include/asm.h.
			 So if you make ELF version, eliminate
			 __LEADING_UNDERSCORE from sh3/include/cdefs.h and
			 sh3/include/asm.h)

		2) It may fail on compiling c++ sources.

So I recommend to make compiler to built COFF.

----------------------------------------------------------------

HOW TO MAKE THE CROSS COMPILE ENVIRONMENT

	1) get patches from

                ftp://ftp.netbsd.org/pub/NetBSD/arch/sh3/crosskit/20010226/

	   this archive contains following diffs:

		binutils-2.9.1.0.25-netbsdsh-20010226-0.dif

			patch for binutils-2.9.1.0.25


		egcs-1.1.2-netbsdsh-20010226-0.dif

			patch for egcs-1.1.2

		egcs-1.1.2-netbsdsh-20010226-1.dif

			patch for egcs-1.1.2 to build libgcc.a
			This patch is optional because libgcc.a will be
			built from NetBSD's source tree.

			If you apply this patch,
				1) read this diff and apply it by
				   hand appropriately

				or

				2) edit this diff directly and
				   apply it

			If you don't apply this diff, you will fail
			on compiling egcs, but it's no problem. After
			error occured, simply type "make install"

        2) make binutils

                Extract binutils and patch.

                Apply diff:
			cd binutils-2.9.1.0.25
			patch -p0 < binutils-2.9.1.0.25-netbsdsh-20010226-0.dif

		Configure:
	                ./configure --target=sh-xxx-netbsdcoff
	                        or
	                ./configure --target=shel-xxx-netbsdcoff
	                        or
	                ./configure --target=sh-xxx-netbsdelf
	                        or
	                ./configure --target=shel-xxx-netbsdelf

                make
                make install

        3) preliminary arrange your environment

		3-1) build script

		copy sh3/conf/build-sh3.eb or build-sh3.el into your path.

		modify build-sh3:

			MACHINE		(evbsh3, dreamcast or hpcsh)
			MACHINE_ARCH	(sh3eb or sh3el)
			TARGET		(target name
					  (e.g shel-dreamcast-netbsdcoff))
			CPP		(SEE COMMENTS)

		3-2) include files

		setenv DESTDIR /cross/compile/destination/directory
		mtree -def /etc/mtree/NetBSD.dist -p $DESTDIR -u
		cd $DESTDIR/usr
		rm -rf lib include
		ln -s /usr/local/TARGET_NAME/include .
		ln -s /usr/local/TARGET_NAME/lib .
		cd /usr/src
		build-sh3 includes

        4) make egcs

                Do:

			cd /usr/local/TARGET_NAME
			ln -s include sys-include

	                (for limits.h)

                Extract egcs and patch

		cd egcs-1.1.2
		patch -p0 < egcs-1.1.2-netbsdsh-20010226-0.dif

                Patch egcs-1.1.2-netbsdsh-20010226-1.dif appropriately

                ./configure --target=sh-xxx-netbsdcoff
                        or
                ./configure --target=shel-xxx-netbsdcoff
                        or
                ./configure --target=sh-xxx-netbsdelf
                        or
                ./configure --target=shel-xxx-netbsdelf

                make	(if you encounterd compile error, ignore it)[*1]
                make install

                cd /usr/local/lib/gcc-lib/TARGET_NAME/EGCS_VERSION/
                rm *.a */*.a */*/*.a	(Don't forget) [*2]
		rm -rf include		(Don't forget) [*2]

	5) [OPTIONAL] compile crt*

		cd /usr/src/lib/csu
		make dependall
		make install

		After you compiled and installed crt0, you will be
		able to compile egcs without errors.

	[*1]	You will see some compiler errors if:

			1) you have no crt0.o yet
			2) egcs-1.1.2-netbsdsh-20010226-1.dif isn't applied

	[*2]	The reason why we have to delete there files,
		we use /usr/local/TARGET_NAME/{include,lib}.

----------------------------------------------------------
		SAITOH Masanobu (masanobu@iij.ad.jp
				  msaitoh@netbsd.org)