4

I'm trying to make a bash script that will install a gcc cross-compiler for i686-elf on a Debian computer, but I keep getting the same error:

configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating tests/Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
configure: WARNING: unrecognized options: --disable-nls, --enable-languages, --without-headers
make: *** No rule to make target 'all-gcc'.  Stop.
make: *** No rule to make target 'all-target-libgcc'.  Stop.
make: *** No rule to make target 'install-gcc'.  Stop.
make: *** No rule to make target 'install-target-libgcc'.  Stop.

Does anyone have any idea why these options aren't recognized? I've installed this version before without this problem.

In case it helps, here's my script:

####################################
echo Stage 1 - Building Dependencies
####################################

# make a working directory
cd $HOME/Documents
rm -rf Cross
mkdir Cross
cd Cross

# install or update all apt-get dependencies
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc                   # not cross
sudo apt-get install g++
sudo apt-get install make
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install gawk
sudo apt-get install libgmp3-dev
sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg
sudo apt-get install mpc
sudo apt-get install texinfo               # optional
sudo apt-get install libcloog-isl-dev      # optional
sudo apt-get install build-essential
sudo apt-get install glibc-devel
sudo apt-get -y install gcc-multilib libc6-i386

# download and unpack necessary files
wget http://ftpmirror.gnu.org/binutils/binutils-2.25.1.tar.gz
wget http://ftpmirror.gnu.org/gcc/gcc-5.3.0/gcc-5.2.0.tar.gz
wget http://ftpmirror.gnu.org/mpc/mpc-1.0.3.tar.gz
for f in *.tar*; do tar xf $f; done
mv mpc-1.0.3 gcc-5.2.0

# create installation directory
sudo mkdir -p /opt/cross
sudo chown user /opt/cross
export PREFIX=/opt/cross
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"

################################
echo Stage 2 - Building Compiler
################################

# install binutils
mkdir build-binutils
cd build-binutils
../binutils-2.25.1/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make
make install
cd ..

# install gcc
mkdir build-gcc
cd build-gcc
../gcc-5.2.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
5
  • I can see one thing, you need to have an extraction for the gzip file with your tar command. It would be tar zxf $f or tar zvxf $f
    – Terrance
    Jan 23, 2016 at 5:34
  • @Terrance it seems to extract fine, but I will add that in anyway.
    – David A
    Jan 23, 2016 at 16:03
  • 1
    I guess old habits are still with me. I have always done the z for gzip files. Anyway, I could duplicate your problem with the gcc-5.2.0. But when I downloaded gcc-5.3.0, I was able to make it work.
    – Terrance
    Jan 23, 2016 at 19:01
  • Should I use the same version of binutils and mpc?
    – David A
    Jan 24, 2016 at 16:49
  • Yes, those work fine.
    – Terrance
    Jan 24, 2016 at 16:56

1 Answer 1

1

Here is the finished file (setup-gcc.sh):

####################################
echo Stage 1 - Building Dependencies
####################################

# make a working directory
cd $HOME/Documents
rm -rf Cross
mkdir Cross
cd Cross

# install or update all apt-get dependencies
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc                   # not cross
sudo apt-get install g++
sudo apt-get install make
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install gawk
sudo apt-get install libgmp3-dev
sudo apt-get install libmpfr-dev libmpfr-doc libmpfr4 libmpfr4-dbg
sudo apt-get install mpc
sudo apt-get install texinfo               # optional
sudo apt-get install libcloog-isl-dev      # optional
sudo apt-get install build-essential
sudo apt-get install glibc-devel
sudo apt-get -y install gcc-multilib libc6-i386

# download and unpack necessary files
wget http://ftpmirror.gnu.org/binutils/binutils-2.25.1.tar.gz
wget http://ftpmirror.gnu.org/gcc/gcc-5.3.0/gcc-5.3.0.tar.gz
wget http://ftpmirror.gnu.org/mpc/mpc-1.0.3.tar.gz
for f in *.tar*; do tar zvxf $f; done

# create installation directory
mkdir Install
export PREFIX="$HOME/Documents/Cross/Install"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"

################################
echo Stage 2 - Building Compiler
################################

# install mpc
mkdir build-mpc
cd build-mpc
../mpc-1.0.3/configure --prefix="$PREFIX"
make -j2
make -j2 check
make -j2 install
cd ..

# install binutils
mkdir build-binutils
cd build-binutils
../binutils-2.25.1/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make -j2
make -j2 install
cd ..

# install gcc
mkdir build-gcc
cd build-gcc
../gcc-5.3.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers --with-mpc="$PREFIX"
make -j2 all-gcc
make -j2 all-target-libgcc
make -j2 install-gcc
make -j2 install-target-libgcc

Thanks to @Terrance for helping work out the problems. From there, I worked out the rest, did a few major performance improvements, and made it so it should work on all systems.

Once you have it installed, you can run it with:

export PREFIX="$HOME/Documents/Cross/Install"
export TARGET=i686-elf
$PREFIX/bin/$TARGET-gcc --version

Unfortunately, doing this inside of an alias or bash script doesn't seem to properly launch it, so, unless this gets fixed, you might have to just store the script in a text file and copy-paste it into terminal every time you reboot.

To uninstall your cross-compiler, simply delete the $HOME/Documents/Cross directory.

As a final note, changing the installation directory or target is as easy as changing the value of $PREFIX or $TARGET, but I wouldn't recommend it, because you may run into other unexpected problems.

2
  • 1
    Can you not add those last lines to your ~/.bashrc file?
    – oxr463
    Nov 26, 2019 at 19:17
  • @LucasRamage you can!
    – David A
    Nov 27, 2019 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .