public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
* Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2 (Snow Leopard)
@ 2010-01-31 10:39 Uwe Papengut
  2010-01-31 16:54 ` Titus von Boxberg
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Papengut @ 2010-01-31 10:39 UTC (permalink / raw)
  To: crossgcc

Hello,

I read the article "Building toolchain with crosstool-ng on Mac OS X SL" in the mail archive and I am not sure which version of coreutils, gawk, libtool and so on I need. I read the MacOS-X.txt, too.

I started with the command of the MacOS-X.txt manually and I got a lot of warnings and errors:

--------------------------------------------------------------------------

echo Create new Directory
mkdir /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp

echo Install GNU sed into /usr/local
cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
curl -O http://ftp.gnu.org/gnu/sed/sed-4.2.1.tar.bz2
tar -xf sed-4.2.1.tar.bz2
cd sed-4.2.1
./configure --prefix=/usr/local
make -j 2
sudo make install

echo Install GNU coreutils
cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
curl -O http://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz
tar -xf coreutils-7.4.tar.gz
cd coreutils-7.4
./configure --prefix=/usr/local
make -j 2
sudo make install

echo Install GNU libtool
cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz
tar -xf libtool-2.2.6a.tar.gz
cd libtool-2.2.6
./configure --prefix=/usr/local
make -j 2
sudo make install

echo Install GNU awk, needed to fix a weird error in glibc compile
cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
curl -O http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2
tar -xf gawk-3.1.7.tar.bz2
cd gawk-3.1.7
./configure --prefix=/usr/local
make -j 2
sudo make install

echo Xcode doesn't come with objcopy/objdump, but you need them. 
cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.bz2
tar -xf binutils-2.19.1.tar.bz2
cd binutils-2.19.1
./configure --prefix=/usr/local
make -j 2
sudo cp binutils/obj{dump,copy} /usr/local/bin

echo Done installing prerequisites...now do the fun stuff!

--------------------------------------------------------------------------

Has anyone successfully installed the program crossgcc on MacOS SL manually (or with crosstool-ng)?

Best Regards,
Uwe
















--
For unsubscribe information see http://sourceware.org/lists.html#faq

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2  (Snow Leopard)
  2010-01-31 10:39 Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2 (Snow Leopard) Uwe Papengut
@ 2010-01-31 16:54 ` Titus von Boxberg
  2010-01-31 17:56   ` Yann E. MORIN
  0 siblings, 1 reply; 5+ messages in thread
From: Titus von Boxberg @ 2010-01-31 16:54 UTC (permalink / raw)
  To: Uwe Papengut, crossgcc

Hello Uwe, all

I recently made a patch for using crosstool-ng on mac and freebsd.
I will rework the cosmetics according to Yann's comments this month.

If you need it upfront, I can send it over.

Regards
Titus

-------- Original-Nachricht --------
> Datum: Sun, 31 Jan 2010 11:39:23 +0100
> Von: Uwe Papengut <uwe.papengut@t-online.de>
> An: crossgcc@sourceware.org
> Betreff: Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2 (Snow Leopard)

> Hello,
> 
> I read the article "Building toolchain with crosstool-ng on Mac OS X SL"
> in the mail archive and I am not sure which version of coreutils, gawk,
> libtool and so on I need. I read the MacOS-X.txt, too.
> 
> I started with the command of the MacOS-X.txt manually and I got a lot of
> warnings and errors:
> 
> --------------------------------------------------------------------------
> 
> echo Create new Directory
> mkdir /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
> 
> echo Install GNU sed into /usr/local
> cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
> curl -O http://ftp.gnu.org/gnu/sed/sed-4.2.1.tar.bz2
> tar -xf sed-4.2.1.tar.bz2
> cd sed-4.2.1
> ./configure --prefix=/usr/local
> make -j 2
> sudo make install
> 
> echo Install GNU coreutils
> cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
> curl -O http://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz
> tar -xf coreutils-7.4.tar.gz
> cd coreutils-7.4
> ./configure --prefix=/usr/local
> make -j 2
> sudo make install
> 
> echo Install GNU libtool
> cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
> curl -O http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz
> tar -xf libtool-2.2.6a.tar.gz
> cd libtool-2.2.6
> ./configure --prefix=/usr/local
> make -j 2
> sudo make install
> 
> echo Install GNU awk, needed to fix a weird error in glibc compile
> cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
> curl -O http://ftp.gnu.org/gnu/gawk/gawk-3.1.7.tar.bz2
> tar -xf gawk-3.1.7.tar.bz2
> cd gawk-3.1.7
> ./configure --prefix=/usr/local
> make -j 2
> sudo make install
> 
> echo Xcode doesn't come with objcopy/objdump, but you need them. 
> cd /Applications/arm-linux-gcc/crosstool-ng-1.5.3/_tmp
> curl -O http://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.bz2
> tar -xf binutils-2.19.1.tar.bz2
> cd binutils-2.19.1
> ./configure --prefix=/usr/local
> make -j 2
> sudo cp binutils/obj{dump,copy} /usr/local/bin
> 
> echo Done installing prerequisites...now do the fun stuff!
> 
> --------------------------------------------------------------------------
> 
> Has anyone successfully installed the program crossgcc on MacOS SL
> manually (or with crosstool-ng)?
> 
> Best Regards,
> Uwe
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> For unsubscribe information see http://sourceware.org/lists.html#faq

--
For unsubscribe information see http://sourceware.org/lists.html#faq

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2  (Snow Leopard)
  2010-01-31 16:54 ` Titus von Boxberg
