acinclude.m4 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. dnl Check for how to set a socket to non-blocking state. There seems to exist
  2. dnl four known different ways, with the one used almost everywhere being POSIX
  3. dnl and XPG3, while the other different ways for different systems (old BSD,
  4. dnl Windows and Amiga).
  5. dnl
  6. dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
  7. dnl O_NONBLOCK define is found but does not work. This condition is attempted
  8. dnl to get caught in this script by using an excessive number of #ifdefs...
  9. dnl
  10. AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
  11. [
  12. AC_MSG_CHECKING([non-blocking sockets style])
  13. AC_TRY_COMPILE([
  14. /* headers for O_NONBLOCK test */
  15. #include <sys/types.h>
  16. #include <unistd.h>
  17. #include <fcntl.h>
  18. ],[
  19. /* try to compile O_NONBLOCK */
  20. #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
  21. # if defined(__SVR4) || defined(__srv4__)
  22. # define PLATFORM_SOLARIS
  23. # else
  24. # define PLATFORM_SUNOS4
  25. # endif
  26. #endif
  27. #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
  28. # define PLATFORM_AIX_V3
  29. #endif
  30. #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
  31. #error "O_NONBLOCK does not work on this platform"
  32. #endif
  33. int socket;
  34. int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
  35. ],[
  36. dnl the O_NONBLOCK test was fine
  37. nonblock="O_NONBLOCK"
  38. AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
  39. ],[
  40. dnl the code was bad, try a different program now, test 2
  41. AC_TRY_COMPILE([
  42. /* headers for FIONBIO test */
  43. #include <unistd.h>
  44. #include <stropts.h>
  45. ],[
  46. /* FIONBIO source test (old-style unix) */
  47. int socket;
  48. int flags = ioctl(socket, FIONBIO, &flags);
  49. ],[
  50. dnl FIONBIO test was good
  51. nonblock="FIONBIO"
  52. AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
  53. ],[
  54. dnl FIONBIO test was also bad
  55. dnl the code was bad, try a different program now, test 3
  56. AC_TRY_COMPILE([
  57. /* headers for ioctlsocket test (cygwin?) */
  58. #include <windows.h>
  59. ],[
  60. /* ioctlsocket source code */
  61. int socket;
  62. int flags = ioctlsocket(socket, FIONBIO, &flags);
  63. ],[
  64. dnl ioctlsocket test was good
  65. nonblock="ioctlsocket"
  66. AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
  67. ],[
  68. dnl ioctlsocket didnt compile!, go to test 4
  69. AC_TRY_LINK([
  70. /* headers for IoctlSocket test (Amiga?) */
  71. #include <sys/ioctl.h>
  72. ],[
  73. /* IoctlSocket source code */
  74. int socket;
  75. int flags = IoctlSocket(socket, FIONBIO, (long)1);
  76. ],[
  77. dnl ioctlsocket test was good
  78. nonblock="IoctlSocket"
  79. AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
  80. ],[
  81. dnl Ioctlsocket didnt compile, do test 5!
  82. AC_TRY_COMPILE([
  83. /* headers for SO_NONBLOCK test (BeOS) */
  84. #include <sys/types.h>
  85. #include <unistd.h>
  86. #include <fcntl.h>
  87. ],[
  88. /* SO_NONBLOCK source code */
  89. long b = 1;
  90. int socket;
  91. int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
  92. ],[
  93. dnl the SO_NONBLOCK test was good
  94. nonblock="SO_NONBLOCK"
  95. AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
  96. ],[
  97. dnl test 5 didnt compile!
  98. nonblock="nada"
  99. AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
  100. ])
  101. dnl end of fifth test
  102. ])
  103. dnl end of forth test
  104. ])
  105. dnl end of third test
  106. ])
  107. dnl end of second test
  108. ])
  109. dnl end of non-blocking try-compile test
  110. AC_MSG_RESULT($nonblock)
  111. if test "$nonblock" = "nada"; then
  112. AC_MSG_WARN([non-block sockets disabled])
  113. fi
  114. ])
  115. dnl Check for socklen_t: historically on BSD it is an int, and in
  116. dnl POSIX 1g it is a type of its own, but some platforms use different
  117. dnl types for the argument to getsockopt, getpeername, etc. So we
  118. dnl have to test to find something that will work.
  119. AC_DEFUN([TYPE_SOCKLEN_T],
  120. [
  121. AC_CHECK_TYPE([socklen_t], ,[
  122. AC_MSG_CHECKING([for socklen_t equivalent])
  123. AC_CACHE_VAL([curl_cv_socklen_t_equiv],
  124. [
  125. # Systems have either "struct sockaddr *" or
  126. # "void *" as the second argument to getpeername
  127. curl_cv_socklen_t_equiv=
  128. for arg2 in "struct sockaddr" void; do
  129. for t in int size_t unsigned long "unsigned long"; do
  130. AC_TRY_COMPILE([
  131. #ifdef HAVE_SYS_TYPES_H
  132. #include <sys/types.h>
  133. #endif
  134. #ifdef HAVE_SYS_SOCKET_H
  135. #include <sys/socket.h>
  136. #endif
  137. int getpeername (int, $arg2 *, $t *);
  138. ],[
  139. $t len;
  140. getpeername(0,0,&len);
  141. ],[
  142. curl_cv_socklen_t_equiv="$t"
  143. break
  144. ])
  145. done
  146. done
  147. if test "x$curl_cv_socklen_t_equiv" = x; then
  148. AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
  149. fi
  150. ])
  151. AC_MSG_RESULT($curl_cv_socklen_t_equiv)
  152. AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
  153. [type to use in place of socklen_t if not defined])],
  154. [#include <sys/types.h>
  155. #include <sys/socket.h>])
  156. ])
  157. dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
  158. dnl and a few other things. If not found, we set it to unsigned int, as even
  159. dnl 64-bit implementations use to set it to a 32-bit type.
  160. AC_DEFUN([TYPE_IN_ADDR_T],
  161. [
  162. AC_CHECK_TYPE([in_addr_t], ,[
  163. AC_MSG_CHECKING([for in_addr_t equivalent])
  164. AC_CACHE_VAL([curl_cv_in_addr_t_equiv],
  165. [
  166. curl_cv_in_addr_t_equiv=
  167. for t in "unsigned long" int size_t unsigned long; do
  168. AC_TRY_COMPILE([
  169. #ifdef HAVE_SYS_TYPES_H
  170. #include <sys/types.h>
  171. #endif
  172. #ifdef HAVE_SYS_SOCKET_H
  173. #include <sys/socket.h>
  174. #endif
  175. #ifdef HAVE_ARPA_INET_H
  176. #include <arpa/inet.h>
  177. #endif
  178. ],[
  179. $t data = inet_addr ("1.2.3.4");
  180. ],[
  181. curl_cv_in_addr_t_equiv="$t"
  182. break
  183. ])
  184. done
  185. if test "x$curl_cv_in_addr_t_equiv" = x; then
  186. AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
  187. fi
  188. ])
  189. AC_MSG_RESULT($curl_cv_in_addr_t_equiv)
  190. AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
  191. [type to use in place of in_addr_t if not defined])],
  192. [#include <sys/types.h>
  193. #include <sys/socket.h>
  194. #include <arpa/inet.h>])
  195. ])
  196. dnl ************************************************************
  197. dnl check for "localhost", if it doesn't exist, we can't do the
  198. dnl gethostbyname_r tests!
  199. dnl
  200. AC_DEFUN([CURL_CHECK_WORKING_RESOLVER],[
  201. AC_MSG_CHECKING([if "localhost" resolves])
  202. AC_TRY_RUN([
  203. #include <string.h>
  204. #include <sys/types.h>
  205. #include <netdb.h>
  206. int
  207. main () {
  208. struct hostent *h;
  209. h = gethostbyname("localhost");
  210. exit (h == NULL ? 1 : 0); }],[
  211. AC_MSG_RESULT(yes)],[
  212. AC_MSG_RESULT(no)
  213. AC_MSG_ERROR([can't figure out gethostbyname_r() since localhost doesn't resolve])
  214. ]
  215. )
  216. ])
  217. dnl ************************************************************
  218. dnl check for working getaddrinfo()
  219. dnl
  220. AC_DEFUN([CURL_CHECK_WORKING_GETADDRINFO],[
  221. AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
  222. AC_TRY_RUN( [
  223. #include <netdb.h>
  224. #include <sys/types.h>
  225. #include <sys/socket.h>
  226. void main(void) {
  227. struct addrinfo hints, *ai;
  228. int error;
  229. memset(&hints, 0, sizeof(hints));
  230. hints.ai_family = AF_UNSPEC;
  231. hints.ai_socktype = SOCK_STREAM;
  232. error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
  233. if (error) {
  234. exit(1);
  235. }
  236. else {
  237. exit(0);
  238. }
  239. }
  240. ],[
  241. ac_cv_working_getaddrinfo="yes"
  242. ],[
  243. ac_cv_working_getaddrinfo="no"
  244. ],[
  245. ac_cv_working_getaddrinfo="yes"
  246. ])])
  247. if test "$ac_cv_working_getaddrinfo" = "yes"; then
  248. AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works])
  249. AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support])
  250. IPV6_ENABLED=1
  251. AC_SUBST(IPV6_ENABLED)
  252. fi
  253. ])
  254. AC_DEFUN([CURL_CHECK_LOCALTIME_R],
  255. [
  256. dnl check for a few thread-safe functions
  257. AC_CHECK_FUNCS(localtime_r,[
  258. AC_MSG_CHECKING(whether localtime_r is declared)
  259. AC_EGREP_CPP(localtime_r,[
  260. #include <time.h>],[
  261. AC_MSG_RESULT(yes)],[
  262. AC_MSG_RESULT(no)
  263. AC_MSG_CHECKING(whether localtime_r with -D_REENTRANT is declared)
  264. AC_EGREP_CPP(localtime_r,[
  265. #define _REENTRANT
  266. #include <time.h>],[
  267. AC_DEFINE(NEED_REENTRANT)
  268. AC_MSG_RESULT(yes)],
  269. AC_MSG_RESULT(no))])])
  270. ])
  271. AC_DEFUN([CURL_CHECK_INET_NTOA_R],
  272. [
  273. dnl determine if function definition for inet_ntoa_r exists.
  274. AC_CHECK_FUNCS(inet_ntoa_r,[
  275. AC_MSG_CHECKING(whether inet_ntoa_r is declared)
  276. AC_EGREP_CPP(inet_ntoa_r,[
  277. #include <arpa/inet.h>],[
  278. AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
  279. AC_MSG_RESULT(yes)],[
  280. AC_MSG_RESULT(no)
  281. AC_MSG_CHECKING(whether inet_ntoa_r with -D_REENTRANT is declared)
  282. AC_EGREP_CPP(inet_ntoa_r,[
  283. #define _REENTRANT
  284. #include <arpa/inet.h>],[
  285. AC_DEFINE(HAVE_INET_NTOA_R_DECL, 1, [inet_ntoa_r() is declared])
  286. AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT defined])
  287. AC_MSG_RESULT(yes)],
  288. AC_MSG_RESULT(no))])])
  289. ])
  290. AC_DEFUN([CURL_CHECK_GETHOSTBYADDR_R],
  291. [
  292. dnl check for number of arguments to gethostbyaddr_r. it might take
  293. dnl either 5, 7, or 8 arguments.
  294. AC_CHECK_FUNCS(gethostbyaddr_r,[
  295. AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
  296. AC_TRY_COMPILE([
  297. #include <sys/types.h>
  298. #include <netdb.h>],[
  299. char * address;
  300. int length;
  301. int type;
  302. struct hostent h;
  303. struct hostent_data hdata;
  304. int rc;
  305. rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
  306. AC_MSG_RESULT(yes)
  307. AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
  308. ac_cv_gethostbyaddr_args=5],[
  309. AC_MSG_RESULT(no)
  310. AC_MSG_CHECKING(if gethostbyaddr_r with -D_REENTRANT takes 5 arguments)
  311. AC_TRY_COMPILE([
  312. #define _REENTRANT
  313. #include <sys/types.h>
  314. #include <netdb.h>],[
  315. char * address;
  316. int length;
  317. int type;
  318. struct hostent h;
  319. struct hostent_data hdata;
  320. int rc;
  321. rc = gethostbyaddr_r(address, length, type, &h, &hdata);],[
  322. AC_MSG_RESULT(yes)
  323. AC_DEFINE(HAVE_GETHOSTBYADDR_R_5, 1, [gethostbyaddr_r() takes 5 args])
  324. AC_DEFINE(NEED_REENTRANT, 1, [need REENTRANT])
  325. ac_cv_gethostbyaddr_args=5],[
  326. AC_MSG_RESULT(no)
  327. AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
  328. AC_TRY_COMPILE([
  329. #include <sys/types.h>
  330. #include <netdb.h>],[
  331. char * address;
  332. int length;
  333. int type;
  334. struct hostent h;
  335. char buffer[8192];
  336. int h_errnop;
  337. struct hostent * hp;
  338. hp = gethostbyaddr_r(address, length, type, &h,
  339. buffer, 8192, &h_errnop);],[
  340. AC_MSG_RESULT(yes)
  341. AC_DEFINE(HAVE_GETHOSTBYADDR_R_7, 1, [gethostbyaddr_r() takes 7 args] )
  342. ac_cv_gethostbyaddr_args=7],[
  343. AC_MSG_RESULT(no)
  344. AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments)
  345. AC_TRY_COMPILE([
  346. #include <sys/types.h>
  347. #include <netdb.h>],[
  348. char * address;
  349. int length;
  350. int type;
  351. struct hostent h;
  352. char buffer[8192];
  353. int h_errnop;
  354. struct hostent * hp;
  355. int rc;
  356. rc = gethostbyaddr_r(address, length, type, &h,
  357. buffer, 8192, &hp, &h_errnop);],[
  358. AC_MSG_RESULT(yes)
  359. AC_DEFINE(HAVE_GETHOSTBYADDR_R_8, 1, [gethostbyaddr_r() takes 8 args])
  360. ac_cv_gethostbyaddr_args=8],[
  361. AC_MSG_RESULT(no)
  362. have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"])])])])])
  363. ])
  364. AC_DEFUN([CURL_CHECK_GETHOSTBYNAME_R],
  365. [
  366. dnl check for number of arguments to gethostbyname_r. it might take
  367. dnl either 3, 5, or 6 arguments.
  368. AC_CHECK_FUNCS(gethostbyname_r,[
  369. AC_MSG_CHECKING([if gethostbyname_r takes 3 arguments])
  370. AC_TRY_COMPILE([
  371. #include <string.h>
  372. #include <sys/types.h>
  373. #include <netdb.h>
  374. #undef NULL
  375. #define NULL (void *)0
  376. int
  377. gethostbyname_r(const char *, struct hostent *, struct hostent_data *);],[
  378. struct hostent_data data;
  379. gethostbyname_r(NULL, NULL, NULL);],[
  380. AC_MSG_RESULT(yes)
  381. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
  382. ac_cv_gethostbyname_args=3],[
  383. AC_MSG_RESULT(no)
  384. AC_MSG_CHECKING([if gethostbyname_r with -D_REENTRANT takes 3 arguments])
  385. AC_TRY_COMPILE([
  386. #define _REENTRANT
  387. #include <string.h>
  388. #include <sys/types.h>
  389. #include <netdb.h>
  390. #undef NULL
  391. #define NULL (void *)0
  392. int
  393. gethostbyname_r(const char *,struct hostent *, struct hostent_data *);],[
  394. struct hostent_data data;
  395. gethostbyname_r(NULL, NULL, NULL);],[
  396. AC_MSG_RESULT(yes)
  397. AC_DEFINE(HAVE_GETHOSTBYNAME_R_3, 1, [gethostbyname_r() takes 3 args])
  398. AC_DEFINE(NEED_REENTRANT, 1, [needs REENTRANT])
  399. ac_cv_gethostbyname_args=3],[
  400. AC_MSG_RESULT(no)
  401. AC_MSG_CHECKING([if gethostbyname_r takes 5 arguments])
  402. AC_TRY_COMPILE([
  403. #include <sys/types.h>
  404. #include <netdb.h>
  405. #undef NULL
  406. #define NULL (void *)0
  407. struct hostent *
  408. gethostbyname_r(const char *, struct hostent *, char *, int, int *);],[
  409. gethostbyname_r(NULL, NULL, NULL, 0, NULL);],[
  410. AC_MSG_RESULT(yes)
  411. AC_DEFINE(HAVE_GETHOSTBYNAME_R_5, 1, [gethostbyname_r() takes 5 args])
  412. ac_cv_gethostbyname_args=5],[
  413. AC_MSG_RESULT(no)
  414. AC_MSG_CHECKING([if gethostbyname_r takes 6 arguments])
  415. AC_TRY_COMPILE([
  416. #include <sys/types.h>
  417. #include <netdb.h>
  418. #undef NULL
  419. #define NULL (void *)0
  420. int
  421. gethostbyname_r(const char *, struct hostent *, char *, size_t,
  422. struct hostent **, int *);],[
  423. gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);],[
  424. AC_MSG_RESULT(yes)
  425. AC_DEFINE(HAVE_GETHOSTBYNAME_R_6, 1, [gethostbyname_r() takes 6 args])
  426. ac_cv_gethostbyname_args=6],[
  427. AC_MSG_RESULT(no)
  428. have_missing_r_funcs="$have_missing_r_funcs gethostbyname_r"],
  429. [ac_cv_gethostbyname_args=0])],
  430. [ac_cv_gethostbyname_args=0])],
  431. [ac_cv_gethostbyname_args=0])],
  432. [ac_cv_gethostbyname_args=0])])
  433. if test "$ac_cv_func_gethostbyname_r" = "yes"; then
  434. if test "$ac_cv_gethostbyname_args" = "0"; then
  435. dnl there's a gethostbyname_r() function, but we don't know how
  436. dnl many arguments it wants!
  437. AC_MSG_ERROR([couldn't figure out how to use gethostbyname_r()])
  438. fi
  439. fi
  440. ])
  441. dnl We create a function for detecting which compiler we use and then set as
  442. dnl pendantic compiler options as possible for that particular compiler. The
  443. dnl options are only used for debug-builds.
  444. AC_DEFUN([CURL_CC_DEBUG_OPTS],
  445. [
  446. if test "$GCC" = "yes"; then
  447. dnl figure out gcc version!
  448. AC_MSG_CHECKING([gcc version])
  449. gccver=`$CC -dumpversion`
  450. num1=`echo $gccver | cut -d . -f1`
  451. num2=`echo $gccver | cut -d . -f2`
  452. gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
  453. AC_MSG_RESULT($gccver)
  454. AC_MSG_CHECKING([if this is icc in disguise])
  455. AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
  456. dnl action if the text is found, this it has not been replaced by the
  457. dnl cpp
  458. ICC="no"
  459. AC_MSG_RESULT([no]),
  460. dnl the text was not found, it was replaced by the cpp
  461. ICC="yes"
  462. AC_MSG_RESULT([yes])
  463. )
  464. if test "$ICC" = "yes"; then
  465. dnl this is icc, not gcc.
  466. dnl ICC warnings we ignore:
  467. dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
  468. dnl "invalid format string conversion"
  469. dnl * 279 warns on static conditions in while expressions
  470. dnl * 981 warns on "operands are evaluated in unspecified order"
  471. dnl * 1419 warns on "external declaration in primary source file"
  472. dnl which we know and do on purpose.
  473. WARN="-wd279,269,1419,981"
  474. if test "$gccnum" -gt "600"; then
  475. dnl icc 6.0 and older doesn't have the -Wall flag
  476. WARN="-Wall $WARN"
  477. fi
  478. else dnl $ICC = yes
  479. dnl this is a set of options we believe *ALL* gcc versions support:
  480. WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
  481. dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
  482. if test "$gccnum" -gt "295"; then
  483. dnl only if the compiler is newer than 2.95 since we got lots of
  484. dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
  485. dnl gcc 2.95.4 on FreeBSD 4.9!
  486. WARN="$WARN -Wundef"
  487. fi
  488. if test "$gccnum" -ge "296"; then
  489. dnl gcc 2.96 or later
  490. WARN="$WARN -Wfloat-equal"
  491. fi
  492. if test "$gccnum" -gt "296"; then
  493. dnl this option does not exist in 2.96
  494. WARN="$WARN -Wno-format-nonliteral"
  495. fi
  496. dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
  497. dnl on i686-Linux as it gives us heaps with false positives
  498. if test "$gccnum" -ge "303"; then
  499. dnl gcc 3.3 and later
  500. WARN="$WARN -Wendif-labels -Wstrict-prototypes"
  501. fi
  502. for flag in $CPPFLAGS; do
  503. case "$flag" in
  504. -I*)
  505. dnl Include path, provide a -isystem option for the same dir
  506. dnl to prevent warnings in those dirs. The -isystem was not very
  507. dnl reliable on earlier gcc versions.
  508. add=`echo $flag | sed 's/^-I/-isystem /g'`
  509. WARN="$WARN $add"
  510. ;;
  511. esac
  512. done
  513. fi dnl $ICC = no
  514. CFLAGS="$CFLAGS $WARN"
  515. AC_MSG_NOTICE([Added this set of compiler options: $WARN])
  516. else dnl $GCC = yes
  517. AC_MSG_NOTICE([Added no extra compiler options])
  518. fi dnl $GCC = yes
  519. dnl strip off optimizer flags
  520. NEWFLAGS=""
  521. for flag in $CFLAGS; do
  522. case "$flag" in
  523. -O*)
  524. dnl echo "cut off $flag"
  525. ;;
  526. *)
  527. NEWFLAGS="$NEWFLAGS $flag"
  528. ;;
  529. esac
  530. done
  531. CFLAGS=$NEWFLAGS
  532. ]) dnl end of AC_DEFUN()