The standard fat gcc scripts work well with SDL 2.0
authorSam Lantinga <slouken@libsdl.org>
Sat, 01 Jun 2013 12:53:06 -0700
changeset 7255ea30c1b99365
parent 7251 8c5e575a1315
child 7256 9cad21f6fa4e
The standard fat gcc scripts work well with SDL 2.0
build-scripts/fatbuild.sh
build-scripts/g++-fat.sh
build-scripts/gcc-fat.sh
     1.1 --- a/build-scripts/fatbuild.sh	Sat Jun 01 08:57:17 2013 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,294 +0,0 @@
     1.4 -#!/bin/sh
     1.5 -#
     1.6 -# Build a fat binary on Mac OS X, thanks Ryan!
     1.7 -
     1.8 -# Number of CPUs (for make -j)
     1.9 -NCPU=`sysctl -n hw.ncpu`
    1.10 -if test x$NJOB = x; then
    1.11 -    NJOB=$NCPU
    1.12 -fi
    1.13 -
    1.14 -# Generic, cross-platform CFLAGS you always want go here.
    1.15 -CFLAGS="-O3 -g -pipe"
    1.16 -
    1.17 -# We dynamically load X11, so using the system X11 headers is fine.
    1.18 -BASE_CONFIG_FLAGS="--build=`uname -p`-apple-darwin \
    1.19 ---x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
    1.20 -
    1.21 -# PowerPC 32-bit compiler flags
    1.22 -CONFIG_PPC="--host=powerpc-apple-darwin"
    1.23 -CC_PPC="gcc-4.0"
    1.24 -CXX_PPC="g++-4.0"
    1.25 -BUILD_FLAGS_PPC="-arch ppc -mmacosx-version-min=10.4"
    1.26 -
    1.27 -# Intel 32-bit compiler flags
    1.28 -CONFIG_X86="--host=i386-apple-darwin"
    1.29 -CC_X86="gcc"
    1.30 -CXX_X86="g++"
    1.31 -BUILD_FLAGS_X86="-arch i386 -mmacosx-version-min=10.4"
    1.32 -
    1.33 -# Intel 64-bit compiler flags
    1.34 -CONFIG_X64="--host=x86_64-apple-darwin"
    1.35 -CC_X64="gcc"
    1.36 -CXX_X64="g++"
    1.37 -BUILD_FLAGS_X64="-arch x86_64 -mmacosx-version-min=10.6"
    1.38 -
    1.39 -#
    1.40 -# Find the configure script
    1.41 -#
    1.42 -srcdir=`dirname $0`/..
    1.43 -srcdir=`cd $srcdir && pwd`
    1.44 -auxdir=$srcdir/build-scripts
    1.45 -cd $srcdir
    1.46 -
    1.47 -allow_ppc="yes"
    1.48 -which gcc-4.0 >/dev/null 2>/dev/null
    1.49 -if [ "x$?" = "x1" ]; then
    1.50 -    #echo "WARNING: Can't find gcc-4.0, which means you don't have Xcode 3."
    1.51 -    #echo "WARNING: Therefore, we can't do PowerPC support."
    1.52 -    allow_ppc="no"
    1.53 -fi
    1.54 -
    1.55 -#
    1.56 -# Figure out which phase to build:
    1.57 -# all,
    1.58 -# configure, configure-ppc, configure-x86, configure-x64
    1.59 -# make, make-ppc, make-x86, make-x64, merge
    1.60 -# install
    1.61 -# clean
    1.62 -if test x"$1" = x; then
    1.63 -    phase=all
    1.64 -else
    1.65 -    phase="$1"
    1.66 -fi
    1.67 -case $phase in
    1.68 -    all)
    1.69 -        configure_ppc="$allow_ppc"
    1.70 -        configure_x86="yes"
    1.71 -        configure_x64="yes"
    1.72 -        make_ppc="$allow_ppc"
    1.73 -        make_x86="yes"
    1.74 -        make_x64="yes"
    1.75 -        merge="yes"
    1.76 -        ;;
    1.77 -    configure)
    1.78 -        configure_ppc="$allow_ppc"
    1.79 -        configure_x86="yes"
    1.80 -        configure_x64="yes"
    1.81 -        ;;
    1.82 -    configure-ppc)
    1.83 -        configure_ppc="$allow_ppc"
    1.84 -        ;;
    1.85 -    configure-x86)
    1.86 -        configure_x86="yes"
    1.87 -        ;;
    1.88 -    configure-x64)
    1.89 -        configure_x64="yes"
    1.90 -        ;;
    1.91 -    make)
    1.92 -        make_ppc="$allow_ppc"
    1.93 -        make_x86="yes"
    1.94 -        make_x64="yes"
    1.95 -        merge="yes"
    1.96 -        ;;
    1.97 -    make-ppc)
    1.98 -        make_ppc="$allow_ppc"
    1.99 -        ;;
   1.100 -    make-x86)
   1.101 -        make_x86="yes"
   1.102 -        ;;
   1.103 -    make-x64)
   1.104 -        make_x64="yes"
   1.105 -        ;;
   1.106 -    merge)
   1.107 -        merge="yes"
   1.108 -        ;;
   1.109 -    install)
   1.110 -        install_bin="yes"
   1.111 -        install_hdrs="yes"
   1.112 -        install_lib="yes"
   1.113 -        install_data="yes"
   1.114 -        ;;
   1.115 -    install-bin)
   1.116 -        install_bin="yes"
   1.117 -        ;;
   1.118 -    install-hdrs)
   1.119 -        install_hdrs="yes"
   1.120 -        ;;
   1.121 -    install-lib)
   1.122 -        install_lib="yes"
   1.123 -        ;;
   1.124 -    install-data)
   1.125 -        install_data="yes"
   1.126 -        ;;
   1.127 -    clean)
   1.128 -        clean_ppc="yes"
   1.129 -        clean_x86="yes"
   1.130 -        clean_x64="yes"
   1.131 -        ;;
   1.132 -    clean-ppc)
   1.133 -        clean_ppc="yes"
   1.134 -        ;;
   1.135 -    clean-x86)
   1.136 -        clean_x86="yes"
   1.137 -        ;;
   1.138 -    clean-x64)
   1.139 -        clean_x64="yes"
   1.140 -        ;;
   1.141 -    *)
   1.142 -        echo "Usage: $0 [all|configure[-ppc|-x86|-x64]|make[-ppc|-x86|-x64]|merge|install|clean[-ppc|-x86|-x64]]"
   1.143 -        exit 1
   1.144 -        ;;
   1.145 -esac
   1.146 -case `uname -p` in
   1.147 -    *86)
   1.148 -        native_path=x86
   1.149 -        ;;
   1.150 -    *powerpc)
   1.151 -        native_path=ppc
   1.152 -        ;;
   1.153 -    x86_64)
   1.154 -        native_path=x64
   1.155 -        ;;
   1.156 -    *)
   1.157 -        echo "Couldn't figure out native architecture path"
   1.158 -        exit 1
   1.159 -        ;;
   1.160 -esac
   1.161 -
   1.162 -#
   1.163 -# Create the build directories
   1.164 -#
   1.165 -for dir in build build/ppc build/x86 build/x64; do
   1.166 -    if test -d $dir; then
   1.167 -        :
   1.168 -    else
   1.169 -        mkdir $dir || exit 1
   1.170 -    fi
   1.171 -done
   1.172 -
   1.173 -
   1.174 -#
   1.175 -# Build the PowerPC 32-bit binary
   1.176 -#
   1.177 -if test x$configure_ppc = xyes; then
   1.178 -    (cd build/ppc && \
   1.179 -     sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_PPC CC="$CC_PPC" CXX="$CXX_PPC" CFLAGS="$CFLAGS $BUILD_FLAGS_PPC $CFLAGS_PPC" LDFLAGS="$BUILD_FLAGS_PPC $LFLAGS_PPC") || exit 2
   1.180 -fi
   1.181 -if test x$make_ppc = xyes; then
   1.182 -    (cd build/ppc && make -j$NJOB) || exit 3
   1.183 -fi
   1.184 -#
   1.185 -# Build the Intel 32-bit binary
   1.186 -#
   1.187 -if test x$configure_x86 = xyes; then
   1.188 -    (cd build/x86 && \
   1.189 -     sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_X86 CC="$CC_X86" CXX="$CXX_X86" CFLAGS="$CFLAGS $BUILD_FLAGS_X86 $CFLAGS_X86" LDFLAGS="$BUILD_FLAGS_X86 $LFLAGS_X86") || exit 2
   1.190 -fi
   1.191 -if test x$make_x86 = xyes; then
   1.192 -    (cd build/x86 && make -j$NJOB) || exit 3
   1.193 -fi
   1.194 -
   1.195 -#
   1.196 -# Build the Intel 64-bit binary
   1.197 -#
   1.198 -if test x$configure_x64 = xyes; then
   1.199 -    (cd build/x64 && \
   1.200 -     sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_X64 CC="$CC_X64" CXX="$CXX_X64" CFLAGS="$CFLAGS $BUILD_FLAGS_X64 $CFLAGS_X64" LDFLAGS="$BUILD_FLAGS_X64 $LFLAGS_X64") || exit 2
   1.201 -fi
   1.202 -if test x$make_x64 = xyes; then
   1.203 -    (cd build/x64 && make -j$NJOB) || exit 3
   1.204 -fi
   1.205 -
   1.206 -#
   1.207 -# Combine into fat binary
   1.208 -#
   1.209 -if test x$merge = xyes; then
   1.210 -    output=.libs
   1.211 -    sh $auxdir/mkinstalldirs build/$output
   1.212 -    cd build
   1.213 -    target=`find . -mindepth 4 -maxdepth 4 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
   1.214 -    (lipo -create -o $output/$target `find . -mindepth 4 -maxdepth 4 -type f -name "*.dylib"` &&
   1.215 -     ln -sf $target $output/libSDL2.dylib &&
   1.216 -     lipo -create -o $output/libSDL2.a */build/.libs/libSDL2.a &&
   1.217 -     cp $native_path/build/.libs/libSDL2.la $output &&
   1.218 -     cp $native_path/build/.libs/libSDL2.lai $output &&
   1.219 -     cp $native_path/build/libSDL2.la . &&
   1.220 -     lipo -create -o libSDL2main.a */build/libSDL2main.a &&
   1.221 -     lipo -create -o libSDL2_test.a */build/libSDL2_test.a &&
   1.222 -     echo "Build complete!" &&
   1.223 -     echo "Files can be found in the build directory.") || exit 4
   1.224 -    cd ..
   1.225 -fi
   1.226 -
   1.227 -#
   1.228 -# Install
   1.229 -#
   1.230 -do_install()
   1.231 -{
   1.232 -    echo $*
   1.233 -    $* || exit 5
   1.234 -}
   1.235 -if test x$prefix = x; then
   1.236 -    prefix=/usr/local
   1.237 -fi
   1.238 -if test x$exec_prefix = x; then
   1.239 -    exec_prefix=$prefix
   1.240 -fi
   1.241 -if test x$bindir = x; then
   1.242 -    bindir=$exec_prefix/bin
   1.243 -fi
   1.244 -if test x$libdir = x; then
   1.245 -    libdir=$exec_prefix/lib
   1.246 -fi
   1.247 -if test x$includedir = x; then
   1.248 -    includedir=$prefix/include
   1.249 -fi
   1.250 -if test x$datadir = x; then
   1.251 -    datadir=$prefix/share
   1.252 -fi
   1.253 -if test x$mandir = x; then
   1.254 -    mandir=$prefix/man
   1.255 -fi
   1.256 -if test x$install_bin = xyes; then
   1.257 -    do_install sh $auxdir/mkinstalldirs $bindir
   1.258 -    do_install /usr/bin/install -c -m 755 build/$native_path/sdl2-config $bindir/sdl2-config
   1.259 -fi
   1.260 -if test x$install_hdrs = xyes; then
   1.261 -    do_install sh $auxdir/mkinstalldirs $includedir/SDL2
   1.262 -    for src in $srcdir/include/*.h; do \
   1.263 -        file=`echo $src | sed -e 's|^.*/||'`; \
   1.264 -        do_install /usr/bin/install -c -m 644 $src $includedir/SDL2/$file; \
   1.265 -    done
   1.266 -    do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL2/SDL_config.h
   1.267 -fi
   1.268 -if test x$install_lib = xyes; then
   1.269 -    do_install sh $auxdir/mkinstalldirs $libdir
   1.270 -    do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c  build/libSDL2.la $libdir/libSDL2.la
   1.271 -    do_install /usr/bin/install -c -m 644 build/libSDL2main.a $libdir/libSDL2main.a
   1.272 -    do_install ranlib $libdir/libSDL2main.a
   1.273 -    do_install /usr/bin/install -c -m 644 build/libSDL2_test.a $libdir/libSDL2_test.a
   1.274 -    do_install ranlib $libdir/libSDL2_test.a
   1.275 -fi
   1.276 -if test x$install_data = xyes; then
   1.277 -    do_install sh $auxdir/mkinstalldirs $datadir/aclocal
   1.278 -    do_install /usr/bin/install -c -m 644 $srcdir/sdl2.m4 $datadir/aclocal/sdl2.m4
   1.279 -fi
   1.280 -
   1.281 -#
   1.282 -# Clean up
   1.283 -#
   1.284 -do_clean()
   1.285 -{
   1.286 -    echo $*
   1.287 -    $* || exit 6
   1.288 -}
   1.289 -if test x$clean_ppc = xyes; then
   1.290 -    do_clean rm -r build/ppc
   1.291 -fi
   1.292 -if test x$clean_x86 = xyes; then
   1.293 -    do_clean rm -r build/x86
   1.294 -fi
   1.295 -if test x$clean_x64 = xyes; then
   1.296 -    do_clean rm -r build/x64
   1.297 -fi
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/build-scripts/g++-fat.sh	Sat Jun 01 12:53:06 2013 -0700
     2.3 @@ -0,0 +1,103 @@
     2.4 +#!/bin/sh
     2.5 +#
     2.6 +# Build Universal binaries on Mac OS X, thanks Ryan!
     2.7 +#
     2.8 +# Usage: ./configure CXX="sh g++-fat.sh" && make && rm -rf x86 x64
     2.9 +
    2.10 +DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
    2.11 +
    2.12 +# Intel 32-bit compiler flags (10.6 runtime compatibility)
    2.13 +GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.6 \
    2.14 +-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
    2.15 +-I/usr/local/include"
    2.16 +
    2.17 +GCC_LINK_X86="-mmacosx-version-min=10.6"
    2.18 +
    2.19 +# Intel 64-bit compiler flags (10.6 runtime compatibility)
    2.20 +GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
    2.21 +-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \
    2.22 +-I/usr/local/include"
    2.23 +
    2.24 +GCC_LINK_X64="-mmacosx-version-min=10.6"
    2.25 +
    2.26 +# Output both PowerPC and Intel object files
    2.27 +args="$*"
    2.28 +compile=yes
    2.29 +link=yes
    2.30 +while test x$1 != x; do
    2.31 +    case $1 in
    2.32 +        --version) exec g++ $1;;
    2.33 +        -v) exec g++ $1;;
    2.34 +        -V) exec g++ $1;;
    2.35 +        -print-prog-name=*) exec g++ $1;;
    2.36 +        -print-search-dirs) exec g++ $1;;
    2.37 +        -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
    2.38 +            GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
    2.39 +            compile=no; link=no;;
    2.40 +        -c) link=no;;
    2.41 +        -o) output=$2;;
    2.42 +        *.c|*.cc|*.cpp|*.S) source=$1;;
    2.43 +    esac
    2.44 +    shift
    2.45 +done
    2.46 +if test x$link = xyes; then
    2.47 +    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
    2.48 +    GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
    2.49 +fi
    2.50 +if test x"$output" = x; then
    2.51 +    if test x$link = xyes; then
    2.52 +        output=a.out
    2.53 +    elif test x$compile = xyes; then
    2.54 +        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
    2.55 +    fi
    2.56 +fi
    2.57 +
    2.58 +# Compile X86 32-bit
    2.59 +if test x"$output" != x; then
    2.60 +    dir=x86/`dirname $output`
    2.61 +    if test -d $dir; then
    2.62 +        :
    2.63 +    else
    2.64 +        mkdir -p $dir
    2.65 +    fi
    2.66 +fi
    2.67 +set -- $args
    2.68 +while test x$1 != x; do
    2.69 +    if test -f "x86/$1" && test "$1" != "$output"; then
    2.70 +        x86_args="$x86_args x86/$1"
    2.71 +    else
    2.72 +        x86_args="$x86_args $1"
    2.73 +    fi
    2.74 +    shift
    2.75 +done
    2.76 +$GCC_COMPILE_X86 $x86_args || exit $?
    2.77 +if test x"$output" != x; then
    2.78 +    cp $output x86/$output
    2.79 +fi
    2.80 +
    2.81 +# Compile X86 32-bit
    2.82 +if test x"$output" != x; then
    2.83 +    dir=x64/`dirname $output`
    2.84 +    if test -d $dir; then
    2.85 +        :
    2.86 +    else
    2.87 +        mkdir -p $dir
    2.88 +    fi
    2.89 +fi
    2.90 +set -- $args
    2.91 +while test x$1 != x; do
    2.92 +    if test -f "x64/$1" && test "$1" != "$output"; then
    2.93 +        x64_args="$x64_args x64/$1"
    2.94 +    else
    2.95 +        x64_args="$x64_args $1"
    2.96 +    fi
    2.97 +    shift
    2.98 +done
    2.99 +$GCC_COMPILE_X64 $x64_args || exit $?
   2.100 +if test x"$output" != x; then
   2.101 +    cp $output x64/$output
   2.102 +fi
   2.103 +
   2.104 +if test x"$output" != x; then
   2.105 +    lipo -create -o $output x86/$output x64/$output
   2.106 +fi
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/build-scripts/gcc-fat.sh	Sat Jun 01 12:53:06 2013 -0700
     3.3 @@ -0,0 +1,103 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# Build Universal binaries on Mac OS X, thanks Ryan!
     3.7 +#
     3.8 +# Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf x86 x64
     3.9 +
    3.10 +DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
    3.11 +
    3.12 +# Intel 32-bit compiler flags (10.6 runtime compatibility)
    3.13 +GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.6 \
    3.14 +-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
    3.15 +-I/usr/local/include"
    3.16 +
    3.17 +GCC_LINK_X86="-mmacosx-version-min=10.6"
    3.18 +
    3.19 +# Intel 64-bit compiler flags (10.6 runtime compatibility)
    3.20 +GCC_COMPILE_X64="gcc -arch x86_64 -mmacosx-version-min=10.6 \
    3.21 +-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \
    3.22 +-I/usr/local/include"
    3.23 +
    3.24 +GCC_LINK_X64="-mmacosx-version-min=10.6"
    3.25 +
    3.26 +# Output both PowerPC and Intel object files
    3.27 +args="$*"
    3.28 +compile=yes
    3.29 +link=yes
    3.30 +while test x$1 != x; do
    3.31 +    case $1 in
    3.32 +        --version) exec gcc $1;;
    3.33 +        -v) exec gcc $1;;
    3.34 +        -V) exec gcc $1;;
    3.35 +        -print-prog-name=*) exec gcc $1;;
    3.36 +        -print-search-dirs) exec gcc $1;;
    3.37 +        -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
    3.38 +            GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
    3.39 +            compile=no; link=no;;
    3.40 +        -c) link=no;;
    3.41 +        -o) output=$2;;
    3.42 +        *.c|*.cc|*.cpp|*.S) source=$1;;
    3.43 +    esac
    3.44 +    shift
    3.45 +done
    3.46 +if test x$link = xyes; then
    3.47 +    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
    3.48 +    GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
    3.49 +fi
    3.50 +if test x"$output" = x; then
    3.51 +    if test x$link = xyes; then
    3.52 +        output=a.out
    3.53 +    elif test x$compile = xyes; then
    3.54 +        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
    3.55 +    fi
    3.56 +fi
    3.57 +
    3.58 +# Compile X86 32-bit
    3.59 +if test x"$output" != x; then
    3.60 +    dir=x86/`dirname $output`
    3.61 +    if test -d $dir; then
    3.62 +        :
    3.63 +    else
    3.64 +        mkdir -p $dir
    3.65 +    fi
    3.66 +fi
    3.67 +set -- $args
    3.68 +while test x$1 != x; do
    3.69 +    if test -f "x86/$1" && test "$1" != "$output"; then
    3.70 +        x86_args="$x86_args x86/$1"
    3.71 +    else
    3.72 +        x86_args="$x86_args $1"
    3.73 +    fi
    3.74 +    shift
    3.75 +done
    3.76 +$GCC_COMPILE_X86 $x86_args || exit $?
    3.77 +if test x"$output" != x; then
    3.78 +    cp $output x86/$output
    3.79 +fi
    3.80 +
    3.81 +# Compile X86 32-bit
    3.82 +if test x"$output" != x; then
    3.83 +    dir=x64/`dirname $output`
    3.84 +    if test -d $dir; then
    3.85 +        :
    3.86 +    else
    3.87 +        mkdir -p $dir
    3.88 +    fi
    3.89 +fi
    3.90 +set -- $args
    3.91 +while test x$1 != x; do
    3.92 +    if test -f "x64/$1" && test "$1" != "$output"; then
    3.93 +        x64_args="$x64_args x64/$1"
    3.94 +    else
    3.95 +        x64_args="$x64_args $1"
    3.96 +    fi
    3.97 +    shift
    3.98 +done
    3.99 +$GCC_COMPILE_X64 $x64_args || exit $?
   3.100 +if test x"$output" != x; then
   3.101 +    cp $output x64/$output
   3.102 +fi
   3.103 +
   3.104 +if test x"$output" != x; then
   3.105 +    lipo -create -o $output x86/$output x64/$output
   3.106 +fi