On 11/27/2016 07:52 AM, John W. Eaton wrote:
On 10/22/2016 03:04 PM, Bruno Haible wrote:
The idea would be to have gnulib-tool emit the correct code for the
{Bison,coreutils,Octave} case right away, triggered by some command line
option.
If you want to help us here, please use the *current* gnulib-tool to
generate Makefile.am files. Then hand-edit these Makefile.am files with
a minimum of changes, so that they work in a non-recursive build
(possibly
based on what prefix-gnulib-mk would produce). Then send us these files
(both the original and the edited Makefile.am) files, so that we can see
how gnulib-tool should be modified.
I did that for Octave and the resulting files are attached.
I also started working on a change to replace the
non-recursive-gnulib-prefix-hack module with a --non-recursive-makefile
option for gnulib-tool. My initial attempt is attached. It gets part
of the way there, but I am stuck trying to figure out what to do about
the Makefile.am snippets that appear in module files. I'm not sure
exactly where the file names in lines like
lib_SOURCES += xsize.c xsize.h
should be prefixed with the $sourcebase directory name or exactly how to
handle the rules that might be included there. For example, I think
things like
# We need the following in order to create <errno.h> when the system
# doesn't have one that is POSIX compliant.
if GL_GENERATE_ERRNO_H
errno.h: errno.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
[...] \
< $(srcdir)/errno.in.h; \
} > $@-t && \
mv $@-t $@
else
errno.h: $(top_builddir)/config.status
rm -f $@
endif
from modules/errno will need to have $(sourcebase) included in a few key
spots:
# We need the following in order to create <errno.h> when the system
# doesn't have one that is POSIX compliant.
if GL_GENERATE_ERRNO_H
SOURCEBASE/errno.h: SOURCEBASE/errno.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|${gl_include_guard_prefix}|g' \
[...] \
< $(srcdir)/SOURCEBASE/errno.in.h; \
} > $@-t && \
mv $@-t $@
else
SOURCEBASE/errno.h: $(top_builddir)/config.status
rm -f $@
endif
I'm willing to continue working on this and/or testing with Octave but I
will need a bit of guidance for how best to proceed.
Thanks,
jwe
diff --git a/gnulib-tool b/gnulib-tool
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -253,6 +253,7 @@ Options for --import, --add/remove-impor
--source-base=DIRECTORY
Directory relative to --dir where source code is
placed (default \"lib\").
+ --non-recursive-makefile Generate non-recursive makefile.
--m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
placed (default \"m4\").
--po-base=DIRECTORY Directory relative to --dir where *.po files are
@@ -1011,6 +1012,7 @@ func_determine_path_separator
# - verbose integer, default 0, inc/decremented by --verbose/--quiet
# - libname, supplied_libname from --lib
# - sourcebase from --source-base
+# - non_recursive from --non-recursive-makefile
# - m4base from --m4-base
# - pobase from --po-base
# - docbase from --doc-base
@@ -1062,6 +1064,8 @@ func_determine_path_separator
libname=libgnu
supplied_libname=
sourcebase=
+ non_recursive=false
+ lt_prefix=
m4base=
pobase=
docbase=
@@ -1185,6 +1189,9 @@ func_determine_path_separator
fi
sourcebase=$1
shift ;;
+ --non-recursive-makefile )
+ non_recursive=true
+ shift ;;
--source-base=* )
sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
shift ;;
@@ -2421,6 +2428,9 @@ func_get_automake_snippet_unconditional
echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
extra_files=`for f in $already_mentioned_files; do echo $f; done \
| LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
+ if $non_recursive; then
+ extra_files=`for f in $extra_files; do echo $sourcebase/$f; done`
+ fi
if test -n "$extra_files"; then
echo "EXTRA_DIST +=" $extra_files
echo
@@ -3423,6 +3433,17 @@ func_emit_lib_Makefile_am ()
perhapsLT=
sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
fi
+ lt_prefix="${libname}_${libext}_"
+ if $non_recursive; then
+ lt_prefix_tmp="`echo "$sourcebase" | LC_ALL=C sed -e
's/[^a-zA-Z0-9_]/_/g'`"
+ case "$lt_prefix_tmp" in
+ *_) ;;
+ *)
+ lt_prefix_tmp="${lt_prefix_tmp}_"
+ ;;
+ esac
+ lt_prefix="$lt_prefix_tmp$lt_prefix"
+ fi
if $for_test; then
# When creating a package for testing: Attempt to provoke failures,
# especially link errors, already during "make" rather than during
@@ -3457,19 +3478,19 @@ func_emit_lib_Makefile_am ()
sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
-e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
-e "$sed_eliminate_LDFLAGS" \
- -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
+ -e 's,lib_\([A-Z][A-Z]*\),'"${lt_prefix}"'\1,g' \
-e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
-e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
-e "$sed_transform_check_PROGRAMS" \
-e "$sed_replace_include_guard_prefix"
if test "$module" = 'alloca'; then
- echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
- echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
+ echo "${lt_prefix}LIBADD += @${perhapsLT}ALLOCA@"
+ echo "${lt_prefix}DEPENDENCIES += @${perhapsLT}ALLOCA@"
fi
- } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
+ } | combine_lines "${lt_prefix}SOURCES" > "$tmp"/amsnippet1
{
func_get_automake_snippet_unconditional "$module" |
- LC_ALL=C sed -e
's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
+ LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${lt_prefix}"'\1,g'
} > "$tmp"/amsnippet2
# Skip the contents if it's entirely empty.
if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ;
then
@@ -3511,33 +3532,43 @@ func_emit_lib_Makefile_am ()
if test -n "$uses_subdirs"; then
subdir_options=' subdir-objects'
fi
- echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
+ if ! $non_recursive; then
+ echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
+ fi
fi
echo
if test -z "$makefile_name"; then
- echo "SUBDIRS ="
- echo "noinst_HEADERS ="
- echo "noinst_LIBRARIES ="
- echo "noinst_LTLIBRARIES ="
- # Automake versions < 1.11.4 create an empty pkgdatadir at
- # installation time if you specify pkgdata_DATA to empty.
- # See automake bugs #10997 and #11030:
- # * http://debbugs.gnu.org/10997
- # * http://debbugs.gnu.org/11030
- # So we need this workaround.
- if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
- echo "pkgdata_DATA ="
+ if ! $non_recursive; then
+ echo "SUBDIRS ="
+ echo "noinst_HEADERS ="
+ echo "noinst_LIBRARIES ="
+ echo "noinst_LTLIBRARIES ="
+ # Automake versions < 1.11.4 create an empty pkgdatadir at
+ # installation time if you specify pkgdata_DATA to empty.
+ # See automake bugs #10997 and #11030:
+ # * http://debbugs.gnu.org/10997
+ # * http://debbugs.gnu.org/11030
+ # So we need this workaround.
+ if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
+ echo "pkgdata_DATA ="
+ fi
+ echo "EXTRA_DIST ="
+ echo "BUILT_SOURCES ="
+ echo "SUFFIXES ="
fi
- echo "EXTRA_DIST ="
- echo "BUILT_SOURCES ="
- echo "SUFFIXES ="
fi
- echo "MOSTLYCLEANFILES $assign core *.stackdump"
+ if $non_recursive; then
+ echo "MOSTLYCLEANFILES $assign core *.stackdump"
+ else
+ echo "MOSTLYCLEANFILES $assign ${sourcebase}core ${sourcebase}*.stackdump"
+ fi
if test -z "$makefile_name"; then
- echo "MOSTLYCLEANDIRS ="
- echo "CLEANFILES ="
- echo "DISTCLEANFILES ="
- echo "MAINTAINERCLEANFILES ="
+ if ! $non_recursive; then
+ echo "MOSTLYCLEANDIRS ="
+ echo "CLEANFILES ="
+ echo "DISTCLEANFILES ="
+ echo "MAINTAINERCLEANFILES ="
+ fi
fi
# Execute edits that apply to the Makefile.am being generated.
edit=0
@@ -3565,12 +3596,19 @@ func_emit_lib_Makefile_am ()
fi
if test -z "$makefile_name"; then
echo
- echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
- echo "AM_CFLAGS ="
+ if $non_recursive; then
+ echo "${lt_prefix}CPPFLAGS = -I$sourcebase -I\$(srcdir)/$sourcebase"
+ echo "${lt_prefix}CFLAGS ="
+ else
+ echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
+ echo "AM_CFLAGS ="
+ fi
else
if test -n "$cppflags_part1$cppflags_part2"; then
echo
- echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
+ if ! $non_recursive; then
+ echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
+ fi
fi
fi
echo
@@ -3584,20 +3622,24 @@ func_emit_lib_Makefile_am ()
# it should not be installed.
:
else
- # By default, the generated library should not be installed.
- echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
+ # By default, the generated library should not be installed.
+ if $non_recursive; then
+ echo "noinst_${perhapsLT}LIBRARIES += $sourcebase/$libname.$libext"
+ else
+ echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
+ fi
fi
echo
- echo "${libname}_${libext}_SOURCES ="
+ echo "${lt_prefix}SOURCES ="
# Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
# automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
- echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
- echo "${libname}_${libext}_DEPENDENCIES =
\$(${macro_prefix}_${perhapsLT}LIBOBJS)"
- echo "EXTRA_${libname}_${libext}_SOURCES ="
+ echo "${lt_prefix}LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
+ echo "${lt_prefix}DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
+ echo "EXTRA_${lt_prefix}SOURCES ="
if test "$libtool" = true; then
- echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
- echo "${libname}_${libext}_LDFLAGS += -no-undefined"
- # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
+ echo "${lt_prefix}LDFLAGS = \$(AM_LDFLAGS)"
+ echo "${lt_prefix}LDFLAGS += -no-undefined"
+ # Synthesize an ${lt_prefix}LDFLAGS augmentation by combining
# the link dependencies of all modules.
for module in $modules; do
func_verify_nontests_module
@@ -3607,7 +3649,7 @@ func_emit_lib_Makefile_am ()
done \
| LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
| LC_ALL=C sort -u \
- | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
+ | LC_ALL=C sed -e 's/^/'"${lt_prefix}"'LDFLAGS += /'
fi
echo
if test -n "$pobase"; then
@@ -3617,7 +3659,7 @@ func_emit_lib_Makefile_am ()
cat "$tmp"/allsnippets \
| sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
echo
- echo "mostlyclean-local: mostlyclean-generic"
+ echo "libgnu-mostlyclean-local: mostlyclean-generic"
echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
@@ -5818,12 +5860,11 @@ func_create_testdir ()
if test -z "$modules"; then
# All modules together.
# Except config-h, which breaks all modules which use HAVE_CONFIG_H.
- # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
# way of using Automake.
# Except ftruncate, mountlist, which abort the configuration on mingw.
FIXME.
# Except lib-ignore, which leads to link errors when Sun C++ is used.
FIXME.
modules=`func_all_modules`
- modules=`for m in $modules; do case $m in config-h |
non-recursive-gnulib-prefix-hack | ftruncate | mountlist | lib-ignore) ;; *)
echo $m;; esac; done`
+ modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist
| lib-ignore) ;; *) echo $m;; esac; done`
fi
specified_modules="$modules"