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