ntp_libntp.m4 revision 1.1.1.2
1dnl ###################################################################### 2dnl Common m4sh code for libntp and clients 3dnl 4dnl Any configure tests which libntp or libisc code depends upon should 5dnl be here or in another m4 macro used by the top-level and sntp 6dnl configure.ac files, so that libntp can be moved into the sntp 7dnl subpackage while retaining access to such test results. 8dnl 9AC_DEFUN([NTP_LIBNTP], [ 10 11AC_REQUIRE([NTP_CROSSCOMPILE]) 12 13# HMS: Save $LIBS and empty it. 14# any LIBS we add here should go in to LDADD_LIBNTP 15AC_SUBST([LDADD_LIBNTP]) 16__LIBS=$LIBS 17LIBS= 18 19dnl The contents of NTP_PROG_CC used to be here... 20 21AC_PROG_INSTALL 22# [Bug 2332] because we need to know if we are using GNU ld... 23LT_PATH_LD 24 25NTP_DIR_SEP 26NTP_LINEEDITLIBS 27NTP_LIB_M 28 29AC_FUNC_FORK 30AC_FUNC_ALLOCA 31AC_FUNC_STRERROR_R 32 33ac_busted_vpath_in_make=no 34case "$build" in 35 *-*-irix6.1*) # 64 bit only 36 # busted vpath? 37 ;; 38 *-*-irix6*) # 6.2 (and later?) 39 ac_busted_vpath_in_make=yes 40 ;; 41 *-*-solaris2.5.1) 42 ac_busted_vpath_in_make=yes 43 ;; 44 *-*-unicosmp*) 45 ac_busted_vpath_in_make=yes 46 ;; 47esac 48 49case "$ac_busted_vpath_in_make$srcdir" in 50 yes.|no*) 51 ;; 52 *) case "`${MAKE-make} -v -f /dev/null 2>/dev/null | grep 'GNU Make'`" in 53 '') 54 AC_MSG_ERROR([building outside of the main directory requires GNU make]) 55 esac 56 ;; 57esac 58 59case "$host" in 60 *-*-aix4*) 61 # Bug 2516: 62 # Was *-*-aix[[4-9]]* 63 # XXX only verified thru AIX6. But... 64 # Ken Link says this is fine for AIX 5.3 and 7.1, and sees no reason 65 # that this support would be in 5.3, removed in 6, and added back. 66 # 67 # (prr) aix 4.1 doesn't have clock_settime, but in aix 4.3 it's a stub 68 # (returning ENOSYS). I didn't check 4.2. If, in the future, 69 # IBM pulls its thumbs out long enough to implement clock_settime, 70 # this conditional will need to change. Maybe use AC_TRY_RUN 71 # instead to try to set the time to itself and check errno. 72 ;; 73 *) 74 HMS_SEARCH_LIBS([LDADD_LIBNTP], [clock_gettime], [rt]) 75 AC_CHECK_FUNCS([clock_getres clock_gettime clock_settime]) 76 ;; 77esac 78 79AC_CHECK_FUNCS([getclock stime timegm strlcpy strlcat]) 80 81dnl HP-UX 11.31 on HPPA has a net/if.h that can't be compiled with gcc4 82dnl due to an incomplete type (a union) mpinfou used in an array. gcc3 83dnl compiles it without complaint. The mpinfou union is defined later 84dnl in the resulting preprocessed source than the spu_info array in 85dnl /usr/include/machine/sys/getppdp.h: 86dnl extern union mpinfou spu_info[]; 87dnl triggering the error. Our strategy is on HP-UX only, test compile 88dnl net/if.h. If that fails, try adding a duplicate definition of 89dnl mpinfou, and if that helps add it to confdefs.h (used for further 90dnl configure tests) and config.h. 91# 92AC_CHECK_HEADERS([errno.h sys/socket.h sys/types.h time.h]) 93AC_CHECK_HEADERS([net/if.h], [], [], [ 94 #ifdef HAVE_SYS_SOCKET_H 95 # include <sys/socket.h> 96 #endif 97]) 98case "$host" in 99 *-hp-hpux*) 100 AC_CACHE_CHECK( 101 [if net/if.h requires mpinfou predeclaration], 102 [ntp_cv_predecl_mpinfou], 103 [ 104 np_cv_predecl_mpinfou=no 105 case "$ac_cv_header_net_if_h" in 106 no) 107 AC_COMPILE_IFELSE( 108 [AC_LANG_PROGRAM( 109 [[ 110 typedef union mpinfou { 111 struct pdk_mpinfo *pdkptr; 112 struct mpinfo *pikptr; 113 } mpinfou_t; 114 #ifdef HAVE_SYS_SOCKET_H 115 # include <sys/socket.h> 116 #endif 117 #include <net/if.h> 118 ]], 119 [[ 120 ]] 121 )], 122 [ 123 ntp_cv_predecl_mpinfou=yes 124 ac_cv_header_net_if_h=yes 125 ] 126 ) 127 esac 128 ] 129 ) 130 case "$ntp_cv_predecl_mpinfou" in 131 yes) 132 cat >>confdefs.h <<_ACEOF 133#ifndef MPINFOU_PREDECLARED 134# define MPINFOU_PREDECLARED 135typedef union mpinfou { 136 struct pdk_mpinfo *pdkptr; 137 struct mpinfo *pikptr; 138} mpinfou_t; 139#endif 140_ACEOF 141 AH_BOTTOM([ 142#ifndef MPINFOU_PREDECLARED 143# define MPINFOU_PREDECLARED 144typedef union mpinfou { 145 struct pdk_mpinfo *pdkptr; 146 struct mpinfo *pikptr; 147} mpinfou_t; 148#endif 149]) 150 esac 151esac 152 153case "$host" in 154 *-linux*) 155 AC_CHECK_HEADERS([linux/if_addr.h], [], [], [ 156 #ifdef HAVE_SYS_SOCKET_H 157 # include <sys/socket.h> 158 #endif 159 ]) 160esac 161 162AC_CHECK_HEADERS([arpa/nameser.h sys/param.h sys/time.h sys/timers.h]) 163# sys/sysctl.h depends on sys/param.h on OpenBSD - Bug 1576 164AC_CHECK_HEADERS([sys/sysctl.h], [], [], [ 165 #if defined HAVE_SYS_PARAM_H 166 # include <sys/param.h> 167 #endif 168]) 169AC_CHECK_HEADERS([netinet/in_system.h netinet/in_systm.h netinet/in.h]) 170 171AC_CHECK_HEADERS([resolv.h], [], [], [ 172 #ifdef HAVE_SYS_TYPES_H 173 # include <sys/types.h> 174 #endif 175 #ifdef HAVE_NETINET_IN_H 176 # include <netinet/in.h> 177 #endif 178 #ifdef HAVE_ARPA_NAMESER_H 179 # include <arpa/nameser.h> 180 #endif 181]) 182 183AC_CHECK_HEADERS([net/if_var.h], [], [], [ 184 #if HAVE_SYS_TYPES_H 185 # include <sys/types.h> 186 #endif 187 #ifdef HAVE_SYS_SOCKET_H 188 # include <sys/socket.h> 189 #endif 190 #ifdef HAVE_NETINET_IN_H 191 # include <netinet/in.h> 192 #endif 193 #ifdef HAVE_NET_IF_H 194 # include <net/if.h> 195 #endif 196]) 197 198AC_CHECK_HEADERS([netinet/ip.h netinet/in_var.h], [], [], [ 199 #ifdef HAVE_SYS_TYPES_H 200 # include <sys/types.h> 201 #endif 202 #ifdef HAVE_SYS_SOCKET_H 203 # include <sys/socket.h> 204 #endif 205 #ifdef HAVE_NET_IF_H 206 # include <net/if.h> 207 #endif 208 #ifdef HAVE_NETINET_IN_H 209 # include <netinet/in.h> 210 #endif 211 #ifdef HAVE_NET_IF_VAR_H 212 # include <net/if_var.h> 213 #endif 214 #ifdef HAVE_NETINET_IN_SYSTM_H 215 # include <netinet/in_systm.h> 216 #endif 217]) 218 219# HMS: Do we need to check for -lsocket before or after these tests? 220HMS_SEARCH_LIBS([LDADD_LIBNTP], [inet_pton], [nsl]) 221HMS_SEARCH_LIBS([LDADD_LIBNTP], [inet_ntop], [resolv], , , [-lnsl]) 222 223# [Bug 1628] On Solaris, we need -lxnet -lsocket. Generalize this to 224# avoid keying on the OS name: If we find socket functions in 225# libsocket, next try for them in libxnet without libsocket, if found, 226# list both. If we simply tested libxnet first, we would find the 227# functions there and never add libsocket. See also [Bug 660] 228# http://bugs.ntp.org/show_bug.cgi?id=660#c9 229saved_LIBS=$LIBS 230HMS_SEARCH_LIBS([LDADD_LIBNTP], [setsockopt], [socket]) 231case "$ac_cv_search_setsockopt" in 232 -lsocket) 233 LIBS="$saved_LIBS" 234 HMS_SEARCH_LIBS([LDADD_LIBNTP], [getsockopt], [xnet]) 235 # XXX Possible trouble here - reading the comments above and looking at the 236 # code below I wonder if we'll add -lxnet when we don't need it. 237 # Also, do we need to add -lxnet to LDADD_LIBNTP, or perhaps see if it's 238 # there when it is not needed? 239 case "$ac_cv_search_getsockopt" in 240 -lxnet) 241 LIBS="-lxnet -lsocket $saved_LIBS" 242 ;; 243 *) LIBS="-lsocket $saved_LIBS" 244 ;; 245 esac 246 ;; 247esac 248AS_UNSET([saved_LIBS]) 249 250# Bug 2427 - look for recvmsg here. 251AC_CHECK_FUNCS([recvmsg]) 252 253AC_C_INLINE 254 255case "$ac_cv_c_inline" in 256 '') 257 ;; 258 *) 259 AC_DEFINE([HAVE_INLINE], [1], [inline keyword or macro available]) 260 AC_SUBST([HAVE_INLINE]) 261esac 262 263AC_HEADER_TIME 264AC_CHECK_SIZEOF([time_t]) 265AC_C_CHAR_UNSIGNED dnl CROSS_COMPILE? 266AC_CHECK_SIZEOF([signed char]) 267AC_CHECK_TYPES([s_char, long long]) 268AC_CHECK_SIZEOF([short]) 269AC_CHECK_SIZEOF([int]) 270AC_CHECK_SIZEOF([long]) 271 272case "$ac_cv_type_long_long" in 273 no) 274 ;; 275 *) 276 AC_CHECK_SIZEOF([long long]) 277 ;; 278esac 279 280case "$ac_cv_c_char_unsigned$ac_cv_sizeof_signed_char$ac_cv_type_s_char" in 281 *yes) 282 # We have a typedef for s_char. Might as well believe it... 283 ;; 284 no0no) 285 # We have signed chars, can't say 'signed char', no s_char typedef. 286 AC_DEFINE([NEED_S_CHAR_TYPEDEF], [1], 287 [Do we need an s_char typedef?]) 288 ;; 289 no1no) 290 # We have signed chars, can say 'signed char', no s_char typedef. 291 AC_DEFINE([NEED_S_CHAR_TYPEDEF], [1], 292 [Do we need an s_char typedef?]) 293 ;; 294 yes0no) 295 # We have unsigned chars, can't say 'signed char', no s_char typedef. 296 AC_MSG_ERROR([No way to specify a signed character!]) 297 ;; 298 yes1no) 299 # We have unsigned chars, can say 'signed char', no s_char typedef. 300 AC_DEFINE([NEED_S_CHAR_TYPEDEF], [1], 301 [Do we need an s_char typedef?]) 302 ;; 303esac 304 305AC_TYPE_UID_T 306 307m4_divert_text([HELP_ENABLE], 308[AS_HELP_STRING([defaults:], 309 [+ yes, - no, s system-specific])]) 310 311NTP_DEBUG 312 313# check if we can compile with pthreads 314AC_CHECK_HEADERS([semaphore.h]) 315AC_CHECK_FUNCS([socketpair]) 316AC_ARG_ENABLE( 317 [thread-support], 318 [AS_HELP_STRING([--enable-thread-support], 319 [s use threads (+ if available)])], 320 [], 321 [enable_thread_support=yes] 322 ) 323have_pthreads=no 324case "$enable_thread_support" in 325 yes) 326 ol_found_pthreads=no 327 OL_THREAD_CHECK([ol_found_pthreads=yes]) 328 case "$ol_found_pthreads" in 329 yes) 330 saved_LIBS="$LIBS" 331 LIBS="$LTHREAD_LIBS $LIBS" 332 saved_CFLAGS="$CFLAGS" 333 CFLAGS="$PTHREAD_CFLAGS $CFLAGS" 334 AC_CHECK_FUNCS([sem_timedwait]) 335 LIBS="$saved_LIBS" 336 AS_UNSET([saved_LIBS]) 337 CFLAGS="$saved_CFLAGS" 338 AS_UNSET([saved_CFLAGS]) 339 case "$ac_cv_func_sem_timedwait" in 340 yes) 341 PTHREAD_LIBS="$LTHREAD_LIBS" 342 have_pthreads=yes 343 # Bug 2332: With GCC we need to force a reference to libgcc_s 344 # (if libgcc_s exists) or the combination of 345 # threads + setuid + mlockall does not work on linux because 346 # thread cancellation fails to load libgcc_s with dlopen(). 347 # We have to pass this all as linker options to avoid argument 348 # reordering by libtool. 349 case "$GCC$with_gnu_ld" in 350 yesyes) 351 AC_CHECK_LIB([gcc_s], [exit], 352 [PTHREAD_LIBS="$LTHREAD_LIBS -Wl,--no-as-needed,-lgcc_s,--as-needed"]) 353 ;; 354 esac 355 esac 356 esac 357esac 358AC_SUBST([PTHREAD_LIBS]) 359case "$have_pthreads" in 360 yes) 361 CFLAGS_NTP="$CFLAGS_NTP $PTHREAD_CFLAGS" 362 saved_LIBS="$LIBS" 363 LIBS="$LTHREAD_LIBS $LIBS" 364 saved_CFLAGS="$CFLAGS" 365 CFLAGS="$PTHREAD_CFLAGS $CFLAGS" 366 AC_CHECK_SIZEOF( 367 [pthread_t], 368 , 369 [ 370 AC_INCLUDES_DEFAULT() 371 #include <pthread.h> 372 ] 373 ) 374 LIBISC_PTHREADS_NOTHREADS=pthreads 375 AC_DEFINE([ISC_PLATFORM_USETHREADS], [1], 376 [enable libisc thread support?]) 377 # 378 # We'd like to use sigwait() too 379 # 380 AC_CHECK_FUNC( 381 [sigwait], 382 [have_sigwait=yes], 383 [AC_CHECK_LIB( 384 [c], 385 [sigwait], 386 [have_sigwait=yes], 387 [AC_CHECK_LIB( 388 [pthread], 389 [sigwait], 390 [have_sigwait=yes], 391 [AC_CHECK_LIB( 392 [pthread], 393 [_Psigwait], 394 [have_sigwait=yes], 395 [have_sigwait=no] 396 )] 397 )] 398 )] 399 ) 400 case "$host:$have_sigwait" in 401 *-freebsd*:no) 402 AC_CHECK_LIB( 403 [c_r], 404 [sigwait], 405 [have_sigwait=yes] 406 ) 407 esac 408 case "$have_sigwait" in 409 yes) 410 ac_cv_func_sigwait=yes 411 AC_DEFINE([HAVE_SIGWAIT], [1], [sigwait() available?]) 412 esac 413 414 AC_CHECK_FUNCS([pthread_attr_getstacksize]) 415 AC_CHECK_FUNCS([pthread_attr_setstacksize sysconf]) 416 417 case "$host" in 418 *-freebsd5.[[012]]|*-freebsd5.[[012]].*) 419 ;; 420 *-freebsd5.[[3456789]]|*-freebsd5.[[3456789]].*|*-freebsd6.*) 421 AC_DEFINE([NEED_PTHREAD_SCOPE_SYSTEM], [1], 422 [use PTHREAD_SCOPE_SYSTEM?]) 423 ;; 424 *-bsdi3.*|*-bsdi4.0*) 425 AC_DEFINE([NEED_PTHREAD_INIT], [1], [pthread_init() required?]) 426 ;; 427 *-linux*) 428 AC_DEFINE([HAVE_LINUXTHREADS], [1], [using Linux pthread?]) 429 ;; 430 *-solaris*) 431 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS], [1]) 432 AC_CHECK_FUNCS([pthread_setconcurrency]) 433 case "$ac_cv_func_pthread_setconcurrency" in 434 yes) 435 AC_DEFINE([CALL_PTHREAD_SETCONCURRENCY], [1], 436 [why not HAVE_P_S?]) 437 esac 438 ;; 439 *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*) 440 AC_DEFINE([HAVE_UNIXWARE_SIGWAIT], [1], [deviant sigwait?]) 441 ;; 442 esac 443 hack_shutup_pthreadonceinit=no 444 case "$host" in 445 *-aix5.[[123]].*) 446 hack_shutup_pthreadonceinit=yes 447 ;; 448 *-solaris2.[[89]]) 449 hack_shutup_pthreadonceinit=yes 450 ;; 451 *-solaris2.1[[0-9]]) 452 AC_CACHE_CHECK( 453 [if extra braces are needed for PTHREAD_ONCE_INIT], 454 [ntp_cv_braces_around_pthread_once_init], 455 [AC_COMPILE_IFELSE( 456 [AC_LANG_PROGRAM( 457 [[ 458 #include <pthread.h> 459 ]], 460 [[ 461 static pthread_once_t once_test = 462 PTHREAD_ONCE_INIT; 463 ]] 464 )], 465 [ntp_cv_braces_around_pthread_once_init=no], 466 [ntp_cv_braces_around_pthread_once_init=yes] 467 )] 468 ) 469 case "$ntp_cv_braces_around_pthread_once_init" in 470 yes) 471 hack_shutup_pthreadonceinit=yes 472 esac 473 ;; 474 esac 475 case "$hack_shutup_pthreadonceinit" in 476 yes) 477 AC_DEFINE([ISC_PLATFORM_BRACEPTHREADONCEINIT], [1], 478 [Enclose PTHREAD_ONCE_INIT in extra braces?]) 479 esac 480 LIBS="$saved_LIBS" 481 AS_UNSET([saved_LIBS]) 482 CFLAGS="$saved_CFLAGS" 483 AS_UNSET([saved_CFLAGS]) 484 ;; 485 *) 486 LIBISC_PTHREADS_NOTHREADS=nothreads 487 ;; 488esac 489AC_SUBST([LIBISC_PTHREADS_NOTHREADS]) 490AM_CONDITIONAL([PTHREADS], [test "$have_pthreads" != "no"]) 491 492AC_DEFUN([NTP_BEFORE_HW_FUNC_VSNPRINTF], [ 493 AC_BEFORE([$0], [HW_FUNC_VSNPRINTF])dnl 494 AC_BEFORE([$0], [HW_FUNC_SNPRINTF])dnl 495 AC_ARG_ENABLE( 496 [c99-snprintf], 497 [AS_HELP_STRING([--enable-c99-snprintf], [s force replacement])], 498 [force_c99_snprintf=$enableval], 499 [force_c99_snprintf=no] 500 ) 501 case "$force_c99_snprintf" in 502 yes) 503 hw_force_rpl_snprintf=yes 504 hw_force_rpl_vsnprintf=yes 505 esac 506 AH_VERBATIM( 507 [snprinte],dnl sorted in config.h just before #define snprintf 508 [ 509 #if !defined(_KERNEL) && !defined(PARSESTREAM) 510 /* 511 * stdio.h must be included after _GNU_SOURCE is defined 512 * but before #define snprintf rpl_snprintf 513 */ 514 # include <stdio.h> 515 #endif 516 ]) 517 AH_BOTTOM([ 518 #if !defined(_KERNEL) && !defined(PARSESTREAM) 519 # if defined(HW_WANT_RPL_VSNPRINTF) 520 # if defined(__cplusplus) 521 extern "C" { 522 # endif 523 # include <stdarg.h> 524 int rpl_vsnprintf(char *, size_t, const char *, va_list); 525 # if defined(__cplusplus) 526 } 527 # endif 528 # endif 529 # if defined(HW_WANT_RPL_SNPRINTF) 530 # if defined(__cplusplus) 531 extern "C" { 532 # endif 533 int rpl_snprintf(char *, size_t, const char *, ...); 534 # if defined(__cplusplus) 535 } 536 # endif 537 # endif 538 #endif /* !defined(_KERNEL) && !defined(PARSESTREAM) */ 539 ]) 540]) dnl end of AC_DEFUN of NTP_BEFORE_HW_FUNC_VSNPRINTF 541 542AC_DEFUN([NTP_C99_SNPRINTF], [ 543 AC_REQUIRE([NTP_BEFORE_HW_FUNC_VSNPRINTF])dnl 544 AC_REQUIRE([HW_FUNC_VSNPRINTF])dnl 545 AC_REQUIRE([HW_FUNC_SNPRINTF])dnl 546]) dnl end of DEFUN of NTP_C99_SNPRINTF 547 548NTP_C99_SNPRINTF 549 550dnl C99-snprintf does not handle %m 551case "$hw_use_rpl_vsnprintf:$hw_cv_func_vsnprintf" in 552 no:yes) 553 AC_CACHE_CHECK( 554 [if vsnprintf expands "%m" to strerror(errno)], 555 [ntp_cv_vsnprintf_percent_m], 556 [AC_RUN_IFELSE( 557 [AC_LANG_PROGRAM( 558 [[ 559 #include <stdarg.h> 560 #include <errno.h> 561 #include <stdio.h> 562 #include <string.h> 563 564 int call_vsnprintf( 565 char * dst, 566 size_t sz, 567 const char *fmt, 568 ... 569 ); 570 571 int call_vsnprintf( 572 char * dst, 573 size_t sz, 574 const char *fmt, 575 ... 576 ) 577 { 578 va_list ap; 579 int rc; 580 581 va_start(ap, fmt); 582 rc = vsnprintf(dst, sz, fmt, ap); 583 va_end(ap); 584 585 return rc; 586 } 587 ]], 588 [[ 589 char sbuf[512]; 590 char pbuf[512]; 591 int slen; 592 593 strcpy(sbuf, strerror(ENOENT)); 594 errno = ENOENT; 595 slen = call_vsnprintf(pbuf, sizeof(pbuf), "%m", 596 "wrong"); 597 return strcmp(sbuf, pbuf); 598 ]] 599 )], 600 [ntp_cv_vsnprintf_percent_m=yes], 601 [ntp_cv_vsnprintf_percent_m=no], 602 [ntp_cv_vsnprintf_percent_m=no] 603 )] 604 ) 605 case "$ntp_cv_vsnprintf_percent_m" in 606 yes) 607 AC_DEFINE([VSNPRINTF_PERCENT_M], [1], 608 [vsnprintf expands "%m" to strerror(errno)]) 609 esac 610esac 611 612AC_CHECK_HEADERS([sys/clockctl.h]) 613 614AC_ARG_ENABLE( 615 [clockctl], 616 [AS_HELP_STRING( 617 [--enable-clockctl], 618 [s Use /dev/clockctl for non-root clock control] 619 )], 620 [ntp_use_dev_clockctl=$enableval], 621 [ntp_use_dev_clockctl=$ac_cv_header_sys_clockctl_h] 622) 623 624AC_MSG_CHECKING([if we should use /dev/clockctl]) 625AC_MSG_RESULT([$ntp_use_dev_clockctl]) 626 627 628AC_CHECK_HEADERS([sys/capability.h sys/prctl.h]) 629 630AC_MSG_CHECKING([if we have linux capabilities (libcap)]) 631 632case "$ac_cv_header_sys_capability_h$ac_cv_header_sys_prctl_h" in 633 yesyes) 634 case "$host" in 635 mips-sgi-irix*) 636 ntp_have_linuxcaps=no 637 ;; 638 *) ntp_have_linuxcaps=yes 639 ;; 640 esac 641 ;; 642 *) 643 ntp_have_linuxcaps=no 644 ;; 645esac 646 647AC_ARG_ENABLE( 648 [linuxcaps], 649 [AS_HELP_STRING( 650 [--enable-linuxcaps], 651 [+ Use Linux capabilities for non-root clock control] 652 )], 653 [ntp_have_linuxcaps=$enableval] 654) 655 656AC_MSG_RESULT([$ntp_have_linuxcaps]) 657 658case "$ntp_have_linuxcaps" in 659 yes) 660 AC_DEFINE([HAVE_LINUX_CAPABILITIES], [1], 661 [Do we have Linux capabilities?]) 662 LIBS="$LIBS -lcap" 663 ;; 664esac 665 666 667AC_CHECK_HEADERS([priv.h]) 668 669AC_MSG_CHECKING([if we have solaris privileges]) 670 671case "$ac_cv_header_priv_h" in 672 yes) 673 case "$host" in 674 *-solaris*) 675 AC_CHECK_FUNC( 676 [setppriv], 677 [ntp_have_solarisprivs=yes], 678 [ntp_have_solarisprivs=no] 679 ) 680 ;; 681 esac 682esac 683 684AC_ARG_ENABLE( 685 [solarisprivs], 686 [AS_HELP_STRING( 687 [--enable-solarisprivs], 688 [+ Use Solaris privileges for non-root clock control] 689 )], 690 [ntp_have_solarisprivs=$enableval] 691) 692 693 694case "$ntp_have_solarisprivs" in 695 yes) 696 AC_DEFINE([HAVE_SOLARIS_PRIVS], [1], 697 [Are Solaris privileges available?]) 698esac 699 700AC_MSG_RESULT([$ntp_have_solarisprivs]) 701 702case "$ntp_use_dev_clockctl$ntp_have_linuxcaps$ntp_have_solarisprivs" in 703 *yes*) 704 AC_DEFINE([HAVE_DROPROOT], [1], 705 [Can we drop root privileges?]) 706esac 707 708case "$host" in 709 *-*-darwin*) 710 AC_SEARCH_LIBS([res_9_init], [resolv]) 711 ;; 712 *) AC_SEARCH_LIBS([res_init], [resolv]) 713 ;; 714esac 715AC_HEADER_RESOLV 716#HMS: Why do we do this check so "early"? 717AC_CHECK_FUNCS([res_init], , [AC_CHECK_FUNCS([__res_init])]) 718 719# We also need -lsocket, but we have tested for that already. 720AC_CHECK_FUNC([inet_ntop], [], 721 [AC_DEFINE([ISC_PLATFORM_NEEDNTOP], [1], [ISC: provide inet_ntop()])]) 722AC_CHECK_FUNC([inet_pton], [], 723 [AC_DEFINE([ISC_PLATFORM_NEEDPTON], [1], [ISC: provide inet_pton()])]) 724 725AC_CHECK_TYPES([uintptr_t, int32, u_int32]) 726 727AH_VERBATIM([TYPEDEF_UINTPTR_T], 728[/* Provide a typedef for uintptr_t? */ 729#ifndef HAVE_UINTPTR_T 730typedef unsigned int uintptr_t; 731#define HAVE_UINTPTR_T 1 732#endif]) 733 734case "$ac_cv_type_int32::$ac_cv_header_resolv_h" in 735 no::yes) 736 AC_CACHE_CHECK( 737 [for int32 with DNS headers included], 738 [ntp_cv_type_int32_with_dns], 739 [AC_COMPILE_IFELSE( 740 [AC_LANG_PROGRAM( 741 [[ 742 #ifdef HAVE_ARPA_NAMESER_H 743 # include <arpa/nameser.h> 744 #endif 745 #include <resolv.h> 746 ]], 747 [[ 748 size_t cb = sizeof(int32); 749 ]] 750 )], 751 [ntp_cv_type_int32_with_dns=yes], 752 [ntp_cv_type_int32_with_dns=no] 753 )] 754 ) 755 case "$ntp_cv_type_int32_with_dns" in 756 yes) 757 AC_DEFINE([HAVE_INT32_ONLY_WITH_DNS], [1], 758 [int32 type in DNS headers, not others.]) 759 esac 760esac 761 762case "$ac_cv_type_u_int32::$ac_cv_header_resolv_h" in 763 no::yes) 764 AC_CACHE_CHECK( 765 [for u_int32 with DNS headers included], 766 [ntp_cv_type_u_int32_with_dns], 767 [AC_COMPILE_IFELSE( 768 [AC_LANG_PROGRAM( 769 [[ 770 #ifdef HAVE_ARPA_NAMESER_H 771 # include <arpa/nameser.h> 772 #endif 773 #include <resolv.h> 774 ]], 775 [[ 776 size_t cb = sizeof(u_int32); 777 ]] 778 )], 779 [ntp_cv_type_u_int32_with_dns=yes], 780 [ntp_cv_type_u_int32_with_dns=no] 781 )] 782 ) 783 case "$ntp_cv_type_u_int32_with_dns" in 784 yes) 785 AC_DEFINE([HAVE_U_INT32_ONLY_WITH_DNS], [1], 786 [u_int32 type in DNS headers, not others.]) 787 esac 788esac 789 790AC_CHECK_HEADERS( 791 [sys/timepps.h], 792 [], 793 [], 794 [ 795 #ifdef HAVE_SYS_TIME_H 796 # include <sys/time.h> 797 #endif 798 #ifdef HAVE_ERRNO_H 799 # include <errno.h> 800 #endif 801 ] 802) 803 804AC_CACHE_CHECK( 805 [for struct timespec], 806 [ntp_cv_struct_timespec], 807 [AC_COMPILE_IFELSE( 808 [AC_LANG_PROGRAM( 809 [[ 810 #include <sys/time.h> 811 /* Under SunOS, timespec is in sys/timepps.h, 812 which needs errno.h and FRAC */ 813 #ifdef HAVE_ERRNO_H 814 # include <errno.h> 815 #endif 816 #ifdef HAVE_SYS_TIMEPPS_H 817 # define FRAC 4294967296 818 # include <sys/timepps.h> 819 #endif 820 ]], 821 [[ 822 struct timespec n; 823 ]] 824 )], 825 [ntp_cv_struct_timespec=yes], 826 [ntp_cv_struct_timespec=no] 827 )] 828) 829case "$ntp_cv_struct_timespec" in 830 yes) 831 AC_DEFINE([HAVE_STRUCT_TIMESPEC], [1], [struct timespec declared?]) 832esac 833 834AC_CACHE_CHECK( 835 [for struct ntptimeval], 836 [ntp_cv_struct_ntptimeval], 837 [AC_COMPILE_IFELSE( 838 [AC_LANG_PROGRAM( 839 [[ 840 #include <sys/time.h> 841 #include <sys/timex.h> 842 ]], 843 [[ 844 struct ntptimeval n; 845 ]] 846 )], 847 [ntp_cv_struct_ntptimeval=yes], 848 [ntp_cv_struct_ntptimeval=no] 849 )] 850) 851case "$ntp_cv_struct_ntptimeval" in 852 yes) 853 AC_DEFINE([HAVE_STRUCT_NTPTIMEVAL], [1], 854 [Do we have struct ntptimeval?]) 855esac 856 857AC_CHECK_HEADERS( 858 [md5.h], 859 [], 860 [], 861 [ 862 #ifdef HAVE_SYS_TYPES_H 863 # include <sys/types.h> 864 #endif 865 ] 866) 867 868AC_SEARCH_LIBS([MD5Init], [md5 md]) 869AC_CHECK_FUNCS([MD5Init sysconf getdtablesize sigaction sigset sigvec]) 870 871AC_CACHE_CHECK( 872 [for SIGIO], 873 [ntp_cv_hdr_def_sigio], 874 [AC_PREPROC_IFELSE( 875 [ 876 #include <signal.h> 877 878 #ifndef SIGIO 879 # error 880 #endif 881 ], 882 [ntp_cv_hdr_def_sigio=yes], 883 [ntp_cv_hdr_def_sigio=no] 884 )] 885 ) 886 887dnl Override those system that have a losing SIGIO 888AC_MSG_CHECKING([if we want to use SIGIO]) 889ans=no 890case "$ntp_cv_hdr_def_sigio" in 891 yes) 892 ans=yes 893 case "$host" in 894 alpha*-dec-osf4*|alpha*-dec-osf5*) 895 ans=no 896 ;; 897 *-convex-*) 898 ans=no 899 ;; 900 *-dec-*) 901 ans=no 902 ;; 903 *-pc-cygwin*) 904 ans=no 905 ;; 906 *-sni-sysv*) 907 ans=no 908 ;; 909 *-univel-sysv*) 910 ans=no 911 ;; 912 *-*-irix6*) 913 ans=no 914 ;; 915 *-*-freebsd*) 916 ans=no 917 ;; 918 *-*-*linux*) 919 ans=no 920 ;; 921 *-*-unicosmp*) 922 ans=no 923 ;; 924 *-*-kfreebsd*) 925 ans=no 926 ;; 927 m68k-*-mint*) 928 ans=no 929 ;; 930 esac 931 ;; 932esac 933case "$ans" in 934 yes) 935 AC_DEFINE([HAVE_SIGNALED_IO], [1], 936 [Can we use SIGIO for tcp and udp IO?]) 937esac 938AC_MSG_RESULT([$ans]) 939 940AC_CACHE_CHECK( 941 [for SIGPOLL], 942 [ntp_cv_hdr_def_sigpoll], 943 [AC_PREPROC_IFELSE( 944 [ 945 #include <signal.h> 946 947 #ifndef SIGPOLL 948 # error 949 #endif 950 ], 951 [ntp_cv_hdr_def_sigpoll=yes], 952 [ntp_cv_hdr_def_sigpoll=no] 953 )] 954) 955 956AC_MSG_CHECKING([if we can use SIGPOLL for UDP I/O]) 957ans=no 958case "$ntp_cv_hdr_def_sigpoll" in 959 yes) 960 case "$host" in 961 mips-sgi-irix*) 962 ans=no 963 ;; 964 vax-dec-bsd) 965 ans=no 966 ;; 967 *-pc-cygwin*) 968 ans=no 969 ;; 970 *-sni-sysv*) 971 ans=no 972 ;; 973 *-*-aix[[4-9]]*) 974 # XXX Only verified thru AIX6 975 ans=no 976 ;; 977 *-*-hpux*) 978 ans=no 979 ;; 980 *-*-*linux*) 981 ans=no 982 ;; 983 *-*-osf*) 984 ans=no 985 ;; 986 *-*-qnx*) 987 ans=no 988 ;; 989 *-*-sunos*) 990 ans=no 991 ;; 992 *-*-solaris*) 993 ans=no 994 ;; 995 *-*-ultrix*) 996 ans=no 997 ;; 998 *-*-unicosmp*) 999 ans=no 1000 ;; 1001 *-*-kfreebsd*) 1002 ans=no 1003 ;; 1004 *) ans=yes 1005 ;; 1006 esac 1007 ;; 1008esac 1009case "$ans" in 1010 yes) 1011 AC_DEFINE([USE_UDP_SIGPOLL], [1], [Can we use SIGPOLL for UDP?]) 1012esac 1013AC_MSG_RESULT([$ans]) 1014 1015AC_MSG_CHECKING([if we can use SIGPOLL for TTY I/O]) 1016ans=no 1017case "$ntp_cv_hdr_def_sigpoll" in 1018 yes) 1019 case "$host" in 1020 mips-sgi-irix*) 1021 ans=no 1022 ;; 1023 vax-dec-bsd) 1024 ans=no 1025 ;; 1026 *-pc-cygwin*) 1027 ans=no 1028 ;; 1029 *-sni-sysv*) 1030 ans=no 1031 ;; 1032 *-*-aix[[4-9]]*) 1033 # XXX Only verified thru AIX6 1034 ans=no 1035 ;; 1036 *-*-hpux*) 1037 ans=no 1038 ;; 1039 *-*-*linux*) 1040 ans=no 1041 ;; 1042 *-*-osf*) 1043 ans=no 1044 ;; 1045 *-*-sunos*) 1046 ans=no 1047 ;; 1048 *-*-ultrix*) 1049 ans=no 1050 ;; 1051 *-*-qnx*) 1052 ans=no 1053 ;; 1054 *-*-unicosmp*) 1055 ans=no 1056 ;; 1057 *-*-kfreebsd*) 1058 ans=no 1059 ;; 1060 *) ans=yes 1061 ;; 1062 esac 1063 ;; 1064esac 1065case "$ans" in 1066 yes) 1067 AC_DEFINE([USE_TTY_SIGPOLL], [1], [Can we use SIGPOLL for tty IO?]) 1068esac 1069AC_MSG_RESULT([$ans]) 1070 1071AC_CACHE_CHECK( 1072 [number of arguments to gettimeofday()], 1073 [ntp_cv_func_Xettimeofday_nargs], 1074 [AC_COMPILE_IFELSE( 1075 [AC_LANG_PROGRAM( 1076 [[ 1077 #include <sys/time.h> 1078 ]], 1079 [[ 1080 gettimeofday(0, 0); 1081 settimeofday(0, 0); 1082 ]] 1083 )], 1084 [ntp_cv_func_Xettimeofday_nargs=2], 1085 [ntp_cv_func_Xettimeofday_nargs=1] 1086 )] 1087) 1088case "$ntp_cv_func_Xettimeofday_nargs" in 1089 1) 1090 AC_DEFINE([SYSV_TIMEOFDAY], [1], [Does Xettimeofday take 1 arg?]) 1091esac 1092 1093AC_CHECK_FUNCS([settimeofday], ,[ 1094 case "$host" in 1095 *-*-mpeix*) ac_cv_func_settimeofday=yes 1096 esac 1097]) 1098 1099AC_MSG_CHECKING([if we'll use clock_settime or settimeofday or stime]) 1100ntp_warning='GRONK' 1101ans=none 1102case "$ac_cv_func_clock_settime$ac_cv_func_settimeofday$ac_cv_func_stime" in 1103 yes*) 1104 ntp_warning='' 1105 ans='clock_settime()' 1106 ;; 1107 noyes*) 1108 ntp_warning='But clock_settime() would be better (if we had it)' 1109 ans='settimeofday()' 1110 ;; 1111 nonoyes) 1112 ntp_warning='Which is the worst of the three' 1113 ans='stime()' 1114 ;; 1115 *) 1116 case "$build" in 1117 $host) 1118 ntp_warning='Which leaves us with nothing to use!' 1119 esac 1120esac 1121AC_MSG_RESULT([$ans]) 1122case "$ntp_warning" in 1123 '') 1124 ;; 1125 *) 1126 AC_MSG_WARN([*** $ntp_warning ***]) 1127 ;; 1128esac 1129 1130 1131dnl add to LDADD_LIBNTP set by ntp_compiler.m4 1132LDADD_LIBNTP="$LDADD_LIBNTP $LIBS" 1133LIBS=$__LIBS 1134AS_UNSET([__LIBS]) 1135 1136])dnl 1137dnl ====================================================================== 1138