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