A little fix...
[midnight-commander.git] / acinclude.m4
blobabd5eefeea02e05e0499e5ed3be0402d201ec311
1 dnl MC_UNDELFS_CHECKS
2 dnl    Check for ext2fs undel support.
3 dnl    Set shell variable ext2fs_undel to "yes" if we have it,
4 dnl    "no" otherwise.  May define USE_EXT2FSLIB for cpp.
5 dnl    Will set EXT2FS_UNDEL_LIBS to required libraries.
7 AC_DEFUN([MC_UNDELFS_CHECKS], [
8   ext2fs_undel=no
9   EXT2FS_UNDEL_LIBS=
10   AC_CHECK_HEADERS(linux/ext2_fs.h)
11   if test x$ac_cv_header_linux_ext2_fs_h = xyes
12   then
13     AC_CHECK_HEADERS(ext2fs/ext2fs.h, , , [#include <stdio.h>
14 #include <linux/ext2_fs.h>])
15     if test x$ac_cv_header_ext2fs_ext2fs_h = xyes
16     then
17       AC_DEFINE(USE_EXT2FSLIB, 1,
18                 [Define to enable undelete support on ext2])
19       ext2fs_undel=yes
20       EXT2FS_UNDEL_LIBS="-lext2fs -lcom_err"
21       AC_CHECK_TYPE(ext2_ino_t, ,
22                     [AC_DEFINE(ext2_ino_t, ino_t,
23                                [Define to ino_t if undefined.])],
24                     [#include <errno.h>
25 #include <stdio.h>
26 #include <fcntl.h>
27 #include <stdlib.h>
28 /* asm/types.h defines its own umode_t :-( */
29 #undef umode_t
30 #include <linux/ext2_fs.h>
31 #include <ext2fs/ext2fs.h>])
32     fi
33   fi
38 dnl MC_EXTFS_CHECKS
39 dnl    Check for tools used in extfs scripts.
40 AC_DEFUN([MC_EXTFS_CHECKS], [
41     AC_PATH_PROG([ZIP], [zip], [/usr/bin/zip])
42     AC_PATH_PROG([UNZIP], [unzip], [/usr/bin/unzip])
43     AC_CACHE_CHECK([for zipinfo code in unzip], [mc_cv_have_zipinfo],
44         [mc_cv_have_zipinfo=no
45         if $UNZIP -Z </dev/null 2>&1 >/dev/null; then
46             mc_cv_have_zipinfo=yes
47         fi])
48     if test "x$mc_cv_have_zipinfo" = xyes; then
49         HAVE_ZIPINFO=1
50     else
51         HAVE_ZIPINFO=0
52     fi
53     AC_SUBST([HAVE_ZIPINFO])
54     AC_PATH_PROG([PERL], [perl], [/usr/bin/perl])
59 dnl MC_MCSERVER_CHECKS
60 dnl    Check how mcserver should check passwords.
61 dnl    Possible methods are PAM, pwdauth and crypt.
62 dnl    The later works with both /etc/shadow and /etc/passwd.
63 dnl    If PAM is found, other methods are not checked.
65 AC_DEFUN([MC_MCSERVER_CHECKS], [
67     dnl Check if PAM can be used for mcserv
68     AC_CHECK_LIB(dl, dlopen, [LIB_DL="-ldl"])
69     AC_CHECK_LIB(pam, pam_start, [
70         AC_DEFINE(HAVE_PAM, 1,
71                   [Define if PAM (Pluggable Authentication Modules) is available])
72         MCSERVLIBS="-lpam $LIB_DL"
73         mcserv_pam=yes], [], [$LIB_DL])
75     dnl Check for crypt() - needed for both /etc/shadow and /etc/passwd.
76     if test -z "$mcserv_pam"; then
78         dnl Check for pwdauth() - used on SunOS.
79         AC_CHECK_FUNCS([pwdauth])
81         dnl Check for crypt()
82         AC_CHECK_HEADERS([crypt.h], [crypt_header=yes])
83         if test -n "$crypt_header"; then
84             save_LIBS="$LIBS"
85             LIBS=
86             AC_SEARCH_LIBS(crypt, [crypt crypt_i], [mcserv_auth=crypt])
87             MCSERVLIBS="$LIBS"
88             LIBS="$save_LIBS"
89             if test -n "$mcserv_auth"; then
90                 AC_DEFINE(HAVE_CRYPT, 1,
91                           [Define to use crypt function in mcserv])
93                 dnl Check for shadow passwords
94                 AC_CHECK_HEADERS([shadow.h shadow/shadow.h],
95                                  [shadow_header=yes; break])
96                 if test -n "$shadow_header"; then
97                     save_LIBS="$LIBS"
98                     LIBS="$MCSERVLIBS"
99                     AC_SEARCH_LIBS(getspnam, [shadow], [mcserv_auth=shadow])
100                     MCSERVLIBS="$LIBS"
101                     LIBS="$save_LIBS"
102                     if test -n "$mcserv_auth"; then
103                         AC_DEFINE(HAVE_SHADOW, 1,
104                                   [Define to use shadow passwords for mcserv])
105                     fi
106                 fi
107             fi
108         fi
109     fi
111     AC_SUBST(MCSERVLIBS)
116 dnl MC_VFS_CHECKS
117 dnl   Check for various functions needed by libvfs.
118 dnl   This has various effects:
119 dnl     Sets MC_VFS_LIBS to libraries required
120 dnl     Sets vfs_flags to "pretty" list of vfs implementations we include.
121 dnl     Sets shell variable use_vfs to yes (default, --with-vfs) or
122 dnl        "no" (--without-vfs).
124 dnl Private define
125 AC_DEFUN([MC_WITH_VFS],[
126   MC_EXTFS_CHECKS
128   dnl FIXME: network checks should probably be in their own macro.
129   AC_CHECK_LIB(nsl, t_accept)
130   AC_CHECK_LIB(socket, socket)
132   have_socket=no
133   AC_CHECK_FUNCS(socket, have_socket=yes)
134   if test $have_socket = no; then
135     # socket is not in the default libraries.  See if it's in some other.
136     for lib in bsd socket inet; do
137       AC_CHECK_LIB([$lib], [socket], [
138           LIBS="$LIBS -l$lib"
139           have_socket=yes
140           AC_DEFINE(HAVE_SOCKET)
141           break])
142     done
143   fi
145   have_gethostbyname=no
146   AC_CHECK_FUNC(gethostbyname, have_gethostbyname=yes)
147   if test $have_gethostbyname = no; then
148     # gethostbyname is not in the default libraries.  See if it's in some other.
149     for lib in bsd socket inet; do
150       AC_CHECK_LIB([$lib], [gethostbyname],
151                    [LIBS="$LIBS -l$lib"; have_gethostbyname=yes; break])
152     done
153   fi
155   vfs_flags="cpiofs, extfs, tarfs"
156   use_net_code=false
157   if test $have_socket = yes; then
158       AC_STRUCT_LINGER
159       AC_CHECK_FUNCS(pmap_set, , [
160          AC_CHECK_LIB(rpc, pmap_set, [
161            LIBS="-lrpc $LIBS"
162           AC_DEFINE(HAVE_PMAP_SET)
163           ])])
164       AC_CHECK_FUNCS(pmap_getport pmap_getmaps rresvport)
165       dnl add for source routing support setsockopt
166       AC_CHECK_HEADERS(rpc/pmap_clnt.h, , , [
167 #include <sys/types.h>
168 #include <sys/socket.h>
169 #include <netinet/in.h>
170 #include <rpc/rpc.h>
171 #include <rpc/pmap_prot.h>
172                                             ])
173       dnl
174       dnl mcfs support
175       dnl
176       AC_ARG_WITH(mcfs,
177         [  --with-mcfs              Support mc-specific networking file system [[no]]],
178         [if test "x$withval" != "xno"; then
179             AC_DEFINE(WITH_MCFS, 1, [Define to enable mc-specific networking file system])
180             vfs_flags="$vfs_flags, mcfs"
181             use_mcfs=yes
182             MC_MCSERVER_CHECKS
183         fi]
184       )
185       vfs_flags="$vfs_flags, ftpfs, fish"
186       use_net_code=true
187   fi
189   dnl
190   dnl Samba support
191   dnl
192   use_smbfs=
193   AC_ARG_WITH(samba,
194           [  --with-samba             Support smb virtual file system [[no]]],
195           [if test "x$withval" != "xno"; then
196                   AC_DEFINE(WITH_SMBFS, 1, [Define to enable VFS over SMB])
197                   vfs_flags="$vfs_flags, smbfs"
198                   use_smbfs=yes
199           fi
200   ])
202   if test -n "$use_smbfs"; then
203   #################################################
204   # set Samba configuration directory location
205   configdir="/etc"
206   AC_ARG_WITH(configdir,
207   [  --with-configdir=DIR     Where the Samba configuration files are [[/etc]]],
208   [ case "$withval" in
209     yes|no)
210     #
211     # Just in case anybody does it
212     #
213         AC_MSG_WARN([--with-configdir called without argument - will use default])
214     ;;
215     * )
216         configdir="$withval"
217     ;;
218   esac]
219   )
220   AC_SUBST(configdir)
222   AC_ARG_WITH(codepagedir,
223     [  --with-codepagedir=DIR   Where the Samba codepage files are],
224     [ case "$withval" in
225       yes|no)
226       #
227       # Just in case anybody does it
228       #
229         AC_MSG_WARN([--with-codepagedir called without argument - will use default])
230       ;;
231     esac]
232   )
233   fi
235   AC_DEFINE(USE_VFS, 1, [Define to enable VFS support])
236   if $use_net_code; then
237      AC_DEFINE(USE_NETCODE, 1, [Define to use networked VFS])
238   fi
243 AC_DEFUN([MC_VFS_CHECKS],[
244         use_vfs=yes
245         AC_ARG_WITH(vfs,
246                 [  --with-vfs               Compile with the VFS code [[yes]]],
247                 use_vfs=$withval
248         )
249         case $use_vfs in
250                 yes)    MC_WITH_VFS;;
251                 no)     use_vfs=no;;
252                 *)      use_vfs=no;;
253                         dnl Should we issue a warning?
254         esac
260 dnl Check for struct linger
262 AC_DEFUN([AC_STRUCT_LINGER], [
263 av_struct_linger=no
264 AC_MSG_CHECKING([struct linger is available])
265 AC_TRY_RUN([
266 #include <sys/types.h>
267 #include <sys/socket.h>
269 struct linger li;
271 int main ()
273     li.l_onoff = 1;
274     li.l_linger = 120;
275     return 0;
278 AC_DEFINE(HAVE_STRUCT_LINGER, 1,
279           [Define if `struct linger' is available])
280 av_struct_linger=yes
282 av_struct_linger=no
284 av_struct_linger=no
286 AC_MSG_RESULT([$av_struct_linger])
291 dnl Filesystem information detection
293 dnl To get information about the disk, mount points, etc.
296 AC_DEFUN([AC_GET_FS_INFO], [
297     AC_CHECK_HEADERS(fcntl.h sys/dustat.h sys/param.h sys/statfs.h sys/fstyp.h)
298     AC_CHECK_HEADERS(mnttab.h mntent.h utime.h sys/statvfs.h sys/vfs.h)
299     AC_CHECK_HEADERS(sys/filsys.h sys/fs_types.h)
300     AC_CHECK_HEADERS(sys/mount.h, , , [
301 #include <sys/param.h>
302 #include <sys/stat.h>
303                                       ])
304     AC_CHECK_FUNCS(getmntinfo)
306     dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
307     dnl job is to detect a method to get list of mounted filesystems.
309     AC_MSG_CHECKING([for d_ino member in directory struct])
310     AC_CACHE_VAL(fu_cv_sys_d_ino_in_dirent,
311     [AC_TRY_LINK([
312 #include <sys/types.h>
313 #ifdef HAVE_DIRENT_H
314 # include <dirent.h>
315 #else /* not HAVE_DIRENT_H */
316 # define dirent direct
317 # ifdef HAVE_SYS_NDIR_H
318 #  include <sys/ndir.h>
319 # endif /* HAVE_SYS_NDIR_H */
320 # ifdef HAVE_SYS_DIR_H
321 #  include <sys/dir.h>
322 # endif /* HAVE_SYS_DIR_H */
323 # ifdef HAVE_NDIR_H
324 #  include <ndir.h>
325 # endif /* HAVE_NDIR_H */
326 #endif /* HAVE_DIRENT_H */
327     ],
328       [struct dirent dp; dp.d_ino = 0;],
329         fu_cv_sys_d_ino_in_dirent=yes,
330         fu_cv_sys_d_ino_in_dirent=no)])
331     AC_MSG_RESULT([$fu_cv_sys_d_ino_in_dirent])
332     if test $fu_cv_sys_d_ino_in_dirent = yes; then
333       AC_DEFINE(D_INO_IN_DIRENT, 1,
334                 [Define if `d_ino' is member of `struct directory'])
335     fi
337     # Determine how to get the list of mounted filesystems.
338     list_mounted_fs=
340     # If the getmntent function is available but not in the standard library,
341     # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
342     AC_FUNC_GETMNTENT
344     if test $ac_cv_func_getmntent = yes; then
346       # This system has the getmntent function.
347       # Determine whether it's the one-argument variant or the two-argument one.
349       if test -z "$list_mounted_fs"; then
350         # SVR4
351         AC_MSG_CHECKING([for two-argument getmntent function])
352         AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
353         [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
354           fu_cv_sys_mounted_getmntent2=yes,
355           fu_cv_sys_mounted_getmntent2=no)])
356         AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent2])
357         if test $fu_cv_sys_mounted_getmntent2 = yes; then
358           list_mounted_fs=found
359           AC_DEFINE(MOUNTED_GETMNTENT2, 1,
360                     [Define if function `getmntent' takes 2 arguments])
361         fi
362       fi
364       if test -z "$list_mounted_fs"; then
365         # 4.3BSD, SunOS, HP-UX, Dynix, Irix
366         AC_MSG_CHECKING([for one-argument getmntent function])
367         AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
368                      [test $ac_cv_header_mntent_h = yes \
369                        && fu_cv_sys_mounted_getmntent1=yes \
370                        || fu_cv_sys_mounted_getmntent1=no])
371         AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent1])
372         if test $fu_cv_sys_mounted_getmntent1 = yes; then
373           list_mounted_fs=found
374           AC_DEFINE(MOUNTED_GETMNTENT1, 1,
375                     [Define if function `getmntent' takes 1 argument])
376         fi
377       fi
379     fi
381     if test -z "$list_mounted_fs"; then
382       # DEC Alpha running OSF/1.
383       AC_MSG_CHECKING([for getfsstat function])
384       AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
385       [AC_TRY_LINK([
386 #include <sys/types.h>
387 #include <sys/mount.h>
388 #include <sys/fs_types.h>],
389       [struct statfs *stats;
390       numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
391         fu_cv_sys_mounted_getsstat=yes,
392         fu_cv_sys_mounted_getsstat=no)])
393       AC_MSG_RESULT([$fu_cv_sys_mounted_getsstat])
394       if test $fu_cv_sys_mounted_getsstat = yes; then
395         list_mounted_fs=found
396         AC_DEFINE(MOUNTED_GETFSSTAT, 1,
397                   [Define if function `getfsstat' can be used])
398       fi
399     fi
401     if test -z "$list_mounted_fs"; then
402       # AIX.
403       AC_MSG_CHECKING([for mntctl function and struct vmount])
404       AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
405       [AC_TRY_CPP([#include <fshelp.h>],
406         fu_cv_sys_mounted_vmount=yes,
407         fu_cv_sys_mounted_vmount=no)])
408       AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
409       if test $fu_cv_sys_mounted_vmount = yes; then
410         list_mounted_fs=found
411         AC_DEFINE(MOUNTED_VMOUNT, 1,
412                   [Define if function `mntctl' and `struct vmount' can be used])
413       fi
414     fi
416     if test -z "$list_mounted_fs"; then
417       # SVR3
418       AC_MSG_CHECKING([for existence of three headers])
419       AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
420         [AC_TRY_CPP([
421 #include <sys/statfs.h>
422 #include <sys/fstyp.h>
423 #include <mnttab.h>],
424                     fu_cv_sys_mounted_fread_fstyp=yes,
425                     fu_cv_sys_mounted_fread_fstyp=no)])
426       AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
427       if test $fu_cv_sys_mounted_fread_fstyp = yes; then
428         list_mounted_fs=found
429         AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
430                   [Define if sys/statfs.h, sys/fstyp.h and mnttab.h
431 can be used together])
432       fi
433     fi
435     if test -z "$list_mounted_fs"; then
436       # 4.4BSD and DEC OSF/1.
437       AC_MSG_CHECKING([for getmntinfo function])
438       AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
439         [
440           ok=
441           if test $ac_cv_func_getmntinfo = yes; then
442             AC_EGREP_HEADER(f_type;, sys/mount.h,
443                             ok=yes)
444           fi
445           test -n "$ok" \
446               && fu_cv_sys_mounted_getmntinfo=yes \
447               || fu_cv_sys_mounted_getmntinfo=no
448         ])
449       AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
450       if test $fu_cv_sys_mounted_getmntinfo = yes; then
451         list_mounted_fs=found
452         AC_DEFINE(MOUNTED_GETMNTINFO, 1,
453                   [Define if `getmntinfo' function can be used])
454         AC_MSG_CHECKING([if struct statfs has f_fstypename])
455         AC_CACHE_VAL(fu_cv_sys_mounted_f_fstypename,
456           [AC_EGREP_HEADER([f_fstypename],
457                            [sys/mount.h],
458                            [fu_cv_sys_mounted_f_fstypename=yes],
459                            [fu_cv_sys_mounted_f_fstypename=no])
460           ])
461         AC_MSG_RESULT([$fu_cv_sys_mounted_f_fstypename])
462         if test $fu_cv_sys_mounted_f_fstypename = yes; then
463           AC_DEFINE(HAVE_F_FSTYPENAME, 1,
464                     [Define if `f_fstypename' is member of `struct statfs'])
465         fi
466       fi
467     fi
469     if test -z "$list_mounted_fs"; then
470       # Ultrix
471       AC_MSG_CHECKING([for getmnt function])
472       AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
473         [AC_TRY_CPP([
474 #include <sys/fs_types.h>
475 #include <sys/mount.h>],
476                     fu_cv_sys_mounted_getmnt=yes,
477                     fu_cv_sys_mounted_getmnt=no)])
478       AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
479       if test $fu_cv_sys_mounted_getmnt = yes; then
480         list_mounted_fs=found
481         AC_DEFINE(MOUNTED_GETMNT, 1,
482                   [Define if `getmnt' function can be used])
483       fi
484     fi
486     if test -z "$list_mounted_fs"; then
487       # SVR2
488     AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
489       AC_CACHE_VAL(fu_cv_sys_mounted_fread,
490         [AC_TRY_CPP([#include <mnttab.h>],
491                     fu_cv_sys_mounted_fread=yes,
492                     fu_cv_sys_mounted_fread=no)])
493       AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
494       if test $fu_cv_sys_mounted_fread = yes; then
495         list_mounted_fs=found
496         AC_DEFINE(MOUNTED_FREAD, 1,
497                  [Define if it's possible to resort to fread on /etc/mnttab])
498       fi
499     fi
501     if test -z "$list_mounted_fs"; then
502       AC_MSG_WARN([could not determine how to read list of mounted fs])
503     else
504       AC_DEFINE(HAVE_INFOMOUNT_LIST, 1,
505                 [Define if the list of mounted filesystems can be determined])
506     fi
508 dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
509 dnl job is to detect a method to get file system information.
511     AC_MSG_NOTICE([checking how to get filesystem space usage])
512     space=no
514     # Here we'll compromise a little (and perform only the link test)
515     # since it seems there are no variants of the statvfs function.
516     if test $space = no; then
517       # SVR4
518       AC_CHECK_FUNCS(statvfs)
519       if test $ac_cv_func_statvfs = yes; then
520         space=yes
521         AC_DEFINE(STAT_STATVFS, 1,
522                   [Define if function `statfs' can be used])
523       fi
524     fi
526     if test $space = no; then
527       # DEC Alpha running OSF/1
528       AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
529       AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
530       [AC_TRY_RUN([
531 #include <sys/param.h>
532 #include <sys/types.h>
533 #include <sys/mount.h>
534       main ()
535       {
536         struct statfs fsd;
537         fsd.f_fsize = 0;
538         exit (statfs (".", &fsd, sizeof (struct statfs)));
539       }],
540       fu_cv_sys_stat_statfs3_osf1=yes,
541       fu_cv_sys_stat_statfs3_osf1=no,
542       fu_cv_sys_stat_statfs3_osf1=no)])
543       AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
544       if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
545         space=yes
546         AC_DEFINE(STAT_STATFS3_OSF1, 1,
547                   [Define if function `statfs' takes 3 arguments])
548       fi
549     fi
551     if test $space = no; then
552     # AIX
553       AC_MSG_CHECKING([for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)])
554       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
555       [AC_TRY_RUN([
556 #ifdef HAVE_SYS_PARAM_H
557 #include <sys/param.h>
558 #endif
559 #ifdef HAVE_SYS_MOUNT_H
560 #include <sys/mount.h>
561 #endif
562 #ifdef HAVE_SYS_VFS_H
563 #include <sys/vfs.h>
564 #endif
565       main ()
566       {
567       struct statfs fsd;
568       fsd.f_bsize = 0;
569       exit (statfs (".", &fsd));
570       }],
571       fu_cv_sys_stat_statfs2_bsize=yes,
572       fu_cv_sys_stat_statfs2_bsize=no,
573       fu_cv_sys_stat_statfs2_bsize=no)])
574       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize])
575       if test $fu_cv_sys_stat_statfs2_bsize = yes; then
576         space=yes
577         AC_DEFINE(STAT_STATFS2_BSIZE, 1,
578                   [Define if function `statfs' takes two arguments and
579 `bsize' is member of `struct statfs'])
580       fi
581     fi
583     if test $space = no; then
584     # SVR3
585       AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
586       AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
587       [AC_TRY_RUN([#include <sys/types.h>
588 #include <sys/statfs.h>
589       main ()
590       {
591       struct statfs fsd;
592       exit (statfs (".", &fsd, sizeof fsd, 0));
593       }],
594         fu_cv_sys_stat_statfs4=yes,
595         fu_cv_sys_stat_statfs4=no,
596         fu_cv_sys_stat_statfs4=no)])
597       AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
598       if test $fu_cv_sys_stat_statfs4 = yes; then
599         space=yes
600         AC_DEFINE(STAT_STATFS4, 1,
601                   [Define if function `statfs' takes 4 arguments])
602       fi
603     fi
605     if test $space = no; then
606     # 4.4BSD and NetBSD
607       AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
608     member (4.4BSD and NetBSD)])
609       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
610       [AC_TRY_RUN([#include <sys/types.h>
611 #ifdef HAVE_SYS_PARAM_H
612 #include <sys/param.h>
613 #endif
614 #ifdef HAVE_SYS_MOUNT_H
615 #include <sys/mount.h>
616 #endif
617       main ()
618       {
619       struct statfs fsd;
620       fsd.f_fsize = 0;
621       exit (statfs (".", &fsd));
622       }],
623       fu_cv_sys_stat_statfs2_fsize=yes,
624       fu_cv_sys_stat_statfs2_fsize=no,
625       fu_cv_sys_stat_statfs2_fsize=no)])
626       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize])
627       if test $fu_cv_sys_stat_statfs2_fsize = yes; then
628         space=yes
629         AC_DEFINE(STAT_STATFS2_FSIZE, 1,
630                   [Define if function `statfs' takes two arguments and
631 `fsize' is member of `struct statfs'])
632       fi
633     fi
635     if test $space = no; then
636       # Ultrix
637       AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
638       AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
639       [AC_TRY_RUN([
640 #include <sys/types.h>
641 #ifdef HAVE_SYS_PARAM_H
642 #include <sys/param.h>
643 #endif
644 #ifdef HAVE_SYS_MOUNT_H
645 #include <sys/mount.h>
646 #endif
647 #ifdef HAVE_SYS_FS_TYPES_H
648 #include <sys/fs_types.h>
649 #endif
650       main ()
651       {
652       struct fs_data fsd;
653       /* Ultrix's statfs returns 1 for success,
654          0 for not mounted, -1 for failure.  */
655       exit (statfs (".", &fsd) != 1);
656       }],
657       fu_cv_sys_stat_fs_data=yes,
658       fu_cv_sys_stat_fs_data=no,
659       fu_cv_sys_stat_fs_data=no)])
660       AC_MSG_RESULT([$fu_cv_sys_stat_fs_data])
661       if test $fu_cv_sys_stat_fs_data = yes; then
662         space=yes
663         AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
664                   [Define if function `statfs' takes two arguments
665 and uses `struct fs_data'])
666       fi
667     fi
669     dnl Not supported
670     dnl if test $space = no; then
671     dnl # SVR2
672     dnl AC_TRY_CPP([#include <sys/filsys.h>],
673     dnl   AC_DEFINE(STAT_READ_FILSYS) space=yes)
674     dnl fi
679 dnl Try using termcap database and link with libtermcap if possible.
681 AC_DEFUN([MC_USE_TERMCAP], [
682         screen_msg="$screen_msg with termcap database"
683         AC_MSG_NOTICE([using S-Lang screen library with termcap])
684         AC_DEFINE(USE_TERMCAP, 1, [Define to use termcap database])
685         AC_CHECK_LIB(termcap, tgoto, [MCLIBS="$MCLIBS -ltermcap"], , [$LIBS])
690 dnl Common code for MC_WITH_SLANG and MC_WITH_MCSLANG
692 dnl We check for the existance of setupterm on curses library
693 dnl this is required to load certain definitions on some termcaps
694 dnl editions (AIX and OSF/1 I seem to remember).
695 dnl Note that we avoid using setupterm 
697 AC_DEFUN([_MC_WITH_XSLANG], [
698     screen_type=slang
699     AC_DEFINE(HAVE_SLANG, 1,
700               [Define to use S-Lang library for screen management])
702     case $host_os in
703     linux*)
704         ;;
705     *)
706         AC_CHECK_LIB(curses,setupterm,
707                      [AC_TRY_COMPILE([
708 #include <curses.h>
709 #include <term.h>],
710                         [return (key_end == parm_insert_line);],
711                         [MCLIBS="$MCLIBS -lcurses"
712                         AC_DEFINE(USE_SETUPTERM, 1,
713                                   [Define to use function `setupterm'
714 from `curses' library in S-Lang])])
715         ])
716         ;;
717     esac
722 dnl Check if the system S-Lang library can be used.
723 dnl If not, and $1 is "strict", exit, otherwise fall back to mcslang.
725 AC_DEFUN([MC_WITH_SLANG], [
726     with_screen=slang
728     dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
729     m4_if([$1], strict, ,
730           [AC_CHECK_LIB([slang], [SLsmg_write_nwchars],
731                         [AC_MSG_WARN([Rejecting S-Lang with UTF-8 support, \
732 it doesn't work well])
733                         with_screen=mcslang])])
735     if test x$with_screen = xslang; then
736         AC_CHECK_LIB([slang], [SLang_init_tty], [MCLIBS="$MCLIBS -lslang"],
737                      [with_screen=mcslang])
738     fi
740     dnl Check the header
741     if test x$with_screen = xslang; then
742         slang_h_found=
743         AC_CHECK_HEADERS([slang.h slang/slang.h],
744                          [slang_h_found=yes; break])
746         if test -z "$slang_h_found"; then
747             with_screen=mcslang
748         fi
749     fi
751     dnl Check if the installed S-Lang library uses termcap
752     if test x$with_screen = xslang; then
753         screen_type=slang
754         screen_msg="S-Lang library (installed on the system)"
755         AC_DEFINE(HAVE_SYSTEM_SLANG, 1,
756                   [Define to use S-Lang library installed on the system])
757         ac_save_LIBS="$LIBS"
758         LIBS="$LIBS -lslang"
759         AC_TRY_LINK([ 
760         #ifdef HAVE_SLANG_SLANG_H
761         #include <slang/slang.h>
762         #else
763         #include <slang.h>
764         #endif],
765         [SLtt_get_terminfo();
766         SLtt_tgetflag("");], 
767         [LIBS="$ac_save_LIBS"],
768         [LIBS="$ac_save_LIBS"; MC_USE_TERMCAP])
769         _MC_WITH_XSLANG
770     else
771         m4_if([$1], strict,
772             [if test $with_screen != slang; then
773                 AC_MSG_ERROR([S-Lang library not found])
774             fi],
775             [MC_WITH_MCSLANG]
776         )
777     fi
782 dnl Use the included S-Lang library.
784 AC_DEFUN([MC_WITH_MCSLANG], [
785     screen_type=slang
786     screen_msg="Included S-Lang library (mcslang)"
788     # Search for terminfo database.
789     use_terminfo=
790     if test x"$with_termcap" != xyes; then
791         if test x"$with_termcap" = xno; then
792             use_terminfo=yes
793         fi
794         if test -n "$TERMINFO" && test -r "$TERMINFO/v/vt100"; then
795             use_terminfo=yes
796         fi
797         for dir in "/usr/share/terminfo" "/usr/lib/terminfo" \
798                    "/usr/share/lib/terminfo" "/etc/terminfo" \
799                    "/usr/local/lib/terminfo" "$HOME/.terminfo"; do
800             if test -r "$dir/v/vt100"; then
801                 use_terminfo=yes
802             fi
803         done
804     fi
806     # If there is no terminfo, use termcap
807     if test -z "$use_terminfo"; then
808         MC_USE_TERMCAP
809     fi
811     _MC_WITH_XSLANG
816 dnl Use the ncurses library.  It can only be requested explicitly,
817 dnl so just fail if anything goes wrong.
819 dnl If ncurses exports the ESCDELAY variable it should be set to 0
820 dnl or you'll have to press Esc three times to dismiss a dialog box.
822 AC_DEFUN([MC_WITH_NCURSES], [
823     dnl has_colors() is specific to ncurses, it's not in the old curses
824     AC_CHECK_LIB([ncurses], [has_colors], [MCLIBS="$MCLIBS -lncurses"],
825                  [AC_MSG_ERROR([Cannot find ncurses library])])
827     dnl Check the header
828     ncurses_h_found=
829     AC_CHECK_HEADERS([ncurses/curses.h ncurses.h curses.h],
830                      [ncurses_h_found=yes; break])
832     if test -z "$ncurses_h_found"; then
833         AC_MSG_ERROR([Cannot find ncurses header file])
834     fi
836     screen_type=ncurses
837     screen_msg="ncurses library"
838     AC_DEFINE(USE_NCURSES, 1,
839               [Define to use ncurses for screen management])
841     save_LIBS="$LIBS"
842     LIBS="$LIBS -lncurses"
843     AC_CACHE_CHECK([for ESCDELAY variable],
844                    [mc_cv_ncurses_escdelay],
845                    [AC_TRY_COMPILE([], [
846                         extern int ESCDELAY;
847                         int main ()
848                         {
849                           ESCDELAY = 0;
850                         }
851                         ],
852                         [mc_cv_ncurses_escdelay=yes],
853                         [mc_cv_ncurses_escdelay=no])
854     ])
855     if test "$mc_cv_ncurses_escdelay" = yes; then
856         AC_DEFINE(HAVE_ESCDELAY, 1,
857                   [Define if ncurses has ESCDELAY variable])
858     fi
860     AC_CHECK_FUNCS(resizeterm)
861     LIBS="$save_LIBS"
866 dnl Check for ext2fs recovery code
868 AC_DEFUN([AC_EXT2_UNDEL], [
869   MC_UNDELFS_CHECKS
870   if test "$ext2fs_undel" = yes; then
871      AC_MSG_NOTICE([using ext2fs file recovery code])
872      vfs_flags="${vfs_flags}, undelfs"
873      use_undelfs=yes
874      MCLIBS="$MCLIBS $EXT2FS_UNDEL_LIBS"
875   else
876      AC_MSG_NOTICE([not using ext2fs file recovery code])
877   fi
880 dnl The next line is for compatibility with gettext 0.10.x
881 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])