r104: Unbreak VPATH builds; release rc2
[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],[2.8.0-rc2],[wouter@debian.org])
5 AM_INIT_AUTOMAKE(foreign dist-bzip2)
6 AM_MAINTAINER_MODE
7
8 dnl Assume we want LFS. If there's some weird operating system out there that
9 dnl doesn't support it, we can always add a check.
10 dnl AC_ARG_ENABLE(
11 dnl   lfs,
12 dnl   AC_HELP_STRING(--enable-lfs,Enable Large File Support),
13 dnl   [
14 dnl     if test "x$enableval" = "xyes" ; then
15 dnl       NBD_LFS=1
16 dnl     else
17 dnl       NBD_LFS=0
18 dnl     fi
19 dnl   ],
20 dnl   [NBD_LFS=0]
21 dnl )
22 NBD_LFS=1
23 AC_MSG_CHECKING([whether Large File Support should be enabled])
24 if test $NBD_LFS -eq 1; then
25   AC_DEFINE(NBD_LFS,1, [Define to 1 if Large File Support should be enabled])
26   AC_MSG_RESULT([yes])
27 else
28   AC_DEFINE(NBD_LFS,0)
29   AC_MSG_RESULT([no])
30 fi
31
32 AC_ARG_ENABLE(
33   syslog,
34   AC_HELP_STRING(--enable-syslog,Enable Syslog logging),
35   [
36     if test "x$enableval" = "xyes" ; then
37       ISSERVER=1
38     else
39       ISSERVER=0
40     fi
41   ],
42   [ISSERVER=0]
43 )
44 AC_MSG_CHECKING([whether syslog logging is requested])
45 if test $ISSERVER -eq 1; then
46   AC_DEFINE(ISSERVER,1, [Define to 1 if you want nbd-server to log through syslog])
47   AC_MSG_RESULT([yes])
48 else
49   AC_MSG_RESULT([no])
50 fi
51
52 AC_PROG_CC
53 AC_PROG_CPP
54 AC_PROG_INSTALL
55 AC_C_BIGENDIAN
56 AC_C_INLINE
57 AC_C_CONST
58 AC_CHECK_SIZEOF(unsigned short int)
59 AC_CHECK_SIZEOF(unsigned int)
60 AC_CHECK_SIZEOF(unsigned long int)
61 AC_CHECK_SIZEOF(unsigned long long int)
62 AC_CHECK_FUNCS([llseek alarm gethostbyname inet_ntoa memset socket strerror strstr])
63 AC_FUNC_FORK
64 AC_FUNC_SETVBUF_REVERSED
65 AC_MSG_CHECKING(whether client should be built)
66 case "`uname`" in
67      *Linux*) sbin_PROGRAMS=nbd-client
68               AC_MSG_RESULT(yes)
69               ;;
70      *) AC_MSG_RESULT(no) ;;
71 esac
72 AC_MSG_CHECKING(where to find a working nbd.h)
73 dnl We need to check for NBD_CMD_DISC, but that's part of an enum, it is not
74 dnl #define'd. Therefore, we check for something which is differently #define'd
75 dnl in the old or new versions, even if we don't really care about that.
76 dnl This might break at some time, but it should work for now, so...
77 AC_TRY_COMPILE([#define u32 int
78 #define u64 int
79 #include "nbd.h"
80 ],
81 [int foo=NBD_CMD_DISC], 
82   [AC_DEFINE(NBD_H_LOCAL, 1, Set to 1 if a (2.6) nbd.h can be found in the current directory)
83     NBD_H='"nbd.h"'],
84   AC_TRY_COMPILE([#define u32 int
85 #define u64 int
86 #include <linux/nbd.h>
87   ],
88 [int foo=NBD_CMD_DISC],
89     [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) NBD_H='<linux/nbd.h>'],
90     AC_MSG_ERROR(Could not find an nbd.h from 2.6 or above.)
91   )
92 )
93 if test -f nbd.h
94 then
95   if test $NBD_H='<linux/nbd.h>'
96   then
97     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])
98   fi
99 fi
100 AC_MSG_RESULT($NBD_H)
101 AC_CHECK_HEADERS([sys/mount.h],,,
102 [[#include <sys/param.h>
103 ]])
104 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h sys/ioctl.h sys/socket.h syslog.h])
105 AM_PATH_GLIB_2_0(2.2.0, [HAVE_GLIB=yes], AC_MSG_ERROR([Missing glib]))
106 AC_HEADER_SYS_WAIT
107 AC_TYPE_OFF_T
108 AC_TYPE_PID_T
109 AC_SUBST(sbin_PROGRAMS)
110 AC_CONFIG_HEADERS([config.h])
111 AC_CONFIG_FILES([Makefile])
112 AC_OUTPUT
113