bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gnulib-tool: new option --gnu-make


From: Paul Eggert
Subject: [PATCH] gnulib-tool: new option --gnu-make
Date: Sun, 12 Mar 2017 19:19:43 -0700

This is for applications like GNU Emacs that use GNU Make
features instead of Automake.
* doc/gnulib-tool.texi (Initial import): Mention --gnu-make.
* doc/gnulib.texi (Unit test modules, Build robot for gnulib):
Do not assume Automake.
* gnulib-tool (func_determine_path_separator)
(func_modules_transitive_closure, func_update_file)
(func_emit_lib_Makefile_am, func_emit_tests_Makefile_am)
(func_import): Add support for --gnu-make.
---
 ChangeLog            | 13 +++++++++
 doc/gnulib-tool.texi | 24 ++++++++-------
 doc/gnulib.texi      | 12 ++++----
 gnulib-tool          | 82 +++++++++++++++++++++++++++++++++++++++++++++-------
 4 files changed, 103 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d4b2bf6..3e79fcc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2017-03-12  Paul Eggert  <address@hidden>
+
+       gnulib-tool: new option --gnu-make
+       This is for applications like GNU Emacs that use GNU Make
+       features instead of Automake.
+       * doc/gnulib-tool.texi (Initial import): Mention --gnu-make.
+       * doc/gnulib.texi (Unit test modules, Build robot for gnulib):
+       Do not assume Automake.
+       * gnulib-tool (func_determine_path_separator)
+       (func_modules_transitive_closure, func_update_file)
+       (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am)
+       (func_import): Add support for --gnu-make.
+
 2017-03-11  Paul Eggert  <address@hidden>
 
        gnulib-common.m4: avoid aclocal.m4 bloat
diff --git a/doc/gnulib-tool.texi b/doc/gnulib-tool.texi
index 8ed06a2..2578fc8 100644
--- a/doc/gnulib-tool.texi
+++ b/doc/gnulib-tool.texi
@@ -84,11 +84,13 @@ module that contains this source file, you can use the 
command
 @cindex initial import
 
 Gnulib assumes that your project uses Autoconf.  When using Gnulib, you
-will need to have Autoconf and Automake among your build tools.  Note that
-while the use of Automake in your project's top level directory is an
-easy way to fulfil the Makefile conventions of the GNU coding standards,
-Gnulib does not require it.  But when you use Gnulib, Automake will be
-used at least in a subdirectory of your project.
+will need to have Autoconf among your build tools.
+
+Unless you use @command{gnulib-tool}'s @option{--gnu-make} option,
+Gnulib also assumes that your project uses Automake at least in a
+subdirectory of your project.  While the use of Automake in your
+project's top level directory is an easy way to fulfil the Makefile
+conventions of the GNU coding standards, Gnulib does not require it.
 
 Invoking @samp{gnulib-tool --import} will copy source files, create a
 @file{Makefile.am} to build them, generate a file @file{gnulib-comp.m4} with
@@ -244,7 +246,7 @@ gl_INIT
 
 @code{gl_INIT} will in turn call the macros related with the
 gnulib functions, be it specific gnulib macros, like @code{gl_FUNC_ALLOCA}
-or autoconf or automake macros like @code{AC_FUNC_ALLOCA} or
+or Autoconf or Automake macros like @code{AC_FUNC_ALLOCA} or
 @code{AM_FUNC_GETLINE}.  So there is no need to call those macros yourself
 when you use the corresponding gnulib modules.
 
@@ -564,7 +566,7 @@ invocation.
 @cindex autopoint, caveat
 The programs @code{gettextize} and @code{autopoint}, part of
 GNU @code{gettext}, import or update the internationalization infrastructure.
-Some of this infrastructure, namely ca.@: 20 autoconf macro files and the
+Some of this infrastructure, namely ca.@: 20 Autoconf macro files and the
 @file{config.rpath} file, is also contained in Gnulib and may be imported
 by @code{gnulib-tool}.  The use of @code{gettextize} or @code{autopoint}
 will therefore overwrite some of the files that @code{gnulib-tool} has
@@ -602,8 +604,8 @@ is done for you if you use gnulib's @file{bootstrap} 
script).
 If you get an error message like
 @code{*** error: gettext infrastructure mismatch:
 using a Makefile.in.in from gettext version ...
-but the autoconf macros are from gettext version ...},
-it means that a new GNU gettext release was made, and its autoconf macros
+but the Autoconf macros are from gettext version ...},
+it means that a new GNU gettext release was made, and its Autoconf macros
 were integrated into Gnulib and now mismatch the @file{po/} infrastructure.
 In this case, fetch and install the new GNU gettext release and run
 @code{gettextize} followed by @code{gnulib-tool}.
@@ -870,9 +872,9 @@ in this case.
 
 @cindex conditional dependencies
 In some cases, a module is needed by another module only on specific
