docs: Provide new Readme for MacOS
authorTitus von Boxberg <titus@v9g.de>
Tue May 25 18:25:11 2010 +0200 (2010-05-25)
changeset 1971cbe89e8dfc9c
parent 1970 cdd761ad2d1a
child 1972 7939e7e0573d
docs: Provide new Readme for MacOS

Short README for usage of ct-ng under MacOS.
Remove obsolete MacOS-X.txt

yann.morin.1998@anciens.enib.fr:
Make it 80-columns clean, plus a few fixes
docs/MacOS-X.txt
docs/README.macos.txt
     1.1 --- a/docs/MacOS-X.txt	Sat May 22 22:01:18 2010 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,283 +0,0 @@
     1.4 -Introduction
     1.5 -------------
     1.6 -
     1.7 -This file introduces you to building a cross-toolchain on MacOS-X.
     1.8 -Apart from the crosstool-NG configuration options for the specific target,
     1.9 -what is important is:
    1.10 - - what pre-requisites to install
    1.11 - - how to install them
    1.12 - - how to work around the case-insensitivity of HFS+
    1.13 -
    1.14 -This file was submitted by:
    1.15 -  Blair Burtan <info@northernlightstactical.com>
    1.16 -The original version was found at:
    1.17 -  http://homepage.mac.com/macg3/TS7390-OSX-crosstool-instructions.txt
    1.18 -
    1.19 -
    1.20 -Text
    1.21 -----
    1.22 -
    1.23 -Compiling cross compiler for default TS-7390 debian system on Mac OS X
    1.24 -
    1.25 -Forewarning: It's kind of a pain. Several of OS X's packages aren't good enough
    1.26 -so you need to install some GNU stuff. You might have an easier time using a
    1.27 -package manager for OS X but I prefer to compile everything from source so I'm
    1.28 -going to provide the instructions for that. Also there are a few little catches
    1.29 -with how some of the older gcc/glibc stuff compiles on OS X.
    1.30 -
    1.31 -The version of glibc on the TS-7390 default file system is 2.3.6. So we need to
    1.32 -make a compiler with glibc 2.3.6 or older. I guess you can pick whatever version
    1.33 -of gcc you want to use. I'll pick 4.1.2, which is what is included with the 7390
    1.34 -debian. But you could theoretically do something newer like 4.3.3 (or older,
    1.35 -like 4.0.4) if you want, I think. All I know is the following works fine for gcc
    1.36 -4.1.2 and glibc 2.3.6.
    1.37 -
    1.38 -First, you have to install some prerequisites. Go in a temporary folder
    1.39 -somewhere and follow these directions.
    1.40 -
    1.41 -Some of the included OS X utilities aren't cool enough. So we need to download
    1.42 -and install some GNU utilities. Luckily they compile with no trouble in
    1.43 -Mac OS X! Nice work GNU people!
    1.44 -
    1.45 -First make sure you've installed the latest version of Xcode so you have gcc
    1.46 -on your Mac.
    1.47 -
    1.48 -Install GNU sed into /usr/local. Note: I believe configure defaults to
    1.49 -/usr/local as a prefix, but better safe than sorry.
    1.50 -
    1.51 -    curl -O http://ftp.gnu.org/gnu/sed/sed-4.2.1.tar.bz2
    1.52 -    tar -xf sed-4.2.1.tar.bz2
    1.53 -    cd sed-4.2.1
    1.54 -    ./configure --prefix=/usr/local
    1.55 -    make -j 2 (or 4 or whatever...# of jobs that can run in parallel...
    1.56 -                        on a dual core machine I use 4)
    1.57 -    sudo make install
    1.58 -
    1.59 -Install GNU coreutils:
    1.60 -
    1.61 -    curl -O http://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz
    1.62 -    tar -xf coreutils-7.4.tar.gz
    1.63 -    cd coreutils-7.4
    1.64 -    ./configure --prefix=/usr/local
    1.65 -    make -j 2
    1.66 -    sudo make install
    1.67 -
    1.68 -Install GNU libtool:
    1.69 -
    1.70 -    curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz
    1.71 -    tar -xf libtool-2.2.6a.tar.gz
    1.72 -    cd libtool-2.2.6
    1.73 -    ./configure --prefix=/usr/local
    1.74 -    make -j 2
    1.75 -    sudo make install
    1.76 -
    1.77 -Install GNU awk, needed to fix a weird error in glibc compile:
    1.78 -
    1.79 -    curl -O http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2
    1.80 -    tar -xf gawk-3.1.7.tar.bz2
    1.81 -    cd gawk-3.1.7
    1.82 -    ./configure --prefix=/usr/local
    1.83 -    make -j 2
    1.84 -    sudo make install
    1.85 -
    1.86 -Xcode doesn't come with objcopy/objdump, but you need them. Download GNU
    1.87 -binutils 2.19.1 and install just objcopy and objdump. Not sure how exactly to
    1.88 -do only them so I compile it all and copy them manually....there may be a
    1.89 -better way.
    1.90 -
    1.91 -    curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.bz2
    1.92 -    tar -xf binutils-2.19.1.tar.bz2
    1.93 -    cd binutils-2.19.1
    1.94 -    ./configure --prefix=/usr/local
    1.95 -    make -j 2
    1.96 -    sudo cp binutils/obj{dump,copy} /usr/local/bin
    1.97 -
    1.98 -
    1.99 -Done installing prerequisites...now do the fun stuff!
   1.100 -
   1.101 -
   1.102 -1) Create a disk image with Disk Utility (in /Utilities/Disk Utility).
   1.103 -    Open it and go to File->New->Blank Disk Image.
   1.104 -    Save As: Call it whatever you want.
   1.105 -    Volume name: Call it CrosstoolCompile
   1.106 -    Volume size: Go to custom and choose 2000 MB. This is a temporary image you
   1.107 -                 can delete once you're done compiling if you wish.
   1.108 -    Volume format: Choose Mac OS Extended (Case-sensitive, journaled).
   1.109 -        Mac OS X's default file system does not allow you to name two files
   1.110 -        the same with different cases (abcd and ABCD) but you need this for
   1.111 -        crosstool. So that's why we're creating a disk image. Leave everything
   1.112 -        else the default and save it wherever you want.
   1.113 -
   1.114 -2) Create another disk image where the final toolchain will be installed.
   1.115 -    Your crosstool needs to go on a disk image for the same reason--needs a
   1.116 -    case sensitive file system and regular Mac OS X HFS+ is not. So we have to
   1.117 -    make another one. Follow the steps above but set the volume name to
   1.118 -    Crosstool and then make the volume size something like 300MB. Just make
   1.119 -    sure you leave plenty of room for any libraries you want to add to your
   1.120 -    cross compiler and that kind of stuff. The resulting toolchain will be about
   1.121 -    110 MB in size. Set the Volume Format to
   1.122 -    Mac OS Extended (Case-sensitive, journaled).
   1.123 -    Save this image somewhere handy. You'll be using it forever after this.
   1.124 -
   1.125 -
   1.126 -3) Make sure they're both mounted.
   1.127 -
   1.128 -4) cd /Volumes/CrosstoolCompile
   1.129 -
   1.130 -5) Grab crosstool-ng:
   1.131 -    curl -O http://ymorin.is-a-geek.org/download    \
   1.132 -                /crosstool-ng/crosstool-ng-1.4.2.tar.bz2
   1.133 -    (OS X doesn't come with wget by default)
   1.134 -
   1.135 -6) Expand it
   1.136 -    tar -xf crosstool-ng-1.4.2.tar.bz2
   1.137 -    cd crosstool-ng-1.4.2
   1.138 -
   1.139 -7) Build it
   1.140 -    export PATH=/usr/local/bin:$PATH
   1.141 -
   1.142 -    Make sure you do it like this.
   1.143 -        /usr/local/bin has to come in the path BEFORE anything else.
   1.144 -
   1.145 -    ./configure --local
   1.146 -    make
   1.147 -
   1.148 -8) Configure crosstool
   1.149 -    ./ct-ng menuconfig
   1.150 -
   1.151 -At this point you should have a screen up similar to the Linux kernel config.
   1.152 -Now set up options. Leave options as default if I haven't mentioned them.
   1.153 -
   1.154 -Paths and misc options:
   1.155 -    Enable Use obsolete features
   1.156 -    Enable Try features marked as EXPERIMENTAL
   1.157 -    Set prefix directory to:
   1.158 -        /Volumes/Crosstool/${CT_TARGET}
   1.159 -        (this tells it to install on the disk image you created)
   1.160 -    Number of parallel jobs: Multiply the number of cores you have times 2.
   1.161 -    That's what I generally do. So my dual core can do 4 jobs.
   1.162 -    Makes compiling the toolchain faster.
   1.163 -
   1.164 -Target options:
   1.165 -    Target Architecture: ARM
   1.166 -    Use EABI: Do NOT check this. The default TS Debian filesystem is OABI.
   1.167 -        If you are doing an EABI one, you can set this to true (but may want
   1.168 -        to do a different version of gcc/glibc)
   1.169 -    Architecture level: armv4t
   1.170 -        armv4t is for the EP9302. other processors you would pick the
   1.171 -            right architecture here.
   1.172 -    Floating point: Hardware
   1.173 -
   1.174 -    I believe this is correct even though it's not really using an FPU because
   1.175 -    the pre-EABI debian distro was compiled with hardfloat instructions so
   1.176 -    whenever you do a floating point instruction the kernel is actually
   1.177 -    trapping an illegal instruction error, makes for slow floating point...
   1.178 -    EABI is so much better.
   1.179 -
   1.180 -    I know hardware is the default, but I just wanted to clarify that you need
   1.181 -    to choose hardware here. I'm pretty sure anyway.
   1.182 -
   1.183 -Toolchain Options:
   1.184 -    Tuple's vendor string: whatever you want.
   1.185 -        It'll be arm-yourtuple-linux-gnu when you're finished.
   1.186 -
   1.187 -Operating System:
   1.188 -    Target OS: linux
   1.189 -    Linux kernel version: 2.6.21.7 (best match for TS kernel!)
   1.190 -
   1.191 -binutils:
   1.192 -    version: 2.19.1
   1.193 -C compiler:
   1.194 -    gcc
   1.195 -    version: 4.1.2
   1.196 -    choose C++ below, so you can compile C++!
   1.197 -C-library:
   1.198 -    glibc (NOT eglibc for this)
   1.199 -    glibc version: 2.3.6
   1.200 -    Threading implementation to use: linuxthreads
   1.201 -
   1.202 -(note: nptl is better than linuxthreads, but it looks like nptl didn't support
   1.203 -       ARM back in glibc 2.3.6?
   1.204 -
   1.205 -Exit and save config.
   1.206 -
   1.207 -Now we need to add a patch. Looks like the configure script for glibc does not
   1.208 -like some of apple's binutils, so we need to patch it to skip the version tests
   1.209 -for as and ld. Stick this patch in crosstool-ng-1.4.2/patches/glibc/2.3.6 to
   1.210 -skip the version test for as and ld:
   1.211 -
   1.212 -http://homepage.mac.com/macg3/300-glibc-2.3.6-configure-patch-OSX.patch
   1.213 -
   1.214 -(or see below, at the end of this file)
   1.215 -
   1.216 ----------
   1.217 -
   1.218 -Okay, done setting up crosstool...now...
   1.219 -
   1.220 -./ct-ng build
   1.221 -
   1.222 -Sit back, relax, wait a while. Crosstool-ng will do the rest, automatically
   1.223 -downloading tarballs, patching them, installing them. Could take quite a long
   1.224 -time. The actual compiling took about 30 minutes on my older MacBook Pro. When
   1.225 -you're done you have a cross compiler on your disk image that you named
   1.226 -"Crosstool". Look in there and you're all set!
   1.227 -
   1.228 -So whenever you want to use the cross compiler, you need to mount this disk
   1.229 -image. You could also create an actual partition on your computer that is
   1.230 -Mac OS X extended case-sensitive if you wish. Then you don't need the disk
   1.231 -image.
   1.232 -
   1.233 -You can delete the CrosstoolCompile disk image. It was just used temporarily
   1.234 -while compiling everything.
   1.235 -
   1.236 -Note that I'm pretty sure gcc 4.1.2 has a bug in assembly generation that will
   1.237 -cause Qt 4.5 to segfault. I'm fairly sure I saw this problem before with 4.1.2.
   1.238 -I know for a fact that gcc 4.3.3 has the bug. This bug report:
   1.239 -http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39429 has the details. I adapted the
   1.240 -patch at the bottom to work with gcc 4.3.3. you might be able to apply it to
   1.241 -other gcc versions. Not sure. I think 4.0.4 does not have this bug so you might
   1.242 -even try compiling 4.0.4 instead of 4.1.2. Lots of options. Hope this helps,
   1.243 -I've struggled with this stuff a lot but it's so convenient to have a native
   1.244 -OS X toolchain!
   1.245 -
   1.246 -
   1.247 -Patch
   1.248 ------
   1.249 -
   1.250 -Here is the afore-mentioned patch:
   1.251 -
   1.252 ----8<---
   1.253 -Mac OS X fails configuring because its included binutils kind of suck.
   1.254 -This patch makes the glibc 2.3.6 configure script ignore the
   1.255 -installed version of as and ld. It just makes the configure
   1.256 -script believe that it's as version 2.13 and ld 2.13.
   1.257 -
   1.258 -Made on 2009-08-08 by Doug Brown
   1.259 -
   1.260 ---- glibc-2.3.6/configure.orig	2009-08-08 10:40:10.000000000 -0700
   1.261 -+++ glibc-2.3.6/configure	2009-08-08 10:42:49.000000000 -0700
   1.262 -@@ -3916,10 +3916,7 @@ else
   1.263 - echo $ECHO_N "checking version of $AS... $ECHO_C" >&6
   1.264 -   ac_prog_version=`$AS -v </dev/null 2>&1 | sed -n 's/^.*GNU assembler.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
   1.265 -   case $ac_prog_version in
   1.266 --    '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
   1.267 --    2.1[3-9]*)
   1.268 --       ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
   1.269 --    *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
   1.270 -+    *) ac_prog_version="2.13, ok"; ac_verc_fail=no;;
   1.271 - 
   1.272 -   esac
   1.273 -   echo "$as_me:$LINENO: result: $ac_prog_version" >&5
   1.274 -@@ -3977,10 +3974,7 @@ else
   1.275 - echo $ECHO_N "checking version of $LD... $ECHO_C" >&6
   1.276 -   ac_prog_version=`$LD --version 2>&1 | sed -n 's/^.*GNU ld.* \([0-9][0-9]*\.[0-9.]*\).*$/\1/p'`
   1.277 -   case $ac_prog_version in
   1.278 --    '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
   1.279 --    2.1[3-9]*)
   1.280 --       ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
   1.281 --    *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
   1.282 -+    *) ac_prog_version="2.13, ok"; ac_verc_fail=no;;
   1.283 - 
   1.284 -   esac
   1.285 -   echo "$as_me:$LINENO: result: $ac_prog_version" >&5
   1.286 ----8<---
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/docs/README.macos.txt	Tue May 25 18:25:11 2010 +0200
     2.3 @@ -0,0 +1,39 @@
     2.4 +22 May 2010 - Titus
     2.5 +
     2.6 +Prerequisites and instructions for using crosstool-NG for building a cross
     2.7 +toolchain on MacOS as host.
     2.8 +
     2.9 +0) Mac OS Snow Leopard, with Developer Tools 3.2 installed, or
    2.10 +   Mac OS Leopard, with Developer Tools & newer gcc (>= 4.3) installed
    2.11 +   via macports
    2.12 +
    2.13 +1) You have to use a case sensitive file system for ct-ng's build and target
    2.14 +   directories. Use a disk or disk image with a case sensitive fs that you
    2.15 +   mount somewhere.
    2.16 +
    2.17 +2) Install macports (or similar easy means of installing 3rd party software),
    2.18 +   make sure that macport's bin dir is in your PATH.
    2.19 +   Furtheron assuming it is /opt/local/bin.
    2.20 +
    2.21 +3) Install (at least) the following macports
    2.22 +   ncurses
    2.23 +   lzmautils
    2.24 +   libtool
    2.25 +   binutils
    2.26 +   gsed
    2.27 +   gawk
    2.28 +   gcc43 (only necessary for Leopard OSX 10.5)
    2.29 +
    2.30 +   On Leopard, make sure that the macport's gcc is called with the default
    2.31 +   commands (gcc, g++,...), e.g. via macport gcc_select
    2.32 +
    2.33 +4) run ct-ng's configure with the following tool configuration
    2.34 +   (assuming you have installed the tools via macports in /opt/local):
    2.35 +   ./configure --with-sed=/opt/local/bin/gsed           \
    2.36 +               --with-libtool=/opt/local/bin/glibtool   \
    2.37 +               --with-objcopy=/opt/local/bin/gobjcopy   \
    2.38 +               --with-objdump=/opt/local/bin/gobjdump   \
    2.39 +               --with-readelf=/opt/local/bin/greadelf   \
    2.40 +               [...other configure parameters as you like...]
    2.41 +
    2.42 +5) proceed as described in standard documentation