* ftpfs.c (ftpfs_fill_names): New function.
[midnight-commander.git] / acinclude.m4
blob7ee8031278dfb2f3e05f8f387622d15df96ad629
1 dnl
2 dnl Check for size of d_name dirent member
3 dnl
4 AC_DEFUN([AC_SHORT_D_NAME_LEN], [
5 AC_MSG_CHECKING([filename fits on dirent.d_name])
6 AC_CACHE_VAL(ac_cv_dnamesize, [
7 OCFLAGS="$CFLAGS"
8 CFLAGS="$CFLAGS -I$srcdir"
9 AC_TRY_RUN([
10 #include <src/fs.h>
12 int main ()
14    struct dirent ddd;
16    if (sizeof (ddd.d_name) < 12)
17         return 0;
18    else
19         return 1; 
22 ],[
23     ac_cv_dnamesize="no"
24 ], [
25     ac_cv_dnamesize="yes"
26 ], [
27 # Cannot find out, so assume no
28     ac_cv_dnamesize="no"
30 CFLAGS="$OCFLAGS"
32 if test x$ac_cv_dnamesize = xno; then
33     AC_DEFINE(NEED_EXTRA_DIRENT_BUFFER)
35 AC_MSG_RESULT([$ac_cv_dnamesize])
38 dnl
39 dnl Filesystem information detection
40 dnl
41 dnl To get information about the disk, mount points, etc.
42 dnl
44 AC_DEFUN([AC_GET_FS_INFO], [
45     AC_CHECK_HEADERS(fcntl.h sys/dustat.h sys/param.h sys/statfs.h sys/fstyp.h)
46     AC_CHECK_HEADERS(mnttab.h mntent.h utime.h sys/statvfs.h sys/vfs.h)
47     AC_CHECK_HEADERS(sys/mount.h sys/filsys.h sys/fs_types.h)
48     AC_CHECK_FUNCS(getmntinfo)
50     dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
51     dnl job is to detect a method to get list of mounted filesystems.
53     AC_MSG_CHECKING([for d_ino member in directory struct])
54     AC_CACHE_VAL(fu_cv_sys_d_ino_in_dirent,
55     [AC_TRY_LINK([
56 #include <sys/types.h>
57 #ifdef HAVE_DIRENT_H
58 # include <dirent.h>
59 #else /* not HAVE_DIRENT_H */
60 # define dirent direct
61 # ifdef HAVE_SYS_NDIR_H
62 #  include <sys/ndir.h>
63 # endif /* HAVE_SYS_NDIR_H */
64 # ifdef HAVE_SYS_DIR_H
65 #  include <sys/dir.h>
66 # endif /* HAVE_SYS_DIR_H */
67 # ifdef HAVE_NDIR_H
68 #  include <ndir.h>
69 # endif /* HAVE_NDIR_H */
70 #endif /* HAVE_DIRENT_H */
71     ],
72       [struct dirent dp; dp.d_ino = 0;],
73         fu_cv_sys_d_ino_in_dirent=yes,
74         fu_cv_sys_d_ino_in_dirent=no)])
75     AC_MSG_RESULT([$fu_cv_sys_d_ino_in_dirent])
76     if test $fu_cv_sys_d_ino_in_dirent = yes; then
77       AC_DEFINE(D_INO_IN_DIRENT)
78     fi
80     # Determine how to get the list of mounted filesystems.
81     list_mounted_fs=
83     # If the getmntent function is available but not in the standard library,
84     # make sure LIBS contains -lsun (on Irix4) or -lseq (on PTX).
85     AC_FUNC_GETMNTENT
87     if test $ac_cv_func_getmntent = yes; then
89       # This system has the getmntent function.
90       # Determine whether it's the one-argument variant or the two-argument one.
92       if test -z "$list_mounted_fs"; then
93         # SVR4
94         AC_MSG_CHECKING([for two-argument getmntent function])
95         AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2,
96         [AC_EGREP_HEADER(getmntent, sys/mnttab.h,
97           fu_cv_sys_mounted_getmntent2=yes,
98           fu_cv_sys_mounted_getmntent2=no)])
99         AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent2])
100         if test $fu_cv_sys_mounted_getmntent2 = yes; then
101           list_mounted_fs=found
102           AC_DEFINE(MOUNTED_GETMNTENT2)
103         fi
104       fi
106       if test -z "$list_mounted_fs"; then
107         # 4.3BSD, SunOS, HP-UX, Dynix, Irix
108         AC_MSG_CHECKING([for one-argument getmntent function])
109         AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1,
110                      [test $ac_cv_header_mntent_h = yes \
111                        && fu_cv_sys_mounted_getmntent1=yes \
112                        || fu_cv_sys_mounted_getmntent1=no])
113         AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent1])
114         if test $fu_cv_sys_mounted_getmntent1 = yes; then
115           list_mounted_fs=found
116           AC_DEFINE(MOUNTED_GETMNTENT1)
117         fi
118       fi
120     fi
122     if test -z "$list_mounted_fs"; then
123       # DEC Alpha running OSF/1.
124       AC_MSG_CHECKING([for getfsstat function])
125       AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
126       [AC_TRY_LINK([
127 #include <sys/types.h>
128 #include <sys/mount.h>
129 #include <sys/fs_types.h>],
130       [struct statfs *stats;
131       numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
132         fu_cv_sys_mounted_getsstat=yes,
133         fu_cv_sys_mounted_getsstat=no)])
134       AC_MSG_RESULT([$fu_cv_sys_mounted_getsstat])
135       if test $fu_cv_sys_mounted_getsstat = yes; then
136         list_mounted_fs=found
137         AC_DEFINE(MOUNTED_GETFSSTAT)
138       fi
139     fi
141     if test -z "$list_mounted_fs"; then
142       # AIX.
143       AC_MSG_CHECKING([for mntctl function and struct vmount])
144       AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
145       [AC_TRY_CPP([#include <fshelp.h>],
146         fu_cv_sys_mounted_vmount=yes,
147         fu_cv_sys_mounted_vmount=no)])
148       AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
149       if test $fu_cv_sys_mounted_vmount = yes; then
150         list_mounted_fs=found
151         AC_DEFINE(MOUNTED_VMOUNT)
152       fi
153     fi
155     if test -z "$list_mounted_fs"; then
156       # SVR3
157       AC_MSG_CHECKING([for existence of three headers])
158       AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
159         [AC_TRY_CPP([
160 #include <sys/statfs.h>
161 #include <sys/fstyp.h>
162 #include <mnttab.h>],
163                     fu_cv_sys_mounted_fread_fstyp=yes,
164                     fu_cv_sys_mounted_fread_fstyp=no)])
165       AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
166       if test $fu_cv_sys_mounted_fread_fstyp = yes; then
167         list_mounted_fs=found
168         AC_DEFINE(MOUNTED_FREAD_FSTYP)
169       fi
170     fi
172     if test -z "$list_mounted_fs"; then
173       # 4.4BSD and DEC OSF/1.
174       AC_MSG_CHECKING([for getmntinfo function])
175       AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
176         [
177           ok=
178           if test $ac_cv_func_getmntinfo = yes; then
179             AC_EGREP_HEADER(f_type;, sys/mount.h,
180                             ok=yes)
181           fi
182           test -n "$ok" \
183               && fu_cv_sys_mounted_getmntinfo=yes \
184               || fu_cv_sys_mounted_getmntinfo=no
185         ])
186       AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
187       if test $fu_cv_sys_mounted_getmntinfo = yes; then
188         list_mounted_fs=found
189         AC_DEFINE(MOUNTED_GETMNTINFO)
190         AC_MSG_CHECKING([if struct statfs has f_fstypename])
191         AC_CACHE_VAL(fu_cv_sys_mounted_f_fstypename,
192           [AC_EGREP_HEADER([f_fstypename],
193                            [sys/mount.h],
194                            [fu_cv_sys_mounted_f_fstypename=yes],
195                            [fu_cv_sys_mounted_f_fstypename=no])
196           ])
197         AC_MSG_RESULT([$fu_cv_sys_mounted_f_fstypename])
198         if test $fu_cv_sys_mounted_f_fstypename = yes; then
199           AC_DEFINE(HAVE_F_FSTYPENAME)
200         fi
201       fi
202     fi
204     if test -z "$list_mounted_fs"; then
205       # Ultrix
206       AC_MSG_CHECKING([for getmnt function])
207       AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
208         [AC_TRY_CPP([
209 #include <sys/fs_types.h>
210 #include <sys/mount.h>],
211                     fu_cv_sys_mounted_getmnt=yes,
212                     fu_cv_sys_mounted_getmnt=no)])
213       AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
214       if test $fu_cv_sys_mounted_getmnt = yes; then
215         list_mounted_fs=found
216         AC_DEFINE(MOUNTED_GETMNT)
217       fi
218     fi
220     if test -z "$list_mounted_fs"; then
221       # SVR2
222     AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
223       AC_CACHE_VAL(fu_cv_sys_mounted_fread,
224         [AC_TRY_CPP([#include <mnttab.h>],
225                     fu_cv_sys_mounted_fread=yes,
226                     fu_cv_sys_mounted_fread=no)])
227       AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
228       if test $fu_cv_sys_mounted_fread = yes; then
229         list_mounted_fs=found
230         AC_DEFINE(MOUNTED_FREAD)
231       fi
232     fi
234     if test -z "$list_mounted_fs"; then
235       AC_MSG_WARN([could not determine how to read list of mounted fs])
236     else
237       AC_DEFINE(HAVE_INFOMOUNT_LIST, 1,
238                 [Can determine list of mounted filesystems])
239     fi
241 dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
242 dnl job is to detect a method to get file system information.
244     AC_CHECKING([how to get filesystem space usage])
245     space=no
247     # Here we'll compromise a little (and perform only the link test)
248     # since it seems there are no variants of the statvfs function.
249     if test $space = no; then
250       # SVR4
251       AC_CHECK_FUNCS(statvfs)
252       if test $ac_cv_func_statvfs = yes; then
253         space=yes
254         AC_DEFINE(STAT_STATVFS)
255       fi
256     fi
258     if test $space = no; then
259       # DEC Alpha running OSF/1
260       AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
261       AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
262       [AC_TRY_RUN([
263 #include <sys/param.h>
264 #include <sys/types.h>
265 #include <sys/mount.h>
266       main ()
267       {
268         struct statfs fsd;
269         fsd.f_fsize = 0;
270         exit (statfs (".", &fsd, sizeof (struct statfs)));
271       }],
272       fu_cv_sys_stat_statfs3_osf1=yes,
273       fu_cv_sys_stat_statfs3_osf1=no,
274       fu_cv_sys_stat_statfs3_osf1=no)])
275       AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
276       if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
277         space=yes
278         AC_DEFINE(STAT_STATFS3_OSF1)
279       fi
280     fi
282     if test $space = no; then
283     # AIX
284       AC_MSG_CHECKING([for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)])
285       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
286       [AC_TRY_RUN([
287 #ifdef HAVE_SYS_PARAM_H
288 #include <sys/param.h>
289 #endif
290 #ifdef HAVE_SYS_MOUNT_H
291 #include <sys/mount.h>
292 #endif
293 #ifdef HAVE_SYS_VFS_H
294 #include <sys/vfs.h>
295 #endif
296       main ()
297       {
298       struct statfs fsd;
299       fsd.f_bsize = 0;
300       exit (statfs (".", &fsd));
301       }],
302       fu_cv_sys_stat_statfs2_bsize=yes,
303       fu_cv_sys_stat_statfs2_bsize=no,
304       fu_cv_sys_stat_statfs2_bsize=no)])
305       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize])
306       if test $fu_cv_sys_stat_statfs2_bsize = yes; then
307         space=yes
308         AC_DEFINE(STAT_STATFS2_BSIZE)
309       fi
310     fi
312     if test $space = no; then
313     # SVR3
314       AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
315       AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
316       [AC_TRY_RUN([#include <sys/types.h>
317 #include <sys/statfs.h>
318       main ()
319       {
320       struct statfs fsd;
321       exit (statfs (".", &fsd, sizeof fsd, 0));
322       }],
323         fu_cv_sys_stat_statfs4=yes,
324         fu_cv_sys_stat_statfs4=no,
325         fu_cv_sys_stat_statfs4=no)])
326       AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
327       if test $fu_cv_sys_stat_statfs4 = yes; then
328         space=yes
329         AC_DEFINE(STAT_STATFS4)
330       fi
331     fi
333     if test $space = no; then
334     # 4.4BSD and NetBSD
335       AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
336     member (4.4BSD and NetBSD)])
337       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
338       [AC_TRY_RUN([#include <sys/types.h>
339 #ifdef HAVE_SYS_PARAM_H
340 #include <sys/param.h>
341 #endif
342 #ifdef HAVE_SYS_MOUNT_H
343 #include <sys/mount.h>
344 #endif
345       main ()
346       {
347       struct statfs fsd;
348       fsd.f_fsize = 0;
349       exit (statfs (".", &fsd));
350       }],
351       fu_cv_sys_stat_statfs2_fsize=yes,
352       fu_cv_sys_stat_statfs2_fsize=no,
353       fu_cv_sys_stat_statfs2_fsize=no)])
354       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize])
355       if test $fu_cv_sys_stat_statfs2_fsize = yes; then
356         space=yes
357         AC_DEFINE(STAT_STATFS2_FSIZE)
358       fi
359     fi
361     if test $space = no; then
362       # Ultrix
363       AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
364       AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
365       [AC_TRY_RUN([
366 #include <sys/types.h>
367 #ifdef HAVE_SYS_PARAM_H
368 #include <sys/param.h>
369 #endif
370 #ifdef HAVE_SYS_MOUNT_H
371 #include <sys/mount.h>
372 #endif
373 #ifdef HAVE_SYS_FS_TYPES_H
374 #include <sys/fs_types.h>
375 #endif
376       main ()
377       {
378       struct fs_data fsd;
379       /* Ultrix's statfs returns 1 for success,
380          0 for not mounted, -1 for failure.  */
381       exit (statfs (".", &fsd) != 1);
382       }],
383       fu_cv_sys_stat_fs_data=yes,
384       fu_cv_sys_stat_fs_data=no,
385       fu_cv_sys_stat_fs_data=no)])
386       AC_MSG_RESULT([$fu_cv_sys_stat_fs_data])
387       if test $fu_cv_sys_stat_fs_data = yes; then
388         space=yes
389         AC_DEFINE(STAT_STATFS2_FS_DATA)
390       fi
391     fi
393     dnl Not supported
394     dnl if test $space = no; then
395     dnl # SVR2
396     dnl AC_TRY_CPP([#include <sys/filsys.h>],
397     dnl   AC_DEFINE(STAT_READ_FILSYS) space=yes)
398     dnl fi
401 dnl AC_TRY_WARNINGS(INCLUDES, FUNCTION-BODY,
402 dnl             ACTION-IF-NO-WARNINGS [, ACTION-IF-WARNINGS-OR-ERROR])
403 AC_DEFUN([AC_TRY_WARNINGS],
404 [cat > conftest.$ac_ext <<EOF
405 dnl This sometimes fails to find confdefs.h, for some reason.
406 dnl [#]line __oline__ "[$]0"
407 [#]line __oline__ "configure"
408 #include "confdefs.h"
409 [$1]
410 int main() { return 0; }
411 int t() {
412 [$2]
413 ; return 0; }
415 ac_compile_warn='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1'
416 if { if eval $ac_compile_warn; then :; else echo arning; fi; } | grep arning 1>&AC_FD_CC 2>&AC_FD_CC; then
417   ifelse([$4], , :, [rm -rf conftest*
418   $4])
419 ifelse([$3], , , [else
420   rm -rf conftest*
421   $3
422 ])dnl
424 rm -f conftest*]
427 AC_DEFUN([AC_USE_SUNOS_CURSES], [
428         search_ncurses=false
429         screen_manager="SunOS 4.x /usr/5include curses"
430         AC_MSG_RESULT([Using SunOS 4.x /usr/5include curses])
431         AC_DEFINE(USE_SUNOS_CURSES)
432         AC_DEFINE(NO_COLOR_CURSES)
433         AC_DEFINE(USE_SYSV_CURSES)
434         CPPFLAGS="$CPPFLAGS -I/usr/5include"
435         XCURSES="xcurses.o /usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
436         AC_MSG_RESULT([Please note that some screen refreshs may fail])
437         AC_MSG_WARN([Reconsider using Slang])
440 AC_DEFUN([AC_USE_OSF1_CURSES], [
441        AC_MSG_RESULT([Using OSF1 curses])
442        search_ncurses=false
443        screen_manager="OSF1 curses"
444        AC_DEFINE(NO_COLOR_CURSES)
445        AC_DEFINE(USE_SYSV_CURSES)
446        XCURSES="xcurses.o"
447        LIBS="$LIBS -lcurses"
450 AC_DEFUN([AC_USE_SYSV_CURSES], [
451         AC_MSG_RESULT([Using SysV curses])
452         AC_DEFINE(USE_SYSV_CURSES)
453         XCURSES=""
454         search_ncurses=false
455         screen_manager="SysV/curses"
456         LIBS="$LIBS -lcurses"
459 AC_DEFUN([AC_USE_TERMINFO], [
460         AC_DEFINE(SLANG_TERMINFO)
461         AC_MSG_RESULT([Using SLang screen manager/terminfo])
462         slang_term=" with terminfo"
465 AC_DEFUN([AC_USE_TERMCAP], [
466         AC_MSG_RESULT([Using SLang screen manager/termcap])
467         AC_DEFINE(USE_TERMCAP)
468         dnl Check with $LIBS at the end so that it works with ELF libs.
469         AC_CHECK_LIB(termcap, tgoto, LIBS="$LIBS -ltermcap", , $LIBS)
470         slang_term=" with termcap"
472         
473 AC_DEFUN([AC_WITH_SLANG], [
474         AC_DEFINE(HAVE_SLANG)
475         search_ncurses=false
476         if $slang_use_system_installed_lib
477         then
478             AC_DEFINE(HAVE_SYSTEM_SLANG)
479             LSLANG="-lslang"
480             screen_manager="SLang (system-installed library)"
481             AC_MSG_RESULT([Using system installed SLang library])
482             rm -f slang/slang.h
483             ac_save_LIBS="$LIBS"
484             LIBS="$LIBS $LSLANG"
485             AC_TRY_RUN(
486             [ 
487             #ifdef SLANG_H_INSIDE_SLANG_DIR
488             #include <slang/slang.h>
489             #else
490             #include <slang.h>
491             #endif
492             int main(void){
493                 SLtt_get_terminfo();
494                 SLtt_tgetflag("");
495                 return 0;
496             } ], 
497             [LIBS="$ac_save_LIBS"; AC_USE_TERMINFO], 
498             [LIBS="$ac_save_LIBS"; AC_USE_TERMCAP])
499         else
500             MCCPPFLAGS="$MCCPPFLAGS -I\$(slangdir)"
501             LIBSLANG="libmcslang.a"
502             screen_manager="SLang"
503             LSLANG="-lmcslang"
504             CPPFLAGS="$CPPFLAGS -I../slang"
505             fastdepslang=fastdepslang
506             mkdir -p slang
507             rm -f slang/slang.h
508             case "$srcdir" in
509                 /*) ln -sf  $srcdir/slang/slang-mc.h slang/slang.h;;
510                 *)  ln -sf  ../$srcdir/slang/slang-mc.h slang/slang.h;;
511             esac
512         fi
513         if $slang_check_lib
514         then
515             use_terminfo=false
516             for dir in  /usr/lib /usr/share/lib /usr/local/lib /lib \
517                         /usr/local/share /usr/share
518             do
519                 if test -d $dir/terminfo; then
520                 use_terminfo=true; 
521                 break
522                 fi
523             done
524             if $use_terminfo; then
525                 AC_USE_TERMINFO
526             else
527                 AC_USE_TERMCAP
528             fi
529         fi]
532 AC_DEFUN([AC_WITH_EDIT], [
533         AC_DEFINE(USE_INTERNAL_EDIT)
534         LIBEDIT_A="libedit.a"
535         MCEDIT="mcedit"
536         LEDIT="-ledit"
537         EDIT_msg="yes"
538         AC_MSG_RESULT([will call internal editor])
541 AC_DEFUN([AC_EXT2_UNDEL], [
542   GNOME_UNDELFS_CHECKS
543   if test "$ext2fs_undel" = yes; then
544      AC_MSG_RESULT([With ext2fs file recovery code])
545      vfs_flags="${vfs_flags}, undelfs"
546      undelfs_o="undelfs.o"
547      LIBS="$LIBS $EXT2FS_UNDEL_LIBS"
548   else
549      AC_MSG_WARN([No ext2fs file recovery code])
550   fi
554 dnl Parameters: directory filename LIBS_append CPPFLAGS_append nicename
556 AC_DEFUN([AC_NCURSES], [
557     if $search_ncurses
558     then
559         if test -f $1/$2
560         then
561             AC_MSG_RESULT([Found ncurses on $1/$2])
562             LIBS="$LIBS $3"
563             CPPFLAGS="$CPPFLAGS $4"
564             search_ncurses=false
565             screen_manager=$5
566             AC_DEFINE(USE_NCURSES)
567         fi
568     fi