2 # Process this file with autoconf to produce a configure script.
3 m4_include([../version.m4])
5 AC_INIT([sntp], [VERSION_NUMBER])
6 AC_CONFIG_MACRO_DIR([../m4])
9 # Increment sntp_configure_cache_version by one for each change to
10 # configure.ac or .m4 files which invalidates cached values from
13 # If the change affects cache variables used only by the main NTP
14 # configure.ac, then only its version number should be bumped, while
15 # the subdir configure.ac version numbers should be unchanged. The
16 # same is true for a test/variable that is used only by one subdir
17 # being changed incompatibly; only that subdir's cache version needs
20 # If a change affects variables shared by all NTP configure scripts,
21 # please bump the version numbers of all three. If you are not sure,
22 # the safe choice is to bump all three on any cache-invalidating change.
24 # In order to avoid the risk of version stamp collision between -stable
25 # and -dev branches, do not simply increment the version, instead use
26 # the date YYYYMMDD optionally with -HHMM if there is more than one
29 sntp_configure_cache_version=20091117
31 # When the version of config.cache and configure do not
32 # match, NTP_CACHEVERSION will flush the cache.
34 NTP_CACHEVERSION([sntp], [$sntp_configure_cache_version])
39 dnl the 'build' machine is where we run configure and compile
40 dnl the 'host' machine is where the resulting stuff runs.
41 AC_DEFINE_UNQUOTED([STR_SYSTEM], "$host", [canonical system (cpu-vendor-os) of where we should run])
42 AC_CONFIG_HEADER([config.h])
46 # Checks for programs.
49 # AC_PROG_CC_STDC has two functions. It attempts to find a compiler
50 # capable of C99, or failing that, for C89. CC is set afterward with
51 # the selected invocation, such as "gcc --std=gnu99". Also, the
52 # ac_cv_prog_cc_stdc variable is no if the compiler selected for CC
53 # does not accept C89.
57 case "$ac_cv_prog_cc_stdc" in
59 AC_MSG_WARN([ANSI C89/ISO C90 is the minimum to compile SNTP ]
60 [version 4.2.5 and higher.])
65 SAVED_CFLAGS_AC="$CFLAGS"
66 CFLAGS="$CFLAGS -Wstrict-overflow"
68 [if $CC can handle -Wstrict-overflow],
69 ac_cv_gcc_Wstrict_overflow,
72 [AC_LANG_PROGRAM([], [])],
73 [ac_cv_gcc_Wstrict_overflow=yes],
74 [ac_cv_gcc_Wstrict_overflow=no]
78 CFLAGS="$SAVED_CFLAGS_AC"
81 CFLAGS="$CFLAGS -Wall"
82 # CFLAGS="$CFLAGS -Wcast-align"
83 CFLAGS="$CFLAGS -Wcast-qual"
84 # CFLAGS="$CFLAGS -Wconversion"
85 # CFLAGS="$CFLAGS -Werror"
86 # CFLAGS="$CFLAGS -Wextra"
87 # CFLAGS="$CFLAGS -Wfloat-equal"
88 CFLAGS="$CFLAGS -Wmissing-prototypes"
89 CFLAGS="$CFLAGS -Wpointer-arith"
90 CFLAGS="$CFLAGS -Wshadow"
91 CFLAGS="$CFLAGS -Wstrict-prototypes"
92 # CFLAGS="$CFLAGS -Wtraditional"
93 # CFLAGS="$CFLAGS -Wwrite-strings"
94 case "$ac_cv_gcc_Wstrict_overflow" in
96 CFLAGS="$CFLAGS -Wstrict-overflow"
100 # HMS: These need to be moved to AM_CPPFLAGS and/or AM_CFLAGS
103 # see "man standards".
104 # -D_XOPEN_SOURCE=500 is probably OK for c89 and before
105 # -D_XOPEN_SOURCE=600 seems OK for c99
106 #CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
107 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
114 # NTP has (so far) been relying on leading-edge autogen.
115 # Therefore, by default:
116 # - use the version we ship with
117 # - do not install it
118 # - build a static copy (AC_DISABLE_SHARED - done earlier)
119 case "${enable_local_libopts+set}" in
121 *) enable_local_libopts=yes ;;
123 case "${enable_libopts_install+set}" in
125 *) enable_libopts_install=no ;;
127 LIBOPTS_CHECK([libopts])
129 m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
130 m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
135 # Checks for libraries.
137 AC_CHECK_FUNC([gethostent], ,
138 [AC_SEARCH_LIBS([gethostent], [nsl], , , [$libxnet -lsocket])])
139 AC_CHECK_FUNC([openlog], ,
140 [AC_SEARCH_LIBS([openlog], [gen], ,
141 [AC_SEARCH_LIBS([openlog], [syslog], , , [$libxnet -lsocket])])])
143 AC_SEARCH_LIBS([setsockopt], [socket xnet])
145 # Checks for header files.
147 AC_CHECK_HEADERS([netdb.h netinet/in.h stdlib.h string.h strings.h syslog.h])
148 AC_CHECK_HEADERS([sys/socket.h sys/time.h])
151 # Checks for typedefs, structures, and compiler characteristics.
158 case "$ac_cv_c_inline" in
162 AC_DEFINE(HAVE_INLINE,1,[inline keyword or macro available])
163 AC_SUBST(HAVE_INLINE)
166 AC_C_CHAR_UNSIGNED dnl CROSS_COMPILE?
167 AC_CHECK_SIZEOF([signed char])
168 AC_CHECK_SIZEOF([int])
169 AC_CHECK_SIZEOF([long])
171 AC_CHECK_TYPES([s_char])
172 case "$ac_cv_c_char_unsigned$ac_cv_sizeof_signed_char$ac_cv_type_s_char" in
174 # We have a typedef for s_char. Might as well believe it...
177 # We have signed chars, can't say 'signed char', no s_char typedef.
178 AC_DEFINE([NEED_S_CHAR_TYPEDEF], 1, [Do we need an s_char typedef?])
181 # We have signed chars, can say 'signed char', no s_char typedef.
182 AC_DEFINE([NEED_S_CHAR_TYPEDEF])
185 # We have unsigned chars, can't say 'signed char', no s_char typedef.
186 AC_MSG_ERROR([No way to specify a signed character!])
189 # We have unsigned chars, can say 'signed char', no s_char typedef.
190 AC_DEFINE([NEED_S_CHAR_TYPEDEF])
195 AC_MSG_CHECKING([type of socklen arg for getsockname()])
196 AC_CACHE_VAL(ac_cv_func_getsockname_arg2,dnl
197 [AC_CACHE_VAL(ac_cv_func_getsockname_socklen_type,dnl
198 [for ac_cv_func_getsockname_arg2 in 'struct sockaddr *' 'void *'; do
199 for ac_cv_func_getsockname_socklen_type in 'socklen_t' 'size_t' 'unsigned int' 'int'; do
201 [#ifdef HAVE_SYS_TYPES_H
202 #include <sys/types.h>
204 #ifdef HAVE_SYS_SOCKET_H
205 #include <sys/socket.h>
207 extern getsockname (int, $ac_cv_func_getsockname_arg2, $ac_cv_func_getsockname_socklen_type *);],,dnl
208 [ac_not_found=no ; break 2], ac_not_found=yes)
213 if test "$ac_not_found" = yes; then
214 ac_cv_func_getsockname_socklen_type='socklen_t'
216 AC_MSG_RESULT([$ac_cv_func_getsockname_socklen_type])
217 AC_DEFINE_UNQUOTED([GETSOCKNAME_SOCKLEN_TYPE],
218 $ac_cv_func_getsockname_socklen_type,
219 [What is getsockname()'s socklen type?])
222 [for struct sockaddr_storage],
223 ntp_cv_sockaddr_storage,
227 #ifdef HAVE_SYS_TYPES_H
228 # include <sys/types.h>
230 #ifdef HAVE_SYS_SOCKET_H
231 # include <sys/socket.h>
233 #ifdef HAVE_NETINET_IN_H
234 # include <netinet/in.h>
238 struct sockaddr_storage n;
240 [ntp_cv_sockaddr_storage="yes"],
241 [ntp_cv_sockaddr_storage="no"]
245 case "$ntp_cv_sockaddr_storage" in
247 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Does a system header define struct sockaddr_storage?])
251 [for sockaddr_storage.ss_family],
252 ntp_cv_have_ss_family,
256 #ifdef HAVE_SYS_TYPES_H
257 # include <sys/types.h>
259 #ifdef HAVE_SYS_SOCKET_H
260 # include <sys/socket.h>
262 #ifdef HAVE_NETINET_IN_H
263 # include <netinet/in.h>
267 struct sockaddr_storage s;
270 [ntp_cv_have_ss_family="yes"],
271 [ntp_cv_have_ss_family="no"]
276 case "$ntp_cv_have_ss_family" in
279 [for sockaddr_storage.__ss_family],
280 ntp_cv_have___ss_family,
284 #ifdef HAVE_SYS_TYPES_H
285 # include <sys/types.h>
287 #ifdef HAVE_SYS_SOCKET_H
288 # include <sys/socket.h>
290 #ifdef HAVE_NETINET_IN_H
291 # include <netinet/in.h>
295 struct sockaddr_storage s;
298 [ntp_cv_have___ss_family="yes"],
299 [ntp_cv_have___ss_family="no"]
303 case "$ntp_cv_have___ss_family" in
305 AC_DEFINE(HAVE___SS_FAMILY_IN_SS, 1, [Does struct sockaddr_storage have __ss_family?])
310 [HAVE___SS_FAMILY_IN_SS_VERBATIM],
312 /* Handle sockaddr_storage.__ss_family */
313 #ifdef HAVE___SS_FAMILY_IN_SS
314 # define ss_family __ss_family
315 #endif /* HAVE___SS_FAMILY_IN_SS */
320 [for sockaddr_storage.ss_len],
325 #ifdef HAVE_SYS_TYPES_H
326 # include <sys/types.h>
328 #ifdef HAVE_SYS_SOCKET_H
329 # include <sys/socket.h>
331 #ifdef HAVE_NETINET_IN_H
332 # include <netinet/in.h>
336 struct sockaddr_storage s;
339 [ntp_cv_have_ss_len="yes"],
340 [ntp_cv_have_ss_len="no"]
345 case "$ntp_cv_have_ss_len" in
348 [for sockaddr_storage.__ss_len],
349 ntp_cv_have___ss_len,
353 #ifdef HAVE_SYS_TYPES_H
354 # include <sys/types.h>
356 #ifdef HAVE_SYS_SOCKET_H
357 # include <sys/socket.h>
359 #ifdef HAVE_NETINET_IN_H
360 # include <netinet/in.h>
364 struct sockaddr_storage s;
367 [ntp_cv_have___ss_len="yes"],
368 [ntp_cv_have___ss_len="no"]
372 case "$ntp_cv_have___ss_len" in
374 AC_DEFINE(HAVE___SS_LEN_IN_SS, 1, [Does struct sockaddr_storage have __ss_len?])
379 [HAVE___SS_LEN_IN_SS_VERBATIM],
381 /* Handle sockaddr_storage.__ss_len */
382 #ifdef HAVE___SS_LEN_IN_SS
383 # define ss_len __ss_len
384 #endif /* HAVE___SS_LEN_IN_SS */
389 # Look for in_port_t.
393 isc_cv_have_in_port_t,
397 #include <sys/types.h>
398 #include <netinet/in.h>
404 [isc_cv_have_in_port_t=yes],
405 [isc_cv_have_in_port_t=no]
409 case "$isc_cv_have_in_port_t" in
411 AC_DEFINE(ISC_PLATFORM_NEEDPORTT, 1, [Declare in_port_t?])
414 AC_SEARCH_LIBS([inet_ntop], [resolv], , , [-lsocket -lnsl])
415 AC_CHECK_FUNC(inet_ntop, [], [AC_DEFINE(ISC_PLATFORM_NEEDNTOP, 1, [ISC: provide inet_ntop()])])
416 AC_CHECK_FUNC(inet_pton, [], [AC_DEFINE(ISC_PLATFORM_NEEDPTON, 1, [ISC: provide inet_pton()])])
418 AC_ARG_ENABLE([ipv6], [AC_HELP_STRING([--enable-ipv6], [s use IPv6?])])
420 case "$enable_ipv6" in
423 powerpc-ibm-aix4*) ;;
425 AC_DEFINE([WANT_IPV6], ,[ISC: Want IPv6?])
434 [for IPv6 structures],
435 ac_cv_isc_found_ipv6,
441 #include <sys/types.h>
442 #include <sys/socket.h>
443 #include <netinet/in.h>
446 struct sockaddr_in6 sin6;
450 [ac_cv_isc_found_ipv6=yes],
451 [ac_cv_isc_found_ipv6=no]
457 # See whether IPv6 support is provided via a Kame add-on.
458 # This is done before other IPv6 linking tests so LIBS is properly set.
460 AC_MSG_CHECKING([for Kame IPv6 support])
462 [AC_HELP_STRING([--with-kame], [- =/usr/local/v6])],
463 use_kame="$withval", use_kame="no")
469 kame_path=/usr/local/v6
472 kame_path="$use_kame"
481 if test -f $kame_path/lib/libinet6.a; then
482 AC_MSG_RESULT($kame_path/lib/libinet6.a)
483 LIBS="-L$kame_path/lib -linet6 $LIBS"
485 AC_MSG_ERROR([$kame_path/lib/libinet6.a not found.
487 Please choose the proper path with the following command:
489 configure --with-kame=PATH
496 # Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
497 # Including it on Kame-using platforms is very bad, though, because
498 # Kame uses #error against direct inclusion. So include it on only
499 # the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
500 # This is done before the in6_pktinfo check because that's what
501 # netinet6/in6.h is needed for.
505 AC_DEFINE(ISC_PLATFORM_NEEDNETINET6IN6H, 1, [Do we need netinet6/in6.h?])
506 # does anything use LWRES_PLATFORM_NEEDNETINET6IN6H? Can't it use above?
507 AC_DEFINE(LWRES_PLATFORM_NEEDNETINET6IN6H, 1, [Do we need netinet6/in6.h?])
508 isc_netinet6in6_hack="#include <netinet6/in6.h>"
511 isc_netinet6in6_hack=""
515 # This is similar to the netinet6/in6.h issue.
518 *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
519 AC_DEFINE(ISC_PLATFORM_FIXIN6ISADDR, 1,[Do we need to fix in6isaddr?])
520 isc_netinetin6_hack="#include <netinet/in6.h>"
523 isc_netinetin6_hack=""
527 case "$ac_cv_isc_found_ipv6" in
529 AC_DEFINE(ISC_PLATFORM_HAVEIPV6, ,[have IPv6?])
533 ac_cv_have_in6_pktinfo,
539 #include <sys/types.h>
540 #include <sys/socket.h>
541 #include <netinet/in.h>
543 $isc_netinet6in6_hack
546 struct in6_pktinfo xyzzy;
550 [ac_cv_have_in6_pktinfo=yes],
551 [ac_cv_have_in6_pktinfo=no]
556 case "$ac_cv_have_in6_pktinfo" in
558 AC_DEFINE(ISC_PLATFORM_HAVEIN6PKTINFO, , [have struct in6_pktinfo?])
562 # HMS: Use HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID instead?
564 [for sockaddr_in6.sin6_scope_id],
565 ac_cv_have_sin6_scope_id,
571 #include <sys/types.h>
572 #include <sys/socket.h>
573 #include <netinet/in.h>
575 $isc_netinet6in6_hack
578 struct sockaddr_in6 xyzzy;
579 xyzzy.sin6_scope_id = 0;
583 [ac_cv_have_sin6_scope_id=yes],
584 [ac_cv_have_sin6_scope_id=no]
589 case "$ac_cv_have_sin6_scope_id" in
591 AC_DEFINE(ISC_PLATFORM_HAVESCOPEID, , [have sin6_scope_id?])
596 # We need this check run even without ac_cv_isc_found_ipv6=yes
600 isc_cv_have_in6addr_any,
606 #include <sys/types.h>
607 #include <sys/socket.h>
608 #include <netinet/in.h>
610 $isc_netinet6in6_hack
618 [isc_cv_have_in6addr_any=yes],
619 [isc_cv_have_in6addr_any=no]
624 case "$isc_cv_have_in6addr_any" in
626 AC_DEFINE(ISC_PLATFORM_NEEDIN6ADDRANY, , [missing in6addr_any?])
631 [for struct if_laddrconf],
632 ac_cv_isc_struct_if_laddrconf,
638 #include <sys/types.h>
642 struct if_laddrconf a;
646 [ac_cv_isc_struct_if_laddrconf=yes],
647 [ac_cv_isc_struct_if_laddrconf=no]
652 case "$ac_cv_isc_struct_if_laddrconf" in
654 AC_DEFINE(ISC_PLATFORM_HAVEIF_LADDRCONF, , [have struct if_laddrconf?])
658 [for struct if_laddrreq],
659 ac_cv_isc_struct_if_laddrreq,
665 #include <sys/types.h>
669 struct if_laddrreq a;
673 [ac_cv_isc_struct_if_laddrreq=yes],
674 [ac_cv_isc_struct_if_laddrreq=no]
679 case "$ac_cv_isc_struct_if_laddrreq" in
681 AC_DEFINE(ISC_PLATFORM_HAVEIF_LADDRREQ, , [have struct if_laddrreq?])
688 AC_DEFINE(HAVE_NO_NICE, 1, [sntp does not care about 'nice'])
689 AC_DEFINE(HAVE_TERMIOS, 1, [sntp does not care about TTY stuff])
691 # Checks for library functions.
692 AC_CHECK_FUNCS([atexit memset socket])
694 AC_MSG_CHECKING(for bin subdirectory)
695 AC_ARG_WITH(binsubdir,
696 [AC_HELP_STRING([--with-binsubdir], [bin ={bin,sbin}])],
697 use_binsubdir="$withval", use_binsubdir="bin")
699 case "$use_binsubdir" in
705 AC_MSG_ERROR([<$use_binsubdir> is illegal - must be "bin" or "sbin"])
708 AC_MSG_RESULT($use_binsubdir)
709 BINSUBDIR=$use_binsubdir
712 AC_CONFIG_FILES([Makefile])