]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 27.
authorCollin Funk <collin.funk1@gmail.com>
Fri, 23 Feb 2024 04:16:18 +0000 (20:16 -0800)
committerBruno Haible <bruno@clisp.org>
Fri, 23 Feb 2024 12:55:23 +0000 (13:55 +0100)
Follow gnulib-tool changes
2017-03-12  Paul Eggert  <eggert@cs.ucla.edu>
gnulib-tool: new option --gnu-make
2017-03-13  Paul Eggert  <eggert@cs.ucla.edu>
gnulib-tool: minor --gnu-make fixups
2017-03-14  Paul Eggert  <eggert@cs.ucla.edu>
gnulib-tool: fix typo in comment output
2017-05-14  Paul Eggert  <eggert@cs.ucla.edu>
gnulib-tool: improve GNU Make debugging
2018-07-04  Paul Eggert  <eggert@cs.ucla.edu>
gnulib-tool: minor tweaks for --gnu-make

* gnulib-tool.py (main): Add --gnu-make option. Do not allow --gnu-make
in test modes, since they all require Automake.
* pygnulib/GLConfig.py: Add gnu_make argument to constructor.
(getGnuMake, setGnuMake, resetGnuMake): New methods for accessing the
gnu_make instance variable.
* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Use the "+=" operator
with GNU Make and Automake. Transform conditionals to GNU Make syntax if
--gnu-make is in use. Use a Autoconf subprocess to define values and
check the return code for errors.
(GLEmiter.tests_Makefile_am): Likewise.
* pygnulib/GLImport.py (GLImport.actioncmd): Add "--gnu-make" to the
output comment if it is in use.
(GLImport.gnulib_comp): Don't require "AM_PROG_CC_C_O" when using GNU
Make.
* pygnulib/GLInfo.py (GLInfo.usage): Update help message to reflect
addition of --gnu-make.
* pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure): Don't
add Automake snippets as unconditional dependencies when using
--gnu-make.

ChangeLog
gnulib-tool.py
gnulib-tool.py.TODO
pygnulib/GLConfig.py
pygnulib/GLEmiter.py
pygnulib/GLImport.py
pygnulib/GLInfo.py
pygnulib/GLModuleSystem.py

