Updated italian translation
[midnight-commander.git] / acinclude.m4
blob2b6a6879ab96388d5d1aef43c9ae38fa15bf2b3e
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([ext2fs/ext2_fs.h linux/ext2_fs.h], [ext2_fs_h=yes; break])
11   if test x$ext2_fs_h = xyes; then
12     AC_CHECK_HEADERS([ext2fs/ext2fs.h], [ext2fs_ext2fs_h=yes], ,
13                      [
14 #include <stdio.h>
15 #ifdef HAVE_EXT2FS_EXT2_FS_H
16 #include <ext2fs/ext2_fs.h>
17 #else
18 #undef umode_t
19 #include <linux/ext2_fs.h>
20 #endif
21                      ])
22     if test x$ext2fs_ext2fs_h = xyes; then
23       AC_DEFINE(USE_EXT2FSLIB, 1,
24                 [Define to enable undelete support on ext2])
25       ext2fs_undel=yes
26       EXT2FS_UNDEL_LIBS="-lext2fs -lcom_err"
27       AC_CHECK_TYPE(ext2_ino_t, ,
28                     [AC_DEFINE(ext2_ino_t, ino_t,
29                                [Define to ino_t if undefined.])],
30                     [
31 #include <errno.h>
32 #include <stdio.h>
33 #include <fcntl.h>
34 #include <stdlib.h>
35 #ifdef HAVE_EXT2FS_EXT2_FS_H
36 #include <ext2fs/ext2_fs.h>
37 #else
38 #undef umode_t
39 #include <linux/ext2_fs.h>
40 #endif
41 #include <ext2fs/ext2fs.h>
42                     ])
43     fi
44   fi
49 dnl MC_EXTFS_CHECKS
50 dnl    Check for tools used in extfs scripts.
51 AC_DEFUN([MC_EXTFS_CHECKS], [
52     AC_PATH_PROG([ZIP], [zip], [/usr/bin/zip])
53     AC_PATH_PROG([UNZIP], [unzip], [/usr/bin/unzip])
54     AC_CACHE_CHECK([for zipinfo code in unzip], [mc_cv_have_zipinfo],
55         [mc_cv_have_zipinfo=no
56         if $UNZIP -Z </dev/null >/dev/null 2>&1; then
57             mc_cv_have_zipinfo=yes
58         fi])
59     if test "x$mc_cv_have_zipinfo" = xyes; then
60         HAVE_ZIPINFO=1
61     else
62         HAVE_ZIPINFO=0
63     fi
64     AC_SUBST([HAVE_ZIPINFO])
65     AC_PATH_PROG([PERL], [perl], [/usr/bin/perl])
70 dnl MC_MCSERVER_CHECKS
71 dnl    Check how mcserver should check passwords.
72 dnl    Possible methods are PAM, pwdauth and crypt.
73 dnl    The later works with both /etc/shadow and /etc/passwd.
74 dnl    If PAM is found, other methods are not checked.
76 AC_DEFUN([MC_MCSERVER_CHECKS], [
78     dnl Check if PAM can be used for mcserv
79     AC_CHECK_LIB(dl, dlopen, [LIB_DL="-ldl"])
80     AC_CHECK_LIB(pam, pam_start, [
81         AC_DEFINE(HAVE_PAM, 1,
82                   [Define if PAM (Pluggable Authentication Modules) is available])
83         MCSERVLIBS="-lpam $LIB_DL"
84         mcserv_pam=yes], [], [$LIB_DL])
86     dnl Check for crypt() - needed for both /etc/shadow and /etc/passwd.
87     if test -z "$mcserv_pam"; then
89         dnl Check for pwdauth() - used on SunOS.
90         AC_CHECK_FUNCS([pwdauth])
92         dnl Check for crypt()
93         AC_CHECK_HEADERS([crypt.h], [crypt_header=yes])
94         if test -n "$crypt_header"; then
95             save_LIBS="$LIBS"
96             LIBS=
97             AC_SEARCH_LIBS(crypt, [crypt crypt_i], [mcserv_auth=crypt])
98             MCSERVLIBS="$LIBS"
99             LIBS="$save_LIBS"
100             if test -n "$mcserv_auth"; then
101                 AC_DEFINE(HAVE_CRYPT, 1,
102                           [Define to use crypt function in mcserv])
104                 dnl Check for shadow passwords
105                 AC_CHECK_HEADERS([shadow.h shadow/shadow.h],
106                                  [shadow_header=yes; break])
107                 if test -n "$shadow_header"; then
108                     save_LIBS="$LIBS"
109                     LIBS="$MCSERVLIBS"
110                     AC_SEARCH_LIBS(getspnam, [shadow], [mcserv_auth=shadow])
111                     MCSERVLIBS="$LIBS"
112                     LIBS="$save_LIBS"
113                     if test -n "$mcserv_auth"; then
114                         AC_DEFINE(HAVE_SHADOW, 1,
115                                   [Define to use shadow passwords for mcserv])
116                     fi
117                 fi
118             fi
119         fi
120     fi
122     AC_SUBST(MCSERVLIBS)
127 dnl MC_VFS_CHECKS
128 dnl   Check for various functions needed by libvfs.
129 dnl   This has various effects:
130 dnl     Sets MC_VFS_LIBS to libraries required
131 dnl     Sets vfs_flags to "pretty" list of vfs implementations we include.
132 dnl     Sets shell variable use_vfs to yes (default, --with-vfs) or
133 dnl        "no" (--without-vfs).
135 dnl Private define
136 AC_DEFUN([MC_WITH_VFS],[
137   MC_EXTFS_CHECKS
139   vfs_flags="cpiofs, extfs, tarfs"
140   use_net_code=false
142   AC_ARG_ENABLE([netcode],
143                 [  --enable-netcode         Support for networking [[yes]]])
145   if test "x$enable_netcode" != xno; then
146     dnl FIXME: network checks should probably be in their own macro.
147     AC_SEARCH_LIBS(socket, [xnet bsd socket inet], [have_socket=yes])
148     if test x$have_socket = xyes; then
149       AC_SEARCH_LIBS(gethostbyname, [bsd socket inet netinet])
150       AC_CHECK_MEMBERS([struct linger.l_linger], , , [
151 #include <sys/types.h>
152 #include <sys/socket.h>
153                        ])
154       AC_CHECK_FUNCS(pmap_set, , [
155          AC_CHECK_LIB(rpc, pmap_set, [
156            LIBS="-lrpc $LIBS"
157           AC_DEFINE(HAVE_PMAP_SET)
158           ])])
159       AC_CHECK_FUNCS(pmap_getport pmap_getmaps rresvport)
160       dnl add for source routing support setsockopt
161       AC_CHECK_HEADERS(rpc/pmap_clnt.h, , , [
162 #include <sys/types.h>
163 #include <sys/socket.h>
164 #include <netinet/in.h>
165 #include <rpc/rpc.h>
166 #include <rpc/pmap_prot.h>
167                                             ])
168       dnl
169       dnl mcfs support
170       dnl
171       AC_ARG_WITH(mcfs,
172         [  --with-mcfs              Support mc-specific networking file system [[no]]],
173         [if test "x$withval" != "xno"; then
174             AC_DEFINE(WITH_MCFS, 1, [Define to enable mc-specific networking file system])
175             vfs_flags="$vfs_flags, mcfs"
176             use_mcfs=yes
177             MC_MCSERVER_CHECKS
178         fi]
179       )
180       vfs_flags="$vfs_flags, ftpfs, fish"
181       use_net_code=true
182     fi
183   fi
185   dnl
186   dnl Samba support
187   dnl
188   use_smbfs=
189   AC_ARG_WITH(samba,
190           [  --with-samba             Support smb virtual file system [[no]]],
191           [if test "x$withval" != "xno"; then
192                   AC_DEFINE(WITH_SMBFS, 1, [Define to enable VFS over SMB])
193                   vfs_flags="$vfs_flags, smbfs"
194                   use_smbfs=yes
195           fi
196   ])
198   if test -n "$use_smbfs"; then
199   #################################################
200   # set Samba configuration directory location
201   configdir="/etc"
202   AC_ARG_WITH(configdir,
203   [  --with-configdir=DIR     Where the Samba configuration files are [[/etc]]],
204   [ case "$withval" in
205     yes|no)
206     #
207     # Just in case anybody does it
208     #
209         AC_MSG_WARN([--with-configdir called without argument - will use default])
210     ;;
211     * )
212         configdir="$withval"
213     ;;
214   esac]
215   )
216   AC_SUBST(configdir)
218   AC_ARG_WITH(codepagedir,
219     [  --with-codepagedir=DIR   Where the Samba codepage files are],
220     [ case "$withval" in
221       yes|no)
222       #
223       # Just in case anybody does it
224       #
225         AC_MSG_WARN([--with-codepagedir called without argument - will use default])
226       ;;
227     esac]
228   )
229   fi
231   dnl
232   dnl Ext2fs undelete support
233   dnl
234   AC_ARG_WITH(ext2undel,
235     [  --with-ext2undel         Compile with ext2 undelete code [[yes if found]]],
236     [if test x$withval != xno; then
237       if test x$withval != xyes; then
238         LDFLAGS="$LDFLAGS -L$withval/lib"
239         CPPFLAGS="$CPPFLAGS -I$withval/include"
240       fi
241       AC_EXT2_UNDEL
242     fi],[
243     dnl Default: detect
244     AC_CHECK_LIB(ext2fs, ext2fs_close, [AC_EXT2_UNDEL], , [-lcom_err])
245   ])
247   AC_DEFINE(USE_VFS, 1, [Define to enable VFS support])
248   if $use_net_code; then
249      AC_DEFINE(USE_NETCODE, 1, [Define to use networked VFS])
250   fi
255 AC_DEFUN([MC_VFS_CHECKS],[
256         use_vfs=yes
257         AC_ARG_WITH(vfs,
258                 [  --with-vfs               Compile with the VFS code [[yes]]],
259                 use_vfs=$withval
260         )
261         case $use_vfs in
262                 yes)    MC_WITH_VFS;;
263                 no)     use_vfs=no;;
264                 *)      use_vfs=no;;
265                         dnl Should we issue a warning?
266         esac
272 dnl Filesystem information detection
274 dnl To get information about the disk, mount points, etc.
277 AC_DEFUN([AC_GET_FS_INFO], [
278     AC_CHECK_HEADERS(fcntl.h sys/dustat.h sys/param.h sys/statfs.h sys/fstyp.h)
279     AC_CHECK_HEADERS(mnttab.h mntent.h utime.h sys/statvfs.h sys/vfs.h)
280     AC_CHECK_HEADERS(sys/filsys.h sys/fs_types.h)
281     AC_CHECK_HEADERS(sys/mount.h, , , [
282 #include <sys/param.h>
283 #include <sys/stat.h>
284                                       ])
285     AC_CHECK_FUNCS(getmntinfo)
287     dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
288     dnl job is to detect a method to get list of mounted filesystems.
290     AC_MSG_CHECKING([for d_ino member in directory struct])
291     AC_CACHE_VAL(fu_cv_sys_d_ino_in_dirent,
292     [AC_TRY_LINK([
293 #include <sys/types.h>
294 #ifdef HAVE_DIRENT_H
295 # include <dirent.h>
296 #else /* not HAVE_DIRENT_H */
297 # define dirent direct
298 # ifdef HAVE_SYS_NDIR_H
299 #  include <sys/ndir.h>
300 # endif /* HAVE_SYS_NDIR_H */
301 # ifdef HAVE_SYS_DIR_H
302 #  include <sys/dir.h>
303 # endif /* HAVE_SYS_DIR_H */
304 # ifdef HAVE_NDIR_H
305 #  include <ndir.h>
306 # endif /* HAVE_NDIR_H */
307 #endif /* HAVE_DIRENT_H */
308     ],
309       [struct dirent dp; dp.d_ino = 0;],
310         fu_cv_sys_d_ino_in_dirent=yes,
311         fu_cv_sys_d_ino_in_dirent=no)])
312     AC_MSG_RESULT([$fu_cv_sys_d_ino_in_dirent])
313     if test $fu_cv_sys_d_ino_in_dirent = yes; then
314       AC_DEFINE(D_INO_IN_DIRENT, 1,
315                 [Define if `d_ino' is member of `struct directory'])
316     fi
318     # Determine how to get the list of mounted filesystems.
319     list_mounted_fs=
321     # If the getmntent function is available but not in the standard library,
322     # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
323     AC_FUNC_GETMNTENT
325     if test $ac_cv_func_getmntent = yes; then
327       # This system has the getmntent function.
328       # Determine whether it's the one-argument variant or the two-argument one.
330       if test -z "$list_mounted_fs"; then
331         # SVR4
332         AC_MSG_CHECKING([for two-argument getmntent function])
333         AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
334         [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
335           fu_cv_sys_mounted_getmntent2=yes,
336           fu_cv_sys_mounted_getmntent2=no)])
337         AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent2])
338         if test $fu_cv_sys_mounted_getmntent2 = yes; then
339           list_mounted_fs=found
340           AC_DEFINE(MOUNTED_GETMNTENT2, 1,
341                     [Define if function `getmntent' takes 2 arguments])
342         fi
343       fi
345       if test -z "$list_mounted_fs"; then
346         # 4.3BSD, SunOS, HP-UX, Dynix, Irix
347         AC_MSG_CHECKING([for one-argument getmntent function])
348         AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
349                      [test $ac_cv_header_mntent_h = yes \
350                        && fu_cv_sys_mounted_getmntent1=yes \
351                        || fu_cv_sys_mounted_getmntent1=no])
352         AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent1])
353         if test $fu_cv_sys_mounted_getmntent1 = yes; then
354           list_mounted_fs=found
355           AC_DEFINE(MOUNTED_GETMNTENT1, 1,
356                     [Define if function `getmntent' takes 1 argument])
357         fi
358       fi
360     fi
362     if test -z "$list_mounted_fs"; then
363       # DEC Alpha running OSF/1.
364       AC_MSG_CHECKING([for getfsstat function])
365       AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
366       [AC_TRY_LINK([
367 #include <sys/types.h>
368 #include <sys/mount.h>
369 #include <sys/fs_types.h>],
370       [struct statfs *stats;
371       numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
372         fu_cv_sys_mounted_getsstat=yes,
373         fu_cv_sys_mounted_getsstat=no)])
374       AC_MSG_RESULT([$fu_cv_sys_mounted_getsstat])
375       if test $fu_cv_sys_mounted_getsstat = yes; then
376         list_mounted_fs=found
377         AC_DEFINE(MOUNTED_GETFSSTAT, 1,
378                   [Define if function `getfsstat' can be used])
379       fi
380     fi
382     if test -z "$list_mounted_fs"; then
383       # AIX.
384       AC_MSG_CHECKING([for mntctl function and struct vmount])
385       AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
386       [AC_TRY_CPP([#include <fshelp.h>],
387         fu_cv_sys_mounted_vmount=yes,
388         fu_cv_sys_mounted_vmount=no)])
389       AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
390       if test $fu_cv_sys_mounted_vmount = yes; then
391         list_mounted_fs=found
392         AC_DEFINE(MOUNTED_VMOUNT, 1,
393                   [Define if function `mntctl' and `struct vmount' can be used])
394       fi
395     fi
397     if test -z "$list_mounted_fs"; then
398       # SVR3
399       AC_MSG_CHECKING([for existence of three headers])
400       AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
401         [AC_TRY_CPP([
402 #include <sys/statfs.h>
403 #include <sys/fstyp.h>
404 #include <mnttab.h>],
405                     fu_cv_sys_mounted_fread_fstyp=yes,
406                     fu_cv_sys_mounted_fread_fstyp=no)])
407       AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
408       if test $fu_cv_sys_mounted_fread_fstyp = yes; then
409         list_mounted_fs=found
410         AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
411                   [Define if sys/statfs.h, sys/fstyp.h and mnttab.h
412 can be used together])
413       fi
414     fi
416     if test -z "$list_mounted_fs"; then
417       # 4.4BSD and DEC OSF/1.
418       AC_MSG_CHECKING([for getmntinfo function])
419       AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
420         [
421           ok=
422           if test $ac_cv_func_getmntinfo = yes; then
423             AC_EGREP_HEADER(f_type;, sys/mount.h,
424                             ok=yes)
425           fi
426           test -n "$ok" \
427               && fu_cv_sys_mounted_getmntinfo=yes \
428               || fu_cv_sys_mounted_getmntinfo=no
429         ])
430       AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
431       if test $fu_cv_sys_mounted_getmntinfo = yes; then
432         list_mounted_fs=found
433         AC_DEFINE(MOUNTED_GETMNTINFO, 1,
434                   [Define if `getmntinfo' function can be used])
435         AC_MSG_CHECKING([if struct statfs has f_fstypename])
436         AC_CACHE_VAL(fu_cv_sys_mounted_f_fstypename,
437           [AC_EGREP_HEADER([f_fstypename],
438                            [sys/mount.h],
439                            [fu_cv_sys_mounted_f_fstypename=yes],
440                            [fu_cv_sys_mounted_f_fstypename=no])
441           ])
442         AC_MSG_RESULT([$fu_cv_sys_mounted_f_fstypename])
443         if test $fu_cv_sys_mounted_f_fstypename = yes; then
444           AC_DEFINE(HAVE_F_FSTYPENAME, 1,
445                     [Define if `f_fstypename' is member of `struct statfs'])
446         fi
447       fi
448     fi
450     if test -z "$list_mounted_fs"; then
451       # Ultrix
452       AC_MSG_CHECKING([for getmnt function])
453       AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
454         [AC_TRY_CPP([
455 #include <sys/fs_types.h>
456 #include <sys/mount.h>],
457                     fu_cv_sys_mounted_getmnt=yes,
458                     fu_cv_sys_mounted_getmnt=no)])
459       AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
460       if test $fu_cv_sys_mounted_getmnt = yes; then
461         list_mounted_fs=found
462         AC_DEFINE(MOUNTED_GETMNT, 1,
463                   [Define if `getmnt' function can be used])
464       fi
465     fi
467     if test -z "$list_mounted_fs"; then
468       # SVR2
469     AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
470       AC_CACHE_VAL(fu_cv_sys_mounted_fread,
471         [AC_TRY_CPP([#include <mnttab.h>],
472                     fu_cv_sys_mounted_fread=yes,
473                     fu_cv_sys_mounted_fread=no)])
474       AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
475       if test $fu_cv_sys_mounted_fread = yes; then
476         list_mounted_fs=found
477         AC_DEFINE(MOUNTED_FREAD, 1,
478                  [Define if it's possible to resort to fread on /etc/mnttab])
479       fi
480     fi
482     if test -z "$list_mounted_fs"; then
483       AC_MSG_WARN([could not determine how to read list of mounted fs])
484     else
485       AC_DEFINE(HAVE_INFOMOUNT_LIST, 1,
486                 [Define if the list of mounted filesystems can be determined])
487     fi
489 dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
490 dnl job is to detect a method to get file system information.
492     AC_MSG_NOTICE([checking how to get filesystem space usage])
493     space=no
495     # Here we'll compromise a little (and perform only the link test)
496     # since it seems there are no variants of the statvfs function.
497     if test $space = no; then
498       # SVR4
499       AC_CHECK_FUNCS(statvfs)
500       if test $ac_cv_func_statvfs = yes; then
501         space=yes
502         AC_DEFINE(STAT_STATVFS, 1,
503                   [Define if function `statvfs' can be used])
504       fi
505     fi
507     if test $space = no; then
508       # DEC Alpha running OSF/1
509       AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
510       AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
511       [AC_TRY_RUN([
512 #include <sys/param.h>
513 #include <sys/types.h>
514 #include <sys/mount.h>
515       main ()
516       {
517         struct statfs fsd;
518         fsd.f_fsize = 0;
519         exit (statfs (".", &fsd, sizeof (struct statfs)));
520       }],
521       fu_cv_sys_stat_statfs3_osf1=yes,
522       fu_cv_sys_stat_statfs3_osf1=no,
523       fu_cv_sys_stat_statfs3_osf1=no)])
524       AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
525       if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
526         space=yes
527         AC_DEFINE(STAT_STATFS3_OSF1, 1,
528                   [Define if function `statfs' takes 3 arguments])
529       fi
530     fi
532     if test $space = no; then
533     # AIX
534       AC_MSG_CHECKING([for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)])
535       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
536       [AC_TRY_RUN([
537 #ifdef HAVE_SYS_PARAM_H
538 #include <sys/param.h>
539 #endif
540 #ifdef HAVE_SYS_MOUNT_H
541 #include <sys/mount.h>
542 #endif
543 #ifdef HAVE_SYS_VFS_H
544 #include <sys/vfs.h>
545 #endif
546       main ()
547       {
548       struct statfs fsd;
549       fsd.f_bsize = 0;
550       exit (statfs (".", &fsd));
551       }],
552       fu_cv_sys_stat_statfs2_bsize=yes,
553       fu_cv_sys_stat_statfs2_bsize=no,
554       fu_cv_sys_stat_statfs2_bsize=no)])
555       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize])
556       if test $fu_cv_sys_stat_statfs2_bsize = yes; then
557         space=yes
558         AC_DEFINE(STAT_STATFS2_BSIZE, 1,
559                   [Define if function `statfs' takes two arguments and
560 `bsize' is member of `struct statfs'])
561       fi
562     fi
564     if test $space = no; then
565     # SVR3
566       AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
567       AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
568       [AC_TRY_RUN([#include <sys/types.h>
569 #include <sys/statfs.h>
570       main ()
571       {
572       struct statfs fsd;
573       exit (statfs (".", &fsd, sizeof fsd, 0));
574       }],
575         fu_cv_sys_stat_statfs4=yes,
576         fu_cv_sys_stat_statfs4=no,
577         fu_cv_sys_stat_statfs4=no)])
578       AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
579       if test $fu_cv_sys_stat_statfs4 = yes; then
580         space=yes
581         AC_DEFINE(STAT_STATFS4, 1,
582                   [Define if function `statfs' takes 4 arguments])
583       fi
584     fi
586     if test $space = no; then
587     # 4.4BSD and NetBSD
588       AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
589     member (4.4BSD and NetBSD)])
590       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
591       [AC_TRY_RUN([#include <sys/types.h>
592 #ifdef HAVE_SYS_PARAM_H
593 #include <sys/param.h>
594 #endif
595 #ifdef HAVE_SYS_MOUNT_H
596 #include <sys/mount.h>
597 #endif
598       main ()
599       {
600       struct statfs fsd;
601       fsd.f_fsize = 0;
602       exit (statfs (".", &fsd));
603       }],
604       fu_cv_sys_stat_statfs2_fsize=yes,
605       fu_cv_sys_stat_statfs2_fsize=no,
606       fu_cv_sys_stat_statfs2_fsize=no)])
607       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize])
608       if test $fu_cv_sys_stat_statfs2_fsize = yes; then
609         space=yes
610         AC_DEFINE(STAT_STATFS2_FSIZE, 1,
611                   [Define if function `statfs' takes two arguments and
612 `fsize' is member of `struct statfs'])
613       fi
614     fi
616     if test $space = no; then
617       # Ultrix
618       AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
619       AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
620       [AC_TRY_RUN([
621 #include <sys/types.h>
622 #ifdef HAVE_SYS_PARAM_H
623 #include <sys/param.h>
624 #endif
625 #ifdef HAVE_SYS_MOUNT_H
626 #include <sys/mount.h>
627 #endif
628 #ifdef HAVE_SYS_FS_TYPES_H
629 #include <sys/fs_types.h>
630 #endif
631       main ()
632       {
633       struct fs_data fsd;
634       /* Ultrix's statfs returns 1 for success,
635          0 for not mounted, -1 for failure.  */
636       exit (statfs (".", &fsd) != 1);
637       }],
638       fu_cv_sys_stat_fs_data=yes,
639       fu_cv_sys_stat_fs_data=no,
640       fu_cv_sys_stat_fs_data=no)])
641       AC_MSG_RESULT([$fu_cv_sys_stat_fs_data])
642       if test $fu_cv_sys_stat_fs_data = yes; then
643         space=yes
644         AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
645                   [Define if function `statfs' takes two arguments
646 and uses `struct fs_data'])
647       fi
648     fi
650     dnl Not supported
651     dnl if test $space = no; then
652     dnl # SVR2
653     dnl AC_TRY_CPP([#include <sys/filsys.h>],
654     dnl   AC_DEFINE(STAT_READ_FILSYS) space=yes)
655     dnl fi
660 dnl Try using termcap database and link with libtermcap if possible.
662 AC_DEFUN([MC_USE_TERMCAP], [
663         screen_msg="$screen_msg with termcap database"
664         AC_MSG_NOTICE([using S-Lang screen library with termcap])
665         AC_DEFINE(USE_TERMCAP, 1, [Define to use termcap database])
666         AC_CHECK_LIB(termcap, tgoto, [MCLIBS="$MCLIBS -ltermcap"], , [$LIBS])
671 dnl Check if private functions are available for linking
673 AC_DEFUN([MC_SLANG_PRIVATE], [
674     AC_CACHE_CHECK([if S-Lang exports private functions],
675                    [mc_cv_slang_private], [
676         ac_save_LIBS="$LIBS"
677         LIBS="$LIBS -lslang"
678         AC_TRY_LINK([
679                      #ifdef HAVE_SLANG_SLANG_H
680                      #include <slang/slang.h>
681                      #else
682                      #include <slang.h>
683                      #endif
684                      #if SLANG_VERSION >= 10000
685                      extern unsigned int SLsys_getkey (void);
686                      #else
687                      extern unsigned int _SLsys_getkey (void);
688                      #endif
689                     ], [
690                      #if SLANG_VERSION >= 10000
691                      _SLsys_getkey ();
692                      #else
693                      SLsys_getkey ();
694                      #endif
695                     ],
696                     [mc_cv_slang_private=yes],
697                     [mc_cv_slang_private=no])
698         LIBS="$ac_save_LIBS"
699     ])
701     if test x$mc_cv_slang_private = xyes; then
702         AC_DEFINE(HAVE_SLANG_PRIVATE, 1,
703                   [Define if private S-Lang functions are available])
704     fi
709 dnl Check if the installed S-Lang library uses termcap
711 AC_DEFUN([MC_SLANG_TERMCAP], [
712     AC_CACHE_CHECK([if S-Lang uses termcap], [mc_cv_slang_termcap], [
713         ac_save_LIBS="$LIBS"
714         LIBS="$LIBS -lslang"
715         AC_TRY_LINK([
716                      #ifdef HAVE_SLANG_SLANG_H
717                      #include <slang/slang.h>
718                      #else
719                      #include <slang.h>
720                      #endif
721                     ],
722                     [SLtt_get_terminfo(); SLtt_tgetflag("");],
723                     [mc_cv_slang_termcap=no],
724                     [mc_cv_slang_termcap=yes])
725         LIBS="$ac_save_LIBS"
726     ])
728     if test x$mc_cv_slang_termcap = xyes; then
729         MC_USE_TERMCAP
730     fi
734 dnl Common code for MC_WITH_SLANG and MC_WITH_MCSLANG
736 AC_DEFUN([_MC_WITH_XSLANG], [
737     screen_type=slang
738     AC_DEFINE(HAVE_SLANG, 1,
739               [Define to use S-Lang library for screen management])
744 dnl Check if the system S-Lang library can be used.
745 dnl If not, and $1 is "strict", exit, otherwise fall back to mcslang.
747 AC_DEFUN([MC_WITH_SLANG], [
748     with_screen=slang
750     dnl Check the header
751     slang_h_found=
752     AC_CHECK_HEADERS([slang.h slang/slang.h],
753                      [slang_h_found=yes; break])
754     if test -z "$slang_h_found"; then
755         with_screen=mcslang
756     fi
758     dnl Check if termcap is needed.
759     dnl This check must be done before anything is linked against S-Lang.
760     if test x$with_screen = xslang; then
761         MC_SLANG_TERMCAP
762     fi
764     dnl Check the library
765     if test x$with_screen = xslang; then
766         AC_CHECK_LIB([slang], [SLang_init_tty], [MCLIBS="$MCLIBS -lslang"],
767                      [with_screen=mcslang], ["$MCLIBS"])
768     fi
770     dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
771     if test x$with_screen = xslang; then
772         :
773         m4_if([$1], strict, ,
774               [AC_CHECK_LIB([slang], [SLsmg_write_nwchars],
775                             [AC_MSG_WARN([Rejecting S-Lang with UTF-8 support, \
776 it's not fully supported yet])
777               with_screen=mcslang])])
778     fi
780     if test x$with_screen = xslang; then
781         AC_DEFINE(HAVE_SYSTEM_SLANG, 1,
782                   [Define to use S-Lang library installed on the system])
783         MC_SLANG_PRIVATE
784         screen_type=slang
785         screen_msg="S-Lang library (installed on the system)"
786     else
787         m4_if([$1], strict,
788             [if test $with_screen != slang; then
789                 AC_MSG_ERROR([S-Lang library not found])
790             fi],
791             [MC_WITH_MCSLANG]
792         )
793     fi
795     _MC_WITH_XSLANG
800 dnl Use the included S-Lang library.
802 AC_DEFUN([MC_WITH_MCSLANG], [
803     screen_type=mcslang
804     screen_msg="Included S-Lang library (mcslang)"
806     # Search for terminfo database.
807     use_terminfo=
808     if test x"$with_termcap" != xyes; then
809         if test x"$with_termcap" = xno; then
810             use_terminfo=yes
811         fi
812         if test -n "$TERMINFO" && test -r "$TERMINFO/v/vt100"; then
813             use_terminfo=yes
814         fi
815         for dir in "/usr/share/terminfo" "/usr/lib/terminfo" \
816                    "/usr/share/lib/terminfo" "/etc/terminfo" \
817                    "/usr/local/lib/terminfo" "$HOME/.terminfo"; do
818             if test -r "$dir/v/vt100"; then
819                 use_terminfo=yes
820             fi
821         done
822     fi
824     # If there is no terminfo, use termcap
825     if test -z "$use_terminfo"; then
826         MC_USE_TERMCAP
827     fi
829     _MC_WITH_XSLANG
834 dnl Use the ncurses library.  It can only be requested explicitly,
835 dnl so just fail if anything goes wrong.
837 dnl If ncurses exports the ESCDELAY variable it should be set to 0
838 dnl or you'll have to press Esc three times to dismiss a dialog box.
840 AC_DEFUN([MC_WITH_NCURSES], [
841     dnl has_colors() is specific to ncurses, it's not in the old curses
842     save_LIBS="$LIBS"
843     LIBS=
844     AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
845                    [AC_MSG_ERROR([Cannot find ncurses library])])
847     dnl Check the header
848     ncurses_h_found=
849     AC_CHECK_HEADERS([ncurses/curses.h ncurses.h curses.h],
850                      [ncurses_h_found=yes; break])
852     if test -z "$ncurses_h_found"; then
853         AC_MSG_ERROR([Cannot find ncurses header file])
854     fi
856     screen_type=ncurses
857     screen_msg="ncurses library"
858     AC_DEFINE(USE_NCURSES, 1,
859               [Define to use ncurses for screen management])
861     AC_CACHE_CHECK([for ESCDELAY variable],
862                    [mc_cv_ncurses_escdelay],
863                    [AC_TRY_LINK([], [
864                         extern int ESCDELAY;
865                         ESCDELAY = 0;
866                         ],
867                         [mc_cv_ncurses_escdelay=yes],
868                         [mc_cv_ncurses_escdelay=no])
869     ])
870     if test "$mc_cv_ncurses_escdelay" = yes; then
871         AC_DEFINE(HAVE_ESCDELAY, 1,
872                   [Define if ncurses has ESCDELAY variable])
873     fi
875     AC_CHECK_FUNCS(resizeterm)
876     LIBS="$save_LIBS"
881 dnl Check for ext2fs recovery code
883 AC_DEFUN([AC_EXT2_UNDEL], [
884   MC_UNDELFS_CHECKS
885   if test "$ext2fs_undel" = yes; then
886      AC_MSG_NOTICE([using ext2fs file recovery code])
887      vfs_flags="${vfs_flags}, undelfs"
888      use_undelfs=yes
889      MCLIBS="$MCLIBS $EXT2FS_UNDEL_LIBS"
890   else
891      AC_MSG_NOTICE([not using ext2fs file recovery code])
892   fi
895 dnl The next line is for compatibility with gettext 0.10.x
896 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
899 dnl Check whether the g_module_* family of functions works
900 dnl on this system.  We need to know that at the compile time to
901 dnl decide whether to link with X11.
903 AC_DEFUN([AC_G_MODULE_SUPPORTED], [
904     AC_CACHE_CHECK([if gmodule functionality is supported], mc_cv_g_module_supported, [
905         ac_save_CFLAGS="$CFLAGS"
906         ac_save_LIBS="$LIBS"
907         CFLAGS="$CFLAGS $GMODULE_CFLAGS"
908         LIBS="$GMODULE_LIBS $LIBS"
909         AC_TRY_RUN([
910 #include <gmodule.h>
912 int main ()
914     int ret = (g_module_supported () == TRUE) ? 0 : 1;
915     return ret;
917         ],
918             [mc_cv_g_module_supported=yes],
919             [mc_cv_g_module_supported=no],
920             [mc_cv_g_module_supported=no]
921         )
922         CFLAGS="$ac_save_CFLAGS"
923         LIBS="$ac_save_LIBS"
924     ])
926 if test "$mc_cv_g_module_supported" = yes; then
927     AC_DEFINE(HAVE_GMODULE, 1,
928               [Define if gmodule functionality is supported])
934 dnl Check if it's possible to use asm labels to rename functions.
935 dnl This macro is necessary because gettext wrongly assumes that gcc
936 dnl can do it regardless of the OS.
938 AC_DEFUN([MC_ASM_LABELS], [
939     AC_CACHE_CHECK([whether functions can be renamed by asm labels],
940                    mc_cv_asm_labels,
941                    [mc_cv_asm_labels=no
942                    if test -n "$GCC"; then
943                         AC_TRY_LINK(, [
944 static int function1 (void) __asm__ ("function2");
945 static int function1 (void)
947     return 0;
949 return function2();
950 ], [mc_cv_asm_labels=yes])
951                    fi
952    ])
954 if test "$mc_cv_asm_labels" != yes; then
955     AC_DEFINE(_INTL_REDIRECT_MACROS, 1,
956               [Define if functions cannot be renamed by asm labels])