public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: newlib@sourceware.org
Subject: [PATCH 8/8] newlib: switch newlib.h to autoheader
Date: Mon, 17 Jan 2022 23:47:41 -0500	[thread overview]
Message-ID: <20220118044741.21027-9-vapier@gentoo.org> (raw)
In-Reply-To: <20220118044741.21027-1-vapier@gentoo.org>

Now that newlib.hin has been brought up to date and all of its defines
are produced by configure, we can switch it to using autoheader without
manual editing.  This relies on a few pieces:
* Moving the header & footer into configure.ac via AH_TOP & AH_BOTTOM.
* Running a post-process step on newlib.h to delete all the defines we
  didn't export ourselves.  Basically, anything without a _ prefix.

This will leave behind some spurious comments in newlib.h related to
the defines we filtered out, but should be harmless, so it's probably
not worth the effort to construct a more complicated sed expression to
also strip those out.
---
 newlib/Makefile.in  | 26 +++++++++----------
 newlib/configure    | 15 ++++++++---
 newlib/configure.ac | 18 ++++++++++++-
 newlib/newlib.hin   | 63 ++++++++++++++++++++++++++++++++++++++++++---
 4 files changed, 100 insertions(+), 22 deletions(-)

diff --git a/newlib/configure.ac b/newlib/configure.ac
index cb65cdd78778..69b3e827f08e 100644
--- a/newlib/configure.ac
+++ b/newlib/configure.ac
@@ -3,7 +3,23 @@ dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT([newlib],[NEWLIB_VERSION])
 AC_CONFIG_SRCDIR([libc])
-AC_CONFIG_HEADERS([_newlib_version.h:_newlib_version.hin newlib.h:newlib.hin])
+
+dnl Since we can't control what defines autoheader picks up (various autoconf
+dnl macros will add their own), filter out all the ones with a _ prefix.  All
+dnl the ones we want to export use a _ prefix, and all the rest we don't want
+dnl to export as it'll pollute the namespace of newlib users.
+dnl NB: newlib.h must be the first AC_CONFIG_HEADERS call for autoheader.
+AC_CONFIG_HEADERS([newlib.h:newlib.hin], [sed -i.tmp -e '/^#define [^_]/d' -e '/^\/\* #undef [^_]/d' newlib.h && rm -f newlib.h.tmp])
+AH_TOP([/* NB: The contents are filtered before being installed. */
+
+#ifndef __NEWLIB_H__
+#define __NEWLIB_H__ 1
+
+/* Newlib version */
+#include <_newlib_version.h>])
+AH_BOTTOM([#endif /* !__NEWLIB_H__ */])
+
+AC_CONFIG_HEADERS([_newlib_version.h:_newlib_version.hin])
 
 dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake. 
 AC_CONFIG_AUX_DIR(..)
diff --git a/newlib/newlib.hin b/newlib/newlib.hin
index 15543f4030a4..69a7cb7a7480 100644
--- a/newlib/newlib.hin
+++ b/newlib/newlib.hin
@@ -1,13 +1,68 @@
-/* newlib.hin.  Manually edited from the output of autoheader to
-   remove all PACKAGE_ macros which will collide with any user
-   package using newlib header files and having its own package name,
-   version, etc...  */
+/* newlib.hin.  Generated from configure.ac by autoheader.  */
+
+/* NB: The contents are filtered before being installed. */
+
 #ifndef __NEWLIB_H__
 #define __NEWLIB_H__ 1
 
 /* Newlib version */
 #include <_newlib_version.h>
 
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#undef LT_OBJDIR
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
 /* If atexit() may dynamically allocate space for cleanup functions. */
 #undef _ATEXIT_DYNAMIC_ALLOC
 
-- 
2.33.0


  parent reply	other threads:[~2022-01-18  4:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  4:47 [PATCH 0/8] newlib: convert " Mike Frysinger
2022-01-18  4:47 ` [PATCH 1/8] newlib: internalize HAVE_INITFINI_ARRAY Mike Frysinger
     [not found]   ` <DM3P110MB0522248DFEE102BB37B43A8F9A589@DM3P110MB0522.NAMP110.PROD.OUTLOOK.COM>
2022-01-18 16:10     ` Fw: " C Howland
2022-01-19  0:53       ` Mike Frysinger
2022-01-19  2:39         ` C Howland
2022-01-19  3:44           ` Mike Frysinger
2022-01-19 23:50           ` Mike Frysinger
2022-01-18  4:47 ` [PATCH 2/8] newlib: merge acconfig.h changes into newlib.hin Mike Frysinger
2022-01-18  4:47 ` [PATCH 3/8] newlib: clean up autoheader templates Mike Frysinger
2022-01-18  4:47 ` [PATCH 4/8] newlib: sort newlib.h output Mike Frysinger
2022-01-18  4:47 ` [PATCH 5/8] newlib: move version defines out of the config headers Mike Frysinger
2022-01-18  4:47 ` [PATCH 6/8] newlib: add missing _NANO_MALLOC to newlib.hin Mike Frysinger
2022-01-18  4:47 ` [PATCH 7/8] newlib: iconv: autogenerate iconv define list Mike Frysinger
2022-01-18  4:47 ` Mike Frysinger [this message]
2022-01-19 14:51 ` [PATCH 0/8] newlib: convert newlib.h to autoheader Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220118044741.21027-9-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).