Autoconf insists on adding macros like PACKAGE_NAME and
PACKAGE_BUG_TARNAME to config.h but those are useless for libstdc++
because it's not a complete package, just a sub-directory of gcc, and we
never use any of those strings in our sources.

Since we include the generated config.h in our installed c++config.h
header, those useless macros are exposed to users. We do transform them
to use the reserved _GLIBCXX_ prefix, but they're still just useless
noise in the installed header.

I don't know any way to get autoconf to not add them to config.h but
this change comments them out so they're not defined when users include
our headers.

Although not really important now that the macro isn't being defined,
this change also avoids the double substitution for PACKAGE_VERSION
which was resulting in _GLIBCXX_PACKAGE__GLIBCXX_VERSION.

libstdc++-v3/ChangeLog:

        PR libstdc++/79147
        * include/Makefile.am (c++config.h): Adjust sed command to
        comment out all PACKAGE_XXX macros and to avoid adjusting
        PACKAGE_VERSION twice.
        * include/Makefile.in: Regenerate.
---

Tested powerpc64le-linux.

I've checked that AIX, Solaris and macOS all support the sed syntax (and
it's been in POSIX since at least 2001).

 libstdc++-v3/include/Makefile.am | 4 ++--
 libstdc++-v3/include/Makefile.in | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 0b0cbe2d3faf..d1e5c3d84918 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1420,8 +1420,8 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \
        -e "$$verbose_assert" \
            < ${glibcxx_srcdir}/include/bits/c++config > $@ ;\
        sed -e 's/HAVE_/_GLIBCXX_HAVE_/g' \
-           -e 's/PACKAGE/_GLIBCXX_PACKAGE/g' \
-           -e 's/VERSION/_GLIBCXX_VERSION/g' \
+           -e '/PACKAGE/s,^,// ,' \
+           -e '/PACKAGE/!s/VERSION/_GLIBCXX_VERSION/g' \
            -e 's/WORDS_/_GLIBCXX_WORDS_/g' \
            -e 's/LT_OBJDIR/_GLIBCXX_LT_OBJDIR/g' \
            -e 's/STDC_HEADERS/_GLIBCXX_STDC_HEADERS/g' \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index e3a6d5f13905..13c0b5b4f839 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -1897,8 +1897,8 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \
        -e "$$verbose_assert" \
            < ${glibcxx_srcdir}/include/bits/c++config > $@ ;\
        sed -e 's/HAVE_/_GLIBCXX_HAVE_/g' \
-           -e 's/PACKAGE/_GLIBCXX_PACKAGE/g' \
-           -e 's/VERSION/_GLIBCXX_VERSION/g' \
+           -e '/PACKAGE/s,^,// ,' \
+           -e '/PACKAGE/!s/VERSION/_GLIBCXX_VERSION/g' \
            -e 's/WORDS_/_GLIBCXX_WORDS_/g' \
            -e 's/LT_OBJDIR/_GLIBCXX_LT_OBJDIR/g' \
            -e 's/STDC_HEADERS/_GLIBCXX_STDC_HEADERS/g' \
-- 
2.51.0

Reply via email to