1 AC_INIT(gnio/ginetaddress.h)
3 AM_INIT_AUTOMAKE(gnio, 0.0.1)
4 AM_CONFIG_HEADER(config.h)
17 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
25 AH_VERBATIM([_GNU_SOURCE],
26 [/* Enable GNU extensions on systems that have them. */
32 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])
35 LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
36 AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
39 DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc"
40 AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
42 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
47 PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
50 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [The gettext domain name])
51 AC_SUBST(GETTEXT_PACKAGE)
55 AC_CHECK_FUNC(getaddrinfo_a)
56 AC_CHECK_FUNC(gethostbyname_r)
58 dnl ==========================================================================
60 dnl Globally define_GNU_SOURCE and therefore enable the GNU extensions
61 AC_DEFINE(_GNU_SOURCE, 1, [Enable GNU Extensions])
63 AC_CHECK_HEADERS([sys/sockio.h sys/param.h ifaddrs.h])
65 AM_CONDITIONAL(WIN32, [echo "$host" | grep -qE '^.*-.*-mingw.*$'])
69 AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if IPv6 is potentially available])
70 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if the system provides getaddrinfo(2)])
71 AC_DEFINE(HAVE_GETADDRINFO_THREADSAFE, 1, [Define if getaddrinfo is threadsafe])
72 AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether you have struct sockaddr_storage])
75 AC_MSG_CHECKING([for linux/netlink.h])
76 AC_TRY_CPP([#include <linux/netlink.h>],
79 AC_DEFINE(HAVE_LINUX_NETLINK_H, 1,
80 [Define if linux/netlink.h header exists])
85 AC_CHECK_MEMBER([struct sockaddr.sa_len],
86 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1,
87 [Define if struct sockaddr has sa_len field]),,
88 [#include <sys/types.h>
89 #include <sys/socket.h>])
91 AC_MSG_CHECKING([for struct sockaddr_storage])
92 AC_TRY_COMPILE([ #include <sys/types.h>
93 #include <sys/socket.h>], [struct sockaddr_storage s; s],
94 have_sockaddr_storage=yes, have_sockaddr_storage=no)
95 if test "$have_sockaddr_storage" = yes; then
96 AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether you have struct sockaddr_storage])
102 # Check for IPv6 support on unix
103 # (will be done at runtime on win32)
104 AC_MSG_CHECKING([for IPv6 availability])
105 AC_TRY_LINK([ #include <sys/types.h>
106 #include <sys/socket.h>
107 #include <netinet/in.h> ],
108 [ struct sockaddr_in6 s;
109 struct in6_addr t=in6addr_any;
114 AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if IPv6 is potentially available])
118 AC_DEFINE(HAVE_IPV6, 0, [Define to 1 if IPv6 is potentially available])
122 # Most of this code checks for variants of gethostbyname(). For
123 # simplicity and curiosity, we check for all variants, though only one
124 # working variant is needed.
126 # Look for getifaddrs()
127 AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS, 1,
128 [Define if getifaddrs() is available]))
131 # The user may be able to tell us if a function is thread-safe. We
132 # know of no good way to test this programaticly.
134 # On some systems, getaddrinfo() is thread-safe
135 AC_ARG_ENABLE(threadsafe_getaddrinfo,
136 AC_HELP_STRING([--enable-threadsafe-getaddrinfo],
137 [assume getaddrinfo() is threadsafe]))
139 # On some systems, gethostbyname() is thread-safe
140 AC_ARG_ENABLE(threadsafe_gethostbyname,
141 AC_HELP_STRING([--enable-threadsafe-gethostbyname],
142 [assume gethostbyname() is threadsafe]))
145 # Look for getaddrinfo(). If we have that, we don't need
146 # gethostbyname(). We assume if the system has getaddrinfo(), they
147 # have getnameinfo().
148 AC_CHECK_FUNC(getaddrinfo,
149 [ # have getaddrinfo()
151 AC_DEFINE(HAVE_GETADDRINFO, 1,
152 [Define if getaddrinfo() is available])
153 # Check for threadsafe getaddrinfo()
154 AC_MSG_CHECKING([for threadsafe getaddrinfo()])
155 if test "x$enable_threadsafe_getaddrinfo" = "xyes" ; then
156 HAVE_GETADDRINFO_THREADSAFE=yes
158 AC_DEFINE(HAVE_GETADDRINFO_THREADSAFE, 1,
159 [Define if getaddrinfo is threadsafe])
162 # If there is no threadsafe getaddrinfo, use a Glib mutex.
163 if test "x$GTHREAD_CFLAGS" != "x"; then
164 AC_DEFINE(HAVE_GETADDRINFO_GLIB_MUTEX, 1,
165 [Define if getaddrinfo requires a mutex for thread-safety])
166 HAVE_GETADDRINFO_GLIB_MUTEX=yes
170 You do not have a thread-safe getaddrinfo() or GLib threads.
171 Calls to getaddrinfo() may
172 not be thread-safe. This build of GNIO could malfunction if used in
173 programs that use threads. If your system has a thread-safe version
174 of getaddrinfo(), pass the option --enable-threadsafe-getaddrinfo
175 to configure. The function's manpage may be able to tell you whether
176 it is thread-safe or not.
185 # Check if the user told use gethostbyname() is thread-safe.
186 AC_MSG_CHECKING([for threadsafe gethostbyname()])
187 if test "x$enable_threadsafe_gethostbyname" = "xyes" ; then
189 AC_DEFINE(HAVE_GETHOSTBYNAME_THREADSAFE, 1,
190 [Define if gethostbyname is threadsafe])
191 HAVE_GETHOSTBYNAME_THREADSAFE=yes
196 # Look for a gethostbyname_r() we can use. We assume that if the
197 # system has gethostbyname_r(), they also have gethostbyaddr_r().
199 # First, look for the glibc varient
200 AC_MSG_CHECKING([for glibc gethostbyname_r])
201 AC_TRY_LINK([#include <netdb.h>],
202 [struct hostent result_buf;
204 struct hostent *result;
207 gethostbyname_r("localhost",
213 [AC_MSG_RESULT([yes])
214 AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC, 1,
215 [Define if glibc variant of gethostbyname() is available])
216 HAVE_GETHOSTBYNAME_R=yes],
217 [AC_MSG_RESULT([no])])
218 # Whups, maybe we're on Solaris or Irix
219 AC_MSG_CHECKING([for Solaris/Irix gethostbyname_r])
220 AC_TRY_LINK([#include <netdb.h>],
221 [struct hostent result;
225 gethostbyname_r("localhost",
230 [AC_MSG_RESULT([yes])
231 AC_DEFINE(HAVE_GETHOSTBYNAME_R_SOLARIS, 1,
232 [Define if Solaris variant of gethostbyname() is available])
233 HAVE_GETHOSTBYNAME_R=yes],
234 [AC_MSG_RESULT([no])])
236 # Or not. Perhaps we're on HP-UX?
237 AC_MSG_CHECKING([for HP-UX gethostbyname_r])
238 AC_TRY_LINK([#include <netdb.h>],
239 [struct hostent result;
242 gethostbyname_r("localhost",
245 [AC_MSG_RESULT([yes])
246 AC_DEFINE(HAVE_GETHOSTBYNAME_R_HPUX, 1,
247 [Define if HPUX variant of gethostbyname() is available])
248 HAVE_GETHOSTBYNAME_R=yes],
249 [AC_MSG_RESULT([no])])
250 # If there is no gethostbyname_r, use Glib threads.
251 if test -z "$HAVE_GETHOSTBYNAME_THREADSAFE" -a -z "$HAVE_GETHOSTBYNAME_R" -a "$GTHREAD_CFLAGS"; then
252 AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIB_MUTEX, 1,
253 [Define if gethostbyname requires a mutex for thread-safety])
254 HAVE_GETHOSTBYNAME_R=yes
257 # Duh-oh. We don't have _any_ thread-safety, so warn the builder
258 if test -z "$HAVE_GETADDRINFO_THREADSAFE" -a -z "$HAVE_GETHOSTBYNAME_THREADSAFE" -a -z "$HAVE_GETHOSTBYNAME_R"; then
261 You do not have a thread-safe gethostbyname_r() or GLib threads.
262 Calls to gethostbyname() (called by the GOIO address functions) may
263 not be thread-safe. This build of GOIO could malfunction if used in
264 programs that use threads. If your system has a thread-safe version
265 of gethostbyname(), pass the option --enable-threadsafe-gethostbyname
266 to configure. The function's manpage may be able to tell you whether
267 it is thread-safe or not.
275 dnl ==========================================================================
277 AC_DEFINE(_FILE_OFFSET_BITS, 64, [Enable LFS])
279 dnl ==========================================================================
281 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
283 dnl ==========================================================================
284 dnl Turn on the additional warnings last, so -Werror doesn't affect other tests.
286 AC_ARG_ENABLE(more-warnings,
287 [ --enable-more-warnings Maximum compiler warnings],
288 set_more_warnings="$enableval",[
289 if test -f $srcdir/CVSVERSION; then
291 set_more_warnings=yes
296 AC_MSG_CHECKING(for more warnings, including -Werror)
297 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
301 -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \
302 -Wnested-externs -Wpointer-arith \
303 -Wcast-align -Wsign-compare \
306 for option in -Wno-strict-aliasing -Wno-sign-compare; do
307 SAVE_CFLAGS="$CFLAGS"
308 CFLAGS="$CFLAGS $option"
309 AC_MSG_CHECKING([whether gcc understands $option])
310 AC_TRY_COMPILE([], [],
313 if test $has_option = no; then
314 CFLAGS="$SAVE_CFLAGS"
316 AC_MSG_RESULT($has_option)
333 echo "gnio configuration summary:"