-platforms.  But when a module is present, its autoconf checks are always
+platforms.  But when a module is present, its Autoconf checks are always
 executed, and its @code{Makefile.am} additions are always enabled.  So
-it can happen that some autoconf checks are executed and some source files
+it can happen that some Autoconf checks are executed and some source files
 are compiled, although no other module needs them on this particular
 platform, just @emph{in case} some other module would need them.
 
diff --git a/doc/gnulib.texi b/doc/gnulib.texi
index ddbac2f..b2defc0 100644
--- a/doc/gnulib.texi
+++ b/doc/gnulib.texi
@@ -589,10 +589,10 @@ check_PROGRAMS += test-foo
 
 Here, the @code{TESTS_ENVIRONMENT} variable can be used to pass values
 determined by @code{configure} or by the @code{Makefile} to the shell
-script, as environment variables.  The values of @code{EXEEXT} and of
address@hidden, from Autoconf and Automake, are already provided as
-environment variables, through an initial value of @code{TESTS_ENVIRONMENT}
-that @code{gnulib-tool} puts in place.
+script, as environment variables.  The Autoconf values @code{EXEEXT}
+and @code{srcdir} are already provided as environment variables,
+through an initial value of @code{TESTS_ENVIRONMENT} that
address@hidden puts in place.
 
 Regardless of the specific form of the unit test, the following guidelines
 should be respected:
@@ -1073,8 +1073,8 @@ your favorite platform, you may perform these steps:
 
 @item Create gnulib directory
 
-On a machine with recent automake, autoconf, m4 installed and with a
-gnulib git checkout (typically a Linux machine), use
+On a machine with GNU development tools installed and with a gnulib
+git checkout, use
 
 @example
 gnulib-tool --create-megatestdir --with-tests --dir=...