@ 2010-01-31 17:56   ` Yann E. MORIN
  0 siblings, 0 replies; 5+ messages in thread
From: Yann E. MORIN @ 2010-01-31 17:56 UTC (permalink / raw)
  To: crossgcc; +Cc: Titus von Boxberg, Uwe Papengut

Titus, Uwe, All,

On Sunday 31 January 2010 17:53:48 Titus von Boxberg wrote:
> I recently made a patch for using crosstool-ng on mac and freebsd.
> I will rework the cosmetics according to Yann's comments this month.

Titus, I think you are the one that can handle this stuff, as you have a
MacOS-X at hands, and you have already handled the most difficult part.
I'd be really happy to look at your new patchset.

BTW, please next time also CC the list for your updated patchset.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
`------------------------------^-------^------------------^--------------------'



--
For unsubscribe information see http://sourceware.org/lists.html#faq

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2  (Snow Leopard)
  2010-02-01  2:26 tvb377
@ 2010-02-02 18:16 ` Yann E. MORIN
  0 siblings, 0 replies; 5+ messages in thread
From: Yann E. MORIN @ 2010-02-02 18:16 UTC (permalink / raw)
  To: tvb377; +Cc: crossgcc

Titus, All,

On Monday 01 February 2010 03:25:56 tvb377@gmx.de wrote:
> here is the reworked patch for crosstool-ng on FreeBSD and MacOS

This patch is still very large, and contains unrelated changes.
It is thus hard to see the implications of each change.

Please, split the patch into self-contained patches that each add a
single change, as I suggested ealier. For example:
- the sed->$(sed) change in samples.mk on its own
- the configure+Makefile.in changes into their own (one for libtool, one
  for objcopy, ...)
- one for Darwin/*BSD vs. GNU
- and so on...

Having each change in a separate patch will help with review. Small patches
(few-liners) will most probably pass in a blink of an eye. When they get
applied, they will each yield a new changeset in the tree, and that would
be easier to revert the one(s) that is(are) faulty without having to revert
the whole stuff.

Also, if you would provide mercurial patches, it would be easier to work
with. See docs/overview.txt, section "Contributing".

> And two new READMEs (instead of docs/MacOS-X.txt).

Good. :-)

> Almost all patch parts revolve around GNU/BSD incompatibilities.
> I try to explain what I did:
> - enlarge the list of configurable tools that ctng uses (for usage of
> GNU tools).
> - also make sure that the configured tools actually get used.

One patch per new tool, please. Also, be sure to see how it plays with
the companion tools that were recently added.

> - make all calls to stat(1) dependent to `uname -s` or replace the call.

One patch for that.

> - replace all calls to readlink(1GNU) with compatible variants.

"readlink -e" and "readlink" are not equivalent.

>   This makes the usage of wrapper.c mandatory on MacOS because there is
>   no way known to me emulating readlink -m without a lengthy shell script.

Separate patch for that.

> - uname -o is not portable. use -s when -o fails

Ditto.

> - a bug in the sed-expression that sets the nanoseconds to 0 for a
>   date(1) not handling %N

On my system (%Q is not recognised, so use that)
  > date +%Q
  %Q

So this change seems to imply that on MacOS-X or *BSD, we get:
  > date +%N
  N

Right?

> Notable other reasons besides GNU/BSD are:
> - have to compile mpfr with --disable-thread-safe on darwin.

Separate patch for that as well.

> - "You did not specify the build system. That's OK, I can guess...":
>   Under MacOS 10.6 gcc reports itself as "i686-apple-..."
>   However, it's default behaviour is to generate 64bit objects.
>   This clashes with some configure scripts that require "x86_64-..." for
>   configuring for a 64bit host.
>   Using CT_DoConfigGuess does the job correctly.
>   Why not use that in general?

Not reliable on my system:
  > config.guess
  x86_64-unknown-linux-gnu
  > gcc -dumpmachine
  x86_64-linux-gnu

And I have the tools for x86_64-linux-gnu-{gcc,ld,...}, but not the ones for
x86_64-unknown-linux-gnu-{gcc,ld,...}. So it is much more reliable to ask
gcc than to ask config.guess.

gcc -dumpmachine will tell us the tuple for which it was configured, and
that means the prefix to use to the actual tools, which is what we need.

> BTW, the above two changes are the only changes actually for BUILDING the
> toolchain, and not for porting ctng itself.
> - the compiler command line options for compiling wrapper.c crashes gcc
>   on MacOS (and IMHO were a little bit overdone for the complexity of
>   wrapper.c).

Separate patch for that.

> - you should not link statically on MacOS (wrapper.c command line again)

Statically linking should hopefully speed up things. Having a /slow/
wrapper is not very interesting, is it? Of course, the ratio
time-in-wrapper / (time-in-wrapper + time-in-actual-tool) should be
fairly small, except for very trivial programs, where the total time
will anyway be almost imperceptible...

> - under Darwin, use DYLD_LIBRARY_PATH in wrapper.c

Separate patch for that as well.

> - added printenv to the build.log (I found that helpful).

Separate patch.

> I can now compile gcc4.4.2 for powerpc for linux/glibc under Linux, BSD,
> and MacOS. I only shortly grepped through scripts not necessary for this
> configuration, so more incompatibilities may arise. However, they should
> be easy to fix in this manner.

Please, provide a split-up patchset as instructed above, and we'll be
able to easily review it.

Thank you! :-)

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
`------------------------------^-------^------------------^--------------------'



