Detect version of libblkid and act accordingly.
[nfs-utils.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 AC_INIT([linux nfs-utils],[1.1.0-rc2],[nfs@lists.sf.net],[nfs-utils])
4 AC_CANONICAL_BUILD([])
5 AC_CANONICAL_HOST([])
6 AC_CONFIG_MACRO_DIR(aclocal)
7 AM_INIT_AUTOMAKE
8 AC_PREREQ(2.59)
9 AC_PREFIX_DEFAULT(/usr)
10 AM_MAINTAINER_MODE
11
12 dnl *************************************************************
13 dnl * Define the set of applicable options
14 dnl *************************************************************
15 AC_ARG_WITH(release,
16         [AC_HELP_STRING([--with-release=XXX], [set release to XXX [1]])],
17         RELEASE=$withval,
18         RELEASE=1)
19         AC_SUBST(RELEASE)
20 AC_ARG_WITH(statedir,
21         [  --with-statedir=/foo    use state dir /foo [/var/lib/nfs]],
22         statedir=$withval,
23         statedir=/var/lib/nfs)
24         AC_SUBST(statedir)
25 AC_ARG_WITH(statduser,
26         [AC_HELP_STRING([--with-statduser=rpcuser],
27                         [statd to run under @<:@rpcuser or nobody@:>@]
28         )],
29         statduser=$withval,
30         if test "x$cross_compiling" = "xno"; then
31                 if grep -s '^rpcuser:' /etc/passwd > /dev/null; then
32                         statduser=rpcuser
33                 else
34                         statduser=nobody
35                 fi
36         else
37                 statduser=nobody
38         fi)
39         AC_SUBST(statduser)
40 AC_ARG_WITH(start-statd,
41         [AC_HELP_STRING([--with-start-statd=scriptname],
42                         [When an nfs filesystems is mounted with locking, run this script]
43         )],
44         startstatd=$withval,
45         startstatd=/usr/sbin/start-statd
46         )
47         AC_SUBST(startstatd)
48         AC_DEFINE_UNQUOTED(START_STATD, "$startstatd", [Define this to a script which can start statd on mount])
49 AC_ARG_ENABLE(nfsv3,
50         [AC_HELP_STRING([--enable-nfsv3],
51                         [enable support for NFSv3 @<:@default=yes@:>@])],
52         enable_nfsv3=$enableval,
53         enable_nfsv3=yes)
54         if test "$enable_nfsv3" = yes; then
55                 AC_DEFINE(NFS3_SUPPORTED, 1, [Define this if you want NFSv3 support compiled in])
56         else
57                 enable_nfsv3=
58         fi
59         AC_SUBST(enable_nfsv3)
60 AC_ARG_ENABLE(nfsv4,
61         [AC_HELP_STRING([--enable-nfsv4],
62                         [enable support for NFSv4 @<:@default=yes@:>@])],
63         enable_nfsv4=$enableval,
64         enable_nfsv4=yes)
65         if test "$enable_nfsv4" = yes; then
66                 AC_DEFINE(NFS4_SUPPORTED, 1, [Define this if you want NFSv4 support compiled in])
67                 IDMAPD=idmapd
68         else
69                 enable_nfsv4=
70                 IDMAPD=
71         fi
72         AC_SUBST(IDMAPD)
73         AC_SUBST(enable_nfsv4)
74         AM_CONDITIONAL(CONFIG_NFSV4, [test "$enable_nfsv4" = "yes"])
75 AC_ARG_ENABLE(gss,
76         [AC_HELP_STRING([--enable-gss],
77                         [enable support for rpcsec_gss @<:@default=yes@:>@])],
78         enable_gss=$enableval,
79         enable_gss=yes)
80         if test "$enable_gss" = yes; then
81                 AC_DEFINE(GSS_SUPPORTED, 1, [Define this if you want rpcsec_gss support compiled in])
82                 GSSD=gssd
83                 SVCGSSD=svcgssd
84         else
85                 enable_gss=
86                 GSSD=
87                 SVCGSSD=
88         fi
89         AC_SUBST(GSSD)
90         AC_SUBST(SVCGSSD)
91         AC_SUBST(enable_gss)
92         AM_CONDITIONAL(CONFIG_GSS, [test "$enable_gss" = "yes"])
93 AC_ARG_ENABLE(kprefix,
94         [AC_HELP_STRING([--enable-kprefix], [install progs as rpc.knfsd etc])],
95         test "$enableval" = "yes" && kprefix=k,
96         kprefix=)
97         AC_SUBST(kprefix)
98 AC_ARG_ENABLE(secure-statd,
99         [AC_HELP_STRING([--enable-secure-statd],
100                         [Only lockd can use statd (security)])],
101         test "$enableval" = "yes" && secure_statd=yes,
102         secure_statd=yes)
103         if test "$secure_statd" = yes; then
104                 AC_DEFINE(RESTRICTED_STATD, 1, [Define this if you want to enable various security checks in statd. These checks basically keep anyone but lockd from using this service.])
105         fi
106         AC_SUBST(secure_statd)
107 AC_ARG_ENABLE(rquotad,
108         [AC_HELP_STRING([--enable-rquotad],
109                         [enable rquotad @<:@default=yes@:>@])],
110         enable_rquotad=$enableval,
111         enable_rquotad=yes)
112         if test "$enable_rquotad" = yes; then
113                 RQUOTAD=rquotad
114         else
115                 RQUOTAD=
116         fi
117         AM_CONDITIONAL(CONFIG_RQUOTAD, [test "$enable_rquotad" = "yes"])
118 AC_ARG_WITH(rpcgen,
119         [AC_HELP_STRING([--with-rpcgen=internal], [use internal rpcgen instead of system one])],
120         rpcgen_path=$withval,
121         rpcgen_path=yes )
122         RPCGEN_PATH=
123         if test "$rpcgen_path" == "yes"; then
124             for p in /usr/local/bin/rpcgen /usr/bin/rpcgen /bin/rpcgen
125             do if test -f $p ; then RPCGEN_PATH=$p ; break; fi ; done
126         elif test "$rpcgen_path" != "internal"; then
127             RPCGEN_PATH=$rpcgen_path
128         fi
129         AC_SUBST(RPCGEN_PATH)
130         AM_CONDITIONAL(CONFIG_RPCGEN, [test "$RPCGEN_PATH" == ""])
131 AC_ARG_ENABLE(uuid,
132         [AC_HELP_STRING([--without-uuid], [Exclude uuid support and so avoid possibly buggy libblkid])],
133         if test "$enableval" = "yes" ; then choose_blkid=yes; else choose_blkid=no; fi,
134         choose_blkid=default)
135 AC_ARG_ENABLE(mount,
136         [AC_HELP_STRING([--enable-mount],
137                         [Create mount.nfs and don't use the util-linux mount(8) functionality. @<:@default=no@:>@])],
138         enable_mount=$enableval,
139         enable_mount=yes)
140         AM_CONDITIONAL(CONFIG_MOUNT, [test "$enable_mount" = "yes"])
141
142 # Check whether user wants TCP wrappers support
143 AC_TCP_WRAPPERS
144
145 # Arrange for large-file support
146 AC_SYS_LARGEFILE
147
148 AC_CONFIG_SRCDIR([support/include/config.h.in])
149 AC_CONFIG_HEADERS([support/include/config.h])
150
151 # Checks for programs.
152 AC_PROG_CXX
153 AC_PROG_CC
154 AC_PROG_CPP
155 AC_PROG_INSTALL
156 AC_PROG_LN_S
157 AC_PROG_MAKE_SET
158 AC_PROG_LIBTOOL
159 AM_PROG_CC_C_O
160
161 if test "x$cross_compiling" = "xno"; then
162         CC_FOR_BUILD=${CC_FOR_BUILD-${CC-gcc}}
163 else
164         CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
165 fi
166
167 AC_SUBST(CC_FOR_BUILD)
168
169 AC_CHECK_TOOL(AR, ar)
170 AC_CHECK_TOOL(LD, ld)
171
172 AC_HEADER_STDC([])
173 AC_GNULIBC
174 AC_BSD_SIGNALS
175
176 dnl *************************************************************
177 dnl * Check for required libraries
178 dnl *************************************************************
179 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname, [LIBNSL="-lnsl"])])
180 AC_SUBST(LIBNSL)
181
182 AC_CHECK_FUNC(connect, ,
183       AC_CHECK_LIB(socket, connect, [LIBSOCKET="-lsocket"],
184                 AC_MSG_ERROR(Function 'socket' not found.), $LIBNSL))
185
186 AC_CHECK_LIB(crypt, crypt, [LIBCRYPT="-lcrypt"])
187 if test "$enable_nfsv4" = yes; then
188     AC_CHECK_LIB(event, event_dispatch, [libevent=1], AC_MSG_ERROR([libevent needed for nfsv4 support]))
189     AC_CHECK_LIB(nfsidmap, nfs4_init_name_mapping, [libnfsidmap=1], AC_MSG_ERROR([libnfsidmap needed for nfsv4 support]))
190     AC_CHECK_HEADERS(event.h, ,AC_MSG_ERROR([libevent needed for nfsv4 support]))
191     AC_CHECK_HEADERS(nfsidmap.h, ,AC_MSG_ERROR([libnfsidmap needed for nfsv4 support]))
192     dnl librpcsecgss already has a dependency on libgssapi,
193     dnl but we need to make sure we get the right version
194     if test "$enable_gss" = yes; then
195      PKG_CHECK_MODULES(RPCSECGSS, librpcsecgss >= 0.10, ,
196       [AC_MSG_ERROR([Unable to locate information required to use librpcsecgss.  If you have pkgconfig installed, you might try setting environment variable PKG_CONFIG_PATH to /usr/local/lib/pkgconfig])
197       ]
198      )
199     PKG_CHECK_MODULES(GSSAPI, libgssapi >= 0.11)
200     fi
201
202 fi
203 if test "$knfsd_cv_glibc2" = no; then
204     AC_CHECK_LIB(bsd, daemon, [LIBBSD="-lbsd"])
205 fi
206
207 if test "$choose_blkid" != no; then 
208    AC_CHECK_LIB(blkid, blkid_get_library_version, [LIBBLKID="-lblkid"], AC_MSG_ERROR([libblkid needed]))
209    AC_CHECK_HEADER(blkid/blkid.h, , AC_MSG_ERROR([Cannot find libblkid header file blkid/blkid.h]))
210    AC_BLKID_VERS
211    if test $choose_blkid = yes; then
212       use_blkid=1
213       test $libblkid_is_recent = no && AC_MSG_WARN([libblkid is old and may cause mountd to leak memory])
214    else
215       if test $libblkid_is_recent = yes
216       then use_blkid=1
217       else use_blkid=0
218            AC_MSG_WARN([uuid support disabled as libblkid is too old])
219       fi
220     fi
221     AC_DEFINE_UNQUOTED(USE_BLKID, $use_blkid, [Define if you want to use blkid to find uuid of filesystems])
222 fi
223 AC_SUBST(LIBSOCKET)
224 AC_SUBST(LIBCRYPT)
225 AC_SUBST(LIBBSD)
226 AC_SUBST(LIBBLKID)
227
228 if test "$enable_gss" = yes; then
229   dnl 'gss' also depends on nfsidmap.h - at least for svcgssd_proc.c
230   AC_CHECK_HEADERS(nfsidmap.h, ,AC_MSG_ERROR([libnfsidmap needed for gss support]))
231   AC_CHECK_HEADERS(spkm3.h, ,AC_MSG_WARN([could not locate SPKM3 header; will not have SPKM3 support]))
232   dnl the nfs4_set_debug function doesn't appear in all version of the library
233   AC_CHECK_LIB(nfsidmap, nfs4_set_debug,
234                AC_DEFINE(HAVE_NFS4_SET_DEBUG,1,
235                          [Whether nfs4_set_debug() is present in libnfsidmap]),)
236
237   dnl Check for Kerberos V5
238   AC_KERBEROS_V5
239
240   dnl This is not done until here because we need to have KRBLIBS set
241   dnl ("librpcsecgss=1" is so that it doesn't get added to LIBS)
242   AC_CHECK_LIB(rpcsecgss, authgss_create_default, [librpcsecgss=1], AC_MSG_ERROR([librpcsecgss needed for nfsv4 support]), -lgssapi -ldl)
243   AC_CHECK_LIB(rpcsecgss, authgss_set_debug_level,
244                AC_DEFINE(HAVE_AUTHGSS_SET_DEBUG_LEVEL, 1, [Define this if the rpcsec_gss library has the function authgss_set_debug_level]),, -lgssapi -ldl)
245
246 fi
247
248 dnl *************************************************************
249 dnl Check for headers
250 dnl *************************************************************
251 AC_CHECK_HEADERS([arpa/inet.h fcntl.h libintl.h limits.h \
252                  malloc.h memory.h netdb.h netinet/in.h paths.h \
253                  stdlib.h string.h sys/file.h sys/ioctl.h sys/mount.h \
254                  sys/param.h sys/socket.h sys/time.h sys/vfs.h \
255                  syslog.h unistd.h com_err.h et/com_err.h \
256                  ifaddrs.h])
257
258 dnl *************************************************************
259 dnl Checks for typedefs, structures, and compiler characteristics
260 dnl *************************************************************
261 AC_C_CONST
262 AC_TYPE_UID_T
263 AC_C_INLINE
264 AC_TYPE_OFF_T
265 AC_TYPE_PID_T
266 AC_TYPE_SIZE_T
267 AC_HEADER_TIME
268 AC_STRUCT_TM
269
270 dnl *************************************************************
271 dnl Check for functions
272 dnl *************************************************************
273 AC_FUNC_ALLOCA
274 AC_FUNC_CLOSEDIR_VOID
275 AC_FUNC_ERROR_AT_LINE
276 AC_FUNC_FORK
277 AC_FUNC_GETGROUPS
278 AC_FUNC_GETMNTENT
279 AC_PROG_GCC_TRADITIONAL
280 AC_FUNC_LSTAT
281 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
282 AC_HEADER_MAJOR
283 #AC_FUNC_MALLOC
284 AC_FUNC_MEMCMP
285 #AC_FUNC_REALLOC
286 AC_FUNC_SELECT_ARGTYPES
287 AC_TYPE_SIGNAL
288 AC_FUNC_STAT
289 AC_FUNC_VPRINTF
290 AC_CHECK_FUNCS([alarm atexit dup2 fdatasync ftruncate getcwd \
291                gethostbyaddr gethostbyname gethostname getmntent \
292                gettimeofday hasmntopt inet_ntoa innetgr memset mkdir pathconf \
293                realpath rmdir select socket strcasecmp strchr strdup \
294                strerror strrchr strtol strtoul sigprocmask])
295
296
297 dnl *************************************************************
298 dnl Check for data sizes (XXX These should go away with libgssapi pkg-config)
299 dnl *************************************************************
300 AC_CHECK_SIZEOF(short)
301 AC_CHECK_SIZEOF(int)
302 AC_CHECK_SIZEOF(long)
303 AC_CHECK_SIZEOF(size_t)
304 AC_CHECK_SIZEOF(socklen_t)
305
306
307 dnl *************************************************************
308 dnl Export some path names to config.h
309 dnl *************************************************************
310 AC_DEFINE_UNQUOTED(NFS_STATEDIR, "$statedir", [This defines the location of the NFS state files. Warning: this must match definitions in config.mk!])
311
312 if test "x$cross_compiling" = "xno"; then
313         CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-"$CFLAGS"}
314         CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-"$CXXFLAGS"}
315         CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"}
316         LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-"$LDFLAGS"}
317 else
318         CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-""}
319         CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-""}
320         CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""}
321         LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""}
322 fi
323
324 AC_SUBST(CFLAGS)
325 AC_SUBST(CXXFLAGS)
326 AC_SUBST(CPPFLAGS)
327 AC_SUBST(LDFLAGS)
328
329 AC_SUBST(CFLAGS_FOR_BUILD)
330 AC_SUBST(CXXFLAGS_FOR_BUILD)
331 AC_SUBST(CPPFLAGS_FOR_BUILD)
332 AC_SUBST(LDFLAGS_FOR_BUILD)
333
334 dnl *************************************************************
335 dnl Set up "global" CFLAGS
336 dnl *************************************************************
337 dnl Use architecture-specific compile flags
338 dnl (We use $host and not $build in case we are cross-compiling)
339 dnl *************************************************************
340 case $host in
341   alpha*)
342     ARCHFLAGS="-mno-fp-regs -ffixed-8" ;;
343   *)
344     ARCHFLAGS="" ;;
345 esac
346
347 my_am_cflags="-Wall $ARCHFLAGS -pipe"
348
349 AC_SUBST([AM_CPPFLAGS], ["-I\${top_srcdir}/support/include"])
350 AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
351
352 # Make sure that $ACLOCAL_FLAGS are used during a rebuild
353 AC_SUBST([ACLOCAL_AMFLAGS], ["-I $ac_macro_dir \$(ACLOCAL_FLAGS)"])
354
355 AC_CONFIG_FILES([
356         Makefile
357         linux-nfs/Makefile
358         support/Makefile
359         support/export/Makefile
360         support/include/nfs/Makefile
361         support/include/rpcsvc/Makefile
362         support/include/sys/fs/Makefile
363         support/include/sys/Makefile
364         support/include/Makefile
365         support/misc/Makefile
366         support/nfs/Makefile
367         tools/Makefile
368         tools/locktest/Makefile
369         tools/nlmtest/Makefile
370         tools/rpcdebug/Makefile
371         tools/rpcgen/Makefile
372         utils/Makefile
373         utils/exportfs/Makefile
374         utils/gssd/Makefile
375         utils/idmapd/Makefile
376         utils/mount/Makefile
377         utils/mountd/Makefile
378         utils/nfsd/Makefile
379         utils/nfsstat/Makefile
380         utils/rquotad/Makefile
381         utils/showmount/Makefile
382         utils/statd/Makefile])
383 AC_OUTPUT
384