328267.notvwxz6.asia/howto/djgpp/debian-djgpp-cross.html
|
search
|
Automatic Debian GNU Linux unstable DOS cross compiler script
Author: | Adrian Montero |
Created: | Mon Jul 1 19:39:37 2002 |
Updated: | Tue Jul 2 14:57:43 2002 |
This is a brief explanation of the available variables in the automatic
script and their values in order to modify and customize the automatic
installation of the DOS debian cross compiler.
It will automatically download and install the files.
Variables:
$HOST variable, this is usually the type of machine we are compiling from.
$TARGET this variable is the name of compiler we are trying to make, do
not modify.
$PREFIX is the directory where you wish to install the files.
Comments:
In reality you shouldnt need to modify any of these. The files
automatically get installed in /usr/local/i386-dos, and if you get
concerned about deleting them you can just delete the i386-pc-msdosdjgpp-*
in /usr/local/bin and the whole directory /usr/local/i386-dos, for those
of you that are concerned on dirtying your Debian distribution ( as I am )
#!/usr/bin/perl
#
# Debian Script for auto generation of a DOS cross compiler
# Copyright (C) 2002 Adrian Montero
#
# 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., 58 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
$HOST = "i686-pc-linux-gnu";
$TARGET = "i386-pc-msdosdjgpp";
$PREFIX = "/usr/local/i386-dos";
$NP = ":$PREFIX/$TARGET";
$PWD = `pwd`;
$ENV{'host'} = $HOST;
$ENV{'target'} = $TARGET;
$ENV{'prefix'} = $PREFIX;
$ENV{'PATH'} .= "$NP/bin";
$ENV{'PATH'} .= ":$PREFIX/bin";
$ENV{'PATH'} .= "$NP/lib";
$ENV{'PATH'} .= "$NP/include";
chop($PWD);
print "Attempting to download the packages required for gcc-dos\n\r";
system ("apt-get source gcc-3.1 binutils");
print "Got the sources with apt\n\r";
chdir ("$PWD");
print "Grabbing DOS libraries\n\r";
system("wget ftp://mirror.blue.aol.com/pub/simtelnet/gnu/djgpp/v2/djcrx203.zip");
`mkdir -p $PREFIX/$TARGET`;
chdir("$PREFIX/$TARGET");
`unzip $PWD/djcrx203.zip`;
chdir("$PWD");
open (X, "ls -l |grep drw |");
while (<X>) {
@args = split(' ', $_);
if ($args[-1] =~ /binutils-/) {
$BINUTILS_DIR = $args[-1];
}
if ($args[-1] =~ /gcc-/) {
$GCC_DIR = $args[-1];
}
}
close(X);
print "Making binutils\n\r";
`mkdir -p dos-binu`;
chdir("$BINUTILS_DIR");
`bzip2 -dc *.tar.bz2 | tar xf -`;
open (X, "ls -l |grep drw |grep binutils |");
while (<X>) {
@binutils = split(' ', $_);
if ($binutils[-1] =~ /binutils/) {
$BINUTILS_DIR .= "/" . $binutils[-1];
}
}
close (X);
chdir("$PWD/dos-binu");
printf("../$BINUTILS_DIR/configure --target=$TARGET --prefix=$PREFIX
-v\n\r");
system("../$BINUTILS_DIR/configure --target=$TARGET --prefix=$PREFIX -v");
system("make all install");
print "Making gcc\n\r";
chdir("..");
`mkdir -p dos-gcc`;
chdir("$GCC_DIR");
`bzip2 -dc *.tar.bz2 | tar xf -`;
open (X, "ls -l |grep drw |grep gcc |");
while (<X>) {
@gcc = split(' ', $_);
if ($gcc[-1] =~ /gcc/) {
$GCC_DIR .= "/" . $gcc[-1];
}
}
close (X);
chdir("$PWD/dos-gcc");
printf("../$GCC_DIR/configure --enable-languages=c --host=$HOST
--target=$TARGET --prefix=$PREFIX -v\n\r");
system("../$GCC_DIR/configure --enable-languages=c --host=$HOST
--target=$TARGET --prefix=$PREFIX -v");
system("make all install");
printf "Patching DJGPP DJL file\n\r";
chdir("$PREFIX/$TARGET/lib");
`mv djgpp.djl djgpp.tmp`;
`sed 's/OUTPUT_FORMAT("coff-go32")/OUTPUT_FORMAT("i386-pc-msdosdjgpp")/g'
djgpp.tmp > djgpp.djl`;
`rm djgpp.tmp`;
printf "Making Stubify\n\r";
chdir("$PREFIX/$TARGET/src/stub");
`gcc -o stubify stubify.c`;
`mv stubify $PREFIX/$TARGET/bin`;
printf "All done!\n\r";
printf "now export your path: PATH=$PATH:$PREFIX/bin ; export PATH\n\r";
printf "Test your compiler with $TARGET-gcc\n\r";