Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

root/tags/releases/0.99.8/lib/build-gdc-mac.sh

Revision 4330, 2.7 kB (checked in by larsivi, 3 years ago)

Various fixes to be able to build a four-way (ppc, ppc64, x86, x86-64) universal binary (mac), closes #1322, many thanks afb

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1 #!/bin/sh
2
3 DARWIN="darwin`uname -r | cut -d. -f1`"
4 FAILED=0
5 # Written by Anders F. Björklund
6 cd "`dirname \"$0\"`"
7
8 # set up symbolic links to compilers without version suffix
9
10 tempdir=/tmp/build-$$
11 mkdir -p $tempdir
12 for target in powerpc-apple-$DARWIN i686-apple-$DARWIN; do
13   for prefix in /usr /usr/local /opt/gdc /sw /opt/local; do
14   if [ -x $prefix/bin/gdc ]; then
15     version=`$prefix/bin/gdc -dumpversion`
16     for program in gcc g++ gdc; do
17     if [ ! -L "$prefix/bin/$target-$program" ]; then
18       if [ -x "$prefix/bin/$target-$program-$version" ]; then
19       echo "$target-$program -> $target-$program-$version"
20       ln -s $prefix/bin/$target-$program-$version $tempdir/$target-$program
21       fi
22     fi
23     done
24   fi
25   if [ -x "$prefix/bin/gdmd" ]; then
26     for program in gdmd; do
27     if [ ! -L "$prefix/bin/$target-$program" ]; then
28       echo "$target-$program -> $program"
29       ln -s $prefix/bin/$program $tempdir/$target-$program
30     fi
31     done
32   fi
33   done
34 done
35 export PATH="$tempdir:$PATH"
36
37 # build Universal Binary versions of the Tango libraries
38
39 export MAKETOOL=make
40
41 HOME=`pwd` make -s clean -fgdc-posix.mak
42
43 LIBS="common/libtango-cc-tango.a gc/libtango-gc-basic.a libgphobos.a"
44
45 for lib in $LIBS; do test -r $lib && rm $lib; done
46
47 DINC="-q,-nostdinc -I`pwd`/common -I`pwd`/.. -I`pwd`/compiler/gdc"
48
49 # Potential additions for later
50 #export CFLAGS="-arch ppc -arch ppc64"
51 #export DFLAGS="-arch ppc -arch ppc64"
52 if ADD_CFLAGS="-m32" ADD_DFLAGS="$DINC -m32" ./build-gdc-x.sh powerpc-apple-$DARWIN 1>&2
53 then
54     for lib in $LIBS; do mv $lib $lib.ppc; done
55     if ADD_CFLAGS="-m64" ADD_DFLAGS="$DINC -m64" ./build-gdc-x.sh powerpc-apple-$DARWIN 1>&2
56     then
57         for lib in $LIBS; do mv $lib $lib.ppc64; done
58     else
59         FAILED=1
60     fi
61 else
62     FAILED=1
63 fi
64
65 if [ "$FAILED" = "0" ]
66 then
67     # Potential additions for later
68     #export CFLAGS="-arch i386 -arch x86_64"
69     #export DFLAGS="-arch i386 -arch x86_64"
70     if ADD_CFLAGS="-m32" ADD_DFLAGS="$DINC -m32" ./build-gdc-x.sh i686-apple-$DARWIN 1>&2
71     then
72         for lib in $LIBS; do mv $lib $lib.i386; done
73         if ADD_CFLAGS="-m64" ADD_DFLAGS="$DINC -m64" ./build-gdc-x.sh i686-apple-$DARWIN 1>&2
74         then
75             for lib in $LIBS; do mv $lib $lib.x86_64; done
76         else
77             FAILED=1
78         fi
79     else
80         FAILED=1
81     fi
82 fi
83
84 if [ "$FAILED" = "1" ]
85 then
86     echo 'Failed to build universal binaries. Trying GDC.'
87     if ./build-gdc.sh 1>&2
88     then
89         echo 'Universal binary failed to build, fallback succeded by using standard GDC.'
90     else
91         echo 'Universal binary failed to build, and so did the fallback method using standard GDC.'
92     fi
93 else
94     for lib in $LIBS; do \
95     lipo -create -output $lib $lib.ppc $lib.ppc64 $lib.i386 $lib.x86_64; done
96 fi
Note: See TracBrowser for help on using the browser.