AC_INIT(gnio/ginetaddress.h) AM_INIT_AUTOMAKE(gnio, 0.0.1) AM_CONFIG_HEADER(config.h) AM_SANITY_CHECK AC_C_CONST AC_ISC_POSIX AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AM_DISABLE_STATIC AM_PROG_LIBTOOL AC_PATH_PROG(PKG_CONFIG, pkg-config, no) AM_PROG_CC_C_O AC_TYPE_PID_T AC_TYPE_SIGNAL AC_TYPE_SIZE_T AC_TYPE_UID_T AH_VERBATIM([_GNU_SOURCE], [/* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE #endif]) saved_CFLAGS=$CFLAGS AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec, struct stat.st_atimensec, struct stat.st_atim.tv_nsec, struct stat.st_ctimensec, struct stat.st_ctim.tv_nsec]) CFLAGS=$saved_CFLAGS LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"' AC_SUBST(LIBTOOL_EXPORT_OPTIONS) GTK_DOC_CHECK DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc" AC_SUBST(DISTCHECK_CONFIGURE_FLAGS) PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.13.8 gthread-2.0 gobject-2.0 gmodule-no-export-2.0 gio-unix-2.0 gio-2.0) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) PKG_CHECK_MODULES(GTHREAD, gthread-2.0) GETTEXT_PACKAGE=gnio AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [The gettext domain name]) AC_SUBST(GETTEXT_PACKAGE) AM_GLIB_GNU_GETTEXT AC_CHECK_FUNC(getaddrinfo_a) AC_CHECK_FUNC(gethostbyname_r) dnl ========================================================================== dnl Globally define_GNU_SOURCE and therefore enable the GNU extensions AC_DEFINE(_GNU_SOURCE, 1, [Enable GNU Extensions]) AC_CHECK_HEADERS([sys/sockio.h sys/param.h ifaddrs.h]) AM_CONDITIONAL(WIN32, [echo "$host" | grep -qE '^.*-.*-mingw.*$']) case "$host" in *-*-mingw*) AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if IPv6 is potentially available]) AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if the system provides getaddrinfo(2)]) AC_DEFINE(HAVE_GETADDRINFO_THREADSAFE, 1, [Define if getaddrinfo is threadsafe]) AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether you have struct sockaddr_storage]) ;; *) AC_MSG_CHECKING([for linux/netlink.h]) AC_TRY_CPP([#include ], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_LINUX_NETLINK_H, 1, [Define if linux/netlink.h header exists]) ],[ AC_MSG_RESULT(no) ]) AC_CHECK_MEMBER([struct sockaddr.sa_len], AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if struct sockaddr has sa_len field]),, [#include #include ]) AC_MSG_CHECKING([for struct sockaddr_storage]) AC_TRY_COMPILE([ #include #include ], [struct sockaddr_storage s; s], have_sockaddr_storage=yes, have_sockaddr_storage=no) if test "$have_sockaddr_storage" = yes; then AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether you have struct sockaddr_storage]) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi # Check for IPv6 support on unix # (will be done at runtime on win32) AC_MSG_CHECKING([for IPv6 availability]) AC_TRY_LINK([ #include #include #include ], [ struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0; ], [ AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if IPv6 is potentially available]) AC_MSG_RESULT(yes) ], [ AC_DEFINE(HAVE_IPV6, 0, [Define to 1 if IPv6 is potentially available]) AC_MSG_RESULT(no) ] ) # Most of this code checks for variants of gethostbyname(). For # simplicity and curiosity, we check for all variants, though only one # working variant is needed. # Look for getifaddrs() AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS, 1, [Define if getifaddrs() is available])) # The user may be able to tell us if a function is thread-safe. We # know of no good way to test this programaticly. # On some systems, getaddrinfo() is thread-safe AC_ARG_ENABLE(threadsafe_getaddrinfo, AC_HELP_STRING([--enable-threadsafe-getaddrinfo], [assume getaddrinfo() is threadsafe])) # On some systems, gethostbyname() is thread-safe AC_ARG_ENABLE(threadsafe_gethostbyname, AC_HELP_STRING([--enable-threadsafe-gethostbyname], [assume gethostbyname() is threadsafe])) # Look for getaddrinfo(). If we have that, we don't need # gethostbyname(). We assume if the system has getaddrinfo(), they # have getnameinfo(). AC_CHECK_FUNC(getaddrinfo, [ # have getaddrinfo() HAVE_GETADDRINFO=yes AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo() is available]) # Check for threadsafe getaddrinfo() AC_MSG_CHECKING([for threadsafe getaddrinfo()]) if test "x$enable_threadsafe_getaddrinfo" = "xyes" ; then HAVE_GETADDRINFO_THREADSAFE=yes AC_MSG_RESULT(yes) AC_DEFINE(HAVE_GETADDRINFO_THREADSAFE, 1, [Define if getaddrinfo is threadsafe]) else AC_MSG_RESULT(no) # If there is no threadsafe getaddrinfo, use a Glib mutex. if test "x$GTHREAD_CFLAGS" != "x"; then AC_DEFINE(HAVE_GETADDRINFO_GLIB_MUTEX, 1, [Define if getaddrinfo requires a mutex for thread-safety]) HAVE_GETADDRINFO_GLIB_MUTEX=yes else AC_MSG_WARN([ You do not have a thread-safe getaddrinfo() or GLib threads. Calls to getaddrinfo() may not be thread-safe. This build of GNIO could malfunction if used in programs that use threads. If your system has a thread-safe version of getaddrinfo(), pass the option --enable-threadsafe-getaddrinfo to configure. The function's manpage may be able to tell you whether it is thread-safe or not. ]) fi fi ], [ # no getaddrinfo() AC_MSG_RESULT(no) ]) # Check if the user told use gethostbyname() is thread-safe. AC_MSG_CHECKING([for threadsafe gethostbyname()]) if test "x$enable_threadsafe_gethostbyname" = "xyes" ; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_GETHOSTBYNAME_THREADSAFE, 1, [Define if gethostbyname is threadsafe]) HAVE_GETHOSTBYNAME_THREADSAFE=yes else AC_MSG_RESULT(no) fi # Look for a gethostbyname_r() we can use. We assume that if the # system has gethostbyname_r(), they also have gethostbyaddr_r(). # First, look for the glibc varient AC_MSG_CHECKING([for glibc gethostbyname_r]) AC_TRY_LINK([#include ], [struct hostent result_buf; char buf[1024]; struct hostent *result; int h_erropp; gethostbyname_r("localhost", &result_buf, buf, sizeof(buf), &result, &h_erropp);], [AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC, 1, [Define if glibc variant of gethostbyname() is available]) HAVE_GETHOSTBYNAME_R=yes], [AC_MSG_RESULT([no])]) # Whups, maybe we're on Solaris or Irix AC_MSG_CHECKING([for Solaris/Irix gethostbyname_r]) AC_TRY_LINK([#include ], [struct hostent result; char buf[1024]; int h_errnop; gethostbyname_r("localhost", &result, buf, sizeof(buf), &h_errnop);], [AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_GETHOSTBYNAME_R_SOLARIS, 1, [Define if Solaris variant of gethostbyname() is available]) HAVE_GETHOSTBYNAME_R=yes], [AC_MSG_RESULT([no])]) # Or not. Perhaps we're on HP-UX? AC_MSG_CHECKING([for HP-UX gethostbyname_r]) AC_TRY_LINK([#include ], [struct hostent result; char buf[1024]; gethostbyname_r("localhost", &result, buf);], [AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_GETHOSTBYNAME_R_HPUX, 1, [Define if HPUX variant of gethostbyname() is available]) HAVE_GETHOSTBYNAME_R=yes], [AC_MSG_RESULT([no])]) # If there is no gethostbyname_r, use Glib threads. if test -z "$HAVE_GETHOSTBYNAME_THREADSAFE" -a -z "$HAVE_GETHOSTBYNAME_R" -a "$GTHREAD_CFLAGS"; then AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIB_MUTEX, 1, [Define if gethostbyname requires a mutex for thread-safety]) HAVE_GETHOSTBYNAME_R=yes fi # Duh-oh. We don't have _any_ thread-safety, so warn the builder if test -z "$HAVE_GETADDRINFO_THREADSAFE" -a -z "$HAVE_GETHOSTBYNAME_THREADSAFE" -a -z "$HAVE_GETHOSTBYNAME_R"; then AC_MSG_WARN([ You do not have a thread-safe gethostbyname_r() or GLib threads. Calls to gethostbyname() (called by the GOIO address functions) may not be thread-safe. This build of GOIO could malfunction if used in programs that use threads. If your system has a thread-safe version of gethostbyname(), pass the option --enable-threadsafe-gethostbyname to configure. The function's manpage may be able to tell you whether it is thread-safe or not. ]) fi ;; esac dnl ========================================================================== AC_DEFINE(_FILE_OFFSET_BITS, 64, [Enable LFS]) dnl ========================================================================== AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) dnl ========================================================================== dnl Turn on the additional warnings last, so -Werror doesn't affect other tests. AC_ARG_ENABLE(more-warnings, [ --enable-more-warnings Maximum compiler warnings], set_more_warnings="$enableval",[ if test -f $srcdir/CVSVERSION; then is_cvs_version=true set_more_warnings=yes else set_more_warnings=no fi ]) AC_MSG_CHECKING(for more warnings, including -Werror) if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then AC_MSG_RESULT(yes) CFLAGS="\ -Wall \ -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith \ -Wcast-align -Wsign-compare \ $CFLAGS" for option in -Wno-strict-aliasing -Wno-sign-compare; do SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $option" AC_MSG_CHECKING([whether gcc understands $option]) AC_TRY_COMPILE([], [], has_option=yes, has_option=no,) if test $has_option = no; then CFLAGS="$SAVE_CFLAGS" fi AC_MSG_RESULT($has_option) unset has_option unset SAVE_CFLAGS done unset option else AC_MSG_RESULT(no) fi AC_OUTPUT([ Makefile gnio/Makefile test/Makefile ]) echo echo "gnio configuration summary:" echo " "