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