--
For unsubscribe information see http://sourceware.org/lists.html#faq

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2   (Snow Leopard)
@ 2010-02-01  2:26 tvb377
  2010-02-02 18:16 ` Yann E. MORIN
  0 siblings, 1 reply; 5+ messages in thread
From: tvb377 @ 2010-02-01  2:26 UTC (permalink / raw)
  To: Yann E. MORIN, crossgcc; +Cc: uwe.papengut

[-- Attachment #1: Type: text/plain, Size: 2311 bytes --]

> > I recently made a patch for using crosstool-ng on mac and freebsd.
> > I will rework the cosmetics according to Yann's comments this month.
> 
> Titus, I think you are the one that can handle this stuff, as you have a

Uwe, Yann, all

here is the reworked patch for crosstool-ng on FreeBSD and MacOS against a current (31 January 23:00 CET) version.
And two new READMEs (instead of docs/MacOS-X.txt).

Almost all patch parts revolve around GNU/BSD incompatibilities.
I try to explain what I did:
- enlarge the list of configurable tools that ctng uses (for usage of GNU tools).
- also make sure that the configured tools actually get used.
- make all calls to stat(1) dependent to `uname -s` or replace the call.
- replace all calls to readlink(1GNU) with compatible variants.
  This makes the usage of wrapper.c mandatory on MacOS because there is no way known to me emulating readlink -m without a lengthy shell script.
- uname -o is not portable. use -s when -o fails
- a bug in the sed-expression that sets the nanoseconds to 0 for a date(1) not handling %N

Notable other reasons besides GNU/BSD are:
- have to compile mpfr with --disable-thread-safe on darwin.
- "You did not specify the build system. That's OK, I can guess...":
  Under MacOS 10.6 gcc reports itself as "i686-apple-..."
  However, it's default behaviour is to generate 64bit objects.
  This clashes with some configure scripts that require "x86_64-..." for configuring for a 64bit host.
  Using CT_DoConfigGuess does the job correctly.
  Why not use that in general?
BTW, the above two changes are the only changes actually for BUILDING the toolchain, and not for porting ctng itself.
- the compiler command line options for compiling wrapper.c crashes gcc on MacOS (and IMHO were a little bit overdone for the complexity of wrapper.c).
- you should not link statically on MacOS (wrapper.c command line again)
- under Darwin, use DYLD_LIBRARY_PATH in wrapper.c
- added printenv to the build.log (I found that helpful).

I can now compile gcc4.4.2 for powerpc for linux/glibc under Linux, BSD, and MacOS.
I only shortly grepped through scripts not necessary for this configuration, so more incompatibilities may arise. However, they should be easy to fix in this manner.

Hope this helps.
Further comments are welcome.

Regards
Titus

[-- Attachment #2: ct-ng-bsdpatch.txt --]
[-- Type: text/plain, Size: 11253 bytes --]

diff -r 160fc94ed49f Makefile.in
--- a/Makefile.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/Makefile.in	Mon Feb 01 02:33:37 2010 +0100
@@ -52,6 +52,11 @@
 grep   := @@grep@@
 make   := @@make@@
 sed    := @@sed@@
+libtool:= @@libtool@@
+objcopy:= @@objcopy@@
+objdump:= @@objdump@@
+readelf:= @@readelf@@
+patch  := @@patch@@
 
 ###############################################################################
 # Sanity checks
@@ -139,6 +144,11 @@
 	  echo "export grep=$(grep)";       \
 	  echo "export make=$(make)";       \
 	  echo "export sed=$(sed)";         \
+	  echo "export libtool=$(libtool)"; \
+	  echo "export objcopy=$(objcopy)"; \
+	  echo "export objdump=$(objdump)"; \
+	  echo "export readelf=$(readelf)"; \
+	  echo "export patch=$(patch)";     \
 	 ) >paths.mk
 
 #--------------------------------------
diff -r 160fc94ed49f configure
--- a/configure	Sun Jan 31 23:04:35 2010 +0100
+++ b/configure	Mon Feb 01 02:33:37 2010 +0100
@@ -160,7 +160,7 @@
                 printf "Checking for '${item}'... "
                 where="$( gcc -print-file-name="${item}" )"
                 if [ "${where}" != "${item}" ]; then
-                    where="$( readlink -e "${where}" )"
+                    where="$( readlink "${where}" )"
                     status=yes
                     break;
                 fi
@@ -346,17 +346,17 @@
              ver='^GNU Make (3.[89][[:digit:]]|[4-9])'  \
              err="GNU 'make' 3.80 or above was not found"
 has_or_abort prog=gcc
-has_or_abort prog="awk gawk" ver='^GNU Awk' err="GNU 'awk' was not found"
+has_or_abort prog="gawk awk" ver='^GNU Awk' err="GNU 'awk' was not found"
 has_or_abort prog=bison
 has_or_abort prog=flex
 has_or_abort prog=makeinfo
 has_or_abort prog=automake                                                      \
              ver='\(GNU automake\) (1\.[[:digit:]]{2,}|[2-9][[:digit:]]*\.)'    \
              err="'automake' 1.10 or above was not found"
-has_or_abort prog=libtool                                                                           \
+has_or_abort prog=libtool var=libtool                                                               \
              ver='\(GNU libtool.*\) (2[[:digit:]]*\.|1\.6[[:digit:]]*\.|1\.5\.[2-9][[:digit:]]+)'   \
              err="'libtool' 1.5.26 or above was not found"
-has_or_abort prog=stat ver='GNU coreutils'
+has_or_abort prog=stat
 has_or_abort prog="aria2c curl wget"
 has_or_abort prog=cvs
 has_or_abort prog=patch
@@ -365,6 +365,10 @@
 has_or_abort prog=bzip2
 has_or_abort prog=lzma
 has_or_abort prog=readlink
+has_or_abort prog=objcopy var=objcopy
+has_or_abort prog=objdump var=objdump
+has_or_abort prog=readelf var=readelf
+has_or_abort prog=patch var=patch
 
 has_or_abort inc="ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h"    \
              err="'ncurses' headers files were not found"
diff -r 160fc94ed49f samples/samples.mk
--- a/samples/samples.mk	Sun Jan 31 23:04:35 2010 +0100
+++ b/samples/samples.mk	Mon Feb 01 02:33:37 2010 +0100
@@ -5,10 +5,10 @@
 CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config))
 CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config)))
 CT_SAMPLES := $(shell echo $(sort $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES))  \
-                      |sed -r -e 's/ /\n/g;'                            \
-                      |sed -r -e 's/(.*),(.*)/\2,\1/;'                  \
+                      |$(sed) -r -e 's/ /\n/g;'                            \
+                      |$(sed) -r -e 's/(.*),(.*)/\2,\1/;'                  \
                       |LC_ALL=C sort                                    \
-                      |sed -r -e 's/(.*),(.*)/\2,\1/;'                  \
+                      |$(sed) -r -e 's/(.*),(.*)/\2,\1/;'                  \
                )
 
 # ----------------------------------------------------------
diff -r 160fc94ed49f scripts/build/companion_libs/mpfr.sh
--- a/scripts/build/companion_libs/mpfr.sh	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/build/companion_libs/mpfr.sh	Mon Feb 01 02:33:37 2010 +0100
@@ -75,6 +75,7 @@
     case "${CT_HOST}" in
         *cygwin*)   mpfr_opt="--disable-thread-safe";;
         *mingw*)    mpfr_opt="--disable-thread-safe";;
+        *darwin*)   mpfr_opt="--disable-thread-safe";;
         *)          mpfr_opt="--enable-thread-safe";;
     esac
 
diff -r 160fc94ed49f scripts/build/internals.sh
--- a/scripts/build/internals.sh	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/build/internals.sh	Mon Feb 01 02:33:37 2010 +0100
@@ -42,6 +42,11 @@
         CT_DoLog EXTRA "Installing toolchain wrappers"
         CT_Pushd "${CT_PREFIX_DIR}/bin"
 
+        if [ "$CT_SYS_OS" = "Darwin" -o "$CT_SYS_OS" = "FreeBSD" ] ; then
+            # wrapper does not work (when using readlink -m)
+            CT_DoLog EXTRA "Forcing usage of binary wrappers"
+            CT_TOOLS_WRAPPER="exec"
+        fi
         # Install the wrapper
         case "${CT_TOOLS_WRAPPER}" in
             script)
@@ -55,9 +60,8 @@
                 if [ "${CT_DEBUG_CT}" = "y" ]; then
                   _t="" # If debugging crosstool-NG, don't strip the wrapper
                 fi
-                CT_DoExecLog DEBUG "${CT_HOST}-gcc"                           \
-                                   -Wall -Wextra -Wunreachable-code -Werror   \
-                                   -O3 -static ${_t}                          \
+                CT_DoExecLog DEBUG "cc" -Wall -Wextra -Werror        \
+                                   -O -D$CT_SYS_OS ${_t}             \
                                    "${CT_LIB_DIR}/scripts/wrapper.c"          \
                                    -o ".${CT_TARGET}-wrapper"
                 ;;
@@ -68,7 +72,7 @@
         # scripts, we don't know if they would in the end spawn a binary...
         # Just skip symlinks
         for _t in "${CT_TARGET}-"*; do
-            if [ "$( LANG=C stat -c '%F' "${_t}" )" != "symbolic link" ]; then
+            if [ -z "`readlink ${_t}`" ]; then
                 CT_DoExecLog ALL mv "${_t}" ".${_t}"
                 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
             fi
diff -r 160fc94ed49f scripts/crosstool-NG.sh.in
--- a/scripts/crosstool-NG.sh.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/crosstool-NG.sh.in	Mon Feb 01 02:33:37 2010 +0100
@@ -189,8 +189,8 @@
 CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}"
 CT_SYS_KERNEL=$(uname -s)
 CT_SYS_REVISION=$(uname -r)
-# MacOS X lacks '-o' :
-CT_SYS_OS=$(uname -o || echo "Unknown (maybe MacOS-X)")
+# uname -o is a GNU Extension. Others lack '-o' --> use System name for OS name.
+CT_SYS_OS=$(uname -o || uname -s)
 CT_SYS_MACHINE=$(uname -m)
 CT_SYS_PROCESSOR=$(uname -p)
 CT_SYS_GCC=$(gcc -dumpversion)
@@ -326,7 +326,12 @@
     # Determine build system if not set by the user
     CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
     case "${CT_BUILD}" in
-        "") CT_BUILD=$("${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX}" -dumpmachine);;
+        "") if [ "$CT_SYS_OS" = "Darwin" -o "$CT_SYS_OS" = "FreeBSD" ] ; then
+                CT_BUILD=$(CT_DoConfigGuess)
+            else
+                CT_BUILD=$("${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX}" -dumpmachine)
+            fi
+            ;;
     esac
 
     # Prepare mangling patterns to later modify BUILD and HOST (see below)
@@ -454,7 +459,7 @@
     CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/buildtools/makeinfo"
 
     # Help gcc
-    CT_CFLAGS_FOR_HOST=
+    # Why clear that ? CT_CFLAGS_FOR_HOST=
     [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
 
     # Override the configured jobs with what's been given on the command line
@@ -474,7 +479,7 @@
     CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
     CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
     CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
-    CT_DoExecLog DEBUG sed -r -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
+    CT_DoExecLog DEBUG sed -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
     bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
 
     CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
@@ -483,6 +488,8 @@
     CT_DoLog EXTRA "  host   = ${CT_REAL_HOST}"
     CT_DoLog EXTRA "  target = ${CT_TARGET}"
     set |grep -E '^CT_.+=' |sort |CT_DoLog DEBUG
+    CT_DoLog DEBUG "  Other environment:"
+    printenv |grep -v -E '^CT_.+=' |sort |CT_DoLog DEBUG
     CT_EndStep
 fi
 
diff -r 160fc94ed49f scripts/functions
--- a/scripts/functions	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/functions	Mon Feb 01 02:33:37 2010 +0100
@@ -192,7 +192,7 @@
 # to the highest entire second
 # Usage: CT_DoDate <fmt>
 CT_DoDate() {
-    date "$1" |sed -r -e 's/%N$/000000000/;'
+    date "$1" |sed -r -e 's/N$/000000000/;'
 }
 
 CT_STEP_COUNT=1
@@ -249,7 +249,17 @@
     local mode
     for dir in "${@}"; do
         [ -d "${dir}" ] || continue
-        mode="$(stat -c '%a' "$(dirname "${dir}")")"
+        case "$CT_SYS_OS" in
+            GNU/Linux)
+                mode="$(stat -c '%a' "$(dirname "${dir}")")"
+                ;;
+            Darwin|FreeBSD)
+                mode="$(stat -f '%Lp' "$(dirname "${dir}")")"
+                ;;
+            *)
+                CT_Abort "Unhandled host OS $CT_SYS_OS"
+                ;;
+        esac
         CT_DoExecLog ALL chmod u+w "$(dirname "${dir}")"
         CT_DoExecLog ALL chmod -R u+w "${dir}"
         CT_DoExecLog ALL rm -rf "${dir}"
diff -r 160fc94ed49f scripts/wrapper.c
--- a/scripts/wrapper.c	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/wrapper.c	Mon Feb 01 02:33:37 2010 +0100
@@ -7,6 +7,11 @@
 #include <unistd.h>
 #include <errno.h>
 
+#ifdef	Darwin
+static const char * ldlp = "DYLD_LIBRARY_PATH";
+#else
+static const char * ldlp = "LD_LIBRARY_PATH";
+#endif
 
 /* Needed for execve */
 extern char **environ;
@@ -106,7 +111,7 @@
 
   /* Now add the directory with our runtime libraries to the
      front of the library search path, LD_LIBRARY_PATH */
-  ldlibpath = getenv( "LD_LIBRARY_PATH" );
+  ldlibpath = getenv(ldlp);
   if( ldlibpath ) {
     basedir = (char*) realloc( basedir,   strlen( basedir )
                                         + strlen( ldlibpath )
@@ -115,7 +120,7 @@
     strcat( basedir, ldlibpath );
   }
 
-  if( setenv( "LD_LIBRARY_PATH", basedir, 1 ) ) {
+  if( setenv( ldlp, basedir, 1 ) ) {
     errno = ENOMEM;
     perror( "tool wrapper" );
     exit( 1 );
diff -r 160fc94ed49f scripts/wrapper.in
--- a/scripts/wrapper.in	Sun Jan 31 23:04:35 2010 +0100
+++ b/scripts/wrapper.in	Mon Feb 01 02:33:37 2010 +0100
@@ -1,5 +1,10 @@
 #!/bin/sh
 
+# this wrapper will not work under BSD systems or others
+# not containig the GNU readlink.
+# Under those, wrapper.c will forcibly be used
+# regardless of the config file setting.
+
 canonicalizedname=$(readlink -nm "${0}")
 dirname="$(dirname "${canonicalizedname}")"
 basename="$(basename "${canonicalizedname}")"

[-- Attachment #3: README.freebsd --]
[-- Type: application/octet-stream, Size: 517 bytes --]

20 January 2010 - Titus von Boxberg

General instructions for using ct-ng for building a cross toolchain on FreeBSD as host.

1)	Install (at least) the following ports
	archivers/lzma
	textproc/gsed
	devel/gmake
	devel/patch
	shells/bash
	devel/bison

2)	run ct-ng's configure with the following tool configuration:
	./configure --with-sed=/usr/local/bin/gsed --with-make=/usr/local/bin/gmake \
	--with-patch=/usr/local/bin/gpatch
	[...other configure parameters...]

3)	proceed as described in general documentation

[-- Attachment #4: README.macos --]
[-- Type: application/octet-stream, Size: 1287 bytes --]

01 February 2010 - Titus

*General* instructions for using ct-ng for building a cross toolchain on MacOS as host.

0)	Mac OS Snow Leopard, with Developer Tools 3.2 installed, or
	Mac OS Leopard, with Developer Tools & newer gcc (>= 4.3) installed via macports

1)	Install macports (or similar easy means of installing 3rd party software),
	make sure that macport's bin dir is in your PATH. Furtheron assuming it is /opt/local/bin.

2)	Install the following macports
	lzmautils
	libtool
	binutils
	gsed
	gawk
	gcc43 (only necessary for Leopard OSX 10.5)

	On Leopard, make sure that the macport's gcc is called with the default commands
	(gcc, g++,...), e.g. via macport gcc_select

3)	run ct-ng's configure with the following tool configuration
	(assuming you have installed the tools via macports in /opt/local):
	./configure --with-sed=/opt/local/bin/gsed --with-libtool=/opt/local/bin/glibtool \
	--with-objcopy=/opt/local/bin/gobjcopy --with-objdump=/opt/local/bin/gobjdump \
	--with-readelf=/opt/local/bin/greadelf [...other configure parameters as you like...]

4)	You have to use a case sensitive file system for ct-ng's build and target directories.
	Use a disk or disk image with a case sensitive fs that you mount somewhere.

5)	proceed as described in standard documentation
	

[-- Attachment #5: Type: text/plain, Size: 71 bytes --]

--
For unsubscribe information see http://sourceware.org/lists.html#faq

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-02 18:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-31 10:39 Help with Building toolchain with crosstool-ng on Mac OS X 10.6.2 (Snow Leopard) Uwe Papengut
2010-01-31 16:54 ` Titus von Boxberg
2010-01-31 17:56   ` Yann E. MORIN
2010-02-01  2:26 tvb377
2010-02-02 18:16 ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).