Dominick Meglio added ares_parse_aaaa_reply.c and did various adjustments. The
[platform/upstream/c-ares.git] / acinclude.m4
1
2 dnl We create a function for detecting which compiler we use and then set as
3 dnl pendantic compiler options as possible for that particular compiler. The
4 dnl options are only used for debug-builds.
5
6 dnl This is a copy of the original found in curl's configure script. Don't
7 dnl modify this one, edit the one in curl and copy it back here when that one
8 dnl is changed.
9
10 AC_DEFUN([CURL_CC_DEBUG_OPTS],
11 [
12     if test "$GCC" = "yes"; then
13
14        dnl figure out gcc version!
15        AC_MSG_CHECKING([gcc version])
16        gccver=`$CC -dumpversion`
17        num1=`echo $gccver | cut -d . -f1`
18        num2=`echo $gccver | cut -d . -f2`
19        gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
20        AC_MSG_RESULT($gccver)
21
22        AC_MSG_CHECKING([if this is icc in disguise])
23        AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
24          dnl action if the text is found, this it has not been replaced by the
25          dnl cpp
26          ICC="no"
27          AC_MSG_RESULT([no]),
28          dnl the text was not found, it was replaced by the cpp
29          ICC="yes"
30          AC_MSG_RESULT([yes])
31        )
32
33        if test "$ICC" = "yes"; then
34          dnl this is icc, not gcc.
35
36          dnl ICC warnings we ignore:
37          dnl * 279 warns on static conditions in while expressions
38          dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
39          dnl   "invalid format string conversion"
40
41          WARN="-wd279,269"
42
43          if test "$gccnum" -gt "600"; then
44             dnl icc 6.0 and older doesn't have the -Wall flag
45             WARN="-Wall $WARN"
46          fi
47        else dnl $ICC = yes
48          dnl 
49          WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
50
51          dnl -Wcast-align is a bit too annoying ;-)
52
53          if test "$gccnum" -ge "296"; then
54            dnl gcc 2.96 or later
55            WARN="$WARN -Wfloat-equal"
56
57            if test "$gccnum" -gt "296"; then
58              dnl this option does not exist in 2.96
59              WARN="$WARN -Wno-format-nonliteral"
60            fi
61
62            dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
63            dnl on i686-Linux as it gives us heaps with false positives
64            if test "$gccnum" -ge "303"; then
65              dnl gcc 3.3 and later
66              WARN="$WARN -Wendif-labels -Wstrict-prototypes"
67            fi
68          fi
69
70          for flag in $CPPFLAGS; do
71            case "$flag" in
72             -I*)
73               dnl include path
74               add=`echo $flag | sed 's/^-I/-isystem /g'`
75               WARN="$WARN $add"
76               ;;
77            esac
78          done
79
80        fi dnl $ICC = no
81
82        CFLAGS="$CFLAGS $WARN"
83
84     fi dnl $GCC = yes
85
86     dnl strip off optimizer flags
87     NEWFLAGS=""
88     for flag in $CFLAGS; do
89       case "$flag" in
90       -O*)
91         dnl echo "cut off $flag"
92         ;;
93       *)
94         NEWFLAGS="$NEWFLAGS $flag"
95         ;;
96       esac
97     done
98     CFLAGS=$NEWFLAGS
99
100 ]) dnl end of AC_DEFUN()
101
102
103 dnl This macro determines if the specified struct exists in the specified file
104 dnl Syntax:
105 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
106
107 AC_DEFUN([CARES_CHECK_STRUCT], [
108   AC_MSG_CHECKING([for struct $2])
109   AC_TRY_COMPILE([$1], 
110     [
111       struct $2 struct_instance;
112     ], ac_struct="yes", ac_found="no")
113   if test "$ac_struct" = "yes" ; then
114     AC_MSG_RESULT(yes)
115     $3
116   else
117     AC_MSG_RESULT(no)
118     $4
119   fi
120 ])
121
122 dnl This macro determines if the specified constant exists in the specified file
123 dnl Syntax:
124 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
125
126 AC_DEFUN([CARES_CHECK_CONSTANT], [
127   AC_MSG_CHECKING([for $2])
128   AC_TRY_RUN( 
129     [
130       $1
131
132       int main()
133       {
134         #ifdef $2
135           return 0;
136         #else
137           return 1;
138         #endif
139       }
140     ], ac_constant="yes", ac_constant="no")
141   if test "$ac_constant" = "yes" ; then
142     AC_MSG_RESULT(yes)
143     $3
144   else
145     AC_MSG_RESULT(no)
146     $4
147   fi
148 ])
149
150