Fix Mac OS X crc/dwarf2 test for non-default Xcode setup.
[qt:qt.git] / config.tests / mac / dwarf2.test
1 #!/bin/sh
2
3 DWARF2_SUPPORT=no
4 DWARF2_SUPPORT_BROKEN=no
5 COMPILER=$1
6 VERBOSE=$2
7 WORKDIR=$3
8
9 shift 3
10
11 LFLAGS=
12 CXXFLAGS=
13 while [ "$#" -gt 0 ]; do
14     case $1 in
15     -arch)
16         CXXFLAGS="$CXXFLAGS -arch $2"
17         shift
18         ;;
19     -sdk)
20         CXXFLAGS="$CXXFLAGS -isysroot $2"
21         LFLAGS="$LFLAGS -Wl,-syslibroot,$2"
22         shift
23         ;;
24     *)  ;;
25     esac
26     shift
27 done
28
29 touch dwarf2.c
30
31 if "$COMPILER" -c dwarf2.c $CXXFLAGS -Werror -gdwarf-2 2>/dev/null 1>&2; then
32     if "$COMPILER" -c dwarf2.c $CXXFLAGS -Werror -gdwarf-2  2>&1 | grep "unsupported" >/dev/null ; then
33         true
34     else
35         DWARF2_SUPPORT=yes
36     fi
37 fi
38 rm -f dwarf2.c dwarf2.o
39
40 # Test for xcode 2.4.0, which has a broken implementation of DWARF
41 "$COMPILER" $WORKDIR/xcodeversion.cpp $CXXFLAGS $LFLAGS -o xcodeversion -framework Carbon;
42 ./xcodeversion
43
44 if [ "$?" == "1" ]; then
45     DWARF2_SUPPORT_BROKEN=yes
46 fi
47
48 rm xcodeversion
49
50 # done
51 if [ "$DWARF2_SUPPORT" != "yes" ]; then
52     [ "$VERBOSE" = "yes" ] && echo "DWARF2 debug symbols disabled."
53     exit 0
54 else
55     if [ "$DWARF2_SUPPORT_BROKEN" == "yes" ]; then
56         [ "$VERBOSE" = "yes" ] && echo "DWARF2 debug symbols disabled."
57         exit 0
58     else
59         [ "$VERBOSE" = "yes" ] && echo "DWARF2 debug symbols enabled."
60         exit 1
61     fi
62 fi