Copyright © 2002,2003 Ed Manlove.
Revision History | ||
---|---|---|
Revision Release Ver. 1 | 8 January 2003 | Revised by: ecm |
| ||
Revision Pre-Release Ver. 2 | 21 October 2002 | Revised by: ecm |
| ||
Revision Pre-Release | 13 October 2002 | Revised by: ecm |
|
The following are instructions I am using for building the Hitachi H8300 cross compiler for the DJGPP environment. Due to difficulty compiling gcc Version 2.95.2 and the eventual goal of upgrading brickOS to gcc 3.2, I am using version 3.2 in these instructions. Please read through the entire message before proceeding. -- Ed Manlove
Many thanks to ...
Rossz Vamos-Wentworth | For providing the model to follow and technical support. |
Steve Hassenplug | For providing a "virtual" deadline and constant words of support. |
Nicolas Tarleton | For providing technical support which led me down the correct path. |
Eli Zaretski | For providing excellent technical support with DJGPP and helping those who came before me. |
Martin Stromberg | For providing technical support with DJGPP. |
If you have problems related to these instruction, you can write to Ed Manlove
Download the following DJGPP/GNU packages from www.delorie.com or one of its mirror sites. A complete listing of ftp sites can be found at DJGPP Zip-Picker Tool. I use ftp://ftp.bu.edu/pub/mirrors/simtelnet/gnu/djgpp/. Place the files into the C:\temp directory.
unzip32.exe v2\djdev203.zip v2\faq230b.zip v2\djcrx203.zip v2gnu\bnu2121b.zip v2gnu\bnu2121a.zip v2gnu\bnu2121s.zip v2gnu\gcc32b.zip v2gnu\gcc32s.zip v2gnu\gpp32b.zip v2gnu\bsh204b.zip v2gnu\mak3791b.zip v2gnu\txi42b.zip v2gnu\fil316b.zip v2gnu\shl2011b.zip v2gnu\tar112ab.zip v2gnu\gzip13b.zip v2gnu\sed302b.zip v2gnu\pat253b.zip v2gnu\grep24b.zip v2gnu\txt20b.zip v2gnu\dif28b.zip v2gnu\gtxt040b.zip v2gnu\find41b.zip v2gnu\gwk311b.zip v2gnu\lgp2952b.zip v2gnu\acnf250b.zip v2gnu\m4-14b.zip v2gnu\perl561b.zip |
At the DOS prompt type the following
C:\> mkdir DJGPP C:\> cd djgpp C:\DJGPP> copy C:\temp\unzip32.exe C:\DJGPP> unzip32 c:\temp\djdev203.zip C:\DJGPP> unzip32 c:\temp\faq230b.zip C:\DJGPP> unzip32 c:\temp\djcrx203.zip C:\DJGPP> unzip32 c:\temp\bnu2121b.zip C:\DJGPP> unzip32 c:\temp\bnu2121a.zip C:\DJGPP> unzip32 c:\temp\bnu2121s.zip C:\DJGPP> unzip32 -o c:\temp\gcc32b.zip C:\DJGPP> unzip32 -o c:\temp\gcc32s.zip C:\DJGPP> unzip32 c:\temp\bsh204b.zip C:\DJGPP> unzip32 c:\temp\mak3791b.zip C:\DJGPP> unzip32 c:\temp\txi42b.zip C:\DJGPP> unzip32 c:\temp\fil316b.zip C:\DJGPP> unzip32 c:\temp\shl2011b.zip C:\DJGPP> unzip32 c:\temp\tar112ab.zip C:\DJGPP> unzip32 c:\temp\gzip13b.zip C:\DJGPP> unzip32 c:\temp\sed302b.zip C:\DJGPP> unzip32 c:\temp\pat253b.zip C:\DJGPP> unzip32 c:\temp\grep24b.zip C:\DJGPP> unzip32 c:\temp\txt20b.zip C:\DJGPP> unzip32 c:\temp\dif28b.zip C:\DJGPP> unzip32 c:\temp\gtxt040b.zip C:\DJGPP> unzip32 c:\temp\find41b.zip C:\DJGPP> unzip32 -o c:\temp\gwk311b.zip C:\DJGPP> unzip32 -o c:\temp\lgp2952b.zip C:\DJGPP> unzip32 c:\temp acnf250b.zip C:\DJGPP> unzip32 c:\temp m4-14b.zip C:\DJGPP> unzip32 c:\temp perl561b.zip |
DJGPP port of GCC 3.2 has a know bug in it. To correct for this problem create file C:\DJGPP\brickos\gccpatch.diff which contains the following lines. NOTE: This patch is included at the end of the file C:\DJGPP\gnu\gcc-3.2\readme.DJGPP.
--- ../../../include/sys/djtypes.h~1 Tue Dec 14 06:56:16 1999 +++ ../../../include/sys/djtypes.h Mon Feb 4 16:20:40 2002 @@ -12,7 +12,12 @@ #define __DJ_ssize_t typedef int ssize_t; #define __DJ_time_t typedef unsigned int time_t; #define __DJ_uid_t typedef int uid_t; + +#if __GNUC__>=3 +#define __DJ_va_list typedef __builtin_va_list va_list; +#else #define __DJ_va_list typedef void *va_list; +#endif #if defined(__cplusplus) && ( (__GNUC_MINOR__ >= 8 && __GNUC__ == 2 ) || __GNUC__ >= 3 ) /* wchar_t is now a keyword in C++ */ |
This patch will be applied by the binutils configure script below.
First, create a batch file, C:\DJGPP\DJGPP.BAT, to set the path and environment variables.
@echo off set PATH=c:\djgpp\bin;%PATH% set DJGPP=c:\djgpp\djgpp.env |
To start a DOS session select Start | Programs | MS-Dos Prompt.
Next, set up the DJGPP environment variables. At the DOS prompt type
C:\>cd DJGPP C:\DJGPP> DJGPP |
If you recieve an "Out of Environment Space", as shown in the error box below, you need to expand the size of the enviroment memory.
C:\>cd DJGPP C:\DJGPP>DJGPP Out of environment space C:\DJGPP> |
Microsoft gives the following instructions for expanding the environment memory for a DOS session
Instead of starting a DOS prompt using the instructions above you can alternatively create a shortcut to open a DOS window and setup the DJGPP environment variables.
First, create a batch file, C:\DJGPP\DJGPP.BAT, to set the path and environment variables.
@echo off set PATH=c:\djgpp\bin;%PATH% set DJGPP=c:\djgpp\djgpp.env |
To create a shortcut open the folder in which you wish to place the shortcut or go to the desktop. In the folder or desktop, right-click on the backgrond and choose New -> Shortcut. The Create Shortcut dialog box should appear. Enter the path to Command.com in the Command Line edit box as shown here.
Click next and then enter the Title for the shortcut icon. Choose Finish when done.
Fill in the following parameters
Working | This will be the current directory when the DOS window is opened. In this example, it has been set it to the DJGPP home directory. |
Batch file | Contains the batch file which will be runned when the DOS window is opened. In the example, it has been set to the DJGPP environment batch file. |
Select the Memory tab. Increase the Initial environment memory to 4096. Click OK or Apply to apply changes to the shortcut.
To configure binutils I use the following script. This script, C:\DJGPP\gnu\binutl-2.121\build.djg\h8cfgbnu.sh, is the djconfig.sh script from bintutils-2.121 with a few minor modifications.
#!/bin/sh # # This shell script is a wrapper to the main configure script when # configuring GDB for DJGPP. 99% of it can also be used when # configuring other GNU programs for DJGPP. # #===================================================================== # Copyright 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. # # Originally written by Robert Hoehne, revised by Eli Zaretskii. # This file is part of GDB. # Adapted for binutils by Andris Pavenis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. */ #===================================================================== # # Call this script like the main configure script with one exception. If you # want to pass parameters to configure, you have to pass as the first # argument the srcdir, even when it is `.' !!!!! # # First, undo any CDPATH settings; they will get in our way when we # chdir to directories. unset CDPATH # Where are the sources? If you are used to having the sources # in a separate directory and the objects in another, then set # here the full path to the source directory and run this script # in the directory where you want to build gdb!! # You might give the source directory on commandline, but use # then only forward slashes (/) in the directories. It should be # an absolute path. srcdir=.. # Now set the config shell. It is really needed, that the shell # points to a shell with full path and also it must conatain the # .exe suffix. I assume here, that bash is installed. If not, # install it. Additionally, the pathname must not contain a # drive letter, so use the /dev/x/foo format supported by versions # of Bash 2.03 and later, and by all DJGPP programs compiled with # v2.03 (or later) library. export CONFIG_SHELL=/dev/env/DJDIR/bin/sh.exe # force to have the ltmain.sh script to be in DOS text format, # otherwise the resulting ltconfig script will have mixed # (UNIX/DOS) format and is unusable with Bash ports before v2.03. utod $srcdir/ltmain.sh # set log file LOGFILE=/dev/env/DJDIR/brickos/h8cfgbnu.log # Give the configure script some hints: export AS=as export LD=ld export NM=nm export CC=gcc export CFLAGS="-O2 -g" export RANLIB=ranlib export DEFAULT_YACC="bison -y" export YACC="bison -y" export DEFAULT_LEX=flex # Define explicitly the .exe extension because on W95 with LFN=y # the check might fail export am_cv_exeext=.exe # ltconfig wants to compute the maximum command-line length, but # Bash 2.04 doesn't like that (it doesn't have any limit ;-), and # reboots the system. We know our limit in advance, so we don't # need all that crap. Assuming that the environment size is less # than 4KB, we can afford 12KB of command-line arguments. export lt_cv_sys_max_cmd_len=12288 # The configure script needs to see the `install-sh' script, otherwise # it decides the source installation is broken. But "make install" will # fail on 8+3 filesystems if it finds a file `install-', since there # are numerous "install-foo" targets in Makefile's. So we rename the # offending file after the configure step is done. if test ! -f ${srcdir}/install-sh ; then if test -f ${srcdir}/install-.sh ; then mv ${srcdir}/install-.sh ${srcdir}/install-sh fi fi # patch include\sys\djtypes.h echo "Applying patch to include\sys\djtypes.h ..." patch -p0 -i /dev/env/DJDIR/brickos/gccpatch.diff 2>&1 | tee --append $LOGFILE # Now run the configure script while disabling some things like the NLS # support, which is nearly impossible to be supported in the current way, # since it relies on file names which will never work on DOS. echo "Running the configure script..." $srcdir/configure --srcdir="$srcdir" --prefix='${DJDIR}' --disable-bfd-assembler \ --disable-shared --disable-nls --verbose --enable-build-warnings=\ -Wimplicit,-Wcomment,-Wformat,-Wparentheses,-Wpointer-arith $* 2>&1 | tee --append $LOGFILE if test -f ${srcdir}/install- ; then mv ${srcdir}/install- ${srcdir}/install-.sh fi # patch gnu\binutl-2.121\Makefile.in echo "Applying patch to gnu\binutl-2.121\Makefile.in ..." patch -p0 -i /dev/env/DJDIR/brickos/bnumake.diff 2>&1 | tee --append $LOGFILE # build binutils-2.121 echo "Building binutils-2.121 ..." make 2>&1 | tee --append $LOGFILE # install binutils-2.121 echo "Installing binutils-2.121 ..." make install 2>&1 | tee --append $LOGFILE |
As seen in the configure script a patch must be made to the installation Makefile, gnu\binutil-2.121\Makefile.in. Create the file C:\DJGPP\brickos\bnumake.patch which contains the following lines.
--- ..\Makefile.in Tue Oct 1 20:40:30 2002 +++ ..\Makefile.in Tue Oct 1 20:40:08 2002 @@ -63,7 +63,8 @@ # cygwin host. INSTALL_PROGRAM_ARGS = -INSTALL = $(SHELL) $$s/install-sh -c +#INSTALL = $(SHELL) $$s/install-sh -c +INSTALL = C:/DJGPP/bin/ginstall -c INSTALL_PROGRAM = $(INSTALL) $(INSTALL_PROGRAM_ARGS) INSTALL_SCRIPT = $(INSTALL) INSTALL_DATA = $(INSTALL) -m 644 |
Finally, to configure, build and install the binutils for the hitachi H8300, type
C:\DJGPP> cd gnu\binutl-2.121\build.djg C:\DJGPP\gnu\binutl-2.121\build.djg> sh h8cfgbnu.sh --target=h8300-hitachi-hms |
First a bug in the DJGPP gcc configure scripts needs to be fixed. Create the file C:\DJGPP\brickos\cfggcc.diff which contains the following lines.
--- ..\gcc-3.2\gcc\config.gcc Thu Aug 15 17:40:12 2002 +++ ..\gcc-3.2\gcc\config.gcc Tue Dec 17 20:47:32 2002 @@ -1342,7 +1342,7 @@ gas=yes exeext=.exe float_format=none - case $host in *pc-msdosdjgpp*) + case $target in *pc-msdosdjgpp*) target_alias=djgpp ;; esac |
This patch will be applied by the gcc configure script below.
To configure gcc 3.2 I use the following script. This script, C:\DJGPP\gnu\build.gcc\h8cfggcc.sh, is the djconfig.sh script from gcc-2.95.2 with a few minor modifications.
#! /bin/sh # Location of source directory export srcdir=`cd ../gcc-3.2; pwd | sed -e 's,[a-z][:],,g'` # give now the configure script some hints topdir=`(cd $srcdir/..; pwd | sed -e 's,[a-z][:],,g';)` AS=`test -f $DJDIR/bin/as.exe && echo $DJDIR/bin/as.exe` export AS=${AS-as} export CC=gcc export CFLAGS="-O2 -g -save-temps" export CXX=gpp export LD=ld export DEFAULT_LEX=flex export LEX=flex export RANLIB=ranlib export ac_cv_path_install="ginstall -c" export CONFIG_SHELL=bash dft_target=i586-pc-msdosdjgpp # # just in case export PATH_SEPARATOR=: # # set log file DATE="`date +%b%d`_`date +%Y`_`date +%H%M%S`" LOGFILE="/dev/env/DJDIR/brickos/gcc_${DATE}.log" # patch gnu\gcc-3.2\gcc\config\h8300\h8300.c, gnu\gcc-3.2\gcc\config\h8300\h8300.h #echo "Applying RCX patches to h8300.c, h8300.h ..." #patch -p0 -u -i /dev/env/DJDIR/brickos/gcc-3.2-rcx-1.diff 2>&1 | tee --append $LOGFILE #patch -p0 -u -i /dev/env/DJDIR/brickos/gcc-3.2-rcx-2.diff 2>&1 | tee --append $LOGFILE # patch gnu\gcc-3.2\gcc\config.gcc echo "Applying patch to gnu\gcc-3.2\gcc\config.gcc ..." patch -p0 -u -i /dev/env/DJDIR/brickos/cfggcc.diff 2>&1 | tee --append $LOGFILE # configure gcc for h8300 $srcdir/configure --srcdir=$srcdir --disable-shared --verbose \ --with-gxx-include-dir="${DJDIR}/lang/cxx" \ --enable-languages=c,c++ \ --with-gnu-ld --target=h8300-hitachi-hms \ --prefix="${DJDIR}" 2>&1 | tee --append $LOGFILE # build gcc-3.2 echo "Building gcc-3.2 ..." make 2>&1 | tee --append $LOGFILE |
NOTE: The gcc-3.2-rcx patches are commented out. I have upgraded the previous gcc-2.95.2-rcx patches but have come across some errors when building the gcc cross compiler. As these patches are not nessecary (they provide "optimized" intterrupt support) I am avoiding this issue at this time.
To configure and build the gcc cross compiler type at the dos prompt
C:\DJGPP\gnu\build.gcc> sh h8cfggcc.sh |
During the build the following error occurs.
... (cd intl && c:/djgpp/bin/make.exe all) make.exe[2]: Entering directory `c:/djgpp/gnu/build.gcc/gcc/intl' \gcc -c -DIN_GCC -DLOCALEDIR=\"c:/djgpp/share/locale\" -DLOCALE_ALIAS_PATH=\"c:/ djgpp/share/locale\" -DLIBDIR=\"c:/djgpp/lib\" -DHAVE_CONFIG_H -I.. -I. -I/djgpp /gnu/gcc-3.2/gcc/intl -I/djgpp/gnu/gcc-3.2/gcc -I/djgpp/gnu/gcc-3.2/gcc/config - I/djgpp/gnu/gcc-3.2/gcc/../include -O2 -g -save-temps -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long /djgpp/gnu/gcc-3.2/gcc/intl/intl-compat.c -o intl-compat.o make.exe[2]: *** [intl-compat.o] Error -1 make.exe[2]: Leaving directory `c:/djgpp/gnu/build.gcc/gcc/intl' make.exe[1]: *** [intl.all] Error 1 make.exe[1]: Leaving directory `c:/djgpp/gnu/build.gcc/gcc' make.exe: *** [all-gcc] Error 2 C:\DJGPP\gnu\build.gcc> |
To resolve this, type the following at the DOS prompt
C:\DJGPP\gnu\gcc-2.952\build.djg> cd gcc\intl C:\DJGPP\gnu\gcc-2.952\build.djg\gcc\intl> make |
To finish of the build and install gcc at the DOS prompt, type
C:\DJGPP\gnu\gcc-2.952\build.djg\gcc\intl> cd ..\.. C:\DJGPP\gnu\gcc-2.952\build.djg> make C:\DJGPP\gnu\gcc-2.952\build.djg> make install |