#! /bin/sh # Remarks, Bugs and additions to bon@elektron.ikp.physik.th-darmstadt.de # You must either have : # - untarred binutils and gcc # - or the Tarfiles for binutils and gcc # - or have a link to these files # in $BASEDIR # # If $DJGPPDIR exists, it is assumed that you have the right version of the # cross-devellopment files installed # If $DJGPPDIR doesn't exist, djcrxXXX.zip, or a link to that file is # needed in $BASEDIR # # Get binutils-X.X.X.tar.gz and gcc-X.X.X.tar.gz at your nearest GNU Software # Repository, e.g. ftp://prep.ai.mit.edu/pub/gnu. Get /pub/gnu/GNUinfo/FTP to # find a mirror near you. # At the time of writing, binutils-2.6 have a bug in gas when assembling for # the COFF-Format. So use version 2.5.2 until you know that bug is fixed. # # djcrxXXXX.zip is a collection of needed files to build a cross compiler # to make MSDOS executables. It is part of djgpp, a port of the GNU Utilities # to MSDOS, done by dj@delorie.com and others. At the time of writing this # script this collection only exists for DJGPP Version 2 BETA. # If you want to use version 1, you are on your own. # # Get djcrxXXX.zip, with XXX >=200, from one of the official sites for the # DJGPP beta program: # # Official DJGPP V2 Beta FTP Sites # # ftp.delorie.com pub/djgpp/beta/v2 (slow, USA) # ftp.idsoftware.com djgpp/beta/v2 (fast, USA) # fly.cc.fer.hr pub/msdos/djgpp-v2 (medium, Europe) # turnbull.sk.tsukuba.ac.jp pub/djgpp/2.0-beta (fast, Asia) # phi.sinica.edu.tw pub/GNU/djgpp/mirror/2.0-beta # # Note: ftp.delorie.com will always have the latest copy of this file. # Check there for new sites. # # DJ # dj@delorie.com # http://www.delorie.com/ # # # This script is based on the remarks # "Building GCC 2.7.0 as a Unix to DOS cross-compiler " by DJ Delorie # http://www.delorie.com/djgpp/faq/cross/gcc270-unix-to-dos.html # tested on and adapted for a Linux-1.3.54-a.out machine with gcc-2.7.2 # and libc-4.5.26 by Uwe Bonnes bob@elektron.ikp.physik.th-darmstadt.de # Use at your own risk #Change to your settings BASEDIR=/home/bon/tmp/dos-gcc1 DJGPPDIR=/usr/local/djgpp #Which version for the packages BINUTIL=2.5.2 GCC=2.7.2 DJGPP=200 # No change should be needed BINTARGET=i386-coff-go32 TARGET=i386-go32-msdos # Nothing to change below export BASEDIR export BINTARGET export TARGET export GCC export BINUTIL export DJGPPDIR export DJGPP mkdir -p $BASEDIR cd $BASEDIR #Check requirements if [ ! -d gcc-$GCC ];then if [ -e gcc-$GCC.tar.gz ];then echo "Untarring gcc-$GCC.tar.gz in $BASEDIR" tar fxz gcc-$GCC.tar.gz else echo "You must have gcc-$GCC.tar.gz in $BASEDIR" exit fi fi if [ ! -d binutils-$BINUTIL ];then if [ -e binutils-$BINUTIL.tar.gz ];then echo "Untarring binutils-$BINUTIL.tar.gz in $BASEDIR" tar fxz binutils-$BINUTIL.tar.gz else echo "You have binutils-$BINUTIL.tar.gz in $BASEDIR" exit fi fi mkdir -p $DJGPPDIR if [ ! -w $DJGPPDIR -o ! -w /usr/lib/gcc-lib \ -o ! -w /usr/local/bin ];then echo -n "Must be root, as compiling gcc as a cross-compiler requires access" echo " to some system directories " exit fi if [ ! -d $DJGPPDIR/lib ];then if [ -e djcrx$DJGPP.zip ];then cd $DJGPPDIR echo "Unzipping djcrx$DJGPP.zip in $DJGPPDIR" unzip -L -a $BASEDIR/djcrx$DJGPP.zip > /dev/null 2>&1 cd $BASEDIR else echo "You must have djcrx$DJGPP.zip in $BASEDIR " exit fi fi if [ ! -x $DJGPPDIR/src/stub/stubify ];then echo "Building stubify" cd $DJGPPDIR/src/stub gcc stubify.c -o stubify cd $BASEDIR fi NEEDFIX=`grep coff-go32 $DJGPPDIR/lib/djgpp.lnk` export $NEEDFIX >/dev/null 2>&1 if [ "$NEEDFIX" = 'OUTPUT_FORMAT("coff-go32")' ];then echo "Changing djgpp.lnk " mv $DJGPPDIR/lib/djgpp.lnk $DJGPPDIR/lib/djgpp.org sed 's/OUTPUT_FORMAT("coff-go32")/OUTPUT_FORMAT("coff-i386")/g'\ $DJGPPDIR/lib/djgpp.org >$DJGPPDIR/lib/djgpp.lnk else echo "Good, djgpp.lnk uses right format" fi mkdir -p $BASEDIR/dos-binu cd $BASEDIR/dos-binu echo "Configuring binutils-$BINUTIL to cross-devellop for msdos" ../binutils-$BINUTIL/configure --target=$BINTARGET > configure.log 2>&1 echo "Compiling binutils-$BINUTIL" make CFLAGS=-O > make.log 2>&1 mkdir -p /usr/lib/gcc-lib/$TARGET/$GCC echo "Installing executables in /usr/lib/gcc-lib/$TARGET/$GCC" cd binutils cp ar c++filt objcopy objdump size /usr/lib/gcc-lib/$TARGET/$GCC cp nm.new /usr/lib/gcc-lib/$TARGET/$GCC/nm cp strip.new /usr/lib/gcc-lib/$TARGET/$GCC/strip cd ../gas cp as.new /usr/lib/gcc-lib/$TARGET/$GCC/as cp gasp.new /usr/lib/gcc-lib/$TARGET/$GCC/gasp cd ../ld cp ld.new /usr/lib/gcc-lib/$TARGET/$GCC/ld cd $BASEDIR mkdir -p $BASEDIR/dos-gcc cd $BASEDIR/dos-gcc touch libgcc1.a echo "Configuring gcc-$GCC to cross compiling for msdos" ../gcc-$GCC/configure --target=$TARGET > configure.log 2>&1 echo "Compiling gcc-$GCC" make LANGUAGES=c CFLAGS=-O -s > make.log 2>&1 echo "Installing cross-compiler as /usr/local/bin/gcc-dos" cp xgcc /usr/local/bin/gcc-dos mkdir -p /usr/lib/gcc-lib/$TARGET/$GCC cp cc1 /usr/lib/gcc-lib/$TARGET/$GCC/cc1 cp cccp /usr/lib/gcc-lib/$TARGET/$GCC/cpp cd /usr/lib/gcc-lib/$TARGET/$GCC ln -s $DJGPPDIR/include . ln -s $DJGPPDIR/lib/* . mv $DJGPPDIR/src/stub/stubify . cd $BASEDIR cat < hello.c #include #include #include void main() { printf("Hello world\n"); } eof echo "Done!" echo 'Try "gcc-dos hello.c -o hello.exe" in $BASEDIR ' echo "hallo.exe should run in dosemu"