Security fix patch. Fix insecure temporary file and directory creations. (CAN-2004...
[midnight-commander.git] / configure.ac
blobed5aee2cf0d4fed525e847f7c3fceb001c727f35
1 dnl
2 dnl Configure.in file for the Midnight Commander
3 dnl
5 AC_INIT([GNU Midnight Commander], [], [mc-devel@gnome.org])
6 AC_PREREQ(2.52)
7 AC_CONFIG_SRCDIR(src/main.c)
8 AC_CONFIG_AUX_DIR(config)
9 AM_INIT_AUTOMAKE(mc, 4.6.1-pre1a)
11 AM_CONFIG_HEADER(config.h)
12 AM_MAINTAINER_MODE
14 AC_CANONICAL_HOST
16 AC_AIX
17 AC_MINIX
18 AC_ISC_POSIX
20 AC_PROG_CC_STDC
22 dnl
23 dnl First try glib 2.x.  If it's not found, use glib 1.2.x.
24 dnl Keep this check close to the beginning, so that the users
25 dnl without any glib won't have their time wasted by other checks.
26 dnl
28 AC_ARG_WITH(glib12, 
29         [  --with-glib12            Force using glib 1.2.x [[no]]])
31 AC_ARG_WITH([glib_static],
32             [  --with-glib-static       Link glib statically [[no]]])
34 glib_found=no
35 if test "x$with_glib12" != "xyes"; then
36         PKG_CHECK_MODULES(GLIB, [glib-2.0], [glib_found=yes], [:])
39 dnl Fall back to glib-1.2, don't use pkgconfig to find it.
40 if test "x$glib_found" != "xyes" ; then
41         dnl This temporary variable is a workaround for a bug in Autoconf-2.53
42         glib_path=$PATH:/usr/local/bin
44         dnl Klugde for FreeBSD, where glib-config is renamed to glib12-config.
45         AC_PATH_PROGS([GLIB_CONFIG], [glib-config glib12-config],,[$glib_path])
47         AC_ARG_VAR([GLIB_CONFIG], [Path to glib-config (version 1.2.x only)])
48         AM_PATH_GLIB(1.2.6, , [AC_MSG_ERROR([Test for glib failed.
49 GNU Midnight Commander requires glib 1.2.6 or above.])])
50         dnl Save GLIB_CFLAGS and GLIB_LIBS, since the following call to
51         dnl AM_PATH_GLIB will overwrite them.
52         save_GLIB_CFLAGS="$GLIB_CFLAGS"
53         save_GLIB_LIBS="$GLIB_LIBS"
54         dnl Check for gmodule.  Store the flags necessary to compile and
55         dnl link programs using gmodule functionality in GMODULE_CFLAGS
56         dnl and GMODULE_LIBS.
57         AM_PATH_GLIB(1.2.6, [gmodule_found=yes], , [gmodule])
58         GMODULE_CFLAGS="$GLIB_CFLAGS"
59         GMODULE_LIBS="$GLIB_LIBS"
60         GLIB_CFLAGS="$save_GLIB_CFLAGS"
61         GLIB_LIBS="$save_GLIB_LIBS"
62         GLIB_LIBDIR="`$GLIB_CONFIG --exec-prefix`/lib"
64         dnl Used in src/glibcompat.c
65         AC_CHECK_FUNCS([strlcpy])
66 else
67         PKG_CHECK_MODULES(GMODULE, [gmodule-2.0], [gmodule_found=yes])
68         GLIB_LIBDIR="`$PKG_CONFIG --variable=libdir glib-2.0`"
71 if test "x$gmodule_found" = "xyes" ; then
72         dnl Check if the gmodule functionality supported on this system.
73         AC_G_MODULE_SUPPORTED
76 AC_HEADER_MAJOR
77 AC_C_CONST
78 AC_SYS_LARGEFILE
80 AC_PROG_LN_S
81 AC_CHECK_TOOL(AR, ar, ar)
83 dnl Only list browsers here that can be run in background (i.e. with `&')
84 AC_CHECK_PROGS(X11_WWW, [gnome-moz-remote mozilla konqueror opera netscape])
86 dnl
87 dnl Ovverriding mmap support.  This has to be before AC_FUNC_MMAP is used.
88 dnl We use only part of the functionality of mmap, so on AIX,
89 dnl it's possible to use mmap, even if it doesn't pass the autoconf test.
90 dnl
91 AC_ARG_WITH(mmap,
92         [  --with-mmap              Use the mmap call [[yes if found]]])
93 if test x$with_mmap != xno; then
94     if test x$with_mmap = x; then
95         AC_FUNC_MMAP
96     else
97         AC_DEFINE(HAVE_MMAP, 1)
98     fi
102 dnl Internationalization
104 MC_ASM_LABELS
105 AM_GNU_GETTEXT
106 AM_GNU_GETTEXT_VERSION(0.11.5)
108 if test "x$USE_INCLUDED_LIBINTL" = xyes; then
109     CPPFLAGS="$CPPFLAGS -I\$(top_builddir)/intl -I\$(top_srcdir)/intl"
112 dnl Determine which help translations we want to install.
113 ALL_DOC_LINGUAS="es hu it pl ru sr"
115 DOC_LINGUAS=
116 if test "x$USE_NLS" = xyes; then
117     if test -z "$LINGUAS"; then
118         langs="`grep -v '^#' $srcdir/po/LINGUAS`"
119     else
120         langs="$LINGUAS"
121     fi
122 else
123     langs=
126 for h_lang in $ALL_DOC_LINGUAS; do
127     for lang in $langs; do
128         if test "$lang" = "$h_lang"; then
129             DOC_LINGUAS="$DOC_LINGUAS $lang"
130             break
131         fi
132     done
133 done
134 AC_SUBST(DOC_LINGUAS)
137 dnl Enforce coding standards
139 if test "x$GCC" = xyes; then
140     CFLAGS="$CFLAGS -Wall"
144 dnl OS specific flags.
146 case $host_os in
147 aux*)
148     # A/UX
149     LIBS="$LIBS -lposix"
150     AC_DEFINE(_POSIX_SOURCE)
151     ;;
152 esac
155 AC_PROG_INSTALL
156 AC_CHECK_HEADERS([unistd.h string.h memory.h grp.h limits.h malloc.h \
157         stdlib.h termios.h utime.h fcntl.h pwd.h sys/statfs.h sys/time.h \
158         sys/timeb.h sys/select.h sys/ioctl.h stropts.h arpa/inet.h \
159         security/pam_misc.h])
161 AC_HEADER_TIME
162 AC_HEADER_SYS_WAIT
163 AC_HEADER_DIRENT
164 AC_HEADER_STDC
166 dnl Missing structure components
167 AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev])
168 AC_STRUCT_ST_BLOCKS
171 dnl Check availability of some functions 
172 dnl 
174 AC_CHECK_FUNCS([atoll cfgetospeed getsid initgroups memcpy memmove memset \
175                 putenv setreuid setuid statfs strerror strftime \
176                 sysconf tcgetattr tcsetattr truncate])
178 dnl S-Lang needs all four functions to be defined to use POSIX signal API
179 AC_CHECK_FUNCS([sigaction sigemptyset sigprocmask sigaddset], , [slang_signals=no])
180 if test x$slang_signals != xno; then
181     AC_DEFINE(SLANG_POSIX_SIGNALS, 1, [Define to use POSIX signal API in S-Lang])
185 dnl getpt is a GNU Extension (glibc 2.1.x)
187 AC_CHECK_FUNCS(posix_openpt, , [AC_CHECK_FUNCS(getpt)])
188 AC_CHECK_FUNCS(grantpt, , [AC_CHECK_LIB(pt, grantpt)])
190 dnl replacing lstat with statlstat on sco makes it more portable between
191 dnl sco clones
192 AC_CHECK_FUNCS(statlstat)
195 dnl If running under AIX, AC_AIX does not tell us that
197 AC_MSG_CHECKING([for AIX defines])
198 AC_EGREP_CPP(yes,
199 [#if defined(AIX) || defined(_AIX) || defined(__aix__) || defined(aix)
201 #endif
202 ], [
203 AC_DEFINE(IS_AIX, 1, [Define if compiling for AIX])
204 AC_MSG_RESULT(yes)
205 ], [AC_MSG_RESULT(no)])
208 dnl This is from GNU fileutils, check aclocal.m4 for more information
210 AC_GET_FS_INFO
213 dnl Missing typedefs and replacements
214 dnl 
216 AC_TYPE_MODE_T
217 AC_CHECK_TYPE(umode_t, int)
218 AC_CHECK_TYPE(off_t, long)
219 AC_TYPE_PID_T
220 AC_TYPE_UID_T
221 AC_CHECK_TYPE(nlink_t, unsigned int)
223 dnl This is needed for regex.c only
224 AC_CHECK_TYPE(uintptr_t,
225               [AC_DEFINE(HAVE_UINTPTR_T, 1,
226                          [Define if you have the `uintptr_t' type.])
229 AC_FUNC_ALLOCA
230 AC_FUNC_STRCOLL
233 dnl X11 support.
234 dnl Used to read keyboard modifiers when running under X11.
237 AC_PATH_XTRA
238 if test "x$no_x" = xyes; then
239     textmode_x11_support="no"
240 else
241     CPPFLAGS="$CPPFLAGS $X_CFLAGS"
242     if test "x$mc_cv_g_module_supported" = "xyes" ; then
243         dnl Replace the contents of GLIB_CFLAGS and GLIB_LIBS with those of
244         dnl GMODULE_CFLAGS and GMODULE_LIBS, only if X is available and gmodule
245         dnl functionality is supported on the system.  This way, mc will be
246         dnl linked against the gmodule library only when it's really required.
247         GLIB_CFLAGS="$GMODULE_CFLAGS"
248         GLIB_LIBS="$GMODULE_LIBS"
249     else
250         MCLIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
251     fi
252     AC_DEFINE(HAVE_TEXTMODE_X11_SUPPORT, 1,
253               [Define to enable getting events from X Window System])
254     textmode_x11_support="yes"
258 dnl Try to find static libraries for glib and gmodule.
260 if test x$with_glib_static = xyes; then
261     new_GLIB_LIBS=
262     for i in $GLIB_LIBS; do
263         case x$i in
264         x-lglib*)
265             lib=glib ;;
266         x-lgmodule*)
267             lib=gmodule ;;
268         *)
269             lib=
270             add="$i" ;;
271         esac
273         if test -n "$lib"; then
274             lib1=`echo $i | sed 's/^-l//'`
275             if test -f "$GLIB_LIBDIR/lib${lib1}.a"; then
276                 add="$GLIB_LIBDIR/lib${lib1}.a"
277             else
278                 if test -f "$GLIB_LIBDIR/lib${lib}.a"; then
279                     add="$GLIB_LIBDIR/lib${lib}.a"
280                 else
281                     AC_MSG_ERROR([Cannot find static $lib])
282                 fi
283             fi
284         fi
285         new_GLIB_LIBS="$new_GLIB_LIBS $add"
286     done
287     GLIB_LIBS="$new_GLIB_LIBS"
292 dnl Network related functions
295 AC_CHECK_LIB(nsl, t_accept)
296 AC_CHECK_LIB(socket, socket)
298 have_socket=no
299 AC_CHECK_FUNCS(socket, have_socket=yes)
300 if test $have_socket = no; then
301   # socket is not in the default libraries.  See if it's in some other.
302   for lib in bsd socket inet; do
303     AC_CHECK_LIB($lib, socket, [
304         LIBS="$LIBS -l$lib"
305         have_socket=yes
306         AC_DEFINE(HAVE_SOCKET)
307         break])
308   done
311 have_gethostbyname=no
312 AC_CHECK_FUNC(gethostbyname, [have_gethostbyname=yes])
313 if test $have_gethostbyname = no; then
314   # gethostbyname is not in the default libraries.  See if it's in some other.
315   for lib in bsd socket inet; do
316     AC_CHECK_LIB([$lib], [gethostbyname],
317                  [LIBS="$LIBS -l$lib"; have_gethostbyname=yes; break])
318   done
322 dnl Sequent wants getprocessstats
324 AC_CHECK_LIB(seq, get_process_stats, [
325         LIBS="$LIBS -lseq"
326         AC_DEFINE(HAVE_GET_PROCESS_STATS, 1,
327                   [Define if you have function `get_process_stats' and
328 have to use that instead of gettimeofday])])
330 MC_VFS_CHECKS
332 vfs_type="normal"
333 if test x$use_vfs = xyes; then
334         AC_MSG_NOTICE([enabling VFS code])
335         vfs_type="Midnight Commander Virtual File System"
339 dnl Check for gpm mouse support (Linux only)
341 mouse_lib="xterm only"
342 AC_ARG_WITH(gpm-mouse, 
343         [  --with-gpm-mouse         Compile with gpm mouse support (Linux only)
344                            [[yes if found]]])
346 case $host_os in
347 linux*)
348     if test x$with_gpm_mouse != xno; then
349         AC_CHECK_LIB(gpm, Gpm_Repeat,
350             [AC_DEFINE(HAVE_LIBGPM, 1,
351                        [Define to enable gpm mouse support on Linux])
352             mouse_lib="gpm and xterm"
353             MCLIBS="$MCLIBS -lgpm"],
354             [AC_MSG_WARN([libgpm is missing or older than 0.18])
355         ])
356     fi
357     ;;
358 esac
361 dnl Check nroff and the options it supports
363 AC_CHECK_PROG(HAVE_nroff, nroff, true, false)
365 dnl Default values
366 MANDOC=-man
367 MAN_FLAGS=
369 if $HAVE_nroff; then
370     AC_MSG_CHECKING([for manual formatting macros])
371     AC_CACHE_VAL(mc_cv_mandoc, [
372     nroff -mandoc < /dev/null > /dev/null 2>&1
373     if test $? = 0; then
374         mc_cv_mandoc=-mandoc
375     else
376         mc_cv_mandoc=-man
377     fi
378     ])
379     MANDOC=$mc_cv_mandoc
380     AC_MSG_RESULT([$MANDOC])
382     AC_MSG_CHECKING([for option to disable ANSI color in manuals])
383     AC_CACHE_VAL(mc_cv_man_nocolor, [
384     nroff -c < /dev/null > /dev/null 2>&1
385     if test $? = 0; then
386         mc_cv_man_nocolor=-c
387     else
388         mc_cv_man_nocolor=
389     fi
390     ])
391     MAN_FLAGS=$mc_cv_man_nocolor
392     AC_MSG_RESULT([${MAN_NOCOLOR-none}])
394     AC_MSG_CHECKING([if nroff accepts -Tlatin1 or -Tascii])
395     AC_CACHE_VAL(mc_cv_nroff_tascii, [
396     mc_cv_nroff_tascii=
397     nroff -Tlatin1 < /dev/null > /dev/null 2>&1 /dev/null
398     if test $? = 0; then
399         mc_cv_nroff_tascii=-Tlatin1
400     else
401         nroff -Tascii < /dev/null > /dev/null 2>&1 /dev/null
402         if test $? = 0; then
403             mc_cv_nroff_tascii=-Tascii
404         fi
405     fi
406     ])
407     AC_MSG_RESULT([${mc_cv_nroff_tascii-no}])
408     MAN_FLAGS="$MAN_FLAGS $mc_cv_nroff_tascii"
411 AC_SUBST(MANDOC)
412 AC_SUBST(MAN_FLAGS)
416 dnl Check for -L option to file
418 AC_CHECK_PROG(HAVE_FILECMD, file, true, false)
419 if $HAVE_FILECMD; then
420     AC_MSG_CHECKING([for -L option to file command])
421     AC_CACHE_VAL(mc_cv_filel, [
422     file -L . > /dev/null 2>&1
423     if test $? = 0; then
424         mc_cv_filel=yes
425     else
426         mc_cv_filel=no
427     fi
428     ])
429     if test x$mc_cv_filel = xyes; then
430         AC_DEFINE(FILE_L, 1, [Define if the file command accepts the -L option])
431     fi
432     filel=$mc_cv_filel
433     AC_MSG_RESULT([$filel])
437 AC_MSG_CHECKING([for subshell support])
438 AC_ARG_WITH(subshell,
439         [  --with-subshell          Compile in concurrent subshell [[yes]]
440   --with-subshell=optional Don't run concurrent shell by default [[no]]],
441         [result=no
442         if test x$withval = xoptional
443         then
444                 AC_DEFINE(SUBSHELL_OPTIONAL, 1,
445                           [Define to make subshell support optional])
446                 result="optional"
447         fi
448         if test x$withval = xyes
449         then 
450                 result="yes"
451         fi],
452         [dnl Default: enable the subshell support
453         result="yes"
455 if test "x$result" != xno; then
456         AC_DEFINE(HAVE_SUBSHELL_SUPPORT, 1,
457                   [Define to enable subshell support])
459 AC_MSG_RESULT([$result])
460 subshell="$result"
464 dnl Select the screen library.  mcslang is the included S-Lang library.
466 AC_ARG_WITH(screen,
467         [  --with-screen=LIB        Compile with screen library: slang, mcslang or
468                            ncurses [[slang if found, else mcslang]]])
470 case x$with_screen in
471 xslang)
472         MC_WITH_SLANG(strict)
473         ;;
474 xmcslang)
475         MC_WITH_MCSLANG
476         ;;
477 xncurses)
478         MC_WITH_NCURSES
479         ;;
481         MC_WITH_SLANG
482         ;;
484         AC_MSG_ERROR([Value of the screen library is incorrect])
485         ;;
486 esac
490 dnl Force using termcap.  This option is processed in MC_WITH_MCSLANG.
491 dnl Report an error if this option is not applicable.
493 AC_ARG_WITH(termcap,
494         [  --with-termcap           Try using termcap database [[only if no terminfo]]],
495         [if test x$with_screen != xmcslang; then
496                 AC_MSG_ERROR([Option `--with-termcap' only works with `--with-screen=mcslang'])
497         fi
502 dnl Internal editor support.
504 AC_ARG_WITH(edit,
505         [  --with-edit              Enable internal editor [[yes]]])
507 if test x$with_edit != xno; then
508         AC_DEFINE(USE_INTERNAL_EDIT, 1, [Define to enable internal editor])
509         use_edit=yes
510         edit_msg="yes"
511         AC_MSG_NOTICE([using internal editor])
512 else
513         edit_msg="no"
517 dnl Check if the OS is supported by the console saver.
518 cons_saver=""
519 case $host_os in
520 linux*)
521     cons_saver=yes
522 esac
525 dnl Support for background operations
526 AC_ARG_ENABLE([background],
527               [  --enable-background      Support for background file operations [[yes]]])
528 if test "x$enable_background" != xno; then
529     AC_DEFINE(WITH_BACKGROUND, 1, [Define to enable background file operations])
534 dnl User visible support for charset conversion.
536 AC_ARG_ENABLE([charset],
537               [  --enable-charset         Support for charset selection and conversion [[no]]])
538 have_charset=
539 if test "x$enable_charset" = xyes; then
540   if test "x$am_cv_func_iconv" != xyes; then
541     AC_MSG_WARN([Cannot enable charset support because iconv function is missing])
542   else
543     AC_DEFINE(HAVE_CHARSET, 1,
544               [Define to enable charset selection and conversion])
545     have_charset=yes
546   fi
549 if test "$GLIBC21" != yes; then
550     AC_DEFINE(USE_INCLUDED_REGEX, 1, [Use the regex included here])
553 AC_SUBST(CFLAGS)
554 AC_SUBST(CPPFLAGS)
555 AC_SUBST(LDFLAGS)
556 AC_SUBST(LIBS)
558 dnl Libraries used only when building the mc binary
559 AC_SUBST(MCLIBS)
561 dnl Version for the RedHat package, without dashes
562 RPM_VERSION=`echo $VERSION | sed 's/-//g'`
563 AC_SUBST(RPM_VERSION)
565 if test -n "$use_smbfs"; then
566   AC_CONFIG_SUBDIRS([vfs/samba])
569 AM_CONDITIONAL(USE_EDIT, [test -n "$use_edit"])
570 AM_CONDITIONAL(USE_VFS, [test "x$use_vfs" = xyes])
571 AM_CONDITIONAL(USE_VFS_NET, [test x"$use_net_code" = xtrue])
572 AM_CONDITIONAL(USE_UNDEL_FS, [test -n "$use_undelfs"])
573 AM_CONDITIONAL(USE_SAMBA_FS, [test -n "$use_smbfs"])
574 AM_CONDITIONAL(USE_MCFS, [test -n "$use_mcfs"])
575 AM_CONDITIONAL(INCLUDED_SLANG, [test "x$with_screen" = xmcslang])
576 AM_CONDITIONAL(CHARSET, [test -n "$have_charset"])
577 AM_CONDITIONAL(CONS_SAVER, [test -n "$cons_saver"])
579 AC_CONFIG_FILES([
580 Makefile 
581 mc.spec
582 doc/Makefile 
583 vfs/Makefile
584 vfs/extfs/Makefile
585 lib/Makefile
586 src/Makefile
587 slang/Makefile 
588 edit/Makefile 
589 syntax/Makefile
590 m4/Makefile
592 lib/mc.ext
594 vfs/extfs/a
595 vfs/extfs/apt
596 vfs/extfs/audio
597 vfs/extfs/deb
598 vfs/extfs/deba
599 vfs/extfs/debd
600 vfs/extfs/dpkg
601 vfs/extfs/iso9660
602 vfs/extfs/hp48
603 vfs/extfs/lslR
604 vfs/extfs/mailfs
605 vfs/extfs/patchfs
606 vfs/extfs/rpms
607 vfs/extfs/uar
608 vfs/extfs/uarj
609 vfs/extfs/uha
610 vfs/extfs/ulha 
611 vfs/extfs/urar
612 vfs/extfs/uzip
613 vfs/extfs/uzoo
615 doc/mc.1 doc/mcedit.1 doc/mcview.1 doc/mcserv.8
616 doc/es/mc.1 doc/es/Makefile
617 doc/hu/mc.1 doc/hu/Makefile
618 doc/it/mc.1 doc/it/Makefile
619 doc/pl/mc.1 doc/pl/Makefile
620 doc/ru/mc.1 doc/ru/Makefile
621 doc/sr/mc.1 doc/sr/mcserv.8 doc/sr/Makefile
623 intl/Makefile
624 po/Makefile.in
627 AC_OUTPUT
629 echo "
630 Configuration:
632   Source code location:       ${srcdir}
633   Compiler:                   ${CC}
634   Compiler flags:             ${CFLAGS}
635   File system:                ${vfs_type}
636                               ${vfs_flags}
637   Screen library:             ${screen_msg}
638   Mouse support:              ${mouse_lib}
639   X11 events support:         ${textmode_x11_support}
640   With subshell support:      ${subshell}
641   Internal editor:            ${edit_msg}