On Friday 15 of August 2014 10:45:02 Pavel Raiskup wrote: > On Saturday 14 of June 2014 19:15:51 Pavel Raiskup wrote: > > On Thursday 29 of May 2014 17:29:30 Pavel Raiskup wrote: > > > On Tuesday 27 of May 2014 08:58:22 Pavel Raiskup wrote: > > > > On Monday 26 of May 2014 21:14:23 Eric Blake wrote: > > > > > That said, I'll probably apply this once I know more about why it is > > > > > needed. > > > > > > > > Please don't, the patch is not correct. I'll repost better one. When > > > > man pages are generated by help2man, the man page target should not be > > > > dependant on generated binary (when help2man is also not distributed, > > > > which is IMO bad idea in principle). > > > > > > Sorry for the delay. I tried to fix yet another problem blocking me from > > > building that in Copr [1]. > > > > > > Patch 0000: > > > [..snip..] > > > Patch 0001 enables module loading and file inclusions on my machine (and > > > [..snip..] > > > > Ping? > > Gently pinging again :).
Ping again? :) Patches rebased against current master and attached. Pavel
testsuite.log.xz
Description: application/xz
>From b71abd96ff586c6316f6f38041afa73824f52c60 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup <[email protected]> Date: Fri, 21 Nov 2014 09:32:49 +0100 Subject: [PATCH 1/2] build: fix bootstrap fail Moving the 'doc' related Makefile targets into doc/Makefile.am to avoid building manual page before the m4 binary itself (suggested by automake.info). Also use LT_LIB_DLLOAD macro to perform proper check for dynamic loading API. References: a43fd66dc18 (revert) * Makefile.am (SUBDIRS): Add doc subdir. (m4_libm4_la_LIBADD): Remove redundant $(LIBADD_DL). * Makefile.am. Move to docs-related rules to .. * doc/Makefile.am: .. here. * configure.ac (LT_LIB_DLLOAD): Added, needed for linking dlopen(), dlerror() and dlsym(). --- Makefile.am | 24 ++---------------------- configure.ac | 4 ++++ doc/Makefile.am | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 doc/Makefile.am diff --git a/Makefile.am b/Makefile.am index 86aada4..9f4b2b9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,10 +20,9 @@ ## ## Written by Gary V. Vaughan <[email protected]> -config_aux_dir = build-aux config_macro_dir= $(config_aux_dir)/m4 -SUBDIRS = po m4/gnu . tests/gnu +SUBDIRS = po m4/gnu . doc tests/gnu ACLOCAL_AMFLAGS = -I build-aux/m4 AUTOMAKE_OPTIONS = nostdinc @@ -246,7 +245,7 @@ m4_libm4_la_SOURCES = \ m4/syntax.c \ m4/utility.c m4_libm4_la_LIBADD = m4/gnu/libgnu.la \ - $(LIBLTDL) $(LTLIBINTL) $(LIBADD_DL) + $(LIBLTDL) $(LTLIBINTL) m4_libm4_la_DEPENDENCIES = $(LTDLDEPS) m4/gnu/libgnu.la # This file needs to be regenerated at configure time. @@ -255,25 +254,6 @@ dist-hook: EXTRA_DIST += m4/system_.h -## -------------- ## -## Documentation. ## -## -------------- ## - -info_TEXINFOS = doc/m4.texi -m4_TEXINFOS = doc/regexprops-generic.texi doc/fdl-1.3.texi doc/gpl-3.0.texi -dist_man_MANS = $(srcdir)/doc/m4.1 -EXTRA_DIST += doc/gendocs_template -MAINTAINERCLEANFILES += doc/gendocs_template -HELP2MAN = $(SHELL) $(top_srcdir)/$(config_aux_dir)/missing --run help2man - -# Build the man page once in the srcdir, rather than in every VPATH build -# dir, to match how automake builds info pages. This is safe for 'make -# distcheck' since it is distributed pre-built. -$(srcdir)/doc/m4.1: .version $(srcdir)/src/main.c - @echo "Updating the \`man' page \`$@'"; \ - $(HELP2MAN) --name="macro processor" --source=FSF \ - --info-page=m4 --output=$@ src/m4$(EXEEXT) - TAGS_FILES = $(infos_TEXINFOS) TAGS_DEPENDENCIES = $(TAGS_FILES) ETAGS_ARGS = --language=none --regex='/@node \([^,]*\)/\1/' $(TAGS_FILES) diff --git a/configure.ac b/configure.ac index 3f81671..bfa017f 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,7 @@ M4_CHECK_DEBUGGING ## ----------------------- ## LT_PREREQ([2.2]) LT_INIT([shared dlopen win32-dll]) +LT_LIB_DLLOAD AC_ARG_ENABLE([gcc-warnings], [AS_HELP_STRING([--enable-gcc-warnings], @@ -95,6 +96,8 @@ AC_ARG_ENABLE([gcc-warnings], [gl_gcc_warnings=no] ) +AC_SUBST([config_aux_dir], [build-aux]) + if test "$gl_gcc_warnings" = yes; then gl_WARN_ADD([-Werror], [WERROR_CFLAGS]) AC_SUBST([WERROR_CFLAGS]) @@ -290,6 +293,7 @@ M4_SYSCMD ## -------- ## AC_CONFIG_FILES([ Makefile +doc/Makefile m4/gnu/Makefile m4/system.h:m4/system_.h tests/atlocal diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..614a91a --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,35 @@ +## Makefile.am - template for generating Makefile via Automake +## +## Copyright (C) 2014 Free Software Foundation, Inc. +## +## This file is part of GNU M4. +## +## GNU M4 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. +## +## GNU M4 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/>. +## +## Written by Gary V. Vaughan <[email protected]> + +info_TEXINFOS = m4.texi +m4_TEXINFOS = regexprops-generic.texi fdl-1.3.texi gpl-3.0.texi +dist_man_MANS = m4.1 +EXTRA_DIST = gendocs_template +MAINTAINERCLEANFILES = gendocs_template +HELP2MAN = $(SHELL) $(top_srcdir)/$(config_aux_dir)/missing --run help2man + +# Build the man page once in the srcdir, rather than in every VPATH build +# dir, to match how automake builds info pages. This is safe for 'make +# distcheck' since it is distributed pre-built. +m4.1: $(top_srcdir)/.version $(top_srcdir)/src/main.c + @echo "Updating the \`man' page \`$@'"; \ + $(HELP2MAN) --name="macro processor" --source=FSF \ + --info-page=m4 --output=$@ $(top_srcdir)/src/m4$(EXEEXT) -- 1.9.3
>From a0b22b1670fcfaca39976fec38101bd231f6cd01 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup <[email protected]> Date: Wed, 28 May 2014 12:25:52 +0200 Subject: [PATCH 2/2] modules,inclusions: fix path searching issues When 'm4' directory occurred in M4PATH or current directory, the m4 processor ended up with message 'Is a directory' and did not continue to search for 'm4.so' somewhere else in path. Expanding 'include(Makefile)' for example failed when M4PATH was set because the current directory was not searched. * m4/path.c (try_prefixes): New function. (m4_path_search): Deduplicate suffix trying by try_prefixes. (m4__include_init): Always prepend current directory. * tests/testsuite.at (AT_CHECK_M4): Filter out test output dependant on user's setup. * tests/options.at: Adjust expected stderr output. * doc/m4.texi: likewise. --- doc/m4.texi | 2 + m4/path.c | 111 +++++++++++++++++++++++++++-------------------------- tests/options.at | 6 ++- tests/testsuite.at | 1 + 4 files changed, 64 insertions(+), 56 deletions(-) diff --git a/doc/m4.texi b/doc/m4.texi index e09f3c4..e938a30 100644 --- a/doc/m4.texi +++ b/doc/m4.texi @@ -4683,6 +4683,8 @@ @comment options: -dip @example $ @kbd{m4 -dip -I doc/examples} +@error{}m4debug: path search for 'm4' found 'm4.so' +@error{}m4debug: path search for 'gnu' found 'gnu.so' @error{}m4debug: input read from 'stdin' define(`foo', `m4wrap(`wrapped text ')dnl') diff --git a/m4/path.c b/m4/path.c index 281795e..fb7084d 100644 --- a/m4/path.c +++ b/m4/path.c @@ -144,6 +144,53 @@ m4_add_include_directory (m4 *context, const char *dir, bool prepend) #endif } +/* FILENAME must contain directory path also */ +static char * +try_prefixes (m4 *context, const char *dirname, const char *filename, + size_t max_suffix_len, const char **suffixes) +{ + int e = 0, i; + char *filepath = dirname ? file_name_concat (dirname, filename, NULL) + : strdup (filename); + size_t mem = strlen (filepath); + filepath = xrealloc (filepath, mem + max_suffix_len + 1); + + /* Try appending each of the suffixes we were given. */ +#ifdef DEBUG_INCL + xfprintf (stderr, "path_search (%s) -- trying %s\n", filename, filepath); +#endif + + + /* If search fails, we'll use the error we got from the first try + access (usually with no suffix). */ + for (i = 0; suffixes && suffixes[i]; !i && (e = errno), ++i) + { + struct stat st; + int rc; + strcpy (filepath + mem, suffixes[i]); + + if (stat (filepath, &st)) + continue; + + if (S_ISREG (st.st_mode)) + { + m4_debug_message (context, M4_DEBUG_TRACE_PATH, + _("path search for %s found %s"), + quotearg_style (locale_quoting_style, filename), + quotearg_n_style (1, locale_quoting_style, + filepath)); + return filepath; + } + if (S_ISDIR (st.st_mode)) + errno = EISDIR; + } + free (filepath); + + /* No such file. */ + errno = e; + return NULL; +} + /* Search for FILENAME according to -B options, `.', -I options, then M4PATH environment. If successful, return the open file, and if @@ -182,61 +229,18 @@ m4_path_search (m4 *context, const char *filename, const char **suffixes) /* If file is absolute, or if we are not searching a path, a single lookup will do the trick. */ if (IS_ABSOLUTE_FILE_NAME (filename)) - { - size_t mem = strlen (filename); - - /* Try appending each of the suffixes we were given. */ - filepath = strncpy (xmalloc (mem + max_suffix_len +1), filename, mem); - for (i = 0; suffixes && suffixes[i]; ++i) - { - strcpy (filepath + mem, suffixes[i]); - if (access (filepath, R_OK) == 0) - return filepath; - - /* If search fails, we'll use the error we got from the first - access (usually with no suffix). */ - if (i == 0) - e = errno; - } - free (filepath); - - /* No such file. */ - errno = e; - return NULL; - } + return try_prefixes (context, NULL, filename, max_suffix_len, suffixes); - for (incl = m4__get_search_path (context)->list; - incl != NULL; incl = incl->next) + for (incl = m4__get_search_path (context)->list, i = 0; + incl != NULL; incl = incl->next, ++i) { - char *pathname = file_name_concat (incl->dir, filename, NULL); - size_t mem = strlen (pathname); - -#ifdef DEBUG_INCL - xfprintf (stderr, "path_search (%s) -- trying %s\n", filename, pathname); -#endif - - if (access (pathname, R_OK) == 0) - { - m4_debug_message (context, M4_DEBUG_TRACE_PATH, - _("path search for %s found %s"), - quotearg_style (locale_quoting_style, filename), - quotearg_n_style (1, locale_quoting_style, pathname)); - return pathname; - } - else if (!incl->len) - /* Capture errno only when searching `.'. */ - e = errno; - - filepath = strncpy (xmalloc (mem + max_suffix_len +1), pathname, mem); - free (pathname); + char *pathname = try_prefixes (context, incl->dir, filename, + max_suffix_len, suffixes); + if (pathname) + return pathname; - for (i = 0; suffixes && suffixes[i]; ++i) - { - strcpy (filepath + mem, suffixes[i]); - if (access (filepath, R_OK) == 0) - return filepath; - } - free (filepath); + if (i == 0) + e = errno; } errno = e; @@ -337,8 +341,7 @@ m4__include_init (m4 *context) /* If M4PATH was not set, then search just the current directory by default. */ assert (info); - if (info->list_end == NULL) - search_path_add (info, "", false); + search_path_add (info, "", true); /* Non-core modules installation directory. */ search_path_add (info, PKGLIBDIR, false); diff --git a/tests/options.at b/tests/options.at index 7084207..8fa19b6 100644 --- a/tests/options.at +++ b/tests/options.at @@ -423,10 +423,12 @@ m4debug: input from m4wrap exhausted dnl Test all flags. AT_CHECK_M4([-dV in], [0], [[3 0 -]], [[m4debug: module m4: opening file +]], [[m4debug: path search for 'm4' found 'm4.so' +m4debug: module m4: opening file m4debug: module m4: init hook called m4debug: module m4: opened m4debug: module m4: builtins loaded +m4debug: path search for 'gnu' found 'gnu.so' m4debug: module gnu: opening file m4debug: module gnu: init hook called m4debug: module gnu: opened @@ -701,7 +703,7 @@ AT_CHECK_M4([-I post -B pre in], [1], [[in pre/foo in ./bar in post/blah -]], [[m4:in:3: include: cannot open file 'bad': No such file or directory +]], [[m4:in:3: include: cannot open file 'bad': Too many levels of symbolic links ]]) AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index aad7f0d..5778c8d 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -89,6 +89,7 @@ m4_case([$4], [], [], [ignore], [], /^m4debug: module/s/opening file.*/opening file/ s/\(cannot open module [^:]*\):.*/\1/ s/Bad file number/Bad file descriptor/ + s|search for \([^ ]*\) found '\''.*\/\([^\.]*\.so\)|search for \1 found '\''\2| s/^m4:.* option .*/m4: bad option/ ' stderr >&2]], [0], [], [$4])]) ]) -- 1.9.3
_______________________________________________ M4-patches mailing list [email protected] https://lists.gnu.org/mailman/listinfo/m4-patches
