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-2006 Wouter Verhelst <wouter@debian.org>
5 m4_esyscmd(support/genver.sh | tr -d '\n'),
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 AC_CONFIG_MACRO_DIR([support])
21 AC_HELP_STRING(--disable-lfs,Disable Large File Support (default on)),
23 if test "x$enableval" = "xyes" ; then
31 AC_MSG_CHECKING([whether Large File Support should be enabled])
32 if test $NBD_LFS -eq 1; then
33 AC_DEFINE(NBD_LFS,1, [Define to 1 if Large File Support should be enabled])
42 AC_HELP_STRING(--enable-syslog,Enable Syslog logging),
44 if test "x$enableval" = "xyes" ; then
53 AC_MSG_CHECKING([whether syslog logging is requested])
54 if test $ISSERVER -eq 1; then
55 AC_DEFINE(ISSERVER,1, [Define to 1 if you want nbd-server to log through syslog])
63 AC_HELP_STRING(--enable-debug,Build a debugging version of the server),
65 if test "x$enableval" = "xyes"; then
74 AC_MSG_CHECKING([whether a debugging version is requested])
75 if test $DODBG -eq 1; then
77 if test $ISSERVER -eq 1; then
78 AC_MSG_ERROR([You requested both syslog logging and a debugging version of the server. Bad idea!])
80 AC_DEFINE(DODBG,1,[Define if you want a debugging version of nbd-server (lots of copious output)])
81 AC_DEFINE(NOFORK,1,[Define if you don't want the nbd-server to fork()])
88 AC_HELP_STRING(--enable-sdp,Build a version of nbd-server with support for the Socket Direct Protocol (SDP). Requires you to build and install a kernel with the InfiniBand patches (default disabled)),
90 if test "x$enableval" = "xyes"; then
91 AC_DEFINE(WITH_SDP, 1, [Define to 1 if you have and want support for the Socket Direct Protocol])
98 [AS_HELP_STRING([--enable-gznbd],[Build gznbd too (nbd server with on-the-fly decompression of images. NOTE: no support for newstyle protocol.)])],
101 [test "x$enableval" = "xyes"],
117 AC_CHECK_SIZEOF(unsigned short int)
118 AC_CHECK_SIZEOF(unsigned int)
119 AC_CHECK_SIZEOF(unsigned long int)
120 AC_CHECK_SIZEOF(unsigned long long int)
121 AC_STRUCT_DIRENT_D_TYPE
122 AC_CHECK_FUNCS([llseek alarm gethostbyname inet_ntoa memset socket strerror strstr mkstemp fdatasync])
125 AC_CHECK_FUNC(fallocate,
127 AC_CHECK_HEADERS([linux/falloc.h])
128 if test "x$ac_cv_header_linux_falloc_h" = "xyes"
130 AC_CHECK_DECL(FALLOC_FL_PUNCH_HOLE, [HAVE_FL_PH=yes], [HAVE_FL_PH=no], [[#include <linux/falloc.h>]])
135 AC_MSG_CHECKING([for FALLOC_FL_PUNCH_HOLE support])
136 if test "x$HAVE_FL_PH" = "xyes"
138 AC_DEFINE(HAVE_FALLOC_PH, 1, [Define to 1 if you have FALLOC_FL_PUNCH_HOLE])
141 AC_DEFINE(HAVE_FALLOC_PH, 0, [Define to 1 if you have FALLOC_FL_PUNCH_HOLE])
145 AC_CHECK_FUNC(splice, [HAVE_SPLICE=yes], [HAVE_SPLICE=no])
146 if test "$HAVE_SPLICE" = "yes"
149 AC_CHECK_DECL(F_SETPIPE_SZ, [HAVE_SETPIPE_SZ=yes],
151 unset ac_cv_have_decl_F_SETPIPE_SZ
152 AC_CHECK_HEADERS([linux/fcntl.h])
153 if test "$ac_cv_header_linux_fcntl_h" = "yes"
155 AC_CHECK_DECL(F_SETPIPE_SZ, [HAVE_SETPIPE_SZ=define], [HAVE_SETPIPE_SZ=no], [[#include <linux/fcntl.h>]])
163 AC_MSG_CHECKING([for F_SETPIPE_SZ support])
164 case $HAVE_SETPIPE_SZ in
166 AC_DEFINE(HAVE_SPLICE, 1, [Define to 1 if we have splice support])
170 AC_DEFINE(HAVE_SPLICE, 1, [Define to 1 if we have splice support])
171 AC_DEFINE(F_SETPIPE_SZ, 1031, [Define to 1031 if we have kernel support but no userspace support])
175 AC_MSG_RESULT([missing, disabling splice support])
180 dnl AC_MSG_CHECKING([where to puth systemd unit files])
183 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.])
185 dnl if test "x$enableval" = "xyes"; then
186 dnl ENABLE_SYSTEMD=yes
188 dnl ENABLE_SYSTEMD=no
193 dnl if test "x$ENABLE_SYSTEMD" != "xno"; then
194 dnl PKG_CHECK_VAR([SYSTEMDUNIT],[systemd],systemdsystemunitdir],[AC_SUBST([SYSTEMDLOC], [$SYSTEMDUNIT])])
196 dnl AM_CONDITIONAL(SYSTEMD, [test ! -z "$SYSTEMDUNIT"])
197 dnl if test ! -z $SYSTEMDUNIT; then
198 dnl AC_MSG_RESULT([$SYSTEMDUNIT])
200 dnl case $ENABLE_SYSTEMD in
202 dnl AC_MSG_RESULT([disabled])
205 dnl AC_MSG_ERROR([systemd not found])
208 dnl AC_MSG_RESULT([not found])
213 PKG_CHECK_MODULES(GnuTLS, [gnutls >= 2.12.0],[HAVE_GNUTLS=1],[HAVE_GNUTLS=0])
214 if test x$HAVE_GNUTLS = x1; then
215 AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if you have a GnuTLS version of 2.12 or above])
217 AC_DEFINE(HAVE_GNUTLS, 0)
219 AM_CONDITIONAL([GNUTLS], [test "x$HAVE_GNUTLS" = "x1"])
221 AC_CHECK_HEADERS([winioctl.h], [], [],
226 HAVE_FSCTL_SET_ZERO_DATA=no
227 if test "x$ac_cv_header_winioctl_h" = "xyes"
229 AC_CHECK_DECL(FSCTL_SET_ZERO_DATA, [HAVE_FSCTL_SET_ZERO_DATA=yes], [HAVE_FSCTL_SET_ZERO_DATA=no],
232 #include <winioctl.h>
235 if test "x$HAVE_FSCTL_SET_ZERO_DATA" = "xyes"
237 AC_DEFINE(HAVE_FSCTL_SET_ZERO_DATA, 1, [Define to 1 if you have FSCTL_SET_ZERO_DATA])
239 AC_DEFINE(HAVE_FSCTL_SET_ZERO_DATA, 0, [Define to 1 if you have FSCTL_SET_ZERO_DATA])
242 AC_CHECK_FUNC([sync_file_range],
243 [AC_DEFINE([HAVE_SYNC_FILE_RANGE], [sync_file_range(2) is not supported], [sync_file_range(2) is supported])],
246 AC_FUNC_SETVBUF_REVERSED
247 AC_MSG_CHECKING(whether client should be built)
249 linux*) NBD_CLIENT_NAME="nbd-client"
252 *) NBD_CLIENT_NAME=""
256 AM_CONDITIONAL(CLIENT, [test ! -z "$NBD_CLIENT_NAME"])
257 AC_SEARCH_LIBS(bind, socket,, AC_MSG_ERROR([Could not find an implementation of the bind() system call]))
258 AC_SEARCH_LIBS(inet_ntoa, nsl,, AC_MSG_ERROR([Could not find an implementation of the inet_ntoa() system call]))
259 AC_SEARCH_LIBS(daemon, resolv,, AC_MSG_ERROR([Could not find an implementation of the daemon() system call]))
260 AC_CHECK_HEADERS([sys/mount.h],,,
261 [[#include <sys/param.h>
263 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])
264 AM_PATH_GLIB_2_0(2.26.0, [HAVE_GLIB=yes], AC_MSG_ERROR([Missing glib]), gthread)
266 my_save_cflags="$CFLAGS"
267 CFLAGS="-Wdeprecated-declarations -Werror $GLIB_CFLAGS"
268 AC_MSG_CHECKING([if we are using an old glib 2.0 library])
269 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
270 [[#include <glib.h>]],
271 [[g_thread_init(NULL);]])],
274 AC_DEFINE(HAVE_OLD_GLIB, 1, [Define to 1 if you have an old glib library])
278 AC_DEFINE(HAVE_OLD_GLIB, 0, [Define to 1 if you have an old glib library])
281 CFLAGS="$my_save_cflags"
286 AM_CPPFLAGS=$AM_CPPFLAGS" -DSYSCONFDIR='\"$sysconfdir\"'"
287 AC_SUBST(AM_CPPFLAGS)
288 AM_CONDITIONAL(GZNBD, [test "x$ENABLE_GZNBD" = "xyes"])
289 AC_CONFIG_HEADERS([config.h])
290 AC_CONFIG_FILES([Makefile
304 systemd/nbd@.service.sh