| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 | #!/bin/sh## Build Universal binaries on Mac OS X, thanks Ryan!## Usage: ./configure CC="sh clang-fat.sh" && make && rm -rf arm64 x64DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"# Intel 64-bit compiler flags (10.9 runtime compatibility)CLANG_COMPILE_X64="clang -arch x86_64 -mmacosx-version-min=10.9 \-DMAC_OS_X_VERSION_MIN_REQUIRED=1070 \-I/usr/local/include"CLANG_LINK_X64="-mmacosx-version-min=10.9"# ARM 64-bit compiler flags (11.0 runtime compatibility)CLANG_COMPILE_ARM64="clang -arch arm64 -mmacosx-version-min=11.0 \-I/usr/local/include"CLANG_LINK_ARM64="-mmacosx-version-min=11.0"# Output both Intel and ARM object filesargs="$*"compile=yeslink=yeswhile test x$1 != x; do    case $1 in        --version) exec clang $1;;        -v) exec clang $1;;        -V) exec clang $1;;        -print-prog-name=*) exec clang $1;;        -print-search-dirs) exec clang $1;;        -E) CLANG_COMPILE_X64="$CLANG_COMPILE_X64 -E"            CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 -E"            compile=no; link=no;;        -c) link=no;;        -o) output=$2;;        *.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;    esac    shiftdoneif test x$link = xyes; then    CLANG_COMPILE_X64="$CLANG_COMPILE_X64 $CLANG_LINK_X64"    CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 $CLANG_LINK_ARM64"fiif test x"$output" = x; then    if test x$link = xyes; then        output=a.out    elif test x$compile = xyes; then        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o    fifi# Compile Intel 64-bitif test x"$output" != x; then    dir=x64/`dirname $output`    if test -d $dir; then        :    else        mkdir -p $dir    fifiset -- $argswhile test x$1 != x; do    if test -f "x64/$1" && test "$1" != "$output"; then        x64_args="$x64_args x64/$1"    else        x64_args="$x64_args $1"    fi    shiftdone$CLANG_COMPILE_X64 $x64_args || exit $?if test x"$output" != x; then    cp $output x64/$outputfi# Compile ARM 64-bitif test x"$output" != x; then    dir=arm64/`dirname $output`    if test -d $dir; then        :    else        mkdir -p $dir    fifiset -- $argswhile test x$1 != x; do    if test -f "arm64/$1" && test "$1" != "$output"; then        arm64_args="$arm64_args arm64/$1"    else        arm64_args="$arm64_args $1"    fi    shiftdone$CLANG_COMPILE_ARM64 $arm64_args || exit $?if test x"$output" != x; then    cp $output arm64/$outputfiif test x"$output" != x; then    lipo -create -o $output arm64/$output x64/$outputfi
 |