2d9379f41a745fc421c2656232cbef924a8cc2f7
[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-2004 Wouter Verhelst <wouter@debian.org>
4 AC_INIT([nbd],[CVS],[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 AC_MSG_CHECKING([whether syslog logging is requested])
42 if test $ISSERVER -eq 1; then
43   AC_DEFINE(ISSERVER,1, [Define to 1 if you want nbd-server to log through syslog])
44   AC_MSG_RESULT([yes])
45 else
46   AC_MSG_RESULT([no])
47 fi
48
49 AC_PROG_CC
50 AC_PROG_CPP
51 AC_PROG_INSTALL
52 AC_C_BIGENDIAN
53 AC_C_INLINE
54 AC_C_CONST
55 AC_CHECK_SIZEOF(unsigned short int)
56 AC_CHECK_SIZEOF(unsigned int)
57 AC_CHECK_SIZEOF(unsigned long int)
58 AC_CHECK_SIZEOF(unsigned long long int)
59 AC_CHECK_FUNCS([llseek alarm gethostbyname inet_ntoa memset socket strerror strstr])
60 AC_FUNC_FORK
61 AC_FUNC_SETVBUF_REVERSED
62 AC_MSG_CHECKING(whether client should be built)
63 case "`uname`" in
64      *Linux*) sbin_PROGRAMS=nbd-client
65               AC_MSG_RESULT(yes)
66               ;;
67      *) AC_MSG_RESULT(no) ;;
68 esac
69 AC_MSG_CHECKING(where to find a working nbd.h)
70 dnl We need to check for NBD_CMD_DISC, but that's part of an enum, it is not
71 dnl #define'd. Therefore, we check for something which is differently #define'd
72 dnl in the old or new versions, even if we don't really care about that.
73 dnl This might break at some time, but it should work for now, so...
74 AC_TRY_COMPILE([#define u32 int
75 #define u64 int
76 #include "nbd.h"
77 ],
78 [int foo=NBD_CMD_DISC], 
79   [AC_DEFINE(NBD_H_LOCAL, 1, Set to 1 if a (2.6) nbd.h can be found in the current directory)
80     NBD_H='"nbd.h"'],
81   AC_TRY_COMPILE([#define u32 int
82 #define u64 int
83 #include <linux/nbd.h>
84   ],
85 [int foo=NBD_CMD_DISC],
86     [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)
87       NBD_H='<linux/nbd.h>'],
88     AC_MSG_ERROR(Could not find an nbd.h from 2.6 or above.)
89   )
90 )
91 if test -f nbd.h
92 then
93   if test $NBD_H='<linux/nbd.h>'
94   then
95     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])
96   fi
97 fi
98 AC_MSG_RESULT($NBD_H)
99 AC_CHECK_HEADERS([sys/mount.h],,,
100 [[#include <sys/param.h>
101 ]])
102 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h])
103 AM_PATH_GLIB_2_0(2.6.0, [HAVE_GLIB=yes], AC_MSG_ERROR([Missing glib]))
104 AC_HEADER_SYS_WAIT
105 AC_TYPE_OFF_T
106 AC_TYPE_PID_T
107 AC_SUBST(sbin_PROGRAMS)
108 nbd_server_CPPFLAGS=$nbd_server_CPPFLAGS" -DSYSCONFDIR='\"$sysconfdir\"'"
109 AC_SUBST(nbd_server_CPPFLAGS)
110 AC_CONFIG_HEADERS([config.h])
111 AC_CONFIG_FILES([Makefile Doxyfile])
112 AC_OUTPUT
113