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