geom_gate userland utility improvements
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

513 lines
14 KiB

  1. dnl **********************************************************************
  2. dnl CURL_DETECT_ICC ([ACTION-IF-YES])
  3. dnl
  4. dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
  5. dnl sets the $ICC variable to "yes" or "no"
  6. dnl **********************************************************************
  7. AC_DEFUN([CURL_DETECT_ICC],
  8. [
  9. ICC="no"
  10. AC_MSG_CHECKING([for icc in use])
  11. if test "$GCC" = "yes"; then
  12. dnl check if this is icc acting as gcc in disguise
  13. AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
  14. dnl action if the text is found, this it has not been replaced by the
  15. dnl cpp
  16. ICC="no",
  17. dnl the text was not found, it was replaced by the cpp
  18. ICC="yes"
  19. AC_MSG_RESULT([yes])
  20. [$1]
  21. )
  22. fi
  23. if test "$ICC" = "no"; then
  24. # this is not ICC
  25. AC_MSG_RESULT([no])
  26. fi
  27. ])
  28. dnl We create a function for detecting which compiler we use and then set as
  29. dnl pendantic compiler options as possible for that particular compiler. The
  30. dnl options are only used for debug-builds.
  31. AC_DEFUN([CURL_CC_DEBUG_OPTS],
  32. [
  33. if test "z$ICC" = "z"; then
  34. CURL_DETECT_ICC
  35. fi
  36. if test "$GCC" = "yes"; then
  37. dnl figure out gcc version!
  38. AC_MSG_CHECKING([gcc version])
  39. gccver=`$CC -dumpversion`
  40. num1=`echo $gccver | cut -d . -f1`
  41. num2=`echo $gccver | cut -d . -f2`
  42. gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
  43. AC_MSG_RESULT($gccver)
  44. if test "$ICC" = "yes"; then
  45. dnl this is icc, not gcc.
  46. dnl ICC warnings we ignore:
  47. dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
  48. dnl "invalid format string conversion"
  49. dnl * 279 warns on static conditions in while expressions
  50. dnl * 981 warns on "operands are evaluated in unspecified order"
  51. dnl * 1418 "external definition with no prior declaration"
  52. dnl * 1419 warns on "external declaration in primary source file"
  53. dnl which we know and do on purpose.
  54. WARN="-wd279,269,981,1418,1419"
  55. if test "$gccnum" -gt "600"; then
  56. dnl icc 6.0 and older doesn't have the -Wall flag
  57. WARN="-Wall $WARN"
  58. fi
  59. else dnl $ICC = yes
  60. dnl this is a set of options we believe *ALL* gcc versions support:
  61. WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
  62. dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
  63. if test "$gccnum" -ge "207"; then
  64. dnl gcc 2.7 or later
  65. WARN="$WARN -Wmissing-declarations"
  66. fi
  67. if test "$gccnum" -gt "295"; then
  68. dnl only if the compiler is newer than 2.95 since we got lots of
  69. dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
  70. dnl gcc 2.95.4 on FreeBSD 4.9!
  71. WARN="$WARN -Wundef -Wno-long-long -Wsign-compare"
  72. fi
  73. if test "$gccnum" -ge "296"; then
  74. dnl gcc 2.96 or later
  75. WARN="$WARN -Wfloat-equal"
  76. fi
  77. if test "$gccnum" -gt "296"; then
  78. dnl this option does not exist in 2.96
  79. WARN="$WARN -Wno-format-nonliteral"
  80. fi
  81. dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
  82. dnl on i686-Linux as it gives us heaps with false positives.
  83. dnl Also, on gcc 4.0.X it is totally unbearable and complains all
  84. dnl over making it unusable for generic purposes. Let's not use it.
  85. if test "$gccnum" -ge "303"; then
  86. dnl gcc 3.3 and later
  87. WARN="$WARN -Wendif-labels -Wstrict-prototypes"
  88. fi
  89. if test "$gccnum" -ge "304"; then
  90. # try these on gcc 3.4
  91. WARN="$WARN -Wdeclaration-after-statement"
  92. fi
  93. for flag in $CPPFLAGS; do
  94. case "$flag" in
  95. -I*)
  96. dnl Include path, provide a -isystem option for the same dir
  97. dnl to prevent warnings in those dirs. The -isystem was not very
  98. dnl reliable on earlier gcc versions.
  99. add=`echo $flag | sed 's/^-I/-isystem /g'`
  100. WARN="$WARN $add"
  101. ;;
  102. esac
  103. done
  104. fi dnl $ICC = no
  105. CFLAGS="$CFLAGS $WARN"
  106. AC_MSG_NOTICE([Added this set of compiler options: $WARN])
  107. else dnl $GCC = yes
  108. AC_MSG_NOTICE([Added no extra compiler options])
  109. fi dnl $GCC = yes
  110. dnl strip off optimizer flags
  111. NEWFLAGS=""
  112. for flag in $CFLAGS; do
  113. case "$flag" in
  114. -O*)
  115. dnl echo "cut off $flag"
  116. ;;
  117. *)
  118. NEWFLAGS="$NEWFLAGS $flag"
  119. ;;
  120. esac
  121. done
  122. CFLAGS=$NEWFLAGS
  123. ]) dnl end of AC_DEFUN()
  124. dnl CURL_CHECK_NONBLOCKING_SOCKET
  125. dnl -------------------------------------------------
  126. dnl Check for how to set a socket to non-blocking state. There seems to exist
  127. dnl four known different ways, with the one used almost everywhere being POSIX
  128. dnl and XPG3, while the other different ways for different systems (old BSD,
  129. dnl Windows and Amiga).
  130. dnl
  131. dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
  132. dnl O_NONBLOCK define is found but does not work. This condition is attempted
  133. dnl to get caught in this script by using an excessive number of #ifdefs...
  134. dnl
  135. AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
  136. [
  137. AC_MSG_CHECKING([non-blocking sockets style])
  138. AC_TRY_COMPILE([
  139. /* headers for O_NONBLOCK test */
  140. #include <sys/types.h>
  141. #include <unistd.h>
  142. #include <fcntl.h>
  143. ],[
  144. /* try to compile O_NONBLOCK */
  145. #if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
  146. # if defined(__SVR4) || defined(__srv4__)
  147. # define PLATFORM_SOLARIS
  148. # else
  149. # define PLATFORM_SUNOS4
  150. # endif
  151. #endif
  152. #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
  153. # define PLATFORM_AIX_V3
  154. #endif
  155. #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
  156. #error "O_NONBLOCK does not work on this platform"
  157. #endif
  158. int socket;
  159. int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
  160. ],[
  161. dnl the O_NONBLOCK test was fine
  162. nonblock="O_NONBLOCK"
  163. AC_DEFINE(HAVE_O_NONBLOCK, 1, [use O_NONBLOCK for non-blocking sockets])
  164. ],[
  165. dnl the code was bad, try a different program now, test 2
  166. AC_TRY_COMPILE([
  167. /* headers for FIONBIO test */
  168. #include <unistd.h>
  169. #include <stropts.h>
  170. ],[
  171. /* FIONBIO source test (old-style unix) */
  172. int socket;
  173. int flags = ioctl(socket, FIONBIO, &flags);
  174. ],[
  175. dnl FIONBIO test was good
  176. nonblock="FIONBIO"
  177. AC_DEFINE(HAVE_FIONBIO, 1, [use FIONBIO for non-blocking sockets])
  178. ],[
  179. dnl FIONBIO test was also bad
  180. dnl the code was bad, try a different program now, test 3
  181. AC_TRY_COMPILE([
  182. /* headers for ioctlsocket test (Windows) */
  183. #undef inline
  184. #ifdef HAVE_WINDOWS_H
  185. #ifndef WIN32_LEAN_AND_MEAN
  186. #define WIN32_LEAN_AND_MEAN
  187. #endif
  188. #include <windows.h>
  189. #ifdef HAVE_WINSOCK2_H
  190. #include <winsock2.h>
  191. #else
  192. #ifdef HAVE_WINSOCK_H
  193. #include <winsock.h>
  194. #endif
  195. #endif
  196. #endif
  197. ],[
  198. /* ioctlsocket source code */
  199. SOCKET sd;
  200. unsigned long flags = 0;
  201. sd = socket(0, 0, 0);
  202. ioctlsocket(sd, FIONBIO, &flags);
  203. ],[
  204. dnl ioctlsocket test was good
  205. nonblock="ioctlsocket"
  206. AC_DEFINE(HAVE_IOCTLSOCKET, 1, [use ioctlsocket() for non-blocking sockets])
  207. ],[
  208. dnl ioctlsocket didnt compile!, go to test 4
  209. AC_TRY_LINK([
  210. /* headers for IoctlSocket test (Amiga?) */
  211. #include <sys/ioctl.h>
  212. ],[
  213. /* IoctlSocket source code */
  214. int socket;
  215. int flags = IoctlSocket(socket, FIONBIO, (long)1);
  216. ],[
  217. dnl ioctlsocket test was good
  218. nonblock="IoctlSocket"
  219. AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, [use Ioctlsocket() for non-blocking sockets])
  220. ],[
  221. dnl Ioctlsocket didnt compile, do test 5!
  222. AC_TRY_COMPILE([
  223. /* headers for SO_NONBLOCK test (BeOS) */
  224. #include <socket.h>
  225. ],[
  226. /* SO_NONBLOCK source code */
  227. long b = 1;
  228. int socket;
  229. int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
  230. ],[
  231. dnl the SO_NONBLOCK test was good
  232. nonblock="SO_NONBLOCK"
  233. AC_DEFINE(HAVE_SO_NONBLOCK, 1, [use SO_NONBLOCK for non-blocking sockets])
  234. ],[
  235. dnl test 5 didnt compile!
  236. nonblock="nada"
  237. AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, [disabled non-blocking sockets])
  238. ])
  239. dnl end of fifth test
  240. ])
  241. dnl end of forth test
  242. ])
  243. dnl end of third test
  244. ])
  245. dnl end of second test
  246. ])
  247. dnl end of non-blocking try-compile test
  248. AC_MSG_RESULT($nonblock)
  249. if test "$nonblock" = "nada"; then
  250. AC_MSG_WARN([non-block sockets disabled])
  251. fi
  252. ])
  253. dnl CURL_CHECK_NEED_REENTRANT_SYSTEM
  254. dnl -------------------------------------------------
  255. dnl Checks if the preprocessor _REENTRANT definition
  256. dnl must be unconditionally done for this platform.
  257. dnl Internal macro for CURL_CONFIGURE_REENTRANT.
  258. AC_DEFUN([CURL_CHECK_NEED_REENTRANT_SYSTEM], [
  259. case $host in
  260. *-*-solaris* | *-*-hpux*)
  261. tmp_need_reentrant="yes"
  262. ;;
  263. *)
  264. tmp_need_reentrant="no"
  265. ;;
  266. esac
  267. ])
  268. dnl CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
  269. dnl -------------------------------------------------
  270. dnl This macro ensures that configuration tests done
  271. dnl after this will execute with preprocessor symbol
  272. dnl _REENTRANT defined. This macro also ensures that
  273. dnl the generated config file defines NEED_REENTRANT
  274. dnl and that in turn setup.h will define _REENTRANT.
  275. dnl Internal macro for CURL_CONFIGURE_REENTRANT.
  276. AC_DEFUN([CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT], [
  277. AC_DEFINE(NEED_REENTRANT, 1,
  278. [Define to 1 if _REENTRANT preprocessor symbol must be defined.])
  279. cat >>confdefs.h <<_EOF
  280. #ifndef _REENTRANT
  281. # define _REENTRANT
  282. #endif
  283. _EOF
  284. ])
  285. dnl CURL_CONFIGURE_REENTRANT
  286. dnl -------------------------------------------------
  287. dnl This first checks if the preprocessor _REENTRANT
  288. dnl symbol is already defined. If it isn't currently
  289. dnl defined a set of checks are performed to verify
  290. dnl if its definition is required to make visible to
  291. dnl the compiler a set of *_r functions. Finally, if
  292. dnl _REENTRANT is already defined or needed it takes
  293. dnl care of making adjustments necessary to ensure
  294. dnl that it is defined equally for further configure
  295. dnl tests and generated config file.
  296. AC_DEFUN([CURL_CONFIGURE_REENTRANT], [
  297. AC_PREREQ([2.50])dnl
  298. #
  299. AC_MSG_CHECKING([if _REENTRANT is already defined])
  300. AC_COMPILE_IFELSE([
  301. AC_LANG_PROGRAM([[
  302. ]],[[
  303. #ifdef _REENTRANT
  304. int dummy=1;
  305. #else
  306. force compilation error
  307. #endif
  308. ]])
  309. ],[
  310. AC_MSG_RESULT([yes])
  311. tmp_reentrant_initially_defined="yes"
  312. ],[
  313. AC_MSG_RESULT([no])
  314. tmp_reentrant_initially_defined="no"
  315. ])
  316. #
  317. if test "$tmp_reentrant_initially_defined" = "no"; then
  318. AC_MSG_CHECKING([if _REENTRANT is actually needed])
  319. CURL_CHECK_NEED_REENTRANT_SYSTEM
  320. if test "$tmp_need_reentrant" = "yes"; then
  321. AC_MSG_RESULT([yes])
  322. else
  323. AC_MSG_RESULT([no])
  324. fi
  325. fi
  326. #
  327. AC_MSG_CHECKING([if _REENTRANT is onwards defined])
  328. if test "$tmp_reentrant_initially_defined" = "yes" ||
  329. test "$tmp_need_reentrant" = "yes"; then
  330. CURL_CONFIGURE_FROM_NOW_ON_WITH_REENTRANT
  331. AC_MSG_RESULT([yes])
  332. else
  333. AC_MSG_RESULT([no])
  334. fi
  335. #
  336. ])
  337. dnl LIBSSH2_LIB_HAVE_LINKFLAGS
  338. dnl --------------------------
  339. dnl Wrapper around AC_LIB_HAVE_LINKFLAGS to also check $prefix/lib, if set.
  340. dnl
  341. dnl autoconf only checks $prefix/lib64 if gcc -print-search-dirs output
  342. dnl includes a directory named lib64. So, to find libraries in $prefix/lib
  343. dnl we append -L$prefix/lib to LDFLAGS before checking.
  344. dnl
  345. dnl For conveniece, $4 is expanded if [lib]$1 is found.
  346. AC_DEFUN([LIBSSH2_LIB_HAVE_LINKFLAGS], [
  347. libssh2_save_CPPFLAGS="$CPPFLAGS"
  348. libssh2_save_LDFLAGS="$LDFLAGS"
  349. if test "${with_lib$1_prefix+set}" = set; then
  350. CPPFLAGS="$CPPFLAGS${CPPFLAGS:+ }-I${with_lib$1_prefix}/include"
  351. LDFLAGS="$LDFLAGS${LDFLAGS:+ }-L${with_lib$1_prefix}/lib"
  352. fi
  353. AC_LIB_HAVE_LINKFLAGS([$1], [$2], [$3])
  354. LDFLAGS="$libssh2_save_LDFLAGS"
  355. if test "$ac_cv_lib$1" = "yes"; then :
  356. $4
  357. else
  358. CPPFLAGS="$libssh2_save_CPPFLAGS"
  359. fi
  360. ])
  361. AC_DEFUN([LIBSSH2_CHECK_CRYPTO], [
  362. if test "$use_crypto" = "auto" && test "$found_crypto" = "none" || test "$use_crypto" = "$1"; then
  363. m4_case([$1],
  364. [openssl], [
  365. LIBSSH2_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>], [
  366. AC_DEFINE(LIBSSH2_OPENSSL, 1, [Use $1])
  367. LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }libssl libcrypto"
  368. # Not all OpenSSL have AES-CTR functions.
  369. libssh2_save_LIBS="$LIBS"
  370. LIBS="$LIBS $LIBSSL"
  371. AC_CHECK_FUNCS(EVP_aes_128_ctr)
  372. LIBS="$libssh2_save_LIBS"
  373. found_crypto="$1"
  374. found_crypto_str="OpenSSL (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A})"
  375. ])
  376. ],
  377. [libgcrypt], [
  378. LIBSSH2_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>], [
  379. AC_DEFINE(LIBSSH2_LIBGCRYPT, 1, [Use $1])
  380. found_crypto="$1"
  381. ])
  382. ],
  383. [mbedtls], [
  384. LIBSSH2_LIB_HAVE_LINKFLAGS([mbedcrypto], [], [#include <mbedtls/version.h>], [
  385. AC_DEFINE(LIBSSH2_MBEDTLS, 1, [Use $1])
  386. LIBS="$LIBS -lmbedcrypto"
  387. found_crypto="$1"
  388. support_clear_memory=yes
  389. ])
  390. ],
  391. [wincng], [
  392. # Look for Windows Cryptography API: Next Generation
  393. AC_CHECK_HEADERS([ntdef.h ntstatus.h], [], [], [#include <windows.h>])
  394. AC_CHECK_DECLS([SecureZeroMemory], [], [], [#include <windows.h>])
  395. LIBSSH2_LIB_HAVE_LINKFLAGS([crypt32], [], [
  396. #include <windows.h>
  397. #include <wincrypt.h>
  398. ])
  399. LIBSSH2_LIB_HAVE_LINKFLAGS([bcrypt], [], [
  400. #include <windows.h>
  401. #include <bcrypt.h>
  402. ], [
  403. AC_DEFINE(LIBSSH2_WINCNG, 1, [Use $1])
  404. found_crypto="$1"
  405. found_crypto_str="Windows Cryptography API: Next Generation"
  406. support_clear_memory="$ac_cv_have_decl_SecureZeroMemory"
  407. ])
  408. ],
  409. )
  410. test "$found_crypto" = "none" &&
  411. crypto_errors="${crypto_errors}No $1 crypto library found!
  412. "
  413. fi
  414. ])
  415. dnl LIBSSH2_CHECK_OPTION_WERROR
  416. dnl -------------------------------------------------
  417. dnl Verify if configure has been invoked with option
  418. dnl --enable-werror or --disable-werror, and set
  419. dnl shell variable want_werror as appropriate.
  420. AC_DEFUN([LIBSSH2_CHECK_OPTION_WERROR], [
  421. AC_BEFORE([$0],[LIBSSH2_CHECK_COMPILER])dnl
  422. AC_MSG_CHECKING([whether to enable compiler warnings as errors])
  423. OPT_COMPILER_WERROR="default"
  424. AC_ARG_ENABLE(werror,
  425. AC_HELP_STRING([--enable-werror],[Enable compiler warnings as errors])
  426. AC_HELP_STRING([--disable-werror],[Disable compiler warnings as errors]),
  427. OPT_COMPILER_WERROR=$enableval)
  428. case "$OPT_COMPILER_WERROR" in
  429. no)
  430. dnl --disable-werror option used
  431. want_werror="no"
  432. ;;
  433. default)
  434. dnl configure option not specified
  435. want_werror="no"
  436. ;;
  437. *)
  438. dnl --enable-werror option used
  439. want_werror="yes"
  440. ;;
  441. esac
  442. AC_MSG_RESULT([$want_werror])
  443. if test X"$want_werror" = Xyes; then
  444. CFLAGS="$CFLAGS -Werror"
  445. fi
  446. ])