Codepage messages related translated & other stuff...
[midnight-commander.git] / acinclude.m4
blobc6a292304ef5275f89d9ed35914d8416027b476f
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 main ()
14    struct dirent ddd;
16    if (sizeof (ddd.d_name) < 12)
17         exit (0);
18    else
19         exit (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       if test -z "$list_mounted_fs"; then
121         AC_MSG_WARN([could not determine how to read list of mounted fs])
122         CPPFLAGS="$CPPFLAGS -DNO_INFOMOUNT"
123       fi
125     fi
127     if test -z "$list_mounted_fs"; then
128       # DEC Alpha running OSF/1.
129       AC_MSG_CHECKING([for getfsstat function])
130       AC_CACHE_VAL(fu_cv_sys_mounted_getsstat,
131       [AC_TRY_LINK([
132 #include <sys/types.h>
133 #include <sys/mount.h>
134 #include <sys/fs_types.h>],
135       [struct statfs *stats;
136       numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); ],
137         fu_cv_sys_mounted_getsstat=yes,
138         fu_cv_sys_mounted_getsstat=no)])
139       AC_MSG_RESULT([$fu_cv_sys_mounted_getsstat])
140       if test $fu_cv_sys_mounted_getsstat = yes; then
141         list_mounted_fs=found
142         AC_DEFINE(MOUNTED_GETFSSTAT)
143       fi
144     fi
146     if test -z "$list_mounted_fs"; then
147       # AIX.
148       AC_MSG_CHECKING([for mntctl function and struct vmount])
149       AC_CACHE_VAL(fu_cv_sys_mounted_vmount,
150       [AC_TRY_CPP([#include <fshelp.h>],
151         fu_cv_sys_mounted_vmount=yes,
152         fu_cv_sys_mounted_vmount=no)])
153       AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
154       if test $fu_cv_sys_mounted_vmount = yes; then
155         list_mounted_fs=found
156         AC_DEFINE(MOUNTED_VMOUNT)
157       fi
158     fi
160     if test -z "$list_mounted_fs"; then
161       # SVR3
162       AC_MSG_CHECKING([for existence of three headers])
163       AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp,
164         [AC_TRY_CPP([
165 #include <sys/statfs.h>
166 #include <sys/fstyp.h>
167 #include <mnttab.h>],
168                     fu_cv_sys_mounted_fread_fstyp=yes,
169                     fu_cv_sys_mounted_fread_fstyp=no)])
170       AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
171       if test $fu_cv_sys_mounted_fread_fstyp = yes; then
172         list_mounted_fs=found
173         AC_DEFINE(MOUNTED_FREAD_FSTYP)
174       fi
175     fi
177     if test -z "$list_mounted_fs"; then
178       # 4.4BSD and DEC OSF/1.
179       AC_MSG_CHECKING([for getmntinfo function])
180       AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo,
181         [
182           ok=
183           if test $ac_cv_func_getmntinfo = yes; then
184             AC_EGREP_HEADER(f_type;, sys/mount.h,
185                             ok=yes)
186           fi
187           test -n "$ok" \
188               && fu_cv_sys_mounted_getmntinfo=yes \
189               || fu_cv_sys_mounted_getmntinfo=no
190         ])
191       AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
192       if test $fu_cv_sys_mounted_getmntinfo = yes; then
193         list_mounted_fs=found
194         AC_DEFINE(MOUNTED_GETMNTINFO)
195         AC_MSG_CHECKING([if struct statfs has f_fstypename])
196         AC_CACHE_VAL(fu_cv_sys_mounted_f_fstypename,
197           [
198             AC_EGREP_HEADER(f_type;, sys/mount.h, ok=yes, ok=)
199             test -n "$ok" \
200                 && fu_cv_sys_mounted_f_fstypename=yes \
201                 || fu_cv_sys_mounted_f_fstypename=no
202           ])
203         AC_MSG_RESULT([$fu_cv_sys_mounted_f_fstypename])
204         if test $fu_cv_sys_mounted_f_fstypename = yes; then
205           AC_DEFINE(HAVE_F_FSTYPENAME)
206         fi
207       fi
208     fi
210     if test -z "$list_mounted_fs"; then
211       # Ultrix
212       AC_MSG_CHECKING([for getmnt function])
213       AC_CACHE_VAL(fu_cv_sys_mounted_getmnt,
214         [AC_TRY_CPP([
215 #include <sys/fs_types.h>
216 #include <sys/mount.h>],
217                     fu_cv_sys_mounted_getmnt=yes,
218                     fu_cv_sys_mounted_getmnt=no)])
219       AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
220       if test $fu_cv_sys_mounted_getmnt = yes; then
221         list_mounted_fs=found
222         AC_DEFINE(MOUNTED_GETMNT)
223       fi
224     fi
226     if test -z "$list_mounted_fs"; then
227       # SVR2
228     AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
229       AC_CACHE_VAL(fu_cv_sys_mounted_fread,
230         [AC_TRY_CPP([#include <mnttab.h>],
231                     fu_cv_sys_mounted_fread=yes,
232                     fu_cv_sys_mounted_fread=no)])
233       AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
234       if test $fu_cv_sys_mounted_fread = yes; then
235         list_mounted_fs=found
236         AC_DEFINE(MOUNTED_FREAD)
237       fi
238     fi
240     if test -z "$list_mounted_fs"; then
241       AC_MSG_WARN([could not determine how to read list of mounted fs])
242       CPPFLAGS="$CPPFLAGS -DNO_INFOMOUNT"
243       # FIXME -- no need to abort building the whole package
244       # Can't build mountlist.c or anything that needs its functions
245     fi
247 dnl This configure.in code has been stolen from GNU fileutils-3.12.  Its
248 dnl job is to detect a method to get file system information.
250     AC_CHECKING([how to get filesystem space usage])
251     space=no
253     # Here we'll compromise a little (and perform only the link test)
254     # since it seems there are no variants of the statvfs function.
255     if test $space = no; then
256       # SVR4
257       AC_CHECK_FUNCS(statvfs)
258       if test $ac_cv_func_statvfs = yes; then
259         space=yes
260         AC_DEFINE(STAT_STATVFS)
261       fi
262     fi
264     if test $space = no; then
265       # DEC Alpha running OSF/1
266       AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
267       AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1,
268       [AC_TRY_RUN([
269 #include <sys/param.h>
270 #include <sys/types.h>
271 #include <sys/mount.h>
272       main ()
273       {
274         struct statfs fsd;
275         fsd.f_fsize = 0;
276         exit (statfs (".", &fsd, sizeof (struct statfs)));
277       }],
278       fu_cv_sys_stat_statfs3_osf1=yes,
279       fu_cv_sys_stat_statfs3_osf1=no,
280       fu_cv_sys_stat_statfs3_osf1=no)])
281       AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1)
282       if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
283         space=yes
284         AC_DEFINE(STAT_STATFS3_OSF1)
285       fi
286     fi
288     if test $space = no; then
289     # AIX
290       AC_MSG_CHECKING([for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)])
291       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize,
292       [AC_TRY_RUN([
293 #ifdef HAVE_SYS_PARAM_H
294 #include <sys/param.h>
295 #endif
296 #ifdef HAVE_SYS_MOUNT_H
297 #include <sys/mount.h>
298 #endif
299 #ifdef HAVE_SYS_VFS_H
300 #include <sys/vfs.h>
301 #endif
302       main ()
303       {
304       struct statfs fsd;
305       fsd.f_bsize = 0;
306       exit (statfs (".", &fsd));
307       }],
308       fu_cv_sys_stat_statfs2_bsize=yes,
309       fu_cv_sys_stat_statfs2_bsize=no,
310       fu_cv_sys_stat_statfs2_bsize=no)])
311       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize])
312       if test $fu_cv_sys_stat_statfs2_bsize = yes; then
313         space=yes
314         AC_DEFINE(STAT_STATFS2_BSIZE)
315       fi
316     fi
318     if test $space = no; then
319     # SVR3
320       AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
321       AC_CACHE_VAL(fu_cv_sys_stat_statfs4,
322       [AC_TRY_RUN([#include <sys/types.h>
323 #include <sys/statfs.h>
324       main ()
325       {
326       struct statfs fsd;
327       exit (statfs (".", &fsd, sizeof fsd, 0));
328       }],
329         fu_cv_sys_stat_statfs4=yes,
330         fu_cv_sys_stat_statfs4=no,
331         fu_cv_sys_stat_statfs4=no)])
332       AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
333       if test $fu_cv_sys_stat_statfs4 = yes; then
334         space=yes
335         AC_DEFINE(STAT_STATFS4)
336       fi
337     fi
339     if test $space = no; then
340     # 4.4BSD and NetBSD
341       AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
342     member (4.4BSD and NetBSD)])
343       AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize,
344       [AC_TRY_RUN([#include <sys/types.h>
345 #ifdef HAVE_SYS_PARAM_H
346 #include <sys/param.h>
347 #endif
348 #ifdef HAVE_SYS_MOUNT_H
349 #include <sys/mount.h>
350 #endif
351       main ()
352       {
353       struct statfs fsd;
354       fsd.f_fsize = 0;
355       exit (statfs (".", &fsd));
356       }],
357       fu_cv_sys_stat_statfs2_fsize=yes,
358       fu_cv_sys_stat_statfs2_fsize=no,
359       fu_cv_sys_stat_statfs2_fsize=no)])
360       AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize])
361       if test $fu_cv_sys_stat_statfs2_fsize = yes; then
362         space=yes
363         AC_DEFINE(STAT_STATFS2_FSIZE)
364       fi
365     fi
367     if test $space = no; then
368       # Ultrix
369       AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
370       AC_CACHE_VAL(fu_cv_sys_stat_fs_data,
371       [AC_TRY_RUN([
372 #include <sys/types.h>
373 #ifdef HAVE_SYS_PARAM_H
374 #include <sys/param.h>
375 #endif
376 #ifdef HAVE_SYS_MOUNT_H
377 #include <sys/mount.h>
378 #endif
379 #ifdef HAVE_SYS_FS_TYPES_H
380 #include <sys/fs_types.h>
381 #endif
382       main ()
383       {
384       struct fs_data fsd;
385       /* Ultrix's statfs returns 1 for success,
386          0 for not mounted, -1 for failure.  */
387       exit (statfs (".", &fsd) != 1);
388       }],
389       fu_cv_sys_stat_fs_data=yes,
390       fu_cv_sys_stat_fs_data=no,
391       fu_cv_sys_stat_fs_data=no)])
392       AC_MSG_RESULT([$fu_cv_sys_stat_fs_data])
393       if test $fu_cv_sys_stat_fs_data = yes; then
394         space=yes
395         AC_DEFINE(STAT_STATFS2_FS_DATA)
396       fi
397     fi
399     dnl Not supported
400     dnl if test $space = no; then
401     dnl # SVR2
402     dnl AC_TRY_CPP([#include <sys/filsys.h>],
403     dnl   AC_DEFINE(STAT_READ_FILSYS) space=yes)
404     dnl fi
407 dnl AC_TRY_WARNINGS(INCLUDES, FUNCTION-BODY,
408 dnl             ACTION-IF-NO-WARNINGS [, ACTION-IF-WARNINGS-OR-ERROR])
409 AC_DEFUN([AC_TRY_WARNINGS],
410 [cat > conftest.$ac_ext <<EOF
411 dnl This sometimes fails to find confdefs.h, for some reason.
412 dnl [#]line __oline__ "[$]0"
413 [#]line __oline__ "configure"
414 #include "confdefs.h"
415 [$1]
416 int main() { return 0; }
417 int t() {
418 [$2]
419 ; return 0; }
421 ac_compile_warn='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 2>&1'
422 if { if eval $ac_compile_warn; then :; else echo arning; fi; } | grep arning 1>&AC_FD_CC 2>&AC_FD_CC; then
423   ifelse([$4], , :, [rm -rf conftest*
424   $4])
425 ifelse([$3], , , [else
426   rm -rf conftest*
427   $3
428 ])dnl
430 rm -f conftest*]
433 AC_DEFUN([AC_USE_SUNOS_CURSES], [
434         search_ncurses=false
435         screen_manager="SunOS 4.x /usr/5include curses"
436         AC_MSG_RESULT([Using SunOS 4.x /usr/5include curses])
437         AC_DEFINE(USE_SUNOS_CURSES)
438         AC_DEFINE(NO_COLOR_CURSES)
439         AC_DEFINE(USE_SYSV_CURSES)
440         CPPFLAGS="$CPPFLAGS -I/usr/5include"
441         XCURSES="xcurses.o /usr/5lib/libcurses.a /usr/5lib/libtermcap.a"
442         AC_MSG_RESULT([Please note that some screen refreshs may fail])
443         AC_MSG_WARN([Reconsider using Slang])
446 AC_DEFUN([AC_USE_OSF1_CURSES], [
447        AC_MSG_RESULT([Using OSF1 curses])
448        search_ncurses=false
449        screen_manager="OSF1 curses"
450        AC_DEFINE(NO_COLOR_CURSES)
451        AC_DEFINE(USE_SYSV_CURSES)
452        XCURSES="xcurses.o"
453        LIBS="$LIBS -lcurses"
456 AC_DEFUN([AC_USE_SYSV_CURSES], [
457         AC_MSG_RESULT([Using SysV curses])
458         AC_DEFINE(USE_SYSV_CURSES)
459         XCURSES=""
460         search_ncurses=false
461         screen_manager="SysV/curses"
462         LIBS="$LIBS -lcurses"
465 AC_DEFUN([AC_USE_TERMINFO], [
466         AC_DEFINE(SLANG_TERMINFO)
467         AC_MSG_RESULT([Using SLang screen manager/terminfo])
468         slang_term=" with terminfo"
471 AC_DEFUN([AC_USE_TERMCAP], [
472         AC_MSG_RESULT([Using SLang screen manager/termcap])
473         AC_DEFINE(USE_TERMCAP)
474         dnl Check with $LIBS at the end so that it works with ELF libs.
475         AC_CHECK_LIB(termcap, tgoto, LIBS="$LIBS -ltermcap", , $LIBS)
476         slang_term=" with termcap"
478         
479 AC_DEFUN([AC_WITH_SLANG], [
480         AC_DEFINE(HAVE_SLANG)
481         search_ncurses=false
482         if $slang_use_system_installed_lib
483         then
484             AC_DEFINE(HAVE_SYSTEM_SLANG)
485             LSLANG="-lslang"
486             screen_manager="SLang (system-installed library)"
487             AC_MSG_RESULT([Using system installed SLang library])
488             rm -f slang/slang.h
489             ac_save_LIBS="$LIBS"
490             LIBS="$LIBS $LSLANG"
491             AC_TRY_RUN(
492             [ 
493             #ifdef SLANG_H_INSIDE_SLANG_DIR
494             #include <slang/slang.h>
495             #else
496             #include <slang.h>
497             #endif
498             int main(void){
499                 SLtt_get_terminfo();
500                 SLtt_tgetflag("");
501                 return 0;
502             } ], 
503             [LIBS="$ac_save_LIBS"; AC_USE_TERMINFO], 
504             [LIBS="$ac_save_LIBS"; AC_USE_TERMCAP])
505         else
506             MCCPPFLAGS="$MCCPPFLAGS -I\$(slangdir)"
507             LIBSLANG="libmcslang.a"
508             screen_manager="SLang"
509             LSLANG="-lmcslang"
510             CPPFLAGS="$CPPFLAGS -I../slang"
511             fastdepslang=fastdepslang
512             mkdir -p slang
513             rm -f slang/slang.h
514             case "$srcdir" in
515                 /*) ln -sf  $srcdir/slang/slang-mc.h slang/slang.h;;
516                 *)  ln -sf  ../$srcdir/slang/slang-mc.h slang/slang.h;;
517             esac
518         fi
519         if $slang_check_lib
520         then
521             use_terminfo=false
522             for dir in  /usr/lib /usr/share/lib /usr/local/lib /lib \
523                         /usr/local/share /usr/share
524             do
525                 if test -d $dir/terminfo; then
526                 use_terminfo=true; 
527                 break
528                 fi
529             done
530             if $use_terminfo; then
531                 AC_USE_TERMINFO
532             else
533                 AC_USE_TERMCAP
534             fi
535         fi]
538 AC_DEFUN([AC_WITH_EDIT], [
539         AC_DEFINE(USE_INTERNAL_EDIT)
540         LIBEDIT_A="libedit.a"
541         MCEDIT="mcedit"
542         LEDIT="-ledit"
543         EDIT_msg="yes"
544         AC_MSG_RESULT([will call internal editor])
547 AC_DEFUN([AC_EXT2_UNDEL], [
548   GNOME_UNDELFS_CHECKS
549   if test "$ext2fs_undel" = yes; then
550      AC_MSG_RESULT([With ext2fs file recovery code])
551      vfs_flags="${vfs_flags}, undelfs"
552      undelfs_o="undelfs.o"
553      LIBS="$LIBS $EXT2FS_UNDEL_LIBS"
554   else
555      AC_MSG_WARN([No ext2fs file recovery code])
556   fi
560 dnl Parameters: directory filename LIBS_append CPPFLAGS_append nicename
562 AC_DEFUN([AC_NCURSES], [
563     if $search_ncurses
564     then
565         if test -f $1/$2
566         then
567             AC_MSG_RESULT([Found ncurses on $1/$2])
568             LIBS="$LIBS $3"
569             CPPFLAGS="$CPPFLAGS $4"
570             search_ncurses=false
571             screen_manager=$5
572             AC_DEFINE(USE_NCURSES)
573         fi
574     fi