index 1049bc0a91648fe477e949d9151b207987b75ed3..ec1e23d62f4e4641776ea344f79fc19c72869fe3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2024-02-23  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 27.
+       Follow gnulib-tool changes
+       2017-03-12  Paul Eggert  <eggert@cs.ucla.edu>
+       gnulib-tool: new option --gnu-make
+       2017-03-13  Paul Eggert  <eggert@cs.ucla.edu>
+       gnulib-tool: minor --gnu-make fixups
+       2017-03-14  Paul Eggert  <eggert@cs.ucla.edu>
+       gnulib-tool: fix typo in comment output
+       2017-05-14  Paul Eggert  <eggert@cs.ucla.edu>
+       gnulib-tool: improve GNU Make debugging
+       2018-07-04  Paul Eggert  <eggert@cs.ucla.edu>
+       gnulib-tool: minor tweaks for --gnu-make
+       * gnulib-tool.py (main): Add --gnu-make option. Do not allow --gnu-make
+       in test modes, since they all require Automake.
+       * pygnulib/GLConfig.py: Add gnu_make argument to constructor.
+       (getGnuMake, setGnuMake, resetGnuMake): New methods for accessing the
+       gnu_make instance variable.
+       * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Use the "+=" operator
+       with GNU Make and Automake. Transform conditionals to GNU Make syntax if
+       --gnu-make is in use. Use a Autoconf subprocess to define values and
+       check the return code for errors.
+       (GLEmiter.tests_Makefile_am): Likewise.
+       * pygnulib/GLImport.py (GLImport.actioncmd): Add "--gnu-make" to the
+       output comment if it is in use.
+       (GLImport.gnulib_comp): Don't require "AM_PROG_CC_C_O" when using GNU
+       Make.
+       * pygnulib/GLInfo.py (GLInfo.usage): Update help message to reflect
+       addition of --gnu-make.
+       * pygnulib/GLModuleSystem.py (GLModuleTable.transitive_closure): Don't
+       add Automake snippets as unconditional dependencies when using
+       --gnu-make.
+
 2024-02-23  Bruno Haible  <bruno@clisp.org>
 
        unistdio/*printf tests: Update expected test results regarding %n.
index 876a16ca9f6a26593489489779c71df5026f186b..599dbe098481d0f337b8cbefb658448ade5f7131 100755 (executable)
@@ -358,6 +358,11 @@ def main():
                         action='append',
                         choices=['2', '3orGPLv2', '3'],
                         nargs='?')
+    # gnu-make
+    parser.add_argument('--gnu-make',
+                        dest='gnu_make',
+                        default=None,
+                        action='store_true')
     # makefile-name
     parser.add_argument('--makefile-name',
                         dest='makefile_name',
@@ -602,6 +607,10 @@ def main():
     if cmdargs.pobase == None and cmdargs.podomain != None:
         message = '%s: warning: --po-domain has no effect without a --po-base option\n' % constants.APP['name']
         sys.stderr.write(message)
+    if modules != None and "tests" in mode and gnu_make:
+        message = '%s: --gnu-make not supported when including tests\n' % constants.APP['name']
+        sys.stderr.write(message)
+        sys.exit(1)
 
     # Determine specific settings.
     destdir = cmdargs.destdir
@@ -670,6 +679,7 @@ def main():
             lgpl = True
     cond_dependencies = cmdargs.cond_dependencies
     libtool = cmdargs.libtool
+    gnu_make = cmdargs.gnu_make == True
     makefile_name = cmdargs.makefile_name
     if makefile_name != None:
         makefile_name = makefile_name[0]
@@ -709,6 +719,7 @@ def main():
         excl_test_categories=excl_test_categories,
         libname=libname,
         lgpl=lgpl,
+        gnu_make=gnu_make,
         makefile_name=makefile_name,
         libtool=libtool,
         conddeps=cond_dependencies,
index 2b33ae23084e5e390039b58d80b4f32718854124..aef3ca253b46a2f410784f19a4ee27c89dad965f 100644 (file)
@@ -903,64 +903,6 @@ Date:   Tue Mar 14 12:19:40 2017 +0100
 
 --------------------------------------------------------------------------------
 
-commit 60e8b9303d8ce312bb2322d4801ed08678f93d1e
-Author: Paul Eggert <eggert@cs.ucla.edu>
-Date:   Wed Jul 4 20:42:07 2018 -0700
-
-    gnulib-tool: minor tweaks for --gnu-make
-
-    * gnulib-tool: Do not allow --gnu-make in test modes,
-    since they all require automake.
-    (func_emit_lib_Makefile_am): Don’t emit automake comment
-    if --gnu-make.
-
-commit 8224d65142d7b8cea2b8721a7d09c2cd60d2d312
-Author: Paul Eggert <eggert@cs.ucla.edu>
-Date:   Mon May 15 07:41:10 2017 -0700
-
-    gnulib-tool: improve GNU Make debugging
-
-    * gnulib-tool (func_emit_lib_Makefile_am): Omit unnecessary echo.
-    Report autoconf diagnostics when it fails, in the output makefile.
-
-commit fb8289f44a58c9462434eba8eaffd58c3f417c42
-Author: Paul Eggert <eggert@cs.ucla.edu>
-Date:   Tue Mar 14 08:39:27 2017 -0700
-
-    gnulib-tool: fix typo in comment output
-
-    * gnulib-tool (func_import): Fix typo with previous change.
-
-commit d6088547633af472625ab815452004c22fda6d58
-Author: Paul Eggert <eggert@cs.ucla.edu>
-Date:   Mon Mar 13 15:50:44 2017 -0700
-
-    gnulib-tool: minor --gnu-make fixups
-
-    * gnulib-tool (func_emit_lib_Makefile_am):
-    Remove useless code that was a blind alley during implementation.
-    Problem reported by Thien-Thi Nguyen in:
-    http://lists.gnu.org/archive/html/bug-gnulib/2017-03/msg00029.html
-    (func_import): Note the "--gnu-make" option in the output comment.
-
-commit dfbe4c0276701e42ffaed13a1c7a79003dc8fb30
-Author: Paul Eggert <eggert@cs.ucla.edu>
-Date:   Sun Mar 12 19:18:53 2017 -0700
-
-    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.
-
---------------------------------------------------------------------------------
-
 commit 9bdf6c8a0cdeb13c12e4b65dee9538c5468dbe1d
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Sun Aug 19 14:06:50 2012 +0200
index 3fb78083c67c2b695559a12a50f0102b85b79e5d..bdebf243cc7b79d9501bb30e14ff87a2e27111da 100644 (file)
@@ -56,7 +56,8 @@ class GLConfig(object):
                  sourcebase=None, m4base=None, pobase=None, docbase=None, testsbase=None,
                  modules=None, avoids=None, files=None,
                  incl_test_categories=None, excl_test_categories=None, libname=None,
-                 lgpl=None, makefile_name=None, libtool=None, conddeps=None, macro_prefix=None,
+                 lgpl=None, gnu_make=None, makefile_name=None, libtool=None,
+                 conddeps=None, macro_prefix=None,
                  podomain=None, witness_c_macro=None, vc_files=None, symbolic=None,
                  lsymbolic=None, configure_ac=None, ac_version=None,
                  libtests=None, single_configure=None, verbose=None, dryrun=None,
@@ -130,6 +131,10 @@ class GLConfig(object):
         self.resetLGPL()
         if lgpl != None:
             self.setLGPL(lgpl)
+        # gnu-make
+        self.resetGnuMake()
+        if gnu_make != None:
+            self.setGnuMake(gnu_make)
         # makefile_name
         self.resetMakefileName()
         if makefile_name != None:
@@ -776,6 +781,27 @@ class GLConfig(object):
         Default value is None, which means that lgpl is disabled.'''
         self.table['lgpl'] = None
 
+    # Define gnu-make methods.
+    def getGnuMake(self):
+        '''Return a boolean value describing whether the --gnu-make argument
+        was used.'''
+        return self.table['gnu_make']
+
+    def setGnuMake(self, value):
+        '''Set the --gnu-make argument as if it were invoked using the
+        command-line or disable it.'''
+        if type(value) is bool:
+            self.table['gnu_make'] = value
+        else:  # if type(value) is not bool
+            raise TypeError('value must be a bool, not %s'
+                            % type(value).__name__)
+
+    def resetGnuMake(self):
+        '''Reset the --gnu-make argument to its default. This feature must be
+        explicitly enabled by programs who utilize GNU Make features instead
+        of Autmake.'''
+        self.table['gnu_make'] = False
+
     def getModuleIndicatorPrefix(self):
         '''Return module_indicator_prefix to use inside GLEmiter class.'''
         return self.getIncludeGuardPrefix()
index c7b1e61fc45050eabe8ee822fb391f9f5af67b0f..6de9aba68a1d7545921540e4d533c207db5d8464 100644 (file)
@@ -40,6 +40,7 @@ __copyright__ = constants.__copyright__
 #===============================================================================
 # Define global constants
 #===============================================================================
+UTILS = constants.UTILS
 TESTS = constants.TESTS
 joinpath = constants.joinpath
 relinverse = constants.relinverse
@@ -627,6 +628,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         libname = self.config['libname']
         pobase = self.config['pobase']
         auxdir = self.config['auxdir']
+        gnu_make = self.config['gnu_make']
         makefile_name = self.config['makefile_name']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
@@ -639,9 +641,9 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         destfile = os.path.normpath(destfile)
         emit = ''
 
-        # When creating an includable Makefile.am snippet, augment variables with
-        # += instead of assigning them.
-        if makefile_name:
+        # When using GNU make, or when creating an includable Makefile.am snippet,
+        # augment variables with += instead of assigning them.
+        if gnu_make or makefile_name:
             assign = '+='
         else:  # if not makefile_name
             assign = '='
@@ -662,7 +664,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         else:  # if not for_test
             edit_check_PROGRAMS = False
         emit += "## DO NOT EDIT! GENERATED AUTOMATICALLY!\n"
-        emit += "## Process this file with automake to produce Makefile.in.\n"
+        if not gnu_make:
+            emit += "## Process this file with automake to produce Makefile.in.\n"
         emit += self.copyright_notice()
         if actioncmd:
             # The maximum line length (excluding the terminating newline) of
@@ -711,16 +714,33 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                                                 '$(' + module_indicator_prefix + '_GNULIB_')
                 # Skip the contents if it's entirely empty.
                 if not (amsnippet1 + amsnippet2).isspace():
-                    allsnippets += '## begin gnulib module %s\n\n' % str(module)
+                    allsnippets += '## begin gnulib module %s\n' % str(module)
+                    if gnu_make:
+                        allsnippets += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % str(module)
+                        convert_to_gnu_make = True
+                    else:
+                        convert_to_gnu_make = False
+                    allsnippets += '\n'
                     if conddeps:
                         if moduletable.isConditional(module):
                             name = module.getConditionalName()
-                            allsnippets += 'if %s\n' % name
-                    allsnippets += amsnippet1
+                            if gnu_make:
+                                allsnippets += 'ifneq (,$(%s))\n' % name
+                            else:
+                                allsnippets += 'if %s\n' % name
+                    if convert_to_gnu_make:
+                        allsnippets += re.sub(r'^if (.*)', r'ifneq (,$(\1))', amsnippet1)
+                    else:
+                        allsnippets += amsnippet1
                     if conddeps:
                         if moduletable.isConditional(module):
                             allsnippets += 'endif\n'
-                    allsnippets += amsnippet2
+                    if convert_to_gnu_make:
+                        allsnippets += re.sub(r'^if (.*)', r'ifneq (,$(\1))', amsnippet2)
+                    else:
+                        allsnippets += amsnippet2
+                    if gnu_make:
+                        allsnippets += 'endif\n'
                     allsnippets += '## end   gnulib module %s\n\n' % str(module)
 
                     # Test whether there are some source files in subdirectories.
@@ -763,6 +783,24 @@ AC_DEFUN([%V1%_LIBSOURCES], [
             emit += 'DISTCLEANFILES =\n'
             emit += 'MAINTAINERCLEANFILES =\n'
 
+        if gnu_make:
+            emit += '# Start of GNU Make output.\n'
+            result = sp.run([UTILS['autoconf'], '-t', 'AC_SUBST:$1 = @$1@',
+                            joinpath(self.config['destdir'], 'configure.ac')],
+                            capture_output=True)
+            if result.returncode == 0:
+                # sort -u
+                emit += '\n'.join(sorted(list(set(x.strip() for x in
+                                                  result.stdout.decode(encoding='utf-8').splitlines()))))
+                emit += '\n'
+            else:
+                emit += '== gnulib-tool GNU Make output failed as follows ==\n'
+                emit += ['# stderr: ' + x + '\n' for x in
+                         result.stderr.decode(encoding='utf-8').splitlines()]
+            emit += '# End of GNU Make output.\n'
+        else:
+            emit += '# No GNU Make output.\n'
+
         # Execute edits that apply to the Makefile.am being generated.
         for current_edit in range(0, makefiletable.count()):
             dictionary = makefiletable[current_edit]
@@ -895,6 +933,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         m4base = self.config['m4base']
         pobase = self.config['pobase']
         testsbase = self.config['testsbase']
+        gnu_make = self.config['gnu_make']
         makefile_name = self.config['makefile_name']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
@@ -964,9 +1003,16 @@ AC_DEFUN([%V1%_LIBSOURCES], [
 
                 # Skip the contents if it's entirely empty.
                 if not snippet.isspace():
-                    snippet = ('## begin gnulib module %s\n\n' % str(module)
-                               + snippet
-                               + '## end   gnulib module %s\n\n' % str(module))
+                    nonwrapped_snippet = snippet
+                    snippet = '## begin gnulib module %s\n' % str(module)
+                    if gnu_make:
+                        snippet += 'ifeq (,$(OMIT_GNULIB_MODULE_%s))\n' % str(module)
+                    snippet += '\n'
+                    snippet += nonwrapped_snippet
+                    if gnu_make:
+                        snippet += 'endif\n'
+                    snippet += '## end   gnulib module %s\n' % str(module)
+                    snippet += '\n'
                     # Mention long-running tests at the end.
                     if 'longrunning-test' in module.getStatuses():
                         longrun_snippets += snippet
index 68b2e7b0bb5f5871f4a634a5e155d35af23b12c5..e01cb9f63e622031966438b087b0069b61ab2c1b 100644 (file)
@@ -365,6 +365,7 @@ class GLImport(object):
         conddeps = self.config.checkCondDeps()
         libname = self.config.getLibName()
         lgpl = self.config.getLGPL()
+        gnu_make = self.config.getGnuMake()
         makefile_name = self.config.getMakefileName()
         libtool = self.config.checkLibtool()
         macro_prefix = self.config.getMacroPrefix()
@@ -407,6 +408,8 @@ class GLImport(object):
                 actioncmd += ' --lgpl'
             else:  # if lgpl != True
                 actioncmd += ' --lgpl=%s' % lgpl
+        if gnu_make:
+            actioncmd += ' --gnu-make'
         if makefile_name:
             actioncmd += ' --makefile-name=%s' % makefile_name
         if conddeps:
@@ -563,6 +566,7 @@ class GLImport(object):
         testsbase = self.config['testsbase']
         lgpl = self.config['lgpl']
         libname = self.config['libname']
+        gnu_make = self.config['gnu_make']
         makefile_name = self.config['makefile_name']
         conddeps = self.config['conddeps']
         libtool = self.config['libtool']
@@ -602,7 +606,7 @@ AC_DEFUN([%s_EARLY],
                         and file.count('/') > 1):
                     uses_subdirs = True
                     break
-        if uses_subdirs:
+        if not gnu_make and uses_subdirs:
             emit += '  AC_REQUIRE([AM_PROG_CC_C_O])\n'
         for module in moduletable['final']:
             emit += '  # Code from module %s:\n' % str(module)
index 69d3e4a7f85e6ab817b6d1accf192f3a60c4230f..808f11b06feb0c22b028aebd15adc9d23e004ed7 100644 (file)
@@ -265,14 +265,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
index a97e4b310eedceb0117019d1b73a5d1318216db2..c6f0eb15c7a59b0c00ca3952c1efdc7258e13b22 100644 (file)
@@ -860,7 +860,7 @@ class GLModuleTable(object):
                         automake_snippet = \
                             module.getAutomakeSnippet_Conditional()
                         pattern = re.compile('^if', re.M)
-                        if not pattern.findall(automake_snippet):
+                        if not self.config['gnu_make'] and not pattern.findall(automake_snippet):
                             # 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