1 dnl Configure script for NBD system
2 dnl (c) 1998 Martin Mares <mj@ucw.cz>, (c) 2000 Pavel Machek <pavel@ucw.cz>,
3 dnl (c) 2003-2024 Wouter Verhelst <wouter@debian.org>
5 m4_esyscmd(support/genver.sh | tr -d '\n'),
6 [nbd@other.debian.org],,
7 [http://nbd.sourceforge.net/])
8 m4_define([serial_tests], [
9 m4_esyscmd([automake --version |
11 awk '{split ($NF,a,"."); if (a[1] == 1 && a[2] >= 12) { print "serial-tests" }}'
14 AM_INIT_AUTOMAKE(foreign dist-xz serial_tests subdir-objects)
15 AM_MAINTAINER_MODE([enable])
16 AM_SILENT_RULES([yes])
17 AC_CONFIG_MACRO_DIR([support])
22 AS_HELP_STRING([--disable-lfs],[Disable Large File Support (default on)]),
24 if test "x$enableval" = "xyes" ; then
32 AC_MSG_CHECKING([whether Large File Support should be enabled])
33 if test $NBD_LFS -eq 1; then
34 AC_DEFINE(NBD_LFS,1, [Define to 1 if Large File Support should be enabled])
43 AS_HELP_STRING([--enable-syslog],[Enable Syslog logging]),
45 if test "x$enableval" = "xyes" ; then
54 AC_MSG_CHECKING([whether syslog logging is requested])
55 if test $ISSERVER -eq 1; then
56 AC_DEFINE(ISSERVER,1, [Define to 1 if you want nbd-server to log through syslog])
64 AS_HELP_STRING([--enable-debug],[Build a debugging version of the server]),
66 if test "x$enableval" = "xyes"; then
75 AC_MSG_CHECKING([whether a debugging version is requested])
76 if test $DODBG -eq 1; then
78 if test $ISSERVER -eq 1; then
79 AC_MSG_ERROR([You requested both syslog logging and a debugging version of the server. Bad idea!])
81 AC_DEFINE(DODBG,1,[Define if you want a debugging version of nbd-server (lots of copious output)])
82 AC_DEFINE(NOFORK,1,[Define if you do not want the nbd-server to fork()])
91 m4_ifdef([AX_PROG_BISON],,
92 [m4_fatal([The m4 macro AX_PROG_BISON has not been defined. Please install the autoconf-archive package.])])
93 AX_PROG_BISON([],AC_MSG_ERROR([bison is required]))
99 AC_CHECK_SIZEOF(unsigned short int)
100 AC_CHECK_SIZEOF(unsigned int)
101 AC_CHECK_SIZEOF(unsigned long int)
102 AC_CHECK_SIZEOF(unsigned long long int)
103 AC_STRUCT_DIRENT_D_TYPE
104 AC_CHECK_FUNCS([llseek alarm gethostbyname inet_ntoa memset socket strerror strstr mkstemp fdatasync])
107 AC_CHECK_FUNC(fallocate,
109 AC_CHECK_HEADERS([linux/falloc.h])
110 if test "x$ac_cv_header_linux_falloc_h" = "xyes"
112 AC_CHECK_DECL(FALLOC_FL_PUNCH_HOLE, [HAVE_FL_PH=yes], [HAVE_FL_PH=no], [[#include <linux/falloc.h>]])
117 AC_MSG_CHECKING([for FALLOC_FL_PUNCH_HOLE support])
118 if test "x$HAVE_FL_PH" = "xyes"
120 AC_DEFINE(HAVE_FALLOC_PH, 1, [Define to 1 if you have FALLOC_FL_PUNCH_HOLE])
123 AC_DEFINE(HAVE_FALLOC_PH, 0, [Define to 1 if you have FALLOC_FL_PUNCH_HOLE])
127 AC_CHECK_DECL([BLKDISCARD], AC_DEFINE(HAVE_BLKDISCARD, 1, [Define to 1 if you have the BLKDISCARD ioctl]), AC_DEFINE(HAVE_BLKDISCARD, 0), [#include <linux/fs.h>])
129 AC_CHECK_FUNC(splice, [HAVE_SPLICE=yes], [HAVE_SPLICE=no])
130 if test "$HAVE_SPLICE" = "yes"
133 AC_CHECK_DECL(F_SETPIPE_SZ, [HAVE_SETPIPE_SZ=yes],
135 unset ac_cv_have_decl_F_SETPIPE_SZ
136 AC_CHECK_HEADERS([linux/fcntl.h])
137 if test "$ac_cv_header_linux_fcntl_h" = "yes"
139 AC_CHECK_DECL(F_SETPIPE_SZ, [HAVE_SETPIPE_SZ=define], [HAVE_SETPIPE_SZ=no], [[#include <linux/fcntl.h>]])
147 AC_MSG_CHECKING([for F_SETPIPE_SZ support])
148 case $HAVE_SETPIPE_SZ in
150 AC_DEFINE(HAVE_SPLICE, 1, [Define to 1 if we have splice support])
154 AC_DEFINE(HAVE_SPLICE, 1, [Define to 1 if we have splice support])
155 AC_DEFINE(F_SETPIPE_SZ, 1031, [Define to 1031 if we have kernel support but no userspace support])
159 AC_MSG_RESULT([missing, disabling splice support])
164 m4_ifndef([PKG_CHECK_MODULES], [m4_fatal([Missing pkg-config M4 macros. Please ensure that pkg-config is installed.])])
166 dnl AC_MSG_CHECKING([where to puth systemd unit files])
169 dnl AS_HELP_STRING([--with-systemd=loc|pkgconfig],[Install systemd files in loc; if passing pkgconfig, use pkg-config to detect the correct location and install there.])
171 dnl if test "x$enableval" = "xyes"; then
172 dnl ENABLE_SYSTEMD=yes
174 dnl ENABLE_SYSTEMD=no
179 dnl if test "x$ENABLE_SYSTEMD" != "xno"; then
180 dnl PKG_CHECK_VAR([SYSTEMDUNIT],[systemd],systemdsystemunitdir],[AC_SUBST([SYSTEMDLOC], [$SYSTEMDUNIT])])
182 dnl AM_CONDITIONAL(SYSTEMD, [test ! -z "$SYSTEMDUNIT"])
183 dnl if test ! -z $SYSTEMDUNIT; then
184 dnl AC_MSG_RESULT([$SYSTEMDUNIT])
186 dnl case $ENABLE_SYSTEMD in
188 dnl AC_MSG_RESULT([disabled])
191 dnl AC_MSG_ERROR([systemd not found])
194 dnl AC_MSG_RESULT([not found])
199 AC_ARG_WITH([gnutls],
200 [AS_HELP_STRING([--without-gnutls],
201 [do not use gnutls])],
205 if test "x$with_gnutls" != "xno"; then
206 PKG_CHECK_MODULES(GnuTLS, [gnutls >= 2.12.0],
208 AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if you have a GnuTLS version of 2.12 or above])],
209 [if test "x$with_gnutls" = "xyes"; then
210 AC_MSG_ERROR([--with-gnutls given but cannot find gnutls])
213 AC_DEFINE(HAVE_GNUTLS, 0)
218 AC_DEFINE(HAVE_GNUTLS, 0)
220 AM_CONDITIONAL([GNUTLS], [test "x$HAVE_GNUTLS" = "x1"])
222 AC_CHECK_HEADERS([winioctl.h], [], [],
227 HAVE_FSCTL_SET_ZERO_DATA=no
228 if test "x$ac_cv_header_winioctl_h" = "xyes"
230 AC_CHECK_DECL(FSCTL_SET_ZERO_DATA, [HAVE_FSCTL_SET_ZERO_DATA=yes], [HAVE_FSCTL_SET_ZERO_DATA=no],
233 #include <winioctl.h>
236 if test "x$HAVE_FSCTL_SET_ZERO_DATA" = "xyes"
238 AC_DEFINE(HAVE_FSCTL_SET_ZERO_DATA, 1, [Define to 1 if you have FSCTL_SET_ZERO_DATA])
240 AC_DEFINE(HAVE_FSCTL_SET_ZERO_DATA, 0, [Define to 1 if you have FSCTL_SET_ZERO_DATA])
243 AC_CHECK_FUNC([sync_file_range],
244 [AC_DEFINE([HAVE_SYNC_FILE_RANGE], [sync_file_range(2) is not supported], [sync_file_range(2) is supported])],
247 AC_MSG_CHECKING(whether client should be built)
249 [linux*], [NBD_CLIENT_NAME="nbd-client"; AC_MSG_RESULT(yes)],
250 [NBD_CLIENT_NAME=""; AC_MSG_RESULT(no)]
252 AC_MSG_CHECKING(whether to expect tlshuge test to fail)
254 [darwin*], [RUN_XFAIL=tlshuge; AC_MSG_RESULT(yes)],
255 [RUN_XFAIL=""; AC_MSG_RESULT(no)]
257 AC_SUBST([RUN_XFAIL])
258 AM_CONDITIONAL(CLIENT, [test ! -z "$NBD_CLIENT_NAME"])
259 AC_SEARCH_LIBS(bind, socket,, AC_MSG_ERROR([Could not find an implementation of the bind() system call]))
260 AC_SEARCH_LIBS(inet_ntoa, nsl,, AC_MSG_ERROR([Could not find an implementation of the inet_ntoa() system call]))
261 AC_SEARCH_LIBS(daemon, resolv,, AC_MSG_ERROR([Could not find an implementation of the daemon() system call]))
262 AC_CHECK_HEADERS([sys/mount.h],,,
263 [[#include <sys/param.h>
265 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h linux/types.h sys/dirent.h sys/uio.h])
266 PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.32.0 gthread-2.0 >= 2.32.0], [HAVE_GLIB=yes], AC_MSG_ERROR([Missing glib]))
267 #PKG_CHECK_MODULES(SW, [socket_wrapper], [HAVE_SW=yes], [HAVE_SW=no])
268 #PKG_CHECK_MODULES(NW, [nss_wrapper], [HAVE_NW=yes], [HAVE_NW=no])
269 #AM_CONDITIONAL(CWRAP, test "$HAVE_SW" = "yes" -a "$HAVE_NW" = "yes")
271 my_save_cflags="$CFLAGS"
273 CFLAGS="-Wdeprecated-declarations -Werror $GLIB_CFLAGS"
275 dnl g_memdup2 added in glib-2.68
276 AC_CHECK_FUNCS([g_memdup2])
277 CFLAGS="$my_save_cflags"
280 AC_MSG_CHECKING([whether _BSD_SOURCE needs to be defined for DT_* macros])
282 [AC_LANG_PROGRAM([[#include <dirent.h>]],
286 [AC_MSG_RESULT([no]); NEED_BSD_SOURCE=0],
287 [AC_MSG_RESULT([yes]); NEED_BSD_SOURCE=1])
288 AC_DEFINE([NEED_BSD_SOURCE], $NEED_BSD_SOURCE, [Define to 1 if _BSD_SOURCE needs to be defined before certain inclusions])
291 [AS_HELP_STRING([--without-libnl],
292 [do not use libnl])],
296 if test "x$with_libnl" != "xno"; then
297 PKG_CHECK_MODULES(LIBNL3, libnl-genl-3.0 >= 3.1,
299 AC_DEFINE(HAVE_NETLINK, 1, [Define to 1 if we have netlink support])
300 CFLAGS="$CFLAGS $LIBNL3_CFLAGS"
301 LIBS="$LIBS $LIBNL3_LIBS"],
302 [if test "x$with_libnl" = "xyes"; then
303 AC_MSG_ERROR([--with-libnl given but cannot find libnl])
306 AC_DEFINE(HAVE_NETLINK, 0)
311 AC_DEFINE(HAVE_NETLINK, 0, [Define to 1 if we have netlink support])
314 AM_CONDITIONAL(NETLINK, [test "$HAVE_NETLINK" = "1"])
316 AC_MSG_CHECKING([whether man pages are requested])
317 AC_ARG_ENABLE([manpages],
318 AS_HELP_STRING([--disable-manpages], [Do not install man pages]),
320 [enable_manpages=check]
322 AC_MSG_RESULT([$enable_manpages])
324 AS_IF([test "x$enable_manpages" != "xno"], [
325 AC_CHECK_PROG([DB2M], docbook2man, [docbook2man])
327 AS_IF([test "x$enable_manpages" = "xyes" -a "x$DB2M" = "x"], [
328 AC_MSG_ERROR([docbook2man not found, but is required to build manpages])
330 if test "x$enable_manpages" = "xcheck"; then
331 if test "x$DB2M" = "x"; then
337 AC_MSG_CHECKING([whether to build manpages])
338 AC_MSG_RESULT([$enable_manpages])
340 AM_CONDITIONAL(MANPAGES, test "x$enable_manpages" = "xyes")
341 AS_IF([test "x$enable_manpages" != "xno"], [
342 AC_SUBST([MAN_CONFIG_FILES],["\
343 man/nbd-client.8.sgml \
344 man/nbd-server.5.sgml \
345 man/nbd-server.1.sgml \
346 man/nbd-trdump.1.sgml \
347 man/nbd-trplay.1.sgml \
352 test "x$MAN_PREFIX" = "xNONE" && MAN_PREFIX="$ac_default_prefix"
353 AC_SUBST([MAN_PREFIX])
354 MAN_EXEC_PREFIX=$(eval echo "$exec_prefix")
355 test "x$MAN_EXEC_PREFIX" = "xNONE" && MAN_EXEC_PREFIX="$MAN_PREFIX"
356 AC_SUBST([MAN_EXEC_PREFIX])
357 MAN_SYSCONFDIR=$(eval echo "$sysconfdir")
358 test "x$MAN_SYSCONFDIR" = "xNONE/etc" && MAN_SYSCONFDIR="$MAN_PREFIX/etc"
359 AC_SUBST([MAN_SYSCONFDIR])
364 AM_CPPFLAGS=$AM_CPPFLAGS" -DSYSCONFDIR='\"$sysconfdir\"'"
365 AC_SUBST(AM_CPPFLAGS)
366 AM_CONDITIONAL(GZNBD, [test "x$ENABLE_GZNBD" = "xyes"])
367 AC_CONFIG_HEADERS([config.h])
368 AC_CONFIG_LINKS([tests/run/buffer.c:buffer.c
369 tests/run/crypto-gnutls.c:crypto-gnutls.c
370 tests/run/cliserv.c:cliserv.c])
371 AC_CONFIG_FILES([Makefile
381 systemd/nbd@.service.sh