#!/bin/sh

VERBOSE=$1
SRCDIR=$2
OUTDIR=$3

# debuggery
[ "$VERBOSE" = "yes" ] && echo "Testing Mac 10.2 support..."

# build a test program
test -d $OUTDIR/config.tests/mac/ || mkdir -p $OUTDIR/config.tests/mac/
cd $OUTDIR/config.tests/mac
#TSTFILE=$OUTDIR/config.tests/mac/mac102.cpp
TSTFILE=mac102.cpp

rm -f $TSTFILE
echo "#include <Carbon/Carbon.h>" >$TSTFILE
echo "typedef struct OpaqueEventLoopTimerRef* EventLoopTimerRef;" >>$TSTFILE
echo "typedef struct OpaqueMenuHandle *MenuRef;" >>$TSTFILE

MAC102=no
if [ "$VERBOSE" = "yes" ]; then
    c++ -c -O2 $TSTFILE || MAC102=yes
else
    c++ -c -O2 $TSTFILE >/dev/null 2>&1 || MAC102=yes
fi

# done
if [ "$MAC102" = "yes" ]; then
    [ "$VERBOSE" = "yes" ] && echo "Mac 10.2 support enabled."
    exit 0
else
    [ "$VERBOSE" = "yes" ] && echo "Mac 10.2 support disabled."
    exit 1
fi
