
./configure --build=i386-linux --host=arm-linux

./configure arm-unknown-linux-gnu

--build specifies what machine you are building on, 
--host what machine you are building for
--target what machine you want the produced code to produce code for (makes sense only for development tools I guess).

If you were developing on a Linux PC, you'd therefore write
something like:
configure --build=i386-slackware-linux --host=arm-linux --target=arm-linux

Bash
----
if test "${ac_cv_func_setvbuf_reversed+set}" = set; then
 echo $ECHO_N "(cached) $ECHO_C" >&6
 else

fix: export ac_cv_func_setvbuf_reversed=no
     export bash_cv_have_mbstate_t=no

To work this out, look at config.log and see where it failed (eg 'mbstate')
It'll have some C code near it.
Then look in 'configure' script for something of the same name. It'll have 
a similar 'if test ${..}' as above.  export its test var to 'no'
before running configure.


Easier to use a binary toolchain
--------------------------------
ftp.armlinux.org.uk/pub/armlinux/toolchain
 (or the UKS mirror)
 Use the 2.9 version of gcc.
 cd /usr/local/ && mkdir arm && cd arm
 tar jxf cross-2.95.3.tar.bz2
 chown -R root.root .
 chmod -R og-w .
 chmod -R og-s .
 cd 2.95.3/bin
 # Make gcc (and so on) symlinks to aid with building the Slackware packages
 #
 for i in arm-linux* ; do ln -s $i "$( echo $i | cut -d- -f3- )" ; done

* In /usr/local/arm/*/include/  I put the termcap.h
  that I got when I compiled ARMedSlack's libtermcap*tgz package.
  I'm not sure I need it but I left it there anyway and I doubt
  it does any harm !

  cd /usr/local/arm/*/bin
  ln -s arm-linux-objcopy arm-linuxelf-objcopy
  ln -s arm-linux-objdump arm-linuxelf-objdump



Cross compiling:
ftp://ftp.sthoward.com/pub/crossgcc/one-tree-1.6.sh
ftp://ftp.sthoward.com/pub/crossgcc/build-cross.sh

GCC Patches for ARM:
ftp://ftp.mock.com/pub/arm-linux/gcc-2.95.2-diff-991022.gz

7ARM Linux: 
  http://www.arm.linux.org.uk/docs/
http://www.arm.linux.org.uk/docs/kerncomp.shtml
http://www.lart.tudelft.nl/lartware/compile-tools/
http://web.bluemug.com/~miket/arm/toolchain/arm-toolchain-notebook.txt

http://home.in.tum.de/~atterer/debian/build-cross-gcc.readme.txt


Building a base Linux bootable thing: 
  http://roland.seuhs.com/en/index.php/Development/LiMa/CDB89712


Most of this is based on information at 
   http://qslinux.org/qslinux_2_4/

READ THE REST OF
http://www.mock.com/receiver/tools/

configure script wrapper: http://users.pcnet.ro/pchitescu/konq-e/xconfigure

Download tools
--------------
References:
  http://www.mock.com/receiver/tools/
  ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/src-3.2/build-toolchain

http://www.mock.com/receiver/utils/
Useful stuff there about making Linux boot bash instead of init.

# Making gcc3 use software floating point
http://lists.debian.org/debian-arm/2002/debian-arm-200207/msg00031.html

##################################################
# Compile & build an ARM Bin utils
##################################################
rm -rf /tmp/toolchain
mkdir -p /tmp/toolchain/binutils
cd /tmp/toolchain/binutils
tar jxf /armedslack/source/d/binutils/binutils-2.13.90.0.18.tar.bz2
cd binutils*
mkdir -p /opt/arm

./configure \
         --target=arm-linux \
         --prefix=/opt/arm  \
         && make && make install 

export PATH=$PATH:/opt/arm/bin


#################################################
# Build a bootstrap GCC
# This is just enough to build a Kernel.
#################################################
rm -rf /tmp/toolchain/gcc
mkdir -p /tmp/toolchain/gcc
cd /tmp/toolchain/gcc
tar jxf /armedslack/source/d/gcc/gcc-3.2.2.tar.bz2
cd gcc*
# Make mod so C compiler will build without libc includes
#   Edit file $TOOLCHAIN/gcc-2.95.2/gcc/config/arm/t-linux, change line:
#     TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC
#  Change to:
#     TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix_h
#
( cd gcc/config/arm
sed 's/^TARGET_LIBGCC2_CFLAGS\ =.*/TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc \-D__gthr_posix_h/' t-linux > t-linux2
mv t-linux t-linux.orig
mv t-linux2 t-linux # this file is needed for later !
)

