[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 24 Dec 2024 03:20:52 -0500 (EST) |
branch: master
commit 29079d15506c5b6e997ebe7b480a5eee5ef42c8f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 22 13:04:20 2024 +0100
ctexi2any C program for conversion to HTML with Perl embedding
* tp/load_txi_modules.pl, tp/Texinfo/XS/teximakehtml.c (main),
tp/Texinfo/XS/main/call_perl_function.c (xs_init, call_init_perl)
(call_finish_perl), tp/Texinfo/XS/Makefile.am (noinst_PROGRAMS)
(ctexi2any_SOURCES, ctexi2any_LDADD, ctexi2any_LDFLAGS)
(ctexi2any_CPPFLAGS): add load_txi_modules.pl, a new script that loads
the Texinfo modules, based on texi2any.pl beginning trimmed down.
Add call_init_perl and call_finish_perl to load a Perl interpreter
calling load_txi_modules.pl. In teximakehtml.c, if EMBED_PERL is
defined, call the functions to load an interpreter.
Add ctexi2any based on teximakehtml.c linking against libtexinfo*
libraries with EMBED_PERL defined.
* tp/Texinfo/XS/convert/texinfo.c (txi_general_setup)
(txi_set_base_default_options): add arguments to set
use_external_translate_string, and to be able to avoid setting
XS_STRXFRM_COLLATION_LOCALE. Update callers.
---
ChangeLog | 21 +++
tp/Makefile.am | 1 +
tp/Texinfo/XS/Makefile.am | 28 ++-
tp/Texinfo/XS/convert/texinfo.c | 21 ++-
tp/Texinfo/XS/convert/texinfo.h | 5 +-
tp/Texinfo/XS/main/call_perl_function.c | 52 ++++++
tp/Texinfo/XS/main/call_perl_function.h | 2 +
tp/Texinfo/XS/teximakehtml.c | 34 +++-
tp/load_txi_modules.pl | 296 ++++++++++++++++++++++++++++++++
9 files changed, 445 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9def1f7956..27e1ff1ef2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2024-12-22 Patrice Dumas <pertusus@free.fr>
+
+ ctexi2any C program for conversion to HTML with Perl embedding
+
+ * tp/load_txi_modules.pl, tp/Texinfo/XS/teximakehtml.c (main),
+ tp/Texinfo/XS/main/call_perl_function.c (xs_init, call_init_perl)
+ (call_finish_perl), tp/Texinfo/XS/Makefile.am (noinst_PROGRAMS)
+ (ctexi2any_SOURCES, ctexi2any_LDADD, ctexi2any_LDFLAGS)
+ (ctexi2any_CPPFLAGS): add load_txi_modules.pl, a new script that loads
+ the Texinfo modules, based on texi2any.pl beginning trimmed down.
+ Add call_init_perl and call_finish_perl to load a Perl interpreter
+ calling load_txi_modules.pl. In teximakehtml.c, if EMBED_PERL is
+ defined, call the functions to load an interpreter.
+ Add ctexi2any based on teximakehtml.c linking against libtexinfo*
+ libraries with EMBED_PERL defined.
+
+ * tp/Texinfo/XS/convert/texinfo.c (txi_general_setup)
+ (txi_set_base_default_options): add arguments to set
+ use_external_translate_string, and to be able to avoid setting
+ XS_STRXFRM_COLLATION_LOCALE. Update callers.
+
2024-12-22 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/teximakehtml.c (main): really handle option setting a
diff --git a/tp/Makefile.am b/tp/Makefile.am
index fc2c0bfa0e..2854fa4d1b 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -356,6 +356,7 @@ maintenance_files = \
# test_files_generated_list comes from the generated Makefile.tres
EXTRA_DIST = \
+ load_txi_modules.pl \
texi2any.pl \
texi2any.supp \
$(test_files_generated_list) \
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 2ee5bbc771..4c888a7bfd 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -603,9 +603,11 @@ ConvertXS_la_LDFLAGS = $(XSLIBS_LDFLAGS)
############################################### demonstrator of the API
+noinst_PROGRAMS =
+
if ! DISABLE_ADDITIONAL_CHECKS
if HAVE_ICONV
-noinst_PROGRAMS = teximakehtml
+noinst_PROGRAMS += teximakehtml
endif
endif
@@ -621,3 +623,27 @@ teximakehtml_LDFLAGS = $(EUIDACCESS_LIBGEN) $(LTLIBINTL)
$(LTLIBICONV) $(LTLIBUN
teximakehtml_CPPFLAGS = -I$(srcdir)/parsetexi -I$(srcdir)/convert
-I$(srcdir)/main -I$(srcdir)/structuring_transfo $(AM_CPPFLAGS)
$(GNULIB_CPPFLAGS) -DPATH_SEP=\"${PATH_SEPARATOR}\"
+
+############################################### main program in C
+
+if ! DISABLE_ADDITIONAL_CHECKS
+if HAVE_ICONV
+noinst_PROGRAMS += ctexi2any
+endif
+endif
+
+ctexi2any_SOURCES = \
+ teximakehtml.c
+
+# NOTE PERL_LIBS is needed on GNU/Linux too, but see just below ExtUtils::Embed
+# should be used
+# FIXME use perl -MExtUtils::Embed -e ccopts
+# FIXME use perl -MExtUtils::Embed -e ldopts
+# TODO not sure that gnulib is directly needed
+ctexi2any_LDADD = libtexinfo-convertxs.la libtexinfoxs.la
libtexinfo-convert.la libtexinfo.la $(top_builddir)/gnulib/lib/libgnu.la
$(platform_PERL_LIBADD) $(PERL_LIBS)
+#ctexi2any_LDFLAGS = $(EUIDACCESS_LIBGEN) $(LTLIBINTL) $(LTLIBICONV)
$(LTLIBUNISTRING)
+ctexi2any_LDFLAGS = $(perl_conf_LDFLAGS)
+
+ctexi2any_CPPFLAGS = -I$(srcdir)/parsetexi -I$(srcdir)/convert
-I$(srcdir)/main -I$(srcdir)/structuring_transfo $(AM_CPPFLAGS)
$(GNULIB_CPPFLAGS) -DPATH_SEP=\"${PATH_SEPARATOR}\" -DEMBED_PERL
+
+
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 7a8aba7b44..a894a0b479 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -49,7 +49,8 @@
to be called once */
void
txi_general_setup (int texinfo_uninstalled, const char *converterdatadir,
- const char *tp_builddir, const char *top_srcdir)
+ const char *tp_builddir, const char *top_srcdir,
+ int use_external_translate_string)
{
char *locales_dir;
@@ -64,7 +65,8 @@ txi_general_setup (int texinfo_uninstalled, const char
*converterdatadir,
if (stat (locales_dir, &finfo) == 0 && S_ISDIR (finfo.st_mode))
{
- configure_output_strings_translations (locales_dir, 0, -1);
+ configure_output_strings_translations (locales_dir, 0,
+ use_external_translate_string);
}
else
fprintf (stderr, "Locales dir for document strings not found\n");
@@ -72,7 +74,8 @@ txi_general_setup (int texinfo_uninstalled, const char
*converterdatadir,
else
{
xasprintf (&locales_dir, "%s/locale", converterdatadir);
- configure_output_strings_translations (locales_dir, 0, -1);
+ configure_output_strings_translations (locales_dir, 0,
+ use_external_translate_string);
}
free (locales_dir);
@@ -95,7 +98,8 @@ err_add_option_value (OPTIONS_LIST *options_list, const char
*option_name,
void
txi_set_base_default_options (OPTIONS_LIST *main_program_set_options,
const char *locale_encoding,
- const char *program_file)
+ const char *program_file,
+ int embedded_interpreter)
{
const char *configured_version = PACKAGE_VERSION_CONFIG;
const char *configured_package = PACKAGE_CONFIG;
@@ -123,10 +127,11 @@ txi_set_base_default_options (OPTIONS_LIST
*main_program_set_options,
locale_encoding);
err_add_option_value (main_program_set_options, "LOCALE_ENCODING", 0,
locale_encoding);
- /* filled here because it is the best we have in C */
- err_add_option_value (main_program_set_options,
- "XS_STRXFRM_COLLATION_LOCALE", 0,
- "en_US");
+ if (!embedded_interpreter)
+ /* filled here because it is the best we have in C */
+ err_add_option_value (main_program_set_options,
+ "XS_STRXFRM_COLLATION_LOCALE", 0,
+ "en_US");
/* same as Texinfo::Common::default_main_program_customization_options */
/* in general transmitted to converters as default */
diff --git a/tp/Texinfo/XS/convert/texinfo.h b/tp/Texinfo/XS/convert/texinfo.h
index a7c68cf85d..acd75d7af2 100644
--- a/tp/Texinfo/XS/convert/texinfo.h
+++ b/tp/Texinfo/XS/convert/texinfo.h
@@ -33,11 +33,12 @@
void txi_general_setup (int texinfo_uninstalled,
const char *converterdatadir, const char *tp_builddir,
- const char *top_srcdir);
+ const char *top_srcdir, int use_external_translate_string);
void txi_set_base_default_options (OPTIONS_LIST *options,
const char *locale_encoding,
- const char *program_file);
+ const char *program_file,
+ int embedded_interpreter);
void txi_converter_output_format_setup (const char *format_str);
diff --git a/tp/Texinfo/XS/main/call_perl_function.c
b/tp/Texinfo/XS/main/call_perl_function.c
index baed57d725..c1395a97d0 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -258,3 +258,55 @@ call_collator_getSortKey (const void *collator_sv, const
char *string)
}
+/* following is used to embed a Perl interpreter */
+static PerlInterpreter *my_perl;
+
+/* this is somewhat magic, but it works; obtained according to perlembed with
+ perl -MExtUtils::Embed -e xsinit -- -o perlxsi.c
+ */
+
+EXTERN_C void xs_init (pTHX);
+
+EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
+
+EXTERN_C void
+xs_init(pTHX)
+{
+ static const char file[] = __FILE__;
+ dXSUB_SYS;
+ PERL_UNUSED_CONTEXT;
+
+ /* DynaLoader is a special case */
+ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
+}
+
+/* load a Perl intperpreter and load Texinfo modules. To be called once */
+/* TODO "hide" load_txi_modules.pl in datadir/texi2any and pass the
+ path as call_init_perl argument, with a different name for in-source and
+ installed cases */
+void
+/* call_init_perl (int argc, char **argv, char **env) */
+call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref)
+{
+ char *embedding[] = { "", "load_txi_modules.pl" };
+ /* The arguments of PERL_SYS_INIT3 are not explained clearly anywhere.
+ The only hint is in perlembed:
+ PERL_SYS_INIT3() must be invoked on the C main() argc, argv and env and
only once.
+ */
+ /* PERL_SYS_INIT3(&argc,&argv,&env); */
+ PERL_SYS_INIT3 (argc_ref, argv_ref, env_ref);
+ /* PERL_SYS_INIT3((int *)NULL,(char ***)NULL,(char ***)NULL); */
+ my_perl = perl_alloc();
+ perl_construct(my_perl);
+ PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
+ perl_parse(my_perl, xs_init, 2, embedding, (char **)NULL);
+ /* perl_run(my_perl); */
+}
+
+void
+call_finish_perl (void)
+{
+ perl_destruct(my_perl);
+ perl_free(my_perl);
+ PERL_SYS_TERM();
+}
diff --git a/tp/Texinfo/XS/main/call_perl_function.h
b/tp/Texinfo/XS/main/call_perl_function.h
index 845aaf0f70..140eb332e8 100644
--- a/tp/Texinfo/XS/main/call_perl_function.h
+++ b/tp/Texinfo/XS/main/call_perl_function.h
@@ -20,4 +20,6 @@ const void *call_setup_collator (int use_unicode_collation,
BYTES_STRING *call_collator_getSortKey (const void *collator_sv,
const char *string);
+void call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref);
+void call_finish_perl (void);
#endif
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 33e20c806a..93a8a381ab 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -1,4 +1,4 @@
-/* teximakehtml.c -- simplistic conversion of Texinfo to HTML
+/* teximakehtml.c -- conversion of Texinfo to HTML
Copyright 2010-2024 Free Software Foundation, Inc.
@@ -15,6 +15,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* the program can be compiled standalone with all the required C code,
+ or use libraries with the required C code and also possibilities
+ to embed an interpreter, for now Perl and call Perl code.
+ */
+
#include <config.h>
#include <stdlib.h>
@@ -60,6 +65,10 @@
#include "converter.h"
#include "texinfo.h"
+#ifdef EMBED_PERL
+#include "call_perl_function.h"
+#endif
+
#define LOCALEDIR DATADIR "/locale"
#define _(String) gettext (String)
@@ -830,8 +839,10 @@ static const char *possible_split[] = {
"chapter", "section", "node", NULL
};
+/* we use env in case a Perl interpreter is embedded in order to blindly
+ follow the documentation in perlembed, which is not very explicit */
int
-main (int argc, char *argv[])
+main (int argc, char *argv[], char *env[])
{
int getopt_long_index;
const char *locale_encoding = 0;
@@ -873,6 +884,10 @@ main (int argc, char *argv[])
int do_menu = 0;
size_t format_menu_option_nr;
char *conversion_format_menu_default = 0;
+ /* used to have different parameterization with embedded interpreter and
+ without */
+ int use_external_translate_string = -1;
+ int embedded_interpreter = 0;
parse_file_path (argv[0], program_file_name_and_directory);
program_file = program_file_name_and_directory[0];
@@ -898,7 +913,14 @@ main (int argc, char *argv[])
free (top_builddir);
- txi_general_setup (1, 0, tp_builddir, top_srcdir);
+#ifdef EMBED_PERL
+ call_init_perl (&argc, &argv, &env);
+ embedded_interpreter = 1;
+ use_external_translate_string = 0;
+#endif
+
+ txi_general_setup (1, 0, tp_builddir, top_srcdir,
+ use_external_translate_string);
free (tp_builddir);
free (top_srcdir);
@@ -922,7 +944,7 @@ main (int argc, char *argv[])
/* program_options corresponds to main_program_set_options in texi2any */
txi_set_base_default_options (&program_options, locale_encoding,
- program_file);
+ program_file, embedded_interpreter);
/* set default output format. Is info in texi2any */
/* better than making it the default value independently of the
@@ -2105,6 +2127,10 @@ main (int argc, char *argv[])
destroy_strings_list (texinfo_language_config_dirs);
wipe_values (&values);
+#ifdef EMBED_PERL
+ call_finish_perl ();
+#endif
+
if (errors_count > 0)
exit (EXIT_FAILURE);
}
diff --git a/tp/load_txi_modules.pl b/tp/load_txi_modules.pl
new file mode 100755
index 0000000000..67bbd24a42
--- /dev/null
+++ b/tp/load_txi_modules.pl
@@ -0,0 +1,296 @@
+#! /usr/bin/env perl
+
+# load_txi_modules: Load Texinfo modules for embedding Perl.
+#
+# Copyright 2010-2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License,
+# or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Trimmed down texi2any.pl that is used to load the modules when
+# Perl code is only called from C and no Perl script is run.
+
+use 5.006;
+
+use strict;
+
+use warnings;
+
+# Through rules in Makefile.am, directory paths set through configure are
+# substituted directly in strings in the code, for example
+# my $datadir = '@datadir@';
+# We always use these strings as byte string, therefore we explicitly
+# set no utf8 to be sure that strings in code will never be considered as
+# character strings by Perl.
+no utf8;
+
+# check that autovivification do not happen incorrectly.
+#no autovivification qw(fetch delete exists store strict);
+
+# for file names portability
+use File::Spec;
+# for dirname and fileparse
+use File::Basename;
+
+my ($real_command_name, $command_directory, $command_suffix);
+
+# This big BEGIN block deals with finding modules and
+# some dependencies that we ship
+# * in source or
+# * installed or
+# * installed relative to the script
+BEGIN
+{
+ ($real_command_name, $command_directory, $command_suffix)
+ = fileparse($0, '.pl');
+ my $updir = File::Spec->updir();
+
+ # These are substituted by the Makefile to create "texi2any".
+ my $datadir = '@datadir@';
+ my $converter = '@CONVERTER@';
+ my $libdir = '@libdir@';
+ my $xsdir;
+
+ if ($datadir eq '@' .'datadir@'
+ or defined($ENV{'TEXINFO_DEV_SOURCE'})
+ and $ENV{'TEXINFO_DEV_SOURCE'} ne '0')
+ {
+ # Use uninstalled modules
+
+ # To find Texinfo::ModulePath
+ if (defined($ENV{'top_builddir'})) {
+ unshift @INC, join('/', ($ENV{'top_builddir'}, 'tp'));
+ } else {
+ unshift @INC, $command_directory;
+ }
+
+ require Texinfo::ModulePath;
+ Texinfo::ModulePath::init(undef, undef, undef, 'updirs' => 1);
+ } else {
+ # Look for modules in their installed locations.
+ my $modules_dir = join('/', ($datadir, $converter));
+ # look for package data in the installed location.
+ # actually the same as $converterdatadir in main program below, but use
+ # another name to avoid confusion.
+ my $modules_converterdatadir = $modules_dir;
+ $xsdir = join('/', ($libdir, $converter));
+
+ # try to make package relocatable, will only work if
+ # standard relative paths are used
+ if (! -f join('/', ($modules_dir, 'Texinfo', 'Parser.pm'))
+ and -f join('/', ($command_directory, $updir, 'share',
+ $converter, 'Texinfo', 'Parser.pm'))) {
+ $modules_dir = join('/', ($command_directory, $updir,
+ 'share', $converter));
+ $modules_converterdatadir
+ = join('/', ($command_directory, $updir,
+ 'share', $converter));
+ $xsdir = join('/', ($command_directory, $updir,
+ 'lib', $converter));
+ }
+
+ unshift @INC, $modules_dir;
+
+ require Texinfo::ModulePath;
+ Texinfo::ModulePath::init($modules_dir, $xsdir,
+ $modules_converterdatadir,
+ 'installed' => 1);
+ }
+} # end BEGIN
+
+# This allows disabling use of XS modules when Texinfo is built.
+BEGIN {
+ my $enable_xs = '@enable_xs@';
+ if ($enable_xs eq 'no') {
+ package Texinfo::XSLoader;
+ our $disable_XS;
+ $disable_XS = 1;
+ }
+}
+
+use Texinfo::XSLoader;
+
+use Locale::Messages;
+use Texinfo::Options;
+use Texinfo::Common;
+use Texinfo::Config;
+use Texinfo::Report;
+
+# Paths and file names
+#my $curdir = File::Spec->curdir();
+#my $updir = File::Spec->updir();
+
+# set by configure, prefix for the sysconfdir and so on
+# This could be used in the eval
+my $prefix = '@prefix@';
+my $datadir;
+my $datarootdir;
+my $sysconfdir;
+#my $pkgdatadir;
+my $converter;
+
+# the result is not good when using rootdir, maybe using a concatenation
+# of rootdir would be better.
+#my $fallback_prefix = join('/', (File::Spec->rootdir(), 'usr', 'local'));
+my $fallback_prefix = File::Spec->catdir(File::Spec->rootdir(), 'usr',
'local');
+
+# We need to eval as $prefix has to be expanded. However when we haven't
+# run configure @sysconfdir will be expanded as an array, thus we verify
+# whether configure was run or not
+if ('@sysconfdir@' ne '@' . 'sysconfdir@') {
+ $sysconfdir = eval '"@sysconfdir@"';
+} else {
+ $sysconfdir = "$fallback_prefix/etc";
+}
+
+if ('@datarootdir@' ne '@' . 'datarootdir@') {
+ $datarootdir = eval '"@datarootdir@"';
+} else {
+ $datarootdir = "$fallback_prefix/share";
+}
+
+if ('@datadir@' ne '@' . 'datadir@' and '@PACKAGE@' ne '@' . 'PACKAGE@') {
+ $datadir = eval '"@datadir@"';
+ my $package = '@PACKAGE@';
+ $converter = '@CONVERTER@';
+} else {
+ $datadir = "$fallback_prefix/share";
+ $converter = 'texi2any';
+}
+
+# initial setup of messages internalisation framework
+# work-around in case libintl-perl do not do it itself
+# see
http://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable
+
+if ((defined($ENV{"LC_ALL"}) and $ENV{"LC_ALL"} =~ /^(C|POSIX)$/)
+ or (defined($ENV{"LANG"}) and $ENV{"LANG"} =~ /^(C|POSIX)$/)) {
+ delete $ENV{"LANGUAGE"} if defined($ENV{"LANGUAGE"});
+}
+
+#my $messages_textdomain = 'texinfo';
+my $messages_textdomain = '@PACKAGE@';
+$messages_textdomain = 'texinfo' if ($messages_textdomain eq '@'.'PACKAGE@');
+my $strings_textdomain = '@PACKAGE@' . '_document';
+$strings_textdomain = 'texinfo_document'
+ if ($strings_textdomain eq '@'.'PACKAGE@' . '_document');
+
+# we want a reliable way to switch locale, so we don't use the system
+# gettext.
+Locale::Messages->select_package('gettext_pp');
+
+# Note: this uses installed messages even when the program is uninstalled
+Locale::Messages::bindtextdomain($messages_textdomain,
+ File::Spec->catdir($datadir, 'locale'));
+
+# Set initial configuration
+
+# Version setting is complicated, because we cope with
+# * script with configure values substituted or not
+# * script shipped as part of texinfo or as a standalone perl module
+# (although standalone module infrastructure was removed in 2019)
+
+# When the script could be shipped with perl modules independently from
+# the remaining of Texinfo, $hardcoded_version was set to undef here
+# by a sed one liner. The consequence is that configure.ac is not used
+# to retrieve the version number, version came from Texinfo::Common in that
+# case.
+# Otherwise this is only used as a safety value, and should never be used
+# in practice as a regexp extracts the version from configure.ac.
+my $hardcoded_version = "0.00-hardcoded";
+# Version set in configure.ac
+my $configured_version = '@PACKAGE_VERSION@';
+if ($configured_version eq '@' . 'PACKAGE_VERSION@') {
+ # if not configured, and $hardcoded_version is set search for the version
+ # in configure.ac
+ if (defined($hardcoded_version)) {
+ if (open(CONFIGURE,
+ "< ".File::Spec->catfile($Texinfo::ModulePath::top_srcdir,
+ 'configure.ac'))) {
+ while (<CONFIGURE>) {
+ if (/^AC_INIT\(\[[^\]]+\]\s*,\s*\[([^\]]+)\]\s*,/) {
+ $configured_version = "$1+dev"; # +dev to distinguish from installed
+ last;
+ }
+ }
+ close (CONFIGURE);
+ }
+ # This should never be used, but is a safety value
+ $configured_version = $hardcoded_version if
(!defined($configured_version));
+ } else {
+ # was used in the standalone perl module, as $hardcoded_version is undef
+ # and it should never be configured in that setup.
+ require Texinfo::Common;
+ $configured_version = $Texinfo::Common::VERSION;
+ }
+}
+
+# Compare the version of this file with the version of the modules
+# it is using. If they are different, don't go any further. This
+# can happen if multiple versions of texi2any are installed under a
+# different names, e.g. with the --program-suffix option to 'configure'.
+# The version in Common.pm is checked because that file has been present
+# since Texinfo 5.0 (the first release with texi2any in Perl).
+if ($configured_version ne $Texinfo::Common::VERSION
+ and $configured_version ne $Texinfo::Common::VERSION."+dev") {
+ warn "This is texi2any $configured_version but modules ".
+ "for texi2any $Texinfo::Common::VERSION found!\n";
+ die "Your installation of Texinfo is broken; aborting.\n";
+}
+
+my $configured_package = '@PACKAGE@';
+$configured_package = 'texinfo' if ($configured_package eq '@' . 'PACKAGE@');
+my $configured_name = '@PACKAGE_NAME@';
+$configured_name = 'GNU Texinfo'
+ if ($configured_name eq '@' .'PACKAGE_NAME@');
+my $configured_name_version = "$configured_name $configured_version";
+my $configured_url = '@PACKAGE_URL@';
+$configured_url = 'https://www.gnu.org/software/texinfo/'
+ if ($configured_url eq '@' .'PACKAGE_URL@');
+
+my $configured_information = {
+ 'PACKAGE_VERSION' => $configured_version,
+ 'PACKAGE' => $configured_package,
+ 'PACKAGE_NAME' => $configured_name,
+ 'PACKAGE_AND_VERSION' => $configured_name_version,
+ 'PACKAGE_URL' => $configured_url,
+};
+
+# set configure information as constants
+foreach my $configured_variable (keys(%$configured_information)) {
+ Texinfo::Common::set_build_constant($configured_variable,
+ $configured_information->{$configured_variable});
+ # set also with _CONFIG prepended, as in C code.
+ Texinfo::Common::set_build_constant($configured_variable.'_CONFIG',
+ $configured_information->{$configured_variable});
+}
+
+use Texinfo::Translations;
+use Texinfo::Document;
+use Texinfo::Convert::Utils;
+
+if ($Texinfo::ModulePath::texinfo_uninstalled) {
+ my $locales_dir = File::Spec->catdir($Texinfo::ModulePath::tp_builddir,
+ 'LocaleData');
+ if (-d $locales_dir) {
+ Texinfo::Translations::configure($locales_dir, $strings_textdomain);
+ } else {
+ warn "Locales dir for document strings not found\n";
+ }
+} else {
+ Texinfo::Translations::configure(File::Spec->catdir($datadir, 'locale'),
+ $strings_textdomain);
+}
+
+#use Texinfo::Convert::HTML;
+
+1;