diff --git a/gnulib-tool b/gnulib-tool
index 8b3f61f..18b801e 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -264,14 +264,16 @@ Options for --import, --add/remove-import:
                             placed (default \"tests\").
       --aux-dir=DIRECTORY   Directory relative to --dir where auxiliary build
                             tools are placed (default comes from configure.ac).
+      --gnu-make            Output for GNU Make instead of for the default
+                            Automake
       --lgpl[=2|=3orGPLv2|=3]
                             Abort if modules aren't available under the LGPL.
                             Also modify license template from GPL to LGPL.
                             The version number of the LGPL can be specified;
                             the default is currently LGPLv3.
-      --makefile-name=NAME  Name of makefile in automake syntax in the
-                            source-base and tests-base directories
-                            (default \"Makefile.am\").
+      --makefile-name=NAME  Name of makefile in the source-base and tests-base
+                            directories (default \"Makefile.am\", or
+                            \"Makefile.in\" if --gnu-make).
       --macro-prefix=PREFIX  Specify the prefix of the macros 'gl_EARLY' and
                             'gl_INIT'. Default is 'gl'.
       --po-domain=NAME      Specify the prefix of the i18n domain. Usually use
@@ -1039,6 +1041,7 @@ func_determine_path_separator
 # - cond_dependencies  true if --conditional-dependencies was given, false if
 #                      --no-conditional-dependencies was given, blank otherwise
 # - lgpl            yes or a number if --lgpl was given, blank otherwise
+# - gnu_make        true if --gnu-make was given, false otherwise
 # - makefile_name   from --makefile-name
 # - libtool         true if --libtool was given, false if --no-libtool was
 #                   given, blank otherwise
@@ -1082,6 +1085,7 @@ func_determine_path_separator
   avoidlist=
   cond_dependencies=
   lgpl=
+  gnu_make=false
   makefile_name=
   libtool=
   macro_prefix=
@@ -1305,6 +1309,9 @@ func_determine_path_separator
         esac
         lgpl=$arg
         shift ;;
+      --gnu-make )
+        gnu_make=true
+        shift ;;
       --makefile-name )
         shift
         if test $# = 0; then
@@ -2780,6 +2787,7 @@ sed_dependencies_without_conditions='s/ *\[.*//'
 # func_modules_transitive_closure
 # Input:
 # - local_gnulib_path  from --local-dir
+# - gnu_make        true if --gnu-make was given, false otherwise
 # - modcache        true or false, from --cache-modules/--no-cache-modules
 # - modules         list of specified modules
 # - inctests        true if tests should be included, false otherwise
@@ -2846,7 +2854,9 @@ func_modules_transitive_closure ()
         if func_acceptable $module; then
           func_append outmodules " $module"
           if test "$cond_dependencies" = true; then
-            if func_get_automake_snippet_conditional $module | grep '^if ' > 
/dev/null; then
+            if ! $gnu_make \
+               && func_get_automake_snippet_conditional $module \
+                  | grep '^if ' > /dev/null; then
               # A module whose Makefile.am snippet contains a reference to an
               # automake conditional. If we were to use it conditionally, we
               # would get an error
@@ -3390,6 +3400,7 @@ func_update_file ()
 # - libname         library name
 # - pobase          directory relative to destdir where to place *.po files
 # - auxdir          directory relative to destdir where to place build aux 
files
+# - gnu_make        true if --gnu-make was given, false otherwise
 # - makefile_name   from --makefile-name
 # - libtool         true if libtool will be used, false or blank otherwise
 # - macro_prefix    prefix of gl_LIBOBJS macros to use
@@ -3407,9 +3418,10 @@ func_update_file ()
 # - uses_subdirs    nonempty if object files in subdirs exist
 func_emit_lib_Makefile_am ()
 {
-  # When creating an includable Makefile.am snippet, augment variables with
-  # += instead of assigning them.
-  if test -n "$makefile_name"; then
+
+  # When using GNU make, or when creating an includable Makefile.am snippet,
+  # augment variables with += instead of assigning them.
+  if $gnu_make || test -n "$makefile_name"; then
     assign='+='
   else
     assign='='
@@ -3474,20 +3486,33 @@ func_emit_lib_Makefile_am ()
         # Skip the contents if it's entirely empty.
         if grep '[^     ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; 
then
           echo "## begin gnulib module $module"
+          if $gnu_make; then
+            echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
+            convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
+          else
+            convert_to_gnu_make=
+          fi
           echo
           if test "$cond_dependencies" = true; then
             if func_cond_module_p "$module"; then
               func_module_conditional_name "$module"
-              echo "if $conditional"
+              if $gnu_make; then
+                echo "ifneq (,\$($conditional))"
+              else
+                echo "if $conditional"
+              fi
             fi
           fi
-          cat "$tmp"/amsnippet1
+          sed "$convert_to_gnu_make" "$tmp"/amsnippet1
           if test "$cond_dependencies" = true; then
             if func_cond_module_p "$module"; then
               echo "endif"
             fi
           fi
-          cat "$tmp"/amsnippet2
+          sed "$convert_to_gnu_make" "$tmp"/amsnippet2
+          if $gnu_make; then
+            echo "endif"
+          fi
           echo "## end   gnulib module $module"
           echo
         fi
@@ -3539,6 +3564,15 @@ func_emit_lib_Makefile_am ()
     echo "DISTCLEANFILES ="
     echo "MAINTAINERCLEANFILES ="
   fi
+  if $gnu_make; then
+    echo "# Start of GNU Make output."
+    echo 'gl_EARLY;gl_INIT' \
+      | ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
+      | LC_ALL=C sort -u
+    echo "# End of GNU Make output."
+  else
+    echo "# No GNU Make output."
+  fi
   # Execute edits that apply to the Makefile.am being generated.
   edit=0
   while test $edit != $makefile_am_edits; do
@@ -3616,6 +3650,25 @@ func_emit_lib_Makefile_am ()
   fi
   cat "$tmp"/allsnippets \
     | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
+  # Determine variables the automake snippet mentions.
+  if false && $gnu_make; then
+    sed_get_makefile_vars='
+      :again
+      /@/!d
+      s/address@hidden@//
+      h
+      /^[a-zA-Z_][a-zA-Z_0-9]*@/{
+        s/@.*//p
+        g
+        s/address@hidden@//
+        h
+      }
+      g
+      b again
+    '
+    substs=`func_get_automake_snippet "$module" \
+            | LC_ALL=C sed -e "$sed_get_makefile_vars"`
+  fi
   echo
   echo "mostlyclean-local: mostlyclean-generic"
   echo "       @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
@@ -3713,6 +3766,7 @@ func_emit_po_POTFILES_in ()
 # - modules         list of modules, including dependencies
 # - libname         library name
 # - auxdir          directory relative to destdir where to place build aux 
files
+# - gnu_make        true if --gnu-make was given, false otherwise
 # - makefile_name   from --makefile-name
 # - libtool         true if libtool will be used, false or blank otherwise
 # - sourcebase      relative directory containing lib source code
@@ -3794,8 +3848,14 @@ func_emit_tests_Makefile_am ()
             fi
           done
           { echo "## begin gnulib module $module"
+            if $gnu_make; then
+              echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
+            fi
             echo
             cat "$tmp"/amsnippet
+            if $gnu_make; then
+              echo "endif"
+            fi
             echo "## end   gnulib module $module"
             echo
           } >&$ofd
@@ -5471,7 +5531,7 @@ s,//*$,/,'
 
     func_emit_pre_early_macros : '  ' "$final_modules"
 
-    if test -n "$uses_subdirs"; then
+    if ! $gnu_make && test -n "$uses_subdirs"; then
       echo "  AC_REQUIRE([AM_PROG_CC_C_O])"
     fi
     for module in $final_modules; do
-- 
2.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]