1# Process this file with autoconf to produce a configure script.
2#
3# Copyright 2002-2021 Free Software Foundation, Inc.
4#
5# This file is free software; as a special exception the author gives
6# unlimited permission to copy and/or distribute it, with or without
7# modifications, as long as this notice is preserved.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
11# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12#
13AC_INIT([GNU Texinfo], [6.8], [bug-texinfo@gnu.org])
14
15dnl Must come before AM_INIT_AUTOMAKE.
16AC_CONFIG_AUX_DIR([build-aux])
17dnl tar-ustar because we have long filenames for some test files.
18dnl parallel-tests as recommended by stefano.
19AM_INIT_AUTOMAKE([1.14 dist-xz
20                 info-in-builddir parallel-tests readme-alpha tar-ustar])
21
22# Where to generate output; srcdir location.
23AC_CONFIG_HEADERS([config.h:config.in])dnl Keep filename to 8.3 for MS-DOS.
24AC_CONFIG_SRCDIR([info/info.c])
25
26# TexinfoXML DTD (./util/texinfo.dtd) version:
27# manually set this to the next version number rather than
28# $PACKAGE_VERSION, as soon as the DTD is modified, and perhaps put the
29# file on the web, too.  Several reasons:
30# 1. To avoid using a DTD from the Internet that wouldn't be in sync;
31# 2. To avoid unnnecessary changes in XML output file headers, in
32#    test results for instance.
33# 3. It may be kept as is in case there were no change in the DTD
34#    between releases.  This is rare, but has happened.
35#
36TEXINFO_DTD_VERSION=6.8
37AC_SUBST([TEXINFO_DTD_VERSION])
38
39# Package date.
40PACKAGE_DATE=`${SHELL} "$srcdir"/build-aux/mdate-sh "$srcdir"/configure.ac`
41AC_SUBST([PACKAGE_DATE])
42
43# We need Perl
44AC_ARG_VAR([PERL], [The path to the 'perl' executable.])
45AC_PATH_PROG([PERL], [perl])
46if test -z "$PERL"; then
47   AC_MSG_ERROR(
48[perl not found; Texinfo requires Perl.
49If you have perl installed somewhere not in PATH,
50specify where it is using
51  ./configure PERL=/path/to/perl
52])
53fi
54
55# User variables for a Perl XS extension, which may be different, for
56# example if the Perl interpreter being used was compiled with a
57# different compiler.  Also in tp/Texinfo/XS/configure.ac.
58AC_ARG_VAR([PERL_EXT_CFLAGS], [Compiler flags for a Perl extension])
59AC_ARG_VAR([PERL_EXT_CPPFLAGS], [C preprocessor flags for a Perl extension])
60AC_ARG_VAR([PERL_EXT_LDFLAGS], [Linker flags for a Perl extension])
61AC_ARG_VAR([PERL_EXT_CC], [Compiler for a Perl extension])
62
63AC_MSG_CHECKING([Perl version and modules])
64if $PERL -e "use 5.007_003; use Encode; use Data::Dumper" >/dev/null 2>&1; then
65  perl_version_requirement='yes'
66else
67  perl_version_requirement='no'
68fi
69AC_MSG_RESULT($perl_version_requirement)
70if test z"$perl_version_requirement" = 'zno' ; then
71  AC_MSG_ERROR([perl >= 5.7.3 with Encode and Data::Dumper required by Texinfo.])
72fi
73
74
75AC_REQUIRE_AUX_FILE([tap-driver.sh])
76
77# awk for texindex.
78# don't use AC_PROG_AWK because this prefers gawk, which is much slower
79# than mawk for texindex and texi2dvi
80AC_CHECK_PROGS([TI_AWK], [awk mawk gawk], [])
81if test -z "$TI_AWK"; then
82  AC_MSG_ERROR([awk not found])
83fi
84
85# for generating texindex.awk
86AM_MISSING_PROG(GAWK, gawk)
87
88# Checks for programs.
89AC_PROG_CC
90
91# Since we use gnulib: gl_EARLY must be called as soon as possible after
92# the C compiler is checked.  The others could be later, but we just
93# keep everything together.
94gl_EARLY
95
96# Rest of Gnulib.
97gl_INIT
98
99# To generate man pages.
100AM_MISSING_PROG(HELP2MAN, help2man)
101AM_MISSING_PROG(POD2MAN, pod2man)
102
103AC_PROG_INSTALL
104AC_PROG_MAKE_SET
105
106AC_PROG_LN_S
107AC_PROG_MKDIR_P
108
109# gettext Makefiles may still need MKINSTALLDIRS.
110MKINSTALLDIRS="\$(top_srcdir)/build-aux/install-sh -d"
111AC_SUBST([MKINSTALLDIRS])
112
113# check whether diff accepts the -u option (not on HP-UX).
114AC_MSG_CHECKING(whether diff accepts -u)
115diff_accepts_u_option=no
116echo foo >conftest.dtx
117echo foo | diff -u - conftest.dtx >/dev/null 2>&1
118error_status_diff_u=$?
119if test $error_status_diff_u = 0; then
120  diff_accepts_u_option=yes
121fi
122AC_MSG_RESULT($diff_accepts_u_option)
123rm -f conftest.dtx
124
125DIFF_U_OPTION=
126if test "z$diff_accepts_u_option" = 'zyes' ; then
127  DIFF_U_OPTION=-u
128fi
129AC_SUBST([DIFF_U_OPTION])
130
131# check whether diff accepts the -a option (only needed for GNU diff).
132AC_MSG_CHECKING(whether diff accepts -a)
133diff_accepts_a_option=no
134echo foo >conftest.dtx
135echo foo | diff -a - conftest.dtx >/dev/null 2>&1
136error_status_diff_a=$?
137if test $error_status_diff_a = 0; then
138  diff_accepts_a_option=yes
139fi
140AC_MSG_RESULT($diff_accepts_a_option)
141rm -f conftest.dtx
142
143DIFF_A_OPTION=
144if test "z$diff_accepts_a_option" = 'zyes' ; then
145  DIFF_A_OPTION=-a
146fi
147AC_SUBST([DIFF_A_OPTION])
148
149# Checks for header files.
150AC_CHECK_HEADERS(io.h pwd.h \
151  termcap.h termios.h unistd.h \
152  sys/ioctl.h sys/time.h sys/wait.h)
153
154AC_SYS_POSIX_TERMIOS
155
156AC_TYPE_OFF_T
157
158# Checks for library functions.
159AC_CHECK_FUNCS(setlocale sigaction sigprocmask posix_openpt)
160
161# Used for Info tests
162AM_CONDITIONAL([have_ptys], [test x$ac_cv_func_posix_openpt = xyes])
163
164# We want to recognize djgpp to avoid the useless warning about no
165# term library.
166AC_CANONICAL_BUILD
167
168# We need to run some of our own binaries, most notably makedoc, but as
169# long as we have this process, we also use our own makeinfo and
170# install-info.
171#
172# This means that if we are cross compiling, we have to configure the
173# package twice: once with the native compiler (this is done in a
174# subdirectory $native_tools), and once with the cross compiler.
175# The former is invoked automatically here, with --host=$build.
176# $native_tools is also added to SUBDIRS in the main Makefile.am,
177# so that make compiles the native tools first.
178#
179if test "$cross_compiling" = no; then
180  native_tools=
181else
182  native_tools=tools
183  test -d "$native_tools" || mkdir "$native_tools"
184  confdir=`(cd "$srcdir";pwd)`
185  # Make sure the secondary configure won't fail with
186  # "error: source directory already configured".
187  rm -f config.status
188  AC_MSG_NOTICE([[Doing configure of native tools (${build}).]])
189  cd "$native_tools" || exit 1
190  # Run secondary configure in alternate environment or
191  # it gets the wrong CC etc.
192  # env -i gives this build host configure a clean environment;
193  # consequently, we have to re-initialize $PATH.
194  env -i CC="$BUILD_CC" AR="$BUILD_AR" RANLIB="$BUILD_RANLIB" \
195      PATH="$PATH" \
196      tools_only=1 \
197    ${confdir}/configure --build=${build} --host=${build} \
198                         --disable-rpath --disable-nls
199  cd .. || exit 1
200  AC_MSG_NOTICE([[Continuing with main configure (${host}).]])
201fi
202AC_SUBST(native_tools)
203AM_CONDITIONAL(TOOLS_ONLY, [[test "x$tools_only" = x1]])
204
205# Some GNU/Linux systems (e.g., SuSE 4.3, 1996) don't have curses, but
206# rather ncurses.  So we check for it.
207TERMLIBS=
208# Check for termlib before termcap because Solaris termcap needs libucb.
209TERMLIB_VARIANTS="tinfo ncurses curses termlib termcap terminfo"
210for termlib in ${TERMLIB_VARIANTS}; do
211  AC_CHECK_LIB(${termlib}, tgetent,
212     [TERMLIBS="${TERMLIBS} -l${termlib}"; break])
213done
214have_termlib=yes
215# don't bother warning on djgpp and MinGW, they don't have a term library,
216# and port each termcap-needing program separately according to the needs.
217if test -z "$TERMLIBS" \
218   && echo "$build" | grep -v djgpp | grep -v mingw >/dev/null; then
219  AC_MSG_WARN([info needs a terminal library, one of: ${TERMLIB_VARIANTS}])
220  have_termlib=no
221fi
222
223# Checks for variables.
224# HP-UX 9 (at least) needs -lncurses which defines termcap variables PC etc.
225AC_MSG_CHECKING(for library with termcap variables)
226AC_CACHE_VAL(ac_cv_var_ospeed,
227[oldLIBS=$LIBS
228for trylib in $termlib ${TERMLIB_VARIANTS}; do
229   if test "x$trylib" != "x$termlib"; then
230     LIBS="$oldLIBS -l$termlib -l$trylib"
231   else
232     LIBS="$oldLIBS -l$termlib"
233   fi
234   AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[#ifdef HAVE_NCURSES_TERMCAP_H
235#include <ncurses/termcap.h>
236#else
237#ifdef HAVE_TERMCAP_H
238#include <termcap.h>
239#else
240#undef PC
241char *BC;
242char **UP;
243char PC;
244short ospeed;
245#endif
246#endif
247/* Make sure all variables actually exist.  AIX 4.3 has ospeed but no BC.
248   --Andreas Ley <andy@rz.uni-karlsruhe.de> 24 Aug 2000.  */
249BC++;
250UP++;
251PC++;
252return ospeed != 0;
253]])], [ac_cv_var_ospeed=$trylib; break])
254done
255LIBS=$oldLIBS
256])
257AC_MSG_RESULT($ac_cv_var_ospeed)
258if test -n "$ac_cv_var_ospeed" \
259   && test "x$termlib" != "x$ac_cv_var_ospeed"; then
260  TERMLIBS="${TERMLIBS} -l${ac_cv_var_ospeed}"
261fi
262AC_SUBST(TERMLIBS)#
263AM_CONDITIONAL(HAVE_TERMLIBS, [[test "x$TERMLIBS" != x]])
264
265# Do not use <ncurses/termcap.h> unless we're linking with ncurses.
266# Must come after the termlib tests.
267if test "x$termlib" = xncurses; then
268  # Use AC_CHECK_HEADERS so the HAVE_*_H symbol gets defined.
269  AC_CHECK_HEADERS(ncurses/termcap.h)
270fi
271
272# For teTeX and TeX Live.
273AC_CANONICAL_HOST
274AC_ARG_ENABLE([multiplatform],
275  [AS_HELP_STRING([--enable-multiplatform],
276     [put executables into bin/PLATFORM and libraries into lib/PLATFORM])])dnl
277# if enable_multiplatform is set in the environment, use that.
278if test "x$enable_multiplatform" = xyes; then
279  test "x$bindir" = 'x${exec_prefix}/bin' && bindir="$bindir/$host"
280  test "x$libdir" = 'x${exec_prefix}/lib' && libdir="$libdir/$host"
281fi
282
283# Taken from the example in
284# http://www.gnu.org/software/automake/manual/html_node/Conditionals.html.
285AC_ARG_ENABLE(install-warnings,
286  [  --disable-install-warnings  omit make install warnings about TeX files],
287  [case "${enableval}" in
288     yes) install_warnings=true ;;
289      no) install_warnings=false ;;
290       *) AC_MSG_ERROR(bad value ${enableval} for --enable-install-warnings) ;;
291   esac],
292   [install_warnings=true])
293AM_CONDITIONAL(INSTALL_WARNINGS,
294   test x"$install_warnings" = xtrue || test x"$install_warnings" = xyes)
295
296USE_EXTERNAL_EASTASIANWIDTH=no
297AC_ARG_WITH([external-Unicode-EastAsianWidth],
298   AS_HELP_STRING([--with-external-Unicode-EastAsianWidth],[use external Unicode-EastAsianWidth (default: no)]),
299   [if test $withval = 'yes'; then
300      USE_EXTERNAL_EASTASIANWIDTH=yes
301   fi]
302)
303
304AC_SUBST([USE_EXTERNAL_EASTASIANWIDTH])
305
306USE_EXTERNAL_UNIDECODE=no
307AC_ARG_WITH([external-Text-Unidecode],
308    AS_HELP_STRING([--with-external-Text-Unidecode],[use external Text::Unidecode (default: no)]),
309   [if test $withval = 'yes'; then
310      USE_EXTERNAL_UNIDECODE=yes
311   fi]
312)
313
314AC_SUBST([USE_UNICODE])
315AC_SUBST([USE_EXTERNAL_UNIDECODE])
316
317# i18n support.  To update to a new version of gettext, run:
318#   gettextize -f --po-dir=po --po-dir=po_document
319# See http://gnu.org/s/gnulib/manual/html_node/gettextize-and-autopoint.html.
320AM_GNU_GETTEXT_VERSION([0.21])
321AM_GNU_GETTEXT([external])
322
323USE_EXTERNAL_LIBINTL=no
324AC_ARG_WITH([external-libintl-perl],
325   AS_HELP_STRING([--with-external-libintl-perl],[use external libintl-perl (default: no)]),
326   [if test $withval = 'yes'; then
327      USE_EXTERNAL_LIBINTL=yes
328   fi]
329)
330
331AC_SUBST([USE_EXTERNAL_LIBINTL])
332
333AC_ARG_ENABLE([perl-xs],
334    AS_HELP_STRING([--enable-perl-xs],[build Perl XS modules for speed (default: check)]),
335    [ enable_xs=$enableval],
336    [ enable_xs=check])
337
338# Set xs_srcdir to the path from XS builddir to srcdir
339case $srcdir in
340  .)  # We are building in place.
341    xs_srcdir=../.. ;;
342  [[\\/]]* | ?:[[\\/]]* )  # Absolute name.
343    xs_srcdir=$srcdir/tp ;;
344  *) # Relative name.
345    xs_srcdir=../../../$srcdir/tp ;;
346esac
347
348# Pass on all the options we were given to the subsidiary configure
349# script.
350# Don't use AC_CONFIG_SUBDIRS for this because it isn't done right away,
351# and we need it for the check that follows.
352# We use the _AC_OUTPUT_SUBDIRS internal autoconf macro
353# (in /usr/share/autoconf/autoconf/status.m4) for this in order to
354# pass on the configure command line correctly; for example, adjusting
355# paths.  It is done in a subshell to be resilient against failure of the
356# subsidiary configure script, which happens if the C compiler is found
357# not to work.
358#
359save_subdirs=$subdirs
360subdirs=tp/Texinfo/XS
361( _AC_OUTPUT_SUBDIRS ) || enable_xs=no
362subdirs=$save_subdirs
363
364if test $enable_xs = no; then
365  AC_MSG_NOTICE([building Perl extension (XS) modules will be disabled])
366fi
367
368if test $enable_xs = check; then
369  AC_MSG_CHECKING([whether we can build Perl extension (XS) modules])
370  AC_MSG_RESULT([])
371  enable_xs=no
372  (cd tp/Texinfo/XS \
373   && make clean \
374   && make TestXS.la \
375   && TEXINFO_XS=debug ; export TEXINFO_XS \
376   && ${PERL} -I . \
377              -I ${xs_srcdir} \
378              -e 'require Texinfo::XS::TestXS;' \
379      | grep 'message from XS module') \
380  && enable_xs=yes
381  AC_MSG_CHECKING([whether we can build Perl extension (XS) modules])
382  AC_MSG_RESULT([$enable_xs])
383fi
384
385AC_SUBST([enable_xs])
386
387AM_CONDITIONAL([DISABLE_XS], [test "z$enable_xs" = zno])
388
389# Texinfo JS Interface
390npm_path="${srcdir}/js/node_modules/.bin${PATH_SEPARATOR}$PATH"
391
392AC_PATH_PROG([ESLINT], [eslint], [], [$npm_path])
393AM_CONDITIONAL([HAVE_ESLINT], [test "x$ac_cv_path_ESLINT" != "x"])
394
395AC_PATH_PROG([TSC], [tsc], [], [$npm_path])
396AM_CONDITIONAL([HAVE_TYPESCRIPT], [test "x$ac_cv_path_TSC" != "x"])
397
398AC_PATH_PROG([UGLIFYJS], [uglifyjs], [], [$npm_path])
399AM_CONDITIONAL([HAVE_UGLIFYJS], [test "x$ac_cv_path_UGLIFYJS" != "x"])
400
401AC_PATH_PROG([MODERNIZR], [modernizr], [], [$npm_path])
402AM_CONDITIONAL([HAVE_MODERNIZR], [test "x$ac_cv_path_MODERNIZR" != "x"])
403
404# Tests.
405AC_CONFIG_FILES([install-info/tests/defs])
406dnl We cannot enable the TeX-related tests, so don't waste time
407dnl configuring them.  See contrib/nontests/README.
408dnl AC_CONFIG_FILES([util/tests/defs])
409dnl AC_CHECK_PROGS([HEVEA], [hevea], [])
410dnl AC_CHECK_PROGS([TEX], [tex], [])
411
412AC_CHECK_PROGS([PROVE], [prove], [])
413
414tp_tests='no'
415AC_ARG_ENABLE([tp-tests],
416    AS_HELP_STRING([--enable-tp-tests],[run the parser and converters testsuite (default: detected)]),
417    [if test $enableval = 'no'; then
418       tp_tests='no'
419     else
420       tp_tests='yes'
421     fi],
422    [
423     if test "z$PROVE" = 'z'; then
424       tp_tests='no'
425     elif $PERL -e "use 5.007_003; use Encode; use Test::More; use File::Basename; use File::Copy; use Data::Dumper; use Data::Compare; use Test::Deep; use Storable qw(dclone); use Getopt::Long qw(GetOptions);" > /dev/null 2>&1;
426     then
427       tp_tests='yes'
428     else
429       tp_tests='no'
430     fi
431    ])
432
433AC_MSG_CHECKING([parser tests requirements])
434AC_MSG_RESULT([$tp_tests])
435AM_CONDITIONAL([TP_TESTS], [test "z$tp_tests" = 'zyes'])
436
437build_perl_api_texi='no'
438AC_ARG_ENABLE([perl-api-texi-build],
439    AS_HELP_STRING([--enable-perl-api-texi-build],[build the perl api texinfo files (default: detected)]),
440    [if test $enableval = 'no'; then
441       build_perl_api_texi='no'
442     else
443       build_perl_api_texi='yes'
444     fi],
445    [
446     if $PERL -e "use 5.007_003; use Encode; use Pod::Simple::PullParser;" > /dev/null 2>&1;
447     then
448       build_perl_api_texi='yes'
449     else
450       build_perl_api_texi='no'
451     fi
452    ])
453
454AC_MSG_CHECKING([Perl Texinfo API texinfo documentation build requirements])
455AC_MSG_RESULT([$build_perl_api_texi])
456AM_CONDITIONAL([BUILD_PERL_API_TEXI], [test "z$build_perl_api_texi" = 'zyes'])
457
458pod_simple_texinfo_tests='no'
459AC_ARG_ENABLE([pod-simple-texinfo-tests],
460    AS_HELP_STRING([--enable-pod-simple-texinfo-tests],[run the parser and converters testsuite (default: detected)]),
461    [if test $enableval = 'no'; then
462       pod_simple_texinfo_tests='no'
463     else
464       pod_simple_texinfo_tests='yes'
465     fi],
466    [
467     if test "z$PROVE" = 'z' ; then
468       pod_simple_texinfo_tests='no'
469     elif $PERL -e "use 5.007_003; use Encode; use Test::More; use Pod::Simple::PullParser;" > /dev/null 2>&1;
470     then
471       pod_simple_texinfo_tests='yes'
472     else
473       pod_simple_texinfo_tests='no'
474     fi
475    ])
476
477AC_MSG_CHECKING([Pod::Simple::Texinfo tests requirements])
478AC_MSG_RESULT([$pod_simple_texinfo_tests])
479AM_CONDITIONAL([POD_SIMPLE_TEXINFO_TESTS], [test "z$pod_simple_texinfo_tests" = 'zyes'])
480
481host_is_windows=no
482case "$host" in
483   *-mingw32 | *-mingw64 | *-msdosdjgpp )  host_is_windows=yes ;;
484esac
485AM_CONDITIONAL([HOST_IS_WINDOWS], [test "x$host_is_windows" = "xyes"])
486
487# The config files to generate.
488AC_CONFIG_FILES([\
489  Makefile
490  doc/Makefile
491  doc/tp_api/Makefile
492  gnulib/lib/Makefile
493  info/Makefile
494  install-info/Makefile
495  install-info/tests/Makefile
496  man/Makefile
497  po/Makefile.in
498  po_document/Makefile.in
499  util/Makefile
500  texindex/Makefile
501  tp/Makefile
502  tp/tests/Makefile
503  tp/tests/many_input_files/Makefile
504  tp/tests/sectioning/Makefile
505  tp/tests/formatting/Makefile
506  tp/tests/indices/Makefile
507  tp/tests/contents/Makefile
508  tp/tests/nested_formats/Makefile
509  tp/tests/layout/Makefile
510  tp/tests/tex_html/Makefile
511  tp/defs
512  js/Makefile
513  Pod-Simple-Texinfo/Makefile
514])
515
516AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in],
517  [chmod +x pre-inst-env])
518
519AC_OUTPUT
520
521# Summarize warnings to make them more visible.
522if test $have_termlib = no; then
523  AC_MSG_WARN([Could not find a terminal library among ${TERMLIB_VARIANTS}])
524  AC_MSG_WARN([The programs from `info' directory will not be built.])
525fi
526