# Build the C compiler only
#mkdir build-gcc0 && cd build-gcc0
./configure \
           --target=arm-linux      \
           --prefix=/opt/arm       \
           --disable-shared        \
           --disable-threads       \
           --enable-languages=c    \
           && make && make install
# --with-newlib
# --with-cpu=strongarm110 \
 

# Now we need to build an ARM Kernel so that we can grab
# the headers and insert them into our new toolchain.
# Read /armedslack/source/k/KERNEL.build
#
# Once the new Kernel is built ('linux' should be symlinked to linux-2.???):
 mkdir /opt/arm/include
 cp -a /tmp/armkernel/linux/include/linux   /opt/arm/include/
 cp -a /tmp/armkernel/linux/include/asm-arm /opt/arm/include/
 ( cd /opt/arm/include/ ; ln -s asm-arm asm )

##################################
## Build glibc ###################
##################################
#
mkdir -p /tmp/toolchain/glibc
cd /tmp/toolchain/glibc
PTH=/armedslack/source/l/glibc/
tar jxf $PTH/source/glibc-2.3.1.tar.bz2

cd glibc*

tar jxf $PTH/source/glibc-linuxthreads-2.3.1.tar.bz2

# Fix compatibility problems with old binaries/libraries [for now]:
# This is taken from the Slackware v9 'glibc.build' script.
# When we next rebuild glibc we'll want to check what (if any) patches
# are now relevant.
zcat $PTH/patches/glibc-2.3.1-ctype-compat-v2.patch.gz  | patch -p1
zcat $PTH/patches/glibc-2.3.1-libc_wait-compat.patch.gz | patch -p1
zcat $PTH/patches/glibc-2.3.1-prelinkfix.patch.gz       | patch -p1
zcat $PTH/patches/glibc-2.3.1-stack_end-compat.patch.gz | patch -p1
zcat $PTH/patches/glibc-2.3.1-dl-runtime.diff.gz        | patch -p1

perl -pi -e 's/i386/arm*)\n\tlibc_cv_gcc_unwind_find_fde=yes\n\tarch_minimum_kernel=2.0.10\n\t;;\n   i386/' sysdeps/unix/sysv/linux/configure
perl -pi -e 's/weak_alias \(__old_sys_nerr/\/\/ $&/' sysdeps/unix/sysv/linux/arm/errlist.c

#mkdir build-glibc && cd build-glibc
mkdir /opt/arm/usr
export PATH=$PATH:/opt/arm/bin/      # just incase !
./configure arm-linux                         \
   --with-headers=/tmp/armkernel/linux/include \
   --prefix=/opt/arm/                          \
   --build=i386-slackware-linux                \
   --enable-add-ons                            \
   --with-binutils=/opt/arm/bin/               \
   --enable-shared                             \
   make && make install

( cd /opt/arm/arm-linux/lib ; ln -s /opt/arm/lib/* . )

#   --prefix=/usr                     \
#   --disable-sanity-checks                     \

##################################################
# Rebuild gcc with support for all languages
##################################################
rm -rf /tmp/toolchain/gcc
mkdir -p /tmp/toolchain/gcc
cd /tmp/toolchain/gcc
tar jxf /armedslack/source/d/gcc/gcc-3.2.2.tar.bz2
cd gcc*

#cd /tmp/toolchain/gcc/gcc*
#mv -f gcc/config/arm/t-linux.orig gcc/config/arm/t-linux # remove previous hack


# Configure to build full C and C++ compilers
# mkdir build-gcc1 && cd build-gcc1
#../configure arm-linux                    \

rm -rf /opt/arm/arm-linux/sys-include  # ./configure copies this.
export PATH=$PATH:/opt/arm/bin/      # just incase !
./configure --target=arm-linux                          \
            --prefix=/opt/arm                           \
            --with-headers=/tmp/armkernel/linux/include 
perl -pi -e 's/int namelen/unsigned int namelen/' libjava/java/net/natInetAddress.cc

#            --with-cpu=strongarm110             \
#            --enable-shared                  
#            --enable-add-ons                    \


# This causes ./configure to throw a warning in the first line.
#           --enable-languages="c,c++"      \

make && make install

#EOF
