2a9200944a43bda38f368dc1d235088137180e06
[nbd.git] / configure.ac
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],[SVN],[wouter@debian.org])
5 AM_INIT_AUTOMAKE(foreign dist-bzip2)
6 AM_MAINTAINER_MODE
7
8 AC_ARG_ENABLE(
9   lfs,
10   AC_HELP_STRING(--disable-lfs,Disable Large File Support (default on)),
11   [
12     if test "x$enableval" = "xyes" ; then
13       NBD_LFS=1
14     else
15       NBD_LFS=0
16     fi
17   ],
18   [NBD_LFS=1]
19 )
20 AC_MSG_CHECKING([whether Large File Support should be enabled])
21 if test $NBD_LFS -eq 1; then
22   AC_DEFINE(NBD_LFS,1, [Define to 1 if Large File Support should be enabled])
23   AC_MSG_RESULT([yes])
24 else
25   AC_DEFINE(NBD_LFS,0)
26   AC_MSG_RESULT([no])
27 fi
28
29 AC_ARG_ENABLE(
30   syslog,
31   AC_HELP_STRING(--enable-syslog,Enable Syslog logging),
32   [
33     if test "x$enableval" = "xyes" ; then
34       ISSERVER=1
35     else
36       ISSERVER=0
37     fi
38   ],
39   [ISSERVER=0]
40 )
41
42 AC_MSG_CHECKING([whether syslog logging is requested])
43 if test $ISSERVER -eq 1; then
44   AC_DEFINE(ISSERVER,1, [Define to 1 if you want nbd-server to log through syslog])
45   AC_MSG_RESULT([yes])
46 else
47   AC_MSG_RESULT([no])
48 fi
49
50 AC_ARG_ENABLE(
51   debug,
52   AC_HELP_STRING(--enable-debug,Build a debugging version of the server),
53   [
54     if test "x$enableval" = "xyes"; then
55       DODBG=1
56     else
57       DODBG=0
58     fi
59   ],
60   [DODBG=0]
61 )
62
63 AC_MSG_CHECKING([whether a debugging version is requested])
64 if test $DODBG -eq 1; then
65   AC_MSG_RESULT([yes])
66   if test $ISSERVER -eq 1; then
67     AC_MSG_ERROR([You requested both syslog logging and a debugging version of the server. Bad idea!])
68   fi
69   AC_DEFINE(DODBG,1,[Define if you want a debugging version of nbd-server (lots of copious output)])
70   AC_DEFINE(NOFORK,1,[Define if you don't want the nbd-server to fork()])
71 else
72   AC_MSG_RESULT([no])
73 fi
74
75 AC_ARG_ENABLE(
76   sdp,
77   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)),
78   [
79     if test "x$enableval" = "xyes"; then
80       AC_DEFINE(WITH_SDP, 1, [Define to 1 if you have and want support for the Socket Direct Protocol])
81     fi
82   ]
83 )
84
85 AC_MSG_CHECKING(for klcc)
86 AC_ARG_WITH(
87   klcc,
88   AC_HELP_STRING(--with-klcc,[Build a version of nbd-client against klibc (for initramfs uses). Specify the path to 'klcc' (default autodetected)]),
89   [
90     if test "x$withval" != "x"; then
91       if test -x "$withval"; then
92         KLCC="$withval"
93         sbin_PROGRAMS=knbd-client
94         AC_MSG_RESULT($KLCC)
95       else
96         if test "$withval" = "no"; then
97           KLCC=""
98           AC_MSG_RESULT(Disabled)
99         else
100           AC_MSG_ERROR([specified klcc ($withval) is not executable or does not exist.])
101         fi
102       fi
103     else
104       if test -x /usr/bin/klcc; then
105         KLCC=/usr/bin/klcc
106         sbin_PROGRAMS=knbd-client
107         AC_MSG_RESULT($KLCC)
108       else
109         AC_MSG_ERROR([klcc not found! Please specify it as a parameter to the --with-klcc option]);
110       fi
111     fi
112   ],
113   [ if test -x /usr/bin/klcc; then
114       sbin_PROGRAMS=knbd-client
115       KLCC=/usr/bin/klcc
116       AC_MSG_RESULT($KLCC)
117     else
118       AC_MSG_RESULT(not found)
119     fi
120   ]
121 )
122 AC_SUBST(KLCC)
123
124 AC_PROG_CC
125 AC_PROG_CPP
126 AC_PROG_INSTALL
127 AC_CANONICAL_HOST
128 AC_C_BIGENDIAN
129 AC_C_INLINE
130 AC_C_CONST
131 AC_CHECK_SIZEOF(unsigned short int)
132 AC_CHECK_SIZEOF(unsigned int)
133 AC_CHECK_SIZEOF(unsigned long int)
134 AC_CHECK_SIZEOF(unsigned long long int)
135 AC_CHECK_FUNCS([llseek alarm gethostbyname inet_ntoa memset socket strerror strstr])
136 AC_FUNC_FORK
137 AC_FUNC_SETVBUF_REVERSED
138 AC_MSG_CHECKING(whether client should be built)
139 case $host_os in
140      linux*) sbin_PROGRAMS="$sbin_PROGRAMS nbd-client"
141               AC_MSG_RESULT(yes)
142               ;;
143      *) AC_MSG_RESULT(no) ;;
144 esac
145 AC_MSG_CHECKING(where to find a working nbd.h)
146 AC_TRY_COMPILE([#define u32 int
147 #define u64 int
148 #define __be32 int
149 #define __be64 int
150 #include "nbd.h"
151 #ifdef __GNUC__
152 #define UNUSED __attribute__((__unused__))
153 #else
154 #define UNUSED
155 #endif
156 ],
157 [int UNUSED foo=NBD_CMD_DISC], 
158   [AC_DEFINE(NBD_H_LOCAL, 1, Set to 1 if a (2.6) nbd.h can be found in the current directory)
159     NBD_H='"nbd.h"'],
160   AC_TRY_COMPILE([#define u32 int
161 #define u64 int
162 #define __be32 int
163 #define __be64 int
164 #include <linux/nbd.h>
165 #ifdef __GNUC__
166 #define UNUSED __attribute__((__unused__))
167 #else
168 #define UNUSED
169 #endif
170   ],
171 [int UNUSED foo=NBD_CMD_DISC],
172     [AC_DEFINE(NBD_H_LINUX, 1, Set to 1 if a (2.6) nbd.h can be found in the linux directory in the search path)
173       NBD_H='<linux/nbd.h>'],
174     AC_TRY_COMPILE([#include <linux/nbd.h>
175 #ifdef __GNUC__
176 #define UNUSED __attribute__((__unused__))
177 #else
178 #define UNUSED
179 #endif
180       ],
181       [int UNUSED foo=NBD_CMD_DISC],
182       [AC_DEFINE(NBD_H_LINUX, 1, Set to 1 if a (2.6) nbd.h can be found in the linux directory in the search path)
183         NBD_H='<linux/nbd.h>'],
184     AC_MSG_ERROR(Could not find an nbd.h from 2.6 or above.)
185     )
186   )
187 )
188 if test -f nbd.h
189 then
190   if test "$NBD_H" = '<linux/nbd.h>'
191   then
192     AC_MSG_WARN([there is a local nbd.h, but it is from the 2.4-series of kernels. Using the system-provided, working, nbd.h])
193   fi
194 fi
195 AC_MSG_RESULT($NBD_H)
196 AC_SEARCH_LIBS(bind, socket,, AC_MSG_ERROR([Could not find an implementation of the bind() system call]))
197 AC_SEARCH_LIBS(inet_ntoa, nsl,, AC_MSG_ERROR([Could not find an implementation of the inet_ntoa() system call]))
198 AC_SEARCH_LIBS(daemon, resolv,, AC_MSG_ERROR([Could not find an implementation of the daemon() system call]))
199 AC_CHECK_HEADERS([sys/mount.h],,,
200 [[#include <sys/param.h>
201 ]])
202 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h])
203 AM_PATH_GLIB_2_0(2.6.0, [HAVE_GLIB=yes], AC_MSG_ERROR([Missing glib]))
204 AC_HEADER_SYS_WAIT
205 AC_TYPE_OFF_T
206 AC_TYPE_PID_T
207 AC_SUBST(sbin_PROGRAMS)
208 nbd_server_CPPFLAGS=$nbd_server_CPPFLAGS" -DSYSCONFDIR='\"$sysconfdir\"'"
209 AC_SUBST(nbd_server_CPPFLAGS)
210 AC_CONFIG_HEADERS([config.h])
211 AC_CONFIG_FILES([Makefile Doxyfile nbd-server.1 nbd-server.5])
212 AC_OUTPUT
213