Merge branch 'master' into debian
[nbd.git] / configure.ac
blobda8e3ef48f5f47c951a28a71496e1ebe13482514
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>
4 AC_INIT([nbd],[3.6],[wouter@debian.org])
5 AM_INIT_AUTOMAKE(foreign dist-xz serial-tests)
6 AM_MAINTAINER_MODE([enable])
7 LT_INIT
9 AC_ARG_ENABLE(
10   lfs,
11   AC_HELP_STRING(--disable-lfs,Disable Large File Support (default on)),
12   [
13     if test "x$enableval" = "xyes" ; then
14       NBD_LFS=1
15     else
16       NBD_LFS=0
17     fi
18   ],
19   [NBD_LFS=1]
21 AC_MSG_CHECKING([whether Large File Support should be enabled])
22 if test $NBD_LFS -eq 1; then
23   AC_DEFINE(NBD_LFS,1, [Define to 1 if Large File Support should be enabled])
24   AC_MSG_RESULT([yes])
25 else
26   AC_DEFINE(NBD_LFS,0)
27   AC_MSG_RESULT([no])
30 AC_ARG_ENABLE(
31   syslog,
32   AC_HELP_STRING(--enable-syslog,Enable Syslog logging),
33   [
34     if test "x$enableval" = "xyes" ; then
35       ISSERVER=1
36     else
37       ISSERVER=0
38     fi
39   ],
40   [ISSERVER=0]
43 AC_MSG_CHECKING([whether syslog logging is requested])
44 if test $ISSERVER -eq 1; then
45   AC_DEFINE(ISSERVER,1, [Define to 1 if you want nbd-server to log through syslog])
46   AC_MSG_RESULT([yes])
47 else
48   AC_MSG_RESULT([no])
51 AC_ARG_ENABLE(
52   debug,
53   AC_HELP_STRING(--enable-debug,Build a debugging version of the server),
54   [
55     if test "x$enableval" = "xyes"; then
56       DODBG=1
57     else
58       DODBG=0
59     fi
60   ],
61   [DODBG=0]
64 AC_MSG_CHECKING([whether a debugging version is requested])
65 if test $DODBG -eq 1; then
66   AC_MSG_RESULT([yes])
67   if test $ISSERVER -eq 1; then
68     AC_MSG_ERROR([You requested both syslog logging and a debugging version of the server. Bad idea!])
69   fi
70   AC_DEFINE(DODBG,1,[Define if you want a debugging version of nbd-server (lots of copious output)])
71   AC_DEFINE(NOFORK,1,[Define if you don't want the nbd-server to fork()])
72 else
73   AC_MSG_RESULT([no])
76 AC_ARG_ENABLE(
77   sdp,
78   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)),
79   [
80     if test "x$enableval" = "xyes"; then
81       AC_DEFINE(WITH_SDP, 1, [Define to 1 if you have and want support for the Socket Direct Protocol])
82     fi
83   ]
86 AC_PROG_CC_C99
87 AC_PROG_CPP
88 AC_PROG_INSTALL
89 AC_CANONICAL_HOST
90 AC_C_BIGENDIAN
91 AC_C_INLINE
92 AC_C_CONST
93 AC_CHECK_SIZEOF(unsigned short int)
94 AC_CHECK_SIZEOF(unsigned int)
95 AC_CHECK_SIZEOF(unsigned long int)
96 AC_CHECK_SIZEOF(unsigned long long int)
97 AC_CHECK_FUNCS([llseek alarm gethostbyname inet_ntoa memset socket strerror strstr mkstemp fdatasync])
98 AC_CHECK_HEADERS([linux/falloc.h])
99 HAVE_FL_PH=no
100 if test "x$ac_cv_header_linux_falloc_h" = "xyes"
101 then
102         AC_CHECK_DECL(FALLOC_FL_PUNCH_HOLE, [HAVE_FL_PH=yes], [HAVE_FL_PH=no], [[#include <linux/falloc.h>]])
105 AC_MSG_CHECKING([for FALLOC_FL_PUNCH_HOLE support])
106 if test "x$HAVE_FL_PH" = "xyes"
107 then
108         AC_DEFINE(HAVE_FALLOC_PH, 1, [Define to 1 if you have FALLOC_FL_PUNCH_HOLE])
109         AC_MSG_RESULT([yes])
110 else
111         AC_DEFINE(HAVE_FALLOC_PH, 0, [Define to 1 if you have FALLOC_FL_PUNCH_HOLE])
112         AC_MSG_RESULT([no])
114 AC_COMPILE_IFELSE
115 AC_CHECK_FUNC([sync_file_range],
116         [AC_DEFINE([HAVE_SYNC_FILE_RANGE], [sync_file_range(2) is not supported], [sync_file_range(2) is supported])],
117         [])
118 AC_FUNC_FORK
119 AC_FUNC_SETVBUF_REVERSED
120 AC_MSG_CHECKING(whether client should be built)
121 case $host_os in
122         linux*) NBD_CLIENT_NAME="nbd-client"
123                 AC_MSG_RESULT(yes)
124                 ;;
125         *)      NBD_CLIENT_NAME=""
126                 AC_MSG_RESULT(no)
127                 ;;
128 esac
129 AC_SUBST(NBD_CLIENT_NAME)
130 AC_SEARCH_LIBS(bind, socket,, AC_MSG_ERROR([Could not find an implementation of the bind() system call]))
131 AC_SEARCH_LIBS(inet_ntoa, nsl,, AC_MSG_ERROR([Could not find an implementation of the inet_ntoa() system call]))
132 AC_SEARCH_LIBS(daemon, resolv,, AC_MSG_ERROR([Could not find an implementation of the daemon() system call]))
133 AC_CHECK_HEADERS([sys/mount.h],,,
134 [[#include <sys/param.h>
136 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h linux/types.h])
137 AM_PATH_GLIB_2_0(2.26.0, [HAVE_GLIB=yes], AC_MSG_ERROR([Missing glib]))
138 AC_HEADER_SYS_WAIT
139 AC_TYPE_OFF_T
140 AC_TYPE_PID_T
141 nbd_server_CPPFLAGS=$nbd_server_CPPFLAGS" -DSYSCONFDIR='\"$sysconfdir\"'"
142 AC_SUBST(nbd_server_CPPFLAGS)
143 AC_CONFIG_HEADERS([config.h])
144 AC_CONFIG_FILES([Makefile
145                  doc/Doxyfile
146                  doc/Makefile
147                  man/Makefile
148                  tests/Makefile
149                  tests/code/Makefile
150                  tests/run/Makefile
151                  man/nbd-client.8.sh
152                  man/nbd-server.5.sh
153                  man/nbd-server.1.sh
154                  man/nbd-trdump.1.sh])
155 AC_OUTPUT