#!/bin/bash

set -e

flags=()

sdk=/Developer/SDKs/MacOSX10.4u.sdk
if [[ -e $sdk ]]; then
    flags+=(-mmacosx-version-min=10.4 -isysroot "$sdk")
fi

for arch in i386 x86_64; do
    if g++ -arch "${arch}" --version &>/dev/null; then
        flags+=(-arch "${arch}")
    fi
done

set -x
g++ "${flags[@]}" -o ldid ldid.cpp -I. -x c lookup2.c sha1.c

#!/bin/bash

set -e

if which xcrun &>/dev/null; then
    flags=(xcrun -sdk macosx g++)
    flags+=(-mmacosx-version-min=10.4)

    for arch in i386 x86_64; do
        flags+=(-arch "${arch}")
    done
else
    flags=(g++)
fi

set -x
"${flags[@]}" -o ldid ldid.cpp -I. -x c lookup2.c -x c sha1.c

Fix compile using newer Xcode SDK or gcc on Linux.
Fix compile using newer Xcode SDK or gcc on Linux.
