* subshell.c: Partly revert previous patch to preserve translated strings.
[midnight-commander.git] / acinclude.m4
blobe39d500fa423d9831a6536f4863b928eb428cfa5
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_CHECK_LIB(nsl, main)
148     AC_SEARCH_LIBS(socket, [xnet bsd socket inet], [have_socket=yes])
149     if test x$have_socket = xyes; then
150       AC_SEARCH_LIBS(gethostbyname, [bsd socket inet netinet])
151       AC_CHECK_MEMBERS([struct linger.l_linger], , , [
152 #include <sys/types.h>
153 #include <sys/socket.h>
154                        ])
155       AC_CHECK_FUNCS(pmap_set, , [
156          AC_CHECK_LIB(rpc, pmap_set, [
157            LIBS="-lrpc $LIBS"
158           AC_DEFINE(HAVE_PMAP_SET)
159           ])])
160       AC_CHECK_FUNCS(pmap_getport pmap_getmaps rresvport)
161       dnl add for source routing support setsockopt
162       AC_CHECK_HEADERS(rpc/pmap_clnt.h, , , [
163 #include <sys/types.h>
164 #include <sys/socket.h>
165 #include <netinet/in.h>
166 #include <rpc/rpc.h>
167 #include <rpc/pmap_prot.h>
168                                             ])
169       dnl
170       dnl mcfs support
171       dnl
172       AC_ARG_WITH(mcfs,
173         [  --with-mcfs              Support mc-specific networking file system [[no]]],
174         [if test "x$withval" != "xno"; then
175             AC_DEFINE(WITH_MCFS, 1, [Define to enable mc-specific networking file system])
176             vfs_flags="$vfs_flags, mcfs"
177             use_mcfs=yes
178             MC_MCSERVER_CHECKS
179         fi]
180       )
181       vfs_flags="$vfs_flags, ftpfs, fish"
182       use_net_code=true
183     fi
184   fi
186   dnl
187   dnl Samba support
188   dnl
189   use_smbfs=
190   AC_ARG_WITH(samba,
191           [  --with-samba             Support smb virtual file system [[no]]],
192           [if test "x$withval" != "xno"; then
193                   AC_DEFINE(WITH_SMBFS, 1, [Define to enable VFS over SMB])
194                   vfs_flags="$vfs_flags, smbfs"
195                   use_smbfs=yes
196           fi
197   ])
199   if test -n "$use_smbfs"; then
200   #################################################
201   # set Samba configuration directory location
202   configdir="/etc"
203   AC_ARG_WITH(configdir,
204   [  --with-configdir=DIR     Where the Samba configuration files are [[/etc]]],
205   [ case "$withval" in
206     yes|no)
207     #
208     # Just in case anybody does it
209     #
210         AC_MSG_WARN([--with-configdir called without argument - will use default])
211     ;;
212     * )
213         configdir="$withval"
214     ;;
215   esac]
216   )
217   AC_SUBST(configdir)
219   AC_ARG_WITH(codepagedir,
220     [  --with-codepagedir=DIR   Where the Samba codepage files are],
221     [ case "$withval" in
222       yes|no)
223       #
224       # Just in case anybody does it
225       #
226         AC_MSG_WARN([--with-codepagedir called without argument - will use default])
227       ;;
228     esac]
229   )
230   fi
232   dnl
233   dnl Ext2fs undelete support
234   dnl
235   AC_ARG_WITH(ext2undel,
236     [  --with-ext2undel         Compile with ext2 undelete code [[yes if found]]],
237     [if test x$withval != xno; then
238       if test x$withval != xyes; then
239         LDFLAGS="$LDFLAGS -L$withval/lib"
240         CPPFLAGS="$CPPFLAGS -I$withval/include"
241       fi
242       AC_EXT2_UNDEL
243     fi],[
244     dnl Default: detect
245     AC_CHECK_LIB(ext2fs, ext2fs_close, [AC_EXT2_UNDEL], , [-lcom_err])
246   ])
248   AC_DEFINE(USE_VFS, 1, [Define to enable VFS support])
249   if $use_net_code; then
250      AC_DEFINE(USE_NETCODE, 1, [Define to use networked VFS])
251   fi
256 AC_DEFUN([MC_VFS_CHECKS],[
257         use_vfs=yes
258         AC_ARG_WITH(vfs,
259                 [  --with-vfs               Compile with the VFS code [[yes]]],
260                 use_vfs=$withval
261         )
262         case $use_vfs in
263                 yes)    MC_WITH_VFS;;
264                 no)     use_vfs=no;;
265                 *)      use_vfs=no;;
266                         dnl Should we issue a warning?
267         esac
273 dnl Filesystem information detection
275 dnl To get information about the disk, mount points, etc.
278 AC_DEFUN([AC_GET_FS_INFO], [
279     AC_CHECK_HEADERS(fcntl.h sys/dustat.h sys/param.h sys/statfs.h sys/fstyp.h)
280     AC_CHECK_HEADERS(mnttab.h mntent.h utime.h sys/statvfs.h sys/vfs.h)
281     AC_CHECK_HEADERS(sys/filsys.h sys/fs_types.h)
282     AC_CHECK_HEADERS(sys/mount.h, , , [
283 #include <sys/param.h>
284 #include <sys/stat.h>
285                                       ])
286     AC_CHECK_FUNCS(getmntinfo)
288     dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
289     dnl job is to detect a method to get list of mounted filesystems.
291     AC_MSG_CHECKING([for d_ino member in directory struct])
292     AC_CACHE_VAL(fu_cv_sys_d_ino_in_dirent,
293     [AC_TRY_LINK([
294 #include <sys/types.h>
295 #ifdef HAVE_DIRENT_H
296 # include <dirent.h>
297 #else /* not HAVE_DIRENT_H */
298 # define dirent direct
299 # ifdef HAVE_SYS_NDIR_H
300 #  include <sys/ndir.h>
301 # endif /* HAVE_SYS_NDIR_H */
302 # ifdef HAVE_SYS_DIR_H
303 #  include <sys/dir.h>
304 # endif /* HAVE_SYS_DIR_H */
305 # ifdef HAVE_NDIR_H
306 #  include <ndir.h>
307 # endif /* HAVE_NDIR_H */
308 #endif /* HAVE_DIRENT_H */
309     ],
310       [struct dirent dp; dp.d_ino = 0;],
311         fu_cv_sys_d_ino_in_dirent=yes,
312         fu_cv_sys_d_ino_in_dirent=no)])
313     AC_MSG_RESULT([$fu_cv_sys_d_ino_in_dirent])
314     if test $fu_cv_sys_d_ino_in_dirent = yes; then
315       AC_DEFINE(D_INO_IN_DIRENT, 1,
316                 [Define if `d_ino' is member of `struct directory'])
317     fi
319     # Determine how to get the list of mounted filesystems.
320     list_mounted_fs=
322     # If the getmntent function is available but not in the standard library,
323     # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
324     AC_FUNC_GETMNTENT
326     if test $ac_cv_func_getmntent = yes; then
328       # This system has the getmntent function.
329       # Determine whether it's the one-argument variant or the two-argument one.
331       if test -z "$list_mounted_fs"; then
332         # SVR4
333         AC_MSG_CHECKING([for two-argument getmntent function])
334         AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
335         [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
336           fu_cv_sys_mounted_getmntent2=yes,
337           fu_cv_sys_mounted_getmntent2=no)])
338         AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent2])
339         if test $fu_cv_sys_mounted_getmntent2 = yes; then
340           list_mounted_fs=found
341           AC_DEFINE(MOUNTED_GETMNTENT2, 1,
342                     [Define if function `getmntent' takes 2 arguments])
343         fi
344       fi
346       if test -z "$list_mounted_fs"; then
347         # 4.3BSD, SunOS, HP-UX, Dynix, Irix
348         AC_MSG_CHECKING([for one-argument getmntent function])
349         AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
350                      [test $ac_cv_header_mntent_h = yes \
351                        && fu_cv_sys_mounted_getmntent1=yes \
352                        || fu_cv_sys_mounted_getmntent1=no])
353         AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent1])
354         if test $fu_cv_sys_mounted_getmntent1 = yes; then
355           list_mounted_fs=found
356           AC_DEFINE(MOUNTED_GETMNTENT1, 1,
357                     [Define if function `getmntent' takes 1 argument])
358         fi
359       fi
361     fi
363     if test -z "$list_mounted_fs"; then
364       # DEC Alpha running OSF/1.
365       AC_MSG_CHECKING([for getfsstat function])
366       AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
367       [AC_TRY_LINK([
368 #include <sys/types.h>
369 #include <sys/mount.h>
370 #include <sys/fs_types.h>],
371       [struct statfs *stats;
372       numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
373         fu_cv_sys_mounted_getsstat=yes,
374         fu_cv_sys_mounted_getsstat=no)])
375       AC_MSG_RESULT([$fu_cv_sys_mounted_getsstat])
376       if test $fu_cv_sys_mounted_getsstat = yes; then
377         list_mounted_fs=found
378         AC_DEFINE(MOUNTED_GETFSSTAT, 1,
379                   [Define if function `getfsstat' can be used])
380       fi
381     fi
383     if test -z "$list_mounted_fs"; then
384       # AIX.
385       AC_MSG_CHECKING([for mntctl function and struct vmount])
386       AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
387       [AC_TRY_CPP([#include <fshelp.h>],
388         fu_cv_sys_mounted_vmount=yes,
389         fu_cv_sys_mounted_vmount=no)])
390       AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
391       if test $fu_cv_sys_mounted_vmount = yes; then
392         list_mounted_fs=found
393         AC_DEFINE(MOUNTED_VMOUNT, 1,
394                   [Define if function `mntctl' and `struct vmount' can be used])
395       fi
396     fi
398     if test -z "$list_mounted_fs"; then
399       # SVR3
400       AC_MSG_CHECKING([for existence of three headers])
401       AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
402         [AC_TRY_CPP([
403 #include <sys/statfs.h>
404 #include <sys/fstyp.h>
405 #include <mnttab.h>],
406                     fu_cv_sys_mounted_fread_fstyp=yes,
407                     fu_cv_sys_mounted_fread_fstyp=no)])
408       AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
409       if test $fu_cv_sys_mounted_fread_fstyp = yes; then
410         list_mounted_fs=found
411         AC_DEFINE(MOUNTED_FREAD_FSTYP, 1,
412                   [Define if sys/statfs.h, sys/fstyp.h and mnttab.h
413 can be used together])
414       fi
415     fi
417     if test -z "$list_mounted_fs"; then
418       # 4.4BSD and DEC OSF/1.
419       AC_MSG_CHECKING([for getmntinfo function])
420       AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
421         [
422           ok=
423           if test $ac_cv_func_getmntinfo = yes; then
424             AC_EGREP_HEADER(f_type;, sys/mount.h,
425                             ok=yes)
426           fi
427           test -n "$ok" \
428               && fu_cv_sys_mounted_getmntinfo=yes \
429               || fu_cv_sys_mounted_getmntinfo=no
430         ])
431       AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
432       if test $fu_cv_sys_mounted_getmntinfo = yes; then
433         list_mounted_fs=found
434         AC_DEFINE(MOUNTED_GETMNTINFO, 1,
435                   [Define if `getmntinfo' function can be used])
436         AC_MSG_CHECKING([if struct statfs has f_fstypename])
437         AC_CACHE_VAL(fu_cv_sys_mounted_f_fstypename,
438           [AC_EGREP_HEADER([f_fstypename],
439                            [sys/mount.h],
440                            [fu_cv_sys_mounted_f_fstypename=yes],
441                            [fu_cv_sys_mounted_f_fstypename=no])
442           ])
443         AC_MSG_RESULT([$fu_cv_sys_mounted_f_fstypename])
444         if test $fu_cv_sys_mounted_f_fstypename = yes; then
445           AC_DEFINE(HAVE_F_FSTYPENAME, 1,
446                     [Define if `f_fstypename' is member of `struct statfs'])
447         fi
448       fi
449     fi
451     if test -z "$list_mounted_fs"; then
452       # Ultrix
453       AC_MSG_CHECKING([for getmnt function])
454       AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
455         [AC_TRY_CPP([
456 #include <sys/fs_types.h>
457 #include <sys/mount.h>],
458                     fu_cv_sys_mounted_getmnt=yes,
459                     fu_cv_sys_mounted_getmnt=no)])
460       AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
461       if test $fu_cv_sys_mounted_getmnt = yes; then
462         list_mounted_fs=found
463         AC_DEFINE(MOUNTED_GETMNT, 1,
464                   [Define if `getmnt' function can be used])
465       fi
466     fi
468     if test -z "$list_mounted_fs"; then
469       # SVR2
470     AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
471       AC_CACHE_VAL(fu_cv_sys_mounted_fread,
472         [AC_TRY_CPP([#include <mnttab.h>],
473                     fu_cv_sys_mounted_fread=yes,
474                     fu_cv_sys_mounted_fread=no)])
475       AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
476       if test $fu_cv_sys_mounted_fread = yes; then
477         list_mounted_fs=found
478         AC_DEFINE(MOUNTED_FREAD, 1,
479                  [Define if it's possible to resort to fread on /etc/mnttab])
480       fi
481     fi
483     if test -z "$list_mounted_fs"; then
484       AC_MSG_WARN([could not determine how to read list of mounted fs])
485     else
486       AC_DEFINE(HAVE_INFOMOUNT_LIST, 1,
487                 [Define if the list of mounted filesystems can be determined])
488     fi
490 dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
491 dnl job is to detect a method to get file system information.
493     AC_MSG_NOTICE([checking how to get filesystem space usage])
494     space=no
496     # Here we'll compromise a little (and perform only the link test)
497     # since it seems there are no variants of the statvfs function.
498     if test $space = no; then
499       # SVR4
500       AC_CHECK_FUNCS(statvfs)
501       if test $ac_cv_func_statvfs = yes; then
502         space=yes
503         AC_DEFINE(STAT_STATVFS, 1,
504                   [Define if function `statfs' can be used])
505       fi
506     fi
508     if test $space = no; then
509       # DEC Alpha running OSF/1
510       AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
511       AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
512       [AC_TRY_RUN([
513 #include <sys/param.h>
514 #include <sys/types.h>
515 #include <sys/mount.h>
516       main ()
517       {
518         struct statfs fsd;
519         fsd.f_fsize = 0;
520         exit (statfs (".", &fsd, sizeof (struct statfs)));
521       }],
522       fu_cv_sys_stat_statfs3_osf1=yes,
523       fu_cv_sys_stat_statfs3_osf1=no,
524       fu_cv_sys_stat_statfs3_osf1=no)])
525       AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
526       if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
527         space=yes
528         AC_DEFINE(STAT_STATFS3_OSF1, 1,
529                   [Define if function `statfs' takes 3 arguments])
530       fi
531     fi
533     if test $space = no; then
534     # AIX
535       AC_MSG_CHECKING([for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)])
536       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
537       [AC_TRY_RUN([
538 #ifdef HAVE_SYS_PARAM_H
539 #include <sys/param.h>
540 #endif
541 #ifdef HAVE_SYS_MOUNT_H
542 #include <sys/mount.h>
543 #endif
544 #ifdef HAVE_SYS_VFS_H
545 #include <sys/vfs.h>
546 #endif
547       main ()
548       {
549       struct statfs fsd;
550       fsd.f_bsize = 0;
551       exit (statfs (".", &fsd));
552       }],
553       fu_cv_sys_stat_statfs2_bsize=yes,
554       fu_cv_sys_stat_statfs2_bsize=no,
555       fu_cv_sys_stat_statfs2_bsize=no)])
556       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize])
557       if test $fu_cv_sys_stat_statfs2_bsize = yes; then
558         space=yes
559         AC_DEFINE(STAT_STATFS2_BSIZE, 1,
560                   [Define if function `statfs' takes two arguments and
561 `bsize' is member of `struct statfs'])
562       fi
563     fi
565     if test $space = no; then
566     # SVR3
567       AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
568       AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
569       [AC_TRY_RUN([#include <sys/types.h>
570 #include <sys/statfs.h>
571       main ()
572       {
573       struct statfs fsd;
574       exit (statfs (".", &fsd, sizeof fsd, 0));
575       }],
576         fu_cv_sys_stat_statfs4=yes,
577         fu_cv_sys_stat_statfs4=no,
578         fu_cv_sys_stat_statfs4=no)])
579       AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
580       if test $fu_cv_sys_stat_statfs4 = yes; then
581         space=yes
582         AC_DEFINE(STAT_STATFS4, 1,
583                   [Define if function `statfs' takes 4 arguments])
584       fi
585     fi
587     if test $space = no; then
588     # 4.4BSD and NetBSD
589       AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
590     member (4.4BSD and NetBSD)])
591       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
592       [AC_TRY_RUN([#include <sys/types.h>
593 #ifdef HAVE_SYS_PARAM_H
594 #include <sys/param.h>
595 #endif
596 #ifdef HAVE_SYS_MOUNT_H
597 #include <sys/mount.h>
598 #endif
599       main ()
600       {
601       struct statfs fsd;
602       fsd.f_fsize = 0;
603       exit (statfs (".", &fsd));
604       }],
605       fu_cv_sys_stat_statfs2_fsize=yes,
606       fu_cv_sys_stat_statfs2_fsize=no,
607       fu_cv_sys_stat_statfs2_fsize=no)])
608       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize])
609       if test $fu_cv_sys_stat_statfs2_fsize = yes; then
610         space=yes
611         AC_DEFINE(STAT_STATFS2_FSIZE, 1,
612                   [Define if function `statfs' takes two arguments and
613 `fsize' is member of `struct statfs'])
614       fi
615     fi
617     if test $space = no; then
618       # Ultrix
619       AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
620       AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
621       [AC_TRY_RUN([
622 #include <sys/types.h>
623 #ifdef HAVE_SYS_PARAM_H
624 #include <sys/param.h>
625 #endif
626 #ifdef HAVE_SYS_MOUNT_H
627 #include <sys/mount.h>
628 #endif
629 #ifdef HAVE_SYS_FS_TYPES_H
630 #include <sys/fs_types.h>
631 #endif
632       main ()
633       {
634       struct fs_data fsd;
635       /* Ultrix's statfs returns 1 for success,
636          0 for not mounted, -1 for failure.  */
637       exit (statfs (".", &fsd) != 1);
638       }],
639       fu_cv_sys_stat_fs_data=yes,
640       fu_cv_sys_stat_fs_data=no,
641       fu_cv_sys_stat_fs_data=no)])
642       AC_MSG_RESULT([$fu_cv_sys_stat_fs_data])
643       if test $fu_cv_sys_stat_fs_data = yes; then
644         space=yes
645         AC_DEFINE(STAT_STATFS2_FS_DATA, 1,
646                   [Define if function `statfs' takes two arguments
647 and uses `struct fs_data'])
648       fi
649     fi
651     dnl Not supported
652     dnl if test $space = no; then
653     dnl # SVR2
654     dnl AC_TRY_CPP([#include <sys/filsys.h>],
655     dnl   AC_DEFINE(STAT_READ_FILSYS) space=yes)
656     dnl fi
661 dnl Try using termcap database and link with libtermcap if possible.
663 AC_DEFUN([MC_USE_TERMCAP], [
664         screen_msg="$screen_msg with termcap database"
665         AC_MSG_NOTICE([using S-Lang screen library with termcap])
666         AC_DEFINE(USE_TERMCAP, 1, [Define to use termcap database])
667         AC_CHECK_LIB(termcap, tgoto, [MCLIBS="$MCLIBS -ltermcap"], , [$LIBS])
672 dnl Common code for MC_WITH_SLANG and MC_WITH_MCSLANG
674 AC_DEFUN([_MC_WITH_XSLANG], [
675     screen_type=slang
676     AC_DEFINE(HAVE_SLANG, 1,
677               [Define to use S-Lang library for screen management])
682 dnl Check if the system S-Lang library can be used.
683 dnl If not, and $1 is "strict", exit, otherwise fall back to mcslang.
685 AC_DEFUN([MC_WITH_SLANG], [
686     with_screen=slang
688     dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
689     m4_if([$1], strict, ,
690           [AC_CHECK_LIB([slang], [SLsmg_write_nwchars],
691                         [AC_MSG_WARN([Rejecting S-Lang with UTF-8 support, \
692 it doesn't work well])
693                         with_screen=mcslang])])
695     if test x$with_screen = xslang; then
696         AC_CHECK_LIB([slang], [SLang_init_tty], [MCLIBS="$MCLIBS -lslang"],
697                      [with_screen=mcslang])
698     fi
700     dnl Check the header
701     if test x$with_screen = xslang; then
702         slang_h_found=
703         AC_CHECK_HEADERS([slang.h slang/slang.h],
704                          [slang_h_found=yes; break])
706         if test -z "$slang_h_found"; then
707             with_screen=mcslang
708         fi
709     fi
711     dnl Check if the installed S-Lang library uses termcap
712     if test x$with_screen = xslang; then
713         screen_type=slang
714         screen_msg="S-Lang library (installed on the system)"
715         AC_DEFINE(HAVE_SYSTEM_SLANG, 1,
716                   [Define to use S-Lang library installed on the system])
717         ac_save_LIBS="$LIBS"
718         LIBS="$LIBS -lslang"
719         AC_TRY_LINK([ 
720         #ifdef HAVE_SLANG_SLANG_H
721         #include <slang/slang.h>
722         #else
723         #include <slang.h>
724         #endif],
725         [SLtt_get_terminfo();
726         SLtt_tgetflag("");], 
727         [LIBS="$ac_save_LIBS"],
728         [LIBS="$ac_save_LIBS"; MC_USE_TERMCAP])
729         _MC_WITH_XSLANG
730     else
731         m4_if([$1], strict,
732             [if test $with_screen != slang; then
733                 AC_MSG_ERROR([S-Lang library not found])
734             fi],
735             [MC_WITH_MCSLANG]
736         )
737     fi
742 dnl Use the included S-Lang library.
744 AC_DEFUN([MC_WITH_MCSLANG], [
745     screen_type=slang
746     screen_msg="Included S-Lang library (mcslang)"
748     # Search for terminfo database.
749     use_terminfo=
750     if test x"$with_termcap" != xyes; then
751         if test x"$with_termcap" = xno; then
752             use_terminfo=yes
753         fi
754         if test -n "$TERMINFO" && test -r "$TERMINFO/v/vt100"; then
755             use_terminfo=yes
756         fi
757         for dir in "/usr/share/terminfo" "/usr/lib/terminfo" \
758                    "/usr/share/lib/terminfo" "/etc/terminfo" \
759                    "/usr/local/lib/terminfo" "$HOME/.terminfo"; do
760             if test -r "$dir/v/vt100"; then
761                 use_terminfo=yes
762             fi
763         done
764     fi
766     # If there is no terminfo, use termcap
767     if test -z "$use_terminfo"; then
768         MC_USE_TERMCAP
769     fi
771     _MC_WITH_XSLANG
776 dnl Use the ncurses library.  It can only be requested explicitly,
777 dnl so just fail if anything goes wrong.
779 dnl If ncurses exports the ESCDELAY variable it should be set to 0
780 dnl or you'll have to press Esc three times to dismiss a dialog box.
782 AC_DEFUN([MC_WITH_NCURSES], [
783     dnl has_colors() is specific to ncurses, it's not in the old curses
784     save_LIBS="$LIBS"
785     LIBS=
786     AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
787                    [AC_MSG_ERROR([Cannot find ncurses library])])
789     dnl Check the header
790     ncurses_h_found=
791     AC_CHECK_HEADERS([ncurses/curses.h ncurses.h curses.h],
792                      [ncurses_h_found=yes; break])
794     if test -z "$ncurses_h_found"; then
795         AC_MSG_ERROR([Cannot find ncurses header file])
796     fi
798     screen_type=ncurses
799     screen_msg="ncurses library"
800     AC_DEFINE(USE_NCURSES, 1,
801               [Define to use ncurses for screen management])
803     AC_CACHE_CHECK([for ESCDELAY variable],
804                    [mc_cv_ncurses_escdelay],
805                    [AC_TRY_LINK([], [
806                         extern int ESCDELAY;
807                         ESCDELAY = 0;
808                         ],
809                         [mc_cv_ncurses_escdelay=yes],
810                         [mc_cv_ncurses_escdelay=no])
811     ])
812     if test "$mc_cv_ncurses_escdelay" = yes; then
813         AC_DEFINE(HAVE_ESCDELAY, 1,
814                   [Define if ncurses has ESCDELAY variable])
815     fi
817     AC_CHECK_FUNCS(resizeterm)
818     LIBS="$save_LIBS"
823 dnl Check for ext2fs recovery code
825 AC_DEFUN([AC_EXT2_UNDEL], [
826   MC_UNDELFS_CHECKS
827   if test "$ext2fs_undel" = yes; then
828      AC_MSG_NOTICE([using ext2fs file recovery code])
829      vfs_flags="${vfs_flags}, undelfs"
830      use_undelfs=yes
831      MCLIBS="$MCLIBS $EXT2FS_UNDEL_LIBS"
832   else
833      AC_MSG_NOTICE([not using ext2fs file recovery code])
834   fi
837 dnl The next line is for compatibility with gettext 0.10.x
838 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
841 dnl Check whether the g_module_* family of functions works
842 dnl on this system.  We need to know that at the compile time to
843 dnl decide whether to link with X11.
845 AC_DEFUN([AC_G_MODULE_SUPPORTED], [
846     AC_CACHE_CHECK([if gmodule functionality is supported], mc_cv_g_module_supported, [
847         ac_save_CFLAGS="$CFLAGS"
848         ac_save_LIBS="$LIBS"
849         CFLAGS="$CFLAGS $GMODULE_CFLAGS"
850         LIBS="$GMODULE_LIBS $LIBS"
851         AC_TRY_RUN([
852 #include <gmodule.h>
854 int main ()
856     int ret = (g_module_supported () == TRUE) ? 0 : 1;
857     return ret;
859         ],
860             [mc_cv_g_module_supported=yes],
861             [mc_cv_g_module_supported=no],
862             [mc_cv_g_module_supported=no]
863         )
864         CFLAGS="$ac_save_CFLAGS"
865         LIBS="$ac_save_LIBS"
866     ])
868 if test "$mc_cv_g_module_supported" = yes; then
869     AC_DEFINE(HAVE_GMODULE, 1,
870               [Define if gmodule functionality is supported])
876 dnl Check if it's possible to use asm labels to rename functions.
877 dnl This macro is necessary because gettext wrongly assumes that gcc
878 dnl can do it regardless of the OS.
880 AC_DEFUN([MC_ASM_LABELS], [
881     AC_CACHE_CHECK([whether functions can be renamed by asm labels],
882                    mc_cv_asm_labels,
883                    [mc_cv_asm_labels=no
884                    if test -n "$GCC"; then
885                         AC_TRY_LINK(, [
886 static int function1 (void) __asm__ ("function2");
887 static int function1 (void)
889     return 0;
891 return function2();
892 ], [mc_cv_asm_labels=yes])
893                    fi
894    ])
896 if test "$mc_cv_asm_labels" != yes; then
897     AC_DEFINE(_INTL_REDIRECT_MACROS, 1,
898               [Define if functions cannot be renamed by asm labels])