2 dnl Configure.in file for the Midnight Commander
5 dnl 2.64 is required at least for m4_esyscmd_s()
8 AC_INIT([GNU Midnight Commander], m4_esyscmd_s([./version.sh .]),
9 [https://www.midnight-commander.org/wiki/NewTicket], [mc],
10 [https://www.midnight-commander.org/])
12 m4_pattern_forbid(MC_)
13 AC_CONFIG_MACRO_DIR([m4])
14 AC_CONFIG_AUX_DIR(config)
15 AC_CONFIG_SRCDIR(src/main.c)
16 AC_CONFIG_HEADERS(config.h)
18 dnl Apply "no-define" to avoid defining the VERSION macro in config.h
19 AM_INIT_AUTOMAKE([no-define])
20 dnl PACKAGE macro isn't defined if "no-define" is applied
21 AC_DEFINE([PACKAGE], ["mc"], [Name of package])
23 dnl Enable silent rules by default (if yes)
24 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
32 AC_USE_SYSTEM_EXTENSIONS
35 dnl ############################################################################
36 dnl Check for compiler
37 dnl ############################################################################
39 dnl This should be checked before toolchain macros, otherwise they will remember
40 dnl that ar cannot be found and linking via libtool will fail at a later stage
41 AC_CHECK_TOOLS([AR], [ar gar])
45 # AC_PROG_CC doesn't try enabling C99 in autoconf 2.69 and below, but
46 # AC_PROG_CC_C99 is deprecated in newer ones. In autoconf 2.70+ both
47 # will try enabling features up to C11.
48 m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_C99])
53 if test "x$CFLAGS" = "x"; then
56 if test x$USE_MAINTAINER_MODE = xyes; then
57 CFLAGS_OPTS="-g3 -Og -ggdb"
58 AC_DEFINE(USE_MAINTAINER_MODE, 1, [Use maintainer mode])
61 AC_ARG_ENABLE([werror],
62 AS_HELP_STRING([--enable-werror], [Handle all compiler warnings as errors]))
63 if test "x$enable_werror" = xyes; then
64 AX_APPEND_COMPILE_FLAGS([-Werror], [mc_configured_cflags])
67 dnl Compiler can generate warnings for unrecognized flags added to CFLAGS
68 dnl which causes attribute checks to fail
69 ax_gcc_func_attribute_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
70 _AC_LANG_PREFIX[]FLAGS=
71 AX_GCC_FUNC_ATTRIBUTE([fallthrough])
72 AX_GCC_FUNC_ATTRIBUTE([weak])
73 AX_GCC_FUNC_ATTRIBUTE([unused])
74 _AC_LANG_PREFIX[]FLAGS=$ax_gcc_func_attribute_save_flags
75 unset ax_gcc_func_attribute_save_flags
80 dnl ############################################################################
81 dnl Check for programs
82 dnl ############################################################################
88 dnl See also the "OS specific stuff" section below.
90 dnl Check nroff and the options it supports
91 AC_CHECK_PROG(HAVE_nroff, nroff, true, false)
96 AC_MSG_CHECKING([for manual formatting macros])
97 AC_CACHE_VAL(mc_cv_mandoc, [
98 nroff -mandoc < /dev/null > /dev/null 2>&1
106 AC_MSG_RESULT([$MANDOC])
108 AC_MSG_CHECKING([for option to disable ANSI color in manuals])
109 AC_CACHE_VAL(mc_cv_man_nocolor, [
110 nroff -c < /dev/null > /dev/null 2>&1
117 MAN_FLAGS=$mc_cv_man_nocolor
118 AC_MSG_RESULT([${MAN_NOCOLOR-none}])
120 AC_MSG_CHECKING([if nroff accepts -Tlatin1 or -Tascii])
121 AC_CACHE_VAL(mc_cv_nroff_tascii, [
123 nroff -Tlatin1 < /dev/null > /dev/null 2>&1 /dev/null
125 mc_cv_nroff_tascii=-Tlatin1
127 nroff -Tascii < /dev/null > /dev/null 2>&1 /dev/null
129 mc_cv_nroff_tascii=-Tascii
133 AC_MSG_RESULT([${mc_cv_nroff_tascii-no}])
134 MAN_FLAGS="$MAN_FLAGS $mc_cv_nroff_tascii"
140 dnl Check for -z, -b, -L, and -S options to file
141 AC_CHECK_PROG(HAVE_FILECMD, file, true, false)
142 if $HAVE_FILECMD; then
143 dnl Don't use the file command if it doesn't accept the -z option
144 AC_MSG_CHECKING([for -z option to file command])
145 AC_CACHE_VAL(mc_cv_file_z, [
146 file -z . > /dev/null 2>&1
153 AC_MSG_RESULT([$mc_cv_file_z])
155 if test x$mc_cv_file_z = xyes; then
156 AC_DEFINE(USE_FILE_CMD, 1, [Define if the file command accepts the -z option])
158 AC_MSG_WARN([The file command doesn't accept the -z option and will not be used])
161 if test x$mc_cv_file_z = xyes; then
162 dnl file is used; check -b, -L and -S options
164 AC_MSG_CHECKING([for -b option to file command])
165 AC_CACHE_VAL(mc_cv_file_b, [
166 file -b . > /dev/null 2>&1
173 AC_MSG_RESULT([$mc_cv_file_b])
175 if test x$mc_cv_file_b = xyes; then
176 AC_DEFINE(FILE_B, "-b ", [Define if the file command accepts the -b option])
179 AC_MSG_CHECKING([for -L option to file command])
180 AC_CACHE_VAL(mc_cv_file_L, [
181 file -L . > /dev/null 2>&1
188 AC_MSG_RESULT([$mc_cv_file_L])
190 if test x$mc_cv_file_L = xyes; then
191 AC_DEFINE(FILE_L, "-L ", [Define if the file command accepts the -L option])
193 AC_DEFINE(FILE_L, "", [Define if the file command accepts the -L option])
196 dnl The file command accepts the -S option since 5.33
197 AC_MSG_CHECKING([for -S option to file command])
198 AC_CACHE_VAL(mc_cv_file_S, [
199 file -S . > /dev/null 2>&1
206 AC_MSG_RESULT([$mc_cv_file_S])
208 if test x$mc_cv_file_S = xyes; then
209 AC_DEFINE(FILE_S, "-S ", [Define if file command accepts the -S option])
211 AC_DEFINE(FILE_S, "", [Define if file command accepts the -S option])
216 dnl Only list browsers here that can be run in background (i.e. with `&')
217 AC_CHECK_PROGS(X11_WWW, [gnome-moz-remote mozilla firefox konqueror opera])
220 dnl ############################################################################
221 dnl Check for other tools
222 dnl ############################################################################
224 AC_CHECK_TOOLS([INDENT], [gindent indent])
228 dnl ############################################################################
229 dnl Check for main libraries
230 dnl ############################################################################
233 mc_G_MODULE_SUPPORTED
236 dnl X11 support. Used to read keyboard modifiers when running under X11.
240 dnl ############################################################################
241 dnl Check for header files
242 dnl ############################################################################
244 AC_CHECK_HEADERS([string.h memory.h limits.h malloc.h \
245 utime.h sys/statfs.h sys/vfs.h \
246 sys/select.h sys/ioctl.h stropts.h arpa/inet.h \
248 dnl This macro is redefined in m4.include/gnulib/sys_types_h.m4
249 dnl to work around a buggy version in autoconf <= 2.69.
252 mc_CHECK_HEADER_STDCKDINT
255 dnl ############################################################################
257 dnl ############################################################################
259 dnl Check largefile before type sizeof checks
262 AC_CHECK_SIZEOF(long)
264 AC_CHECK_SIZEOF(uintmax_t)
266 AC_CHECK_SIZEOF(off_t)
268 gl_PROMOTED_TYPE_MODE_T
272 dnl Taken from GNU/Linux, and should be good enough on platforms lacking these types.
273 AC_CHECK_TYPE([dev_t], [unsigned long long int])
274 AC_CHECK_TYPE([ino_t], [unsigned long long int])
276 dnl Taken from GNU/Linux, and should be good enough on platforms lacking these types.
277 AC_CHECK_TYPE([major_t], [unsigned int])
278 AC_CHECK_TYPE([minor_t], [unsigned int])
281 AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_rdev, struct stat.st_mtim, struct stat.st_mtimespec, struct stat.st_mtimensec])
284 AH_TEMPLATE([sig_atomic_t],
285 [/* Define to `int' if <signal.h> doesn't define.])
286 AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T],
287 [Some systems declare sig_atomic_t as volatile, some others -- no.
288 This define will have value `sig_atomic_t' or
289 `volatile sig_atomic_t' accordingly.])
291 AC_MSG_CHECKING(for sig_atomic_t in signal.h)
292 AC_EGREP_HEADER(sig_atomic_t,signal.h,
294 ac_cv_type_sig_atomic_t=yes;
295 AC_EGREP_HEADER(volatile.*sig_atomic_t,
298 is_sig_atomic_t_volatile=yes;
299 AC_MSG_RESULT([yes, volatile])
302 is_sig_atomic_t_volatile=no;
303 AC_MSG_RESULT([yes, non volatile])
308 AC_CHECK_TYPE(sig_atomic_t, int)
309 is_sig_atomic_t_volatile=no
311 if test $is_sig_atomic_t_volatile = 'yes'
313 AC_DEFINE(SIG_ATOMIC_VOLATILE_T, sig_atomic_t)
315 AC_DEFINE(SIG_ATOMIC_VOLATILE_T, [volatile sig_atomic_t])
319 dnl ############################################################################
320 dnl Check for functions
321 dnl ############################################################################
329 dnl getpt is a GNU Extension (glibc 2.1.x)
330 AC_CHECK_FUNCS(posix_openpt, , [AC_CHECK_FUNCS(getpt)])
331 AC_CHECK_FUNCS(grantpt, , [AC_CHECK_LIB(pt, grantpt)])
333 dnl replacing lstat with statlstat on sco makes it more portable between
335 AC_CHECK_FUNCS(statlstat)
340 dnl ############################################################################
341 dnl Internationalization
342 dnl ############################################################################
344 AC_CHECK_FUNCS([setlocale])
346 AM_GNU_GETTEXT([external], [need-ngettext])
347 AM_GNU_GETTEXT_VERSION([0.18.2])
351 dnl ############################################################################
352 dnl OS specific stuff
353 dnl ############################################################################
355 AC_CHECK_DECLS([environ], , ,
356 [ #include <unistd.h>
357 #include <stdlib.h> ])
361 AC_PATH_PROG([PERL], [perl], [/QOpenSys/pkgs/bin/perl])
362 AC_PATH_PROG([PERL_FOR_BUILD], [perl], [/QOpenSys/pkgs/bin/perl])
363 AC_PATH_PROG([PYTHON], [python], [/QOpenSys/pkgs/bin/python2])
364 AC_PATH_PROG([RUBY], [ruby], [/QOpenSys/pkgs/bin/ruby])
367 AC_PATH_PROG([PERL], [perl], [/usr/bin/perl])
368 AC_PATH_PROG([PERL_FOR_BUILD], [perl], [/usr/bin/perl])
369 AC_PATH_PROG([PYTHON], [python], [/usr/bin/python])
370 AC_PATH_PROG([RUBY], [ruby], [/usr/bin/ruby])
377 AC_DEFINE(_POSIX_SOURCE)
381 dnl If running under AIX, AC_USE_SYSTEM_EXTENSIONS does not tell us that
382 AC_MSG_CHECKING([for AIX defines])
385 #if defined(AIX) || defined(_AIX) || defined(__aix__) || defined(aix)
390 AC_DEFINE(IS_AIX, 1, [Define if compiling for AIX])
397 dnl utimensat is supported since glibc 2.6 and specified in POSIX.1-2008
398 AC_CHECK_FUNCS([utimensat])
402 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
405 dnl Check linux/fs.h for FICLONE to support BTRFS's file clone operation
408 AC_CHECK_HEADERS([linux/fs.h])
411 dnl Check if the OS is supported by the console saver.
418 dnl Check for gpm mouse support (Linux only)
419 mouse_lib="xterm only"
420 AC_ARG_WITH([gpm-mouse],
421 AS_HELP_STRING([--with-gpm-mouse], [Compile with gpm mouse support (Linux only) @<:@yes if found@:>@]))
425 if test x$with_gpm_mouse != xno; then
426 AC_CHECK_LIB(gpm, Gpm_Repeat,
427 [AC_DEFINE(HAVE_LIBGPM, 1,
428 [Define to enable gpm mouse support on Linux])
429 mouse_lib="gpm and xterm"
430 MCLIBS="$MCLIBS -lgpm"],
431 if test "x$with_gpm_mouse" = "xyes"; then
432 [AC_MSG_ERROR([libgpm is missing or older than 0.18])]
434 [AC_MSG_WARN([libgpm is missing or older than 0.18])]
442 dnl ############################################################################
444 dnl ############################################################################
446 LIBMC_VERSION="0.0.1"
448 AC_SUBST(LIBMC_VERSION)
449 AC_SUBST(LIBMC_RELEASE)
451 AC_ARG_ENABLE([mclib],
452 [AS_HELP_STRING([--enable-mclib], [Compile shared library libmc.so @<:@no@:>@])],
454 if test "x$enableval" = "xno" ; then
457 if test "x$enable_shared" = "xno" ; then
458 AC_MSG_WARN([Build of shared library is disabled. Specify --enable-shared first])
467 AM_CONDITIONAL([ENABLE_MCLIB], [test x$enable_mclib = xyes])
470 dnl ############################################################################
472 dnl ############################################################################
476 mc_WITH_INTERNAL_EDIT
478 dnl Diff viewer support.
479 AC_ARG_WITH([diff_viewer],
480 AS_HELP_STRING([--with-diff-viewer], [Compile with diff viewer @<:@yes@:>@]))
482 if test x$with_diff_viewer != xno; then
483 AC_DEFINE(USE_DIFF_VIEW, 1, [Define to enable diff viewer])
486 AC_MSG_NOTICE([using diff viewer])
496 dnl ############################################################################
498 dnl ############################################################################
500 dnl ${prefix} and ${exec_prefix} are undefined here if --prefix is not used in command line
501 dnl Let define ${prefix} and ${exec_prefix}
502 test "x$prefix" = "xNONE" && prefix="$ac_default_prefix"
503 test "x$exec_prefix" = "xNONE" && exec_prefix="${prefix}"
505 if test x${libexecdir} = x'${exec_prefix}/libexec'; then
506 EXTHELPERSDIR=${prefix}/libexec/${PACKAGE}/ext.d
507 elif test x${libexecdir} = x'${exec_prefix}/lib'; then
508 EXTHELPERSDIR=${prefix}/lib/${PACKAGE}/ext.d
510 EXTHELPERSDIR=${libexecdir}/${PACKAGE}/ext.d
512 AC_SUBST(EXTHELPERSDIR)
515 dnl ############################################################################
517 dnl ############################################################################
519 MAN_DATE="$(LC_ALL=C date "+%B %Y")"
522 dnl Determine which help translations we want to install.
523 ALL_DOC_LINGUAS="es hu it pl ru sr"
526 if test "x$USE_NLS" = xyes; then
527 if test -z "$LINGUAS"; then
528 langs="`grep -v '^#' $srcdir/po/LINGUAS`"
536 for h_lang in $ALL_DOC_LINGUAS; do
537 for lang in $langs; do
538 if test "$lang" = "$h_lang"; then
539 DOC_LINGUAS="$DOC_LINGUAS $lang"
544 AC_SUBST(DOC_LINGUAS)
554 DX_INIT_DOXYGEN(mc,doxygen.cfg,devel)
557 dnl ############################################################################
558 dnl Configure results
559 dnl ############################################################################
561 CFLAGS="$mc_configured_cflags $CFLAGS_OPTS $CFLAGS"
569 AM_CONDITIONAL(USE_NLS, [test x"$USE_NLS" = xyes])
570 AM_CONDITIONAL(USE_MAINTAINER_MODE, [test x"$USE_MAINTAINER_MODE" = xyes])
571 AM_CONDITIONAL(USE_SCREEN_SLANG, [test x"$with_screen" = xslang])
572 AM_CONDITIONAL(USE_INTERNAL_EDIT, [test x"$use_internal_edit" = xyes ])
573 AM_CONDITIONAL(USE_ASPELL, [test x"$enable_aspell" = xyes ])
574 AM_CONDITIONAL(USE_DIFF, [test -n "$use_diff"])
575 AM_CONDITIONAL(CHARSET, [test -n "$have_charset"])
576 AM_CONDITIONAL(CONS_SAVER, [test -n "$cons_saver"])
577 dnl Clarify do we really need GModule
578 AM_CONDITIONAL([HAVE_GMODULE], [test -n "$g_module_supported" && \
579 test x"$textmode_x11_support" = x"yes" -o x"$enable_aspell" = x"yes"])
581 AC_ARG_ENABLE([configure-args],
582 AS_HELP_STRING([--enable-configure-args], [Embed ./configure arguments into binaries]))
583 if test "x$enable_configure_args" != xno; then
584 AC_DEFINE([ENABLE_CONFIGURE_ARGS], 1, [Define to enable showing configure arguments in help])
585 AC_DEFINE_UNQUOTED([MC_CONFIGURE_ARGS], ["$ac_configure_args"], [MC configure arguments])
594 chmod +x src/man2hlp/man2hlp
612 misc/macros.d/Makefile
616 src/consaver/Makefile
619 src/subshell/Makefile
621 src/diffviewer/Makefile
622 src/filemanager/Makefile
626 src/vfs/cpio/Makefile
628 src/vfs/extfs/Makefile
629 src/vfs/extfs/helpers/Makefile
630 src/vfs/extfs/helpers/a+
631 src/vfs/extfs/helpers/apt+
632 src/vfs/extfs/helpers/audio
633 src/vfs/extfs/helpers/deb
634 src/vfs/extfs/helpers/deba
635 src/vfs/extfs/helpers/debd
636 src/vfs/extfs/helpers/dpkg+
637 src/vfs/extfs/helpers/iso9660
638 src/vfs/extfs/helpers/hp48+
639 src/vfs/extfs/helpers/lslR
640 src/vfs/extfs/helpers/mailfs
641 src/vfs/extfs/helpers/patchfs
642 src/vfs/extfs/helpers/rpms+
643 src/vfs/extfs/helpers/s3+
644 src/vfs/extfs/helpers/uace
645 src/vfs/extfs/helpers/ualz
646 src/vfs/extfs/helpers/uar
647 src/vfs/extfs/helpers/uarc
648 src/vfs/extfs/helpers/uarj
649 src/vfs/extfs/helpers/ucab
650 src/vfs/extfs/helpers/uha
651 src/vfs/extfs/helpers/ulha
652 src/vfs/extfs/helpers/ulib
653 src/vfs/extfs/helpers/unar
654 src/vfs/extfs/helpers/urar
655 src/vfs/extfs/helpers/uwim
656 src/vfs/extfs/helpers/uzip
657 src/vfs/extfs/helpers/uzoo
659 src/vfs/shell/Makefile
660 src/vfs/shell/helpers/Makefile
662 src/vfs/ftpfs/Makefile
664 src/vfs/sftpfs/Makefile
666 src/vfs/local/Makefile
672 src/vfs/undelfs/Makefile
676 lib/filehighlight/Makefile
677 lib/mcconfig/Makefile
692 doc/hints/l10n/Makefile
713 dnl https://stackoverflow.com/questions/30897170/ac-subst-does-not-expand-variable/30932102#30932102
715 [misc/syntax/Syntax], [${SED-sed} -e "s%\${prefix}%$PREFIX%" misc/syntax/Syntax > misc/syntax/Syntax.tmp && \
716 mv -f misc/syntax/Syntax.tmp misc/syntax/Syntax], [export PREFIX=$prefix]
722 tests/lib/mcconfig/Makefile
723 tests/lib/search/Makefile
724 tests/lib/strutil/Makefile
725 tests/lib/vfs/Makefile
726 tests/lib/vfs/mc.charsets
727 tests/lib/widget/Makefile
729 tests/src/filemanager/Makefile
730 tests/src/editor/Makefile
731 tests/src/editor/test-data.txt
732 tests/src/vfs/Makefile
733 tests/src/vfs/extfs/Makefile
734 tests/src/vfs/extfs/helpers-list/Makefile
735 tests/src/vfs/extfs/helpers-list/data/config.sh
736 tests/src/vfs/extfs/helpers-list/misc/Makefile
737 tests/src/vfs/ftpfs/Makefile
746 Source code location: ${srcdir}
748 Compiler flags: ${CFLAGS}
749 Assertions: ${enable_assert}
750 Unit tests: ${tests_msg}
751 File system: ${vfs_type}
753 Screen library: ${screen_msg}
754 Mouse support: ${mouse_lib}
755 X11 events support: ${textmode_x11_support}
756 With subshell support: ${subshell}
757 With background operations: ${enable_background}
758 With ext2fs attributes support: ${ext2fs_attr_msg}
759 Internal editor: ${edit_msg}
760 Diff viewer: ${diff_msg}
761 Support for charset: ${charset_msg}
762 Search type: ${SEARCH_TYPE}
765 dnl option checking is disable by default due to AC_CONFIG_SUBDIRS
766 dnl we enable it back for top-level ./configure
767 if test -n "$ac_unrecognized_opts"; then
768 case $enable_option_checking in
769 fatal) AC_MSG_ERROR([unrecognized options: $ac_unrecognized_opts]) ;;
770 *) AC_MSG_WARN( [unrecognized options: $ac_unrecognized_opts]) ;;