/[svn]/libgig/trunk/osx/autoconf_builder.sh
ViewVC logotype

Diff of /libgig/trunk/osx/autoconf_builder.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1172 by schoenebeck, Sun May 6 16:17:48 2007 UTC revision 1640 by nagata, Sun Jan 13 16:23:50 2008 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2  # autoconf_builder.sh  # autoconf_builder.sh
 # LinuxSampler  
 #  
3  # Created by Toshi Nagata on 07/04/18.  # Created by Toshi Nagata on 07/04/18.
4  # Copyright 2007 __MyCompanyName__. All rights reserved.  #
5    # Copyright 2007 Toshi Nagata.
6    #
7    # Redistribution and use in source and binary forms, with or without modification, are permitted
8    # provided that the following conditions are met:
9    #
10    #   1. Redistributions of source code must retain the above copyright notice, this list of
11    # conditions and the following disclaimer.
12    #   2. Redistributions in binary form must reproduce the above copyright notice, this list of
13    # conditions and the following disclaimer in the documentation and/or other materials provided
14    # with the distribution.
15    #
16    # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
17    # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18    # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19    # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
20    # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21    # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22    # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23    # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  #  #
25  #  Influential environmental variables:  #  Influential environmental variables:
26  #  ACTION(*): autoconf - run "make -f Makefile.cvs"; configure - run "configure";  #  ACTION(*): autoconf - run "make -f Makefile.cvs"; configure - run "configure";
27  #          make - run "make"; install - run "make install";  #               make - run "make"; install - run "make install";
28  #          build (or empty string) - autoconf && configure && make (&& install)  #               build (or empty string) - autoconf && configure && make (&& install)
29  #            "install" step is only done if WITH_INSTALL is non-empty  #               "install" step is only done if WITH_INSTALL is non-empty
30  #  BUILD_STYLE(*): The build style. If it ends with "ppc" or "i386", it also specifies the architecture.  #  BUILD_STYLE(*): The build style. If it ends with "ppc" or "i386", it also specifies the architecture.
31    #               If it ends with "UB" or "Universal", it creates the Universal Binaries for the products
32    #               specified by $UB_PRODUCTS (see below).
33    #               If any of the products are missing, then this script is recursively called for
34    #               $BUILD_STYLE's that have "ppc" and "i386" in place of "UB" or "Universal".
35  #  WITH_INSTALL: When non-empty, "install" action is automatically done in "build" action.  #  WITH_INSTALL: When non-empty, "install" action is automatically done in "build" action.
36  #  CFLAGS, CXXFLAGS: Compiler flags  #  CFLAGS, CXXFLAGS: Compiler flags
37  #  CONFIG_OPTIONS: Options for "configure"  #  CONFIG_OPTIONS: Options for "configure"
38  #  BUILD_BASE_DIR: Temporary building and install directory. By default "$PWD/build".  #  BUILD_BASE_DIR: Temporary building and install directory. By default "$PWD/build". The source
39    #               tree is duplicated (by use of symbolic links) in $BUILD_BASE_DIR/$BUILD_STYLE/<basename>.build,
40    #               where <basename> is the basename of the toplevel directory of the source tree (which also
41    #               should be the current directory when this script is invoked). The product is "installed"
42    #               into $BUILD_BASE_DIR/$BUILD_STYLE/local.
43  #  SDKROOT: The root directory for SDK  #  SDKROOT: The root directory for SDK
44    #  UB_PRODUCTS: The products for which Universal Binaries are to be created. The paths should be
45    #               relative to $BUILD_BASE_DIR/$BUILD_STYLE/local. Eg. bin/some_executable, lib/some_library.a.
46    #  UB_ARCHS: The target architectures for the "UB" build style. If not specified, "ppc i386" is assumed.
47    #  UB_ONEPASS: When non-empty, building "UB" is done with the compiler flag like "-arch i386 -arch ppc".
48    #       Otherwise, binaries for each architecture are separately built and combined later by lipo.
49  #  #
50  #  The variables marked with (*) are automatically set by Xcode.  #  The variables marked with (*) are automatically set by Xcode.
51    
52  BASE_DIR=$PWD  BASE_DIR=$PWD
53  BASE_NAME=`basename $PWD`  BASE_NAME=`basename $PWD`
54    UB_ARCHS=${UB_ARCHS:-"ppc i386"}
55    
56  function rel2abs () {  function rel2abs () {
57          (cd "$1"; pwd)          (cd "$1"; pwd)
 #       pushd "$1" >/dev/null  
 #       pwd  
 #       popd >/dev/null  
58  }  }
59    
60  function abs2rel () {  function abs2rel () {
# Line 66  if test "x$ACTION" = "x"; then Line 94  if test "x$ACTION" = "x"; then
94          ACTION="build"          ACTION="build"
95  fi  fi
96  if test "x$BUILD_BASE_DIR" = "x"; then  if test "x$BUILD_BASE_DIR" = "x"; then
97          BUILD_BASE_DIR=$PWD/build          BUILD_BASE_DIR=$PWD/../temp_build
98  fi  fi
99  BUILD_DIR="$BUILD_BASE_DIR/$BUILD_STYLE/$BASE_NAME.build"  mkdir -p "$BUILD_BASE_DIR" || exit $?
100  mkdir -p "$BUILD_DIR" || exit $?  export BUILD_BASE_DIR=`rel2abs "$BUILD_BASE_DIR"`
 BUILD_BASE_DIR=`rel2abs "$BUILD_BASE_DIR"`  
 BUILD_DIR=`rel2abs "$BUILD_DIR"`  
 CONFIG_OPTIONS="--prefix=$BUILD_BASE_DIR/$BUILD_STYLE/local $CONFIG_OPTIONS"  
101    
102  if test -e "$SDKROOT"; then  if test -e "$SDKROOT"; then
103          SYSROOT_CFLAGS="-isysroot $SDKROOT"          SYSROOT_CFLAGS="-isysroot $SDKROOT"
104  else  else
105          SYSROOT_CFLAGS=          SYSROOT_CFLAGS=
106  fi  fi
107  PATH="/usr/local/bin:$PATH"  if ! expr "$arg" : ".*/usr/local/bin.*" >/dev/null; then
108            PATH=${PATH/\/usr\/bin/\/usr\/local\/bin:\/usr\/bin}
109    fi
110  ARCH_CFLAGS=""  ARCH_CFLAGS=""
111  ARCH_CONFIG_OPTIONS=""  ARCH_CONFIG_OPTIONS=""
112  case "$BUILD_STYLE" in  case "$BUILD_STYLE" in
# Line 89  case "$BUILD_STYLE" in Line 114  case "$BUILD_STYLE" in
114          ARCH="ppc"          ARCH="ppc"
115          ARCH_CFLAGS="-arch ppc"          ARCH_CFLAGS="-arch ppc"
116          ;;          ;;
117            *ppc64)
118            ARCH="ppc64"
119            ARCH_CFLAGS="-arch ppc64"
120            ARCH_CONFIG_OPTIONS="--host=ppc64-apple-darwin8"
121            if expr "$BASE_NAME" : "libsndfile" >/dev/null; then
122                    #  For shortcut endianness detection in libsndfile 1.0.17
123                    export ac_cv_c_byte_order=big
124            fi
125            ;;
126      *i386)      *i386)
127          ARCH="i386"          ARCH="i386"
128          ARCH_CFLAGS="-arch i386 -msse -msse2"          ARCH_CFLAGS="-arch i386 -msse -msse2"
129          ARCH_CONFIG_OPTIONS="--host=i386-apple-darwin8"          ARCH_CONFIG_OPTIONS="--host=i386-apple-darwin8"
130          ;;          ;;
131      *UB|*Universal)          *x86_64)
132            ARCH="x86_64"
133            ARCH_CFLAGS="-arch x86_64 -m64"
134            ARCH_CONFIG_OPTIONS="--host=x86_64-apple-darwin8"
135            ;;
136            *UB)
137          ARCH="UB"          ARCH="UB"
138            BUILD_STYLE_BASE=${BUILD_STYLE/UB/}
139            ;;
140        *Universal)
141            ARCH="UB"      
142            BUILD_STYLE_BASE=${BUILD_STYLE/Universal/}
143          ;;          ;;
144      *)      *)
145          echo "Warning: architecture cannot be recognized from the build style"          echo "Warning: architecture cannot be recognized from the build style"
# Line 112  case "$BUILD_STYLE" in Line 156  case "$BUILD_STYLE" in
156          ;;          ;;
157  esac  esac
158    
159    if test "x$ARCH" = "xUB"; then
160            for arch in $UB_ARCHS; do
161                    case $arch in
162                            ppc)
163                            ARCH_CFLAGS="$ARCH_CFLAGS -arch ppc"
164                            ;;
165                            *ppc64)
166                            ARCH_CFLAGS="$ARCH_CFLAGS -arch ppc64"
167                            ;;
168                            *i386)
169                            ARCH_CFLAGS="$ARCH_CFLAGS -arch i386 -msse -msse2"
170                            ;;
171                            *x86_64)
172                            ARCH_CFLAGS="$ARCH_CFLAGS -arch x86_64 -m64"
173                            ;;
174                    esac
175            done
176    fi
177                    
178    if test "x$ARCH" = "xUB" -a "x$ACTION" != "xclean" -a "x$UB_ONEPASS" = "x"; then
179            #  Test the existence of the products
180            for arch in $UB_ARCHS; do
181                    style=${BUILD_STYLE_BASE}${arch}
182    #       BUILD_STYLE_PPC=${BUILD_STYLE_BASE}ppc
183    #       BUILD_STYLE_386=${BUILD_STYLE_BASE}i386
184    #       for style in $BUILD_STYLE_PPC $BUILD_STYLE_386; do
185                    missing=no
186                    for i in $UB_PRODUCTS; do
187                            if ! test -e "$BUILD_BASE_DIR/$style/local/$i"; then
188                                    missing=yes
189                            fi
190                    done
191                    if test "$missing" = "yes"; then
192                            BUILD_STYLE_SAVE=$BUILD_STYLE
193                            export BUILD_STYLE=$style
194                            echo "Building with BUILD_STYLE=$style"
195                            /bin/sh $0 || exit $?
196                            BUILD_STYLE=$BUILD_STYLE_SAVE
197                    fi
198            done
199            mkdir -p "$BUILD_BASE_DIR/$BUILD_STYLE/local" || exit $?
200            cd "$BUILD_BASE_DIR"
201            for i in $UB_PRODUCTS; do
202                    archbins=""
203                    for arch in $UB_ARCHS; do
204                            archbins="$archbins $BUILD_BASE_DIR/${BUILD_STYLE_BASE}${arch}/local/$i"
205                    done
206                    mkdir -p "$BUILD_STYLE/local/"`dirname $i` || exit $?
207                    echo "Creating universal binary $BUILD_STYLE/local/$i"
208                    lipo -create $archbins -output "$BUILD_STYLE/local/$i" || exit $?
209            done
210            exit $?
211    fi
212    
213  export CFLAGS="$SYSROOT_CFLAGS $ARCH_CFLAGS $OPT_CFLAGS $CFLAGS"  export CFLAGS="$SYSROOT_CFLAGS $ARCH_CFLAGS $OPT_CFLAGS $CFLAGS"
214  export CXXFLAGS="$SYSROOT_CFLAGS $ARCH_CFLAGS $OPT_CFLAGS $CXXFLAGS"  export CXXFLAGS="$SYSROOT_CFLAGS $ARCH_CFLAGS $OPT_CFLAGS $CXXFLAGS"
215    
216    #  Move to the working directory
217    BUILD_DIR="$BUILD_BASE_DIR/$BUILD_STYLE/$BASE_NAME.build"
218    mkdir -p "$BUILD_DIR"
219    BUILD_DIR=`rel2abs "$BUILD_DIR"`
220    CONFIG_OPTIONS="--prefix=$BUILD_BASE_DIR/$BUILD_STYLE/local $CONFIG_OPTIONS"
221    
222  #  Display all environments  #  Display all environments
223  set  set
224    
 #  Move to the working directory  
225  cd $BUILD_DIR  cd $BUILD_DIR
226    
227  #  Clean if specified  #  Clean if specified
228  if test "x$ACTION" = "xclean"; then  if test "x$ACTION" = "xclean"; then
229          if test "x$WITH_INSTALL" != "x" -a -e "Makefile"; then          # if test "x$WITH_INSTALL" != "x" -a -e "Makefile"; then
230                  echo "Doing make uninstall"          #       echo "Doing make uninstall"
231                  make uninstall          #       make uninstall
232          fi          # fi
233      echo "Removing files in $BUILD_DIR"      echo "Removing files in $BUILD_DIR"
234          cd $BASE_DIR          cd $BASE_DIR
235      rm -rf "$BUILD_DIR"      rm -rf "$BUILD_DIR"
236            echo "Removing product files in $BUILD_BASE_DIR/$BUILD_STYLE/local"
237            (cd "$BUILD_BASE_DIR/$BUILD_STYLE/local"; rm -rf $UB_PRODUCTS)
238      exit $?      exit $?
239  fi  fi
240    

Legend:
Removed from v.1172  
changed lines
  Added in v.1640

  ViewVC Help
Powered by ViewVC