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