[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Merge getopt from gnulib to glibc and vice versa, eliminate __need_g
From: |
Bruno Haible |
Subject: |
Re: Merge getopt from gnulib to glibc and vice versa, eliminate __need_getopt |
Date: |
Wed, 19 Apr 2017 00:14:53 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-72-generic; KDE/5.18.0; x86_64; ; ) |
Hi Paul,
> 0002-getopt-gnu-omit-some-duplicate-code.patch
It took me some time to convince myself that this patch is correct.
Here's a test case:
$ tar xvfz hello.tar.gz (attached)
$ cd hello
$ $GNULIB_TOOL --import --lib=libposix --source-base=libp --m4-base=m4p
--macro-prefix=gp getopt-posix
$ $GNULIB_TOOL --import --lib=libgnu --source-base=libg --m4-base=m4g
--macro-prefix=gg getopt-gnu
$ aclocal -I m4p -I m4g
$ autoconf
$ autoheader
$ automake --copy --add-missing --force-missing
Therefore (and because the getopt-gnu module works quite differently from other
gnulib modules) let me add some comments about how it works.
2017-04-18 Bruno Haible <address@hidden>
getopt-gnu: Add comments.
* m4/getopt.m4 (gl_FUNC_GETOPT_GNU): Add comments.
* modules/getopt-gnu (configure.ac): Likewise.
diff --git a/m4/getopt.m4 b/m4/getopt.m4
index ac3b38e..3ebc7b7 100644
--- a/m4/getopt.m4
+++ b/m4/getopt.m4
@@ -32,7 +32,16 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
# getopt_long_only.
AC_DEFUN([gl_FUNC_GETOPT_GNU],
[
+ dnl Set the variable gl_getopt_required, so that all invocations of
+ dnl gl_GETOPT_CHECK_HEADERS in the scope of the current configure file
+ dnl will check for getopt with GNU extensions.
+ dnl This means that if one gnulib-tool invocation requests getopt-posix
+ dnl and another gnulib-tool invocation requests getopt-gnu, it is as if
+ dnl both had requested getopt-gnu.
m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
+
+ dnl No need to invoke gl_FUNC_GETOPT_POSIX here; this is automatically
+ dnl done through the module dependency getopt-gnu -> getopt-posix.
])
# Determine whether to replace the entire getopt facility.
diff --git a/modules/getopt-gnu b/modules/getopt-gnu
index 974ce14..a148693 100644
--- a/modules/getopt-gnu
+++ b/modules/getopt-gnu
@@ -10,6 +10,9 @@ getopt-posix
configure.ac:
gl_FUNC_GETOPT_GNU
+dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the
gl_getopt_required
+dnl mechanism), there is no need to do any AC_LIBOBJ or AC_SUBST here; they are
+dnl done in the getopt-posix module.
Makefile.am:
hello.tar.gz
Description: application/compressed-tar