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

[patches] PATCH: Clean up support for code conditional on option groups



I've committed the patch below:

- EGLIBC now generates the header file <gnu/option-groups.h>, which
  contains #definitions indicating which option groups are enabled.

- EGLIBC code conditional on option groups now #includes that file and
  tests for the symbols it #defines.

- EGLIBC's makefiles no longer provide option group symbol
  #definitions by setting 'CFLAGS-foo.c' variables in various "cute"
  ways.

This is a cleanup, but I think a necessary one.  Especially with the
wide character option group, we're moving into a phase of the project
where our changes will become more and more invasive, one which the
Makefile-based approach was not going to serve well.

ChangeLog.eglibc:
2007-10-29  Jim Blandy  <jimb@xxxxxxxxxxxxxxxx>

	* Makeconfig ($(common-objpfx)gnu/option-groups.h): New generated
	header.
	* scripts/option-groups.awk: New script, to generate it.
	* debug/Makefile (CFLAGS-segfault.c): Don't define option group
	symbols here.
	* wcsmbs/Makefile (CFLAGS-wcsmbsload.c): Same.
	* time/Makefile (CFLAGS-strftime_l.c, CFLAGS-strptime_l.c): Same.
	* intl/Makefile (CFLAGS-dcigettext.c): Same.
	* sysdeps/unix/sysv/linux/Makefile (CFLAGS-gethostid.c)
	(CFLAGS-libc_fatal.c): Same.
	* misc/Makefile (CFLAGS-error.c, CFLAGS-err.c): Same.
	* nss/Makefile (CFLAGS-nsswitch.c, CFLAGS-getnssent_r.c)
	(CFLAGS-getent.c): Same.
	* string/Makefile (CFLAGS-strerror_l.c): Same.
	* iconv/Makefile (CFLAGS-gconv_db.c, CFLAGS-gconv_trans.c)
	(CFLAGS-iconv_prog.c): Same.
	* locale/Makefile (CFLAGS-C-ctype.c, CFLAGS-xlocale.c)
	(CFLAGS-ld-messages.c): Same.
	* argp/Makefile (CFLAGS-argp-help.c, CFLAGS-argp-fmtstream.c): Same.
	* nptl/Makefile (CFLAGS-pthread_create.c): Same.
	* posix/Makefile (CFLAGS-glob.c, CFLAGS-bug-regex1.c): Same.
	* stdio-common/Makefile (CFLAGS-printf_fp.c)
	(CFLAGS-printf_fphex.c, CFLAGS-fxprintf.c, CFLAGS-tst-popen.c): Same.
	* libidn/Makefile (CFLAGS-toutf8.c): Same.
	* debug/segfault.c, wcsmbs/wcsmbsload.c, time/strftime_l.c:
	* time/strptime_l.c, intl/dcigettext.c:
	* sysdeps/unix/sysv/linux/libc_fatal.c:
	* sysdeps/unix/sysv/linux/gethostid.c, misc/err.c, misc/error.c:
	* nss/getnssent_r.c, nss/nsswitch.c, nss/getent.c:
	* string/strerror_l.c, iconv/gconv_db.c, iconv/iconv_prog.c:
	* iconv/gconv_trans.c, locale/xlocale.c, locale/C-ctype.c:
	* locale/programs/ld-messages.c, argp/argp-help.c:
	* argp/argp-fmtstream.c, nptl/pthread_create.c, posix/glob.c:
	* posix/bug-regex1.c, stdio-common/printf_fp.c:
	* stdio-common/printf_fphex.c, stdio-common/tst-popen.c:
	* stdio-common/fxprintf.c, libidn/toutf8.c: #include
	<gnu/option-groups.h>, and test for the symbols that #defines,
	instead.

Index: debug/Makefile
===================================================================
--- debug/Makefile	(revision 4012)
+++ debug/Makefile	(working copy)
@@ -125,9 +125,6 @@
 
 libSegFault-routines = segfault
 libSegFault-inhibit-o = $(filter-out .os,$(object-suffixes))
-OPTION_EGLIBC_BACKTRACE-CFLAGS-$(OPTION_EGLIBC_BACKTRACE) \
-	= -DOPTION_EGLIBC_BACKTRACE
-CFLAGS-segfault.c = $(OPTION_EGLIBC_BACKTRACE-CFLAGS-y)
 
 libpcprofile-routines = pcprofile
 libpcprofile-inhibit-o = $(filter-out .os,$(object-suffixes))
Index: debug/segfault.c
===================================================================
--- debug/segfault.c	(revision 4012)
+++ debug/segfault.c	(working copy)
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <stdio-common/_itoa.h>
 #include <ldsodefs.h>
+#include <gnu/option-groups.h>
 
 #include <bp-checks.h>
 
@@ -95,7 +96,7 @@
   REGISTER_DUMP;
 #endif
 
-#ifdef OPTION_EGLIBC_BACKTRACE
+#if __OPTION_EGLIBC_BACKTRACE
   WRITE_STRING ("\nBacktrace:\n");
 
   /* Get the backtrace.  */
Index: scripts/option-groups.awk
===================================================================
--- scripts/option-groups.awk	(revision 0)
+++ scripts/option-groups.awk	(revision 0)
@@ -0,0 +1,52 @@
+# option-groups.awk --- generate option group header file
+# Given input files containing makefile-style assignments to variables, 
+# print out a header file that #defines an appropriate preprocessor
+# symbol for each variable left set to 'y'.
+
+BEGIN { FS="=" }
+
+# Trim spaces.
+{ gsub (/[[:blank:]]/, "") }
+
+# Skip comments.
+/^#/ { next }
+
+# Process assignments.
+NF == 2 {
+    vars[$1] = $2
+}
+
+# Print final values.
+END {
+    print "/* This file is automatically generated."
+    print "   It defines macros that indicate which EGLIBC option groups were"
+    print "   configured in 'option-groups.config' when this C library was"
+    print "   built.  For each option group named OPTION_foo, it #defines"
+    print "   __OPTION_foo to be 1 if the group is enabled, or leaves that"
+    print "   symbol undefined if the group is disabled."
+    print ""
+    print "   It is generated by scripts/option-groups.awk in the EGLIBC"
+    print "   source tree.  */"
+    print ""
+
+    # Sort the variables by name.
+    i=0
+    for (var in vars)
+        names[i++] = var
+    n = asort (names)
+
+    for (i = 1; i <= n; i++)
+    {
+        var = names[i]
+        if (var ~ /^OPTION_/)
+        {
+            if (vars[var] == "y")
+                print "#define __" var " 1"
+            else if (vars[var] == "n")
+                print "/* #undef __" var " */"
+            # Ignore variables that don't have boolean values.
+            # Ideally, this would be driven by the types given in
+            # option-groups.def.
+        }
+    }
+}
Index: wcsmbs/Makefile
===================================================================
--- wcsmbs/Makefile	(revision 4012)
+++ wcsmbs/Makefile	(working copy)
@@ -72,10 +72,6 @@
 CFLAGS-wcstof_l.c = $(strtox-CFLAGS)
 CFLAGS-tst-wchar-h.c = -D_FORTIFY_SOURCE=2
 
-OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
-	= -DOPTION_EGLIBC_LOCALE_CODE
-CFLAGS-wcsmbsload.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-
 CFLAGS-isoc99_wscanf.c += $(exceptions)
 CFLAGS-isoc99_fwscanf.c += $(exceptions)
 CFLAGS-isoc99_vwscanf.c += $(exceptions)
Index: wcsmbs/wcsmbsload.c
===================================================================
--- wcsmbs/wcsmbsload.c	(revision 4012)
+++ wcsmbs/wcsmbsload.c	(working copy)
@@ -22,6 +22,7 @@
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
+#include <gnu/option-groups.h>
 
 #include <locale/localeinfo.h>
 #include <wcsmbsload.h>
@@ -144,7 +145,7 @@
   })
 
 
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
 /* Some of the functions here must not be used while setlocale is called.  */
 __libc_lock_define (extern, __libc_setlocale_lock attribute_hidden)
 
Index: time/Makefile
===================================================================
--- time/Makefile	(revision 4012)
+++ time/Makefile	(working copy)
@@ -54,12 +54,6 @@
 CFLAGS-tzset.c = $(tz-cflags)
 CFLAGS-getdate.c = -fexceptions
 
-OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
-	= -DOPTION_EGLIBC_LOCALE_CODE
-
-CFLAGS-strftime_l.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-CFLAGS-strptime_l.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-
 # Don't warn about Y2k problem in strftime format string.
 CFLAGS-test_time.c = -Wno-format
 
Index: time/strftime_l.c
===================================================================
--- time/strftime_l.c	(revision 4012)
+++ time/strftime_l.c	(working copy)
@@ -35,6 +35,10 @@
 # include "../locale/localeinfo.h"
 #endif
 
+#ifdef _LIBC
+# include <gnu/option-groups.h>
+#endif
+
 #if defined emacs && !defined HAVE_BCOPY
 # define HAVE_MEMCPY 1
 #endif
@@ -896,7 +900,7 @@
 	    goto bad_format;
 	  if (modifier == L_('E'))
 	    {
-#if defined (OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
+#if (! _LIBC || __OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
 	      struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG);
 	      if (era)
 		{
@@ -969,7 +973,7 @@
 
 	  if (modifier == L_('O') && 0 <= number_value)
 	    {
-#if defined (OPTION_EGLIBC_LOCALE_CODE) && defined (_NL_CURRENT)
+#if (! _LIBC || __OPTION_EGLIBC_LOCALE_CODE) && defined (_NL_CURRENT)
 	      /* Get the locale specific alternate representation of
 		 the number NUMBER_VALUE.  If none exist NULL is returned.  */
 	      const CHAR_T *cp = nl_get_alt_digit (number_value
@@ -1274,7 +1278,7 @@
 	case L_('Y'):
 	  if (modifier == 'E')
 	    {
-#if defined (OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
+#if (! _LIBC || __OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
 	      struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG);
 	      if (era)
 		{
@@ -1299,7 +1303,7 @@
 	case L_('y'):
 	  if (modifier == L_('E'))
 	    {
-#if defined (OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
+#if (! _LIBC || __OPTION_EGLIBC_LOCALE_CODE) && HAVE_STRUCT_ERA_ENTRY
 	      struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG);
 	      if (era)
 		{
Index: time/strptime_l.c
===================================================================
--- time/strptime_l.c	(revision 4012)
+++ time/strptime_l.c	(working copy)
@@ -29,6 +29,7 @@
 #include <stdbool.h>
 
 #ifdef _LIBC
+# include <gnu/option-groups.h>
 # include "../locale/localeinfo.h"
 #endif
 
@@ -93,7 +94,7 @@
     if (val < from || val > to)						      \
       return NULL;							      \
   } while (0)
-#if defined (OPTION_EGLIBC_LOCALE_CODE) && defined (_NL_CURRENT)
+#if (! _LIBC || __OPTION_EGLIBC_LOCALE_CODE) && defined (_NL_CURRENT)
 # define get_alt_number(from, to, n) \
   ({									      \
      __label__ do_normal;						      \
@@ -828,7 +829,7 @@
 	      s.want_xday = 1;
 	      break;
 	    case 'C':
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if ! _LIBC || __OPTION_EGLIBC_LOCALE_CODE
 	      if (s.decided != raw)
 		{
 		  if (s.era_cnt >= 0)
@@ -870,7 +871,7 @@
 		 normal representation.  */
 	      goto match_century;
  	    case 'y':
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if ! _LIBC || __OPTION_EGLIBC_LOCALE_CODE
 	      if (s.decided != raw)
 		{
 		  get_number(0, 9999, 4);
@@ -932,7 +933,7 @@
 #endif
 	      goto match_year_in_century;
 	    case 'Y':
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if ! _LIBC || __OPTION_EGLIBC_LOCALE_CODE
 	      if (s.decided != raw)
 		{
 		  num_eras = _NL_CURRENT_WORD (LC_TIME,
@@ -1132,7 +1133,7 @@
 	tm->tm_year = (s.century - 19) * 100;
     }
 
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if ! _LIBC || __OPTION_EGLIBC_LOCALE_CODE
   if (s.era_cnt != -1)
     {
       era = _nl_select_era_entry (s.era_cnt HELPER_LOCALE_ARG);
Index: intl/dcigettext.c
===================================================================
--- intl/dcigettext.c	(revision 4012)
+++ intl/dcigettext.c	(working copy)
@@ -78,6 +78,10 @@
 #endif
 #include "hash-string.h"
 
+#ifdef _LIBC
+# include <gnu/option-groups.h>
+#endif
+
 /* Thread safetyness.  */
 #ifdef _LIBC
 # include <bits/libc-lock.h>
@@ -464,7 +468,7 @@
   search->category = category;
 # ifdef HAVE_PER_THREAD_LOCALE
 #  ifdef _LIBC
-#   ifdef OPTION_EGLIBC_LOCALE_CODE
+#   if __OPTION_EGLIBC_LOCALE_CODE
   localename = __current_locale_name (category);
 #   else
   localename = "C";
@@ -1337,7 +1341,7 @@
      `LC_xxx', and `LANG'.  On some systems this can be done by the
      `setlocale' function itself.  */
 #ifdef _LIBC
-# ifdef OPTION_EGLIBC_LOCALE_CODE
+# if __OPTION_EGLIBC_LOCALE_CODE
   retval = __current_locale_name (category);
 # else
   retval = "C";
Index: intl/Makefile
===================================================================
--- intl/Makefile	(revision 4012)
+++ intl/Makefile	(working copy)
@@ -102,11 +102,6 @@
 	$(make-target-directory)
 	LC_ALL=C sed -f $^ > $@
 
-OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
-	= -DOPTION_EGLIBC_LOCALE_CODE
-
-CFLAGS-dcigettext.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-
 CFLAGS-tst-gettext.c = -DTESTSTRS_H=\"$(objpfx)msgs.h\"
 CFLAGS-tst-translit.c = -DOBJPFX=\"$(objpfx)\"
 CFLAGS-tst-gettext2.c = -DOBJPFX=\"$(objpfx)\"
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
--- sysdeps/unix/sysv/linux/Makefile	(revision 4012)
+++ sysdeps/unix/sysv/linux/Makefile	(working copy)
@@ -17,14 +17,8 @@
 		   eventfd eventfd_read eventfd_write
 
 
-inet-CFLAGS-$(OPTION_EGLIBC_INET) = -DOPTION_EGLIBC_INET
+CFLAGS-gethostid.c = -fexceptions
 
-CFLAGS-gethostid.c = -fexceptions $(inet-CFLAGS-y)
-
-OPTION_EGLIBC_BACKTRACE-CFLAGS-$(OPTION_EGLIBC_BACKTRACE) \
-	= -DOPTION_EGLIBC_BACKTRACE
-CFLAGS-libc_fatal.c += $(OPTION_EGLIBC_BACKTRACE-CFLAGS-y)
-
 sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
 		  sys/klog.h sys/kdaemon.h \
 		  sys/user.h sys/procfs.h sys/prctl.h \
Index: sysdeps/unix/sysv/linux/libc_fatal.c
===================================================================
--- sysdeps/unix/sysv/linux/libc_fatal.c	(revision 4012)
+++ sysdeps/unix/sysv/linux/libc_fatal.c	(working copy)
@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <sys/syslog.h>
 #include <execinfo.h>
+#include <gnu/option-groups.h>
 
 /* Abort with an error message.  */
 #include <not-cancel.h>
@@ -143,7 +144,7 @@
 
   if (do_abort)
     {
-#ifdef OPTION_EGLIBC_BACKTRACE
+#if __OPTION_EGLIBC_BACKTRACE
       if (do_abort > 1 && written)
 	{
 	  void *addrs[64];
@@ -166,7 +167,7 @@
 	      close_not_cancel_no_status (fd2);
 	    }
 	}
-#endif /* OPTION_EGLIBC_BACKTRACE */
+#endif /* __OPTION_EGLIBC_BACKTRACE */
 
       /* Terminate the process.  */
       abort ();
Index: sysdeps/unix/sysv/linux/gethostid.c
===================================================================
--- sysdeps/unix/sysv/linux/gethostid.c	(revision 4012)
+++ sysdeps/unix/sysv/linux/gethostid.c	(working copy)
@@ -23,6 +23,7 @@
 #include <unistd.h>
 #include <netdb.h>
 #include <not-cancel.h>
+#include <gnu/option-groups.h>
 
 #define HOSTIDFILE "/etc/hostid"
 
@@ -91,7 +92,7 @@
 	return id;
     }
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
   /* Getting from the file was not successful.  An intelligent guess for
      a unique number of a host is its IP address.  Return this.  */
   if (__gethostname (hostname, MAXHOSTNAMELEN) < 0 || hostname[0] == '\0')
Index: misc/err.c
===================================================================
--- misc/err.c	(revision 4012)
+++ misc/err.c	(working copy)
@@ -23,6 +23,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
+#include <gnu/option-groups.h>
 
 #ifdef USE_IN_LIBIO
 # include <wchar.h>
@@ -41,7 +42,7 @@
 }
 
 #ifdef USE_IN_LIBIO
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
 static void
 convert_and_print (const char *format, __gnuc_va_list ap)
 {
@@ -96,7 +97,7 @@
 #ifdef USE_IN_LIBIO
   if (_IO_fwide (stderr, 0) > 0)
     {
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
       __fwprintf (stderr, L"%s: ", __progname);
       convert_and_print (format, ap);
       putwc_unlocked (L'\n', stderr);
@@ -125,7 +126,7 @@
 #ifdef USE_IN_LIBIO
   if (_IO_fwide (stderr, 0) > 0)
     {
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
       __fwprintf (stderr, L"%s: ", __progname);
       if (format)
 	{
Index: misc/error.c
===================================================================
--- misc/error.c	(revision 4012)
+++ misc/error.c	(working copy)
@@ -29,6 +29,7 @@
 #include <string.h>
 
 #ifdef _LIBC
+# include <gnu/option-groups.h>
 # include <libintl.h>
 # include <stdbool.h>
 # include <stdint.h>
@@ -131,7 +132,7 @@
 #if _LIBC
   if (_IO_fwide (stderr, 0) > 0)
     {
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
 # define ALLOCA_LIMIT 2000
       size_t len = strlen (message) + 1;
       wchar_t *wmessage = NULL;
Index: misc/Makefile
===================================================================
--- misc/Makefile	(revision 4012)
+++ misc/Makefile	(working copy)
@@ -94,9 +94,6 @@
 endif
 # eglibc: endif
 
-OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-$(OPTION_POSIX_WIDE_CHAR_DEVICE_IO) \
-	= -DOPTION_POSIX_WIDE_CHAR_DEVICE_IO
-
 CFLAGS-tsearch.c = $(uses-callbacks)
 CFLAGS-lsearch.c = $(uses-callbacks)
 CFLAGS-pselect.c = -fexceptions
@@ -104,13 +101,13 @@
 CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-usleep.c = -fexceptions
 CFLAGS-syslog.c = -fexceptions
-CFLAGS-error.c = -fexceptions $(OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-y)
+CFLAGS-error.c = -fexceptions
 CFLAGS-getpass.c = -fexceptions
 CFLAGS-mkstemp.c = -fexceptions
 CFLAGS-mkstemp64.c = -fexceptions
 CFLAGS-getsysstats.c = -fexceptions
 CFLAGS-getusershell.c = -fexceptions
-CFLAGS-err.c = -fexceptions $(OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-y)
+CFLAGS-err.c = -fexceptions
 CFLAGS-tst-tsearch.c = $(stack-align-test-flags)
 CFLAGS-mntent_r.c = -D_IO_MTSAFE_IO
 
Index: Makeconfig
===================================================================
--- Makeconfig	(revision 4012)
+++ Makeconfig	(working copy)
@@ -913,6 +913,24 @@
 endif
 endif
 
+# Generate a header file that #defines preprocessor symbols indicating
+# which option groups are enabled.  Note that the option-groups.config file
+# may not exist at all.
+before-compile += $(common-objpfx)gnu/option-groups.h
+common-generated += gnu/option-groups.h gnu/option-groups.stmp
+headers += gnu/option-groups.h
+$(common-objpfx)gnu/option-groups.h: $(common-objpfx)gnu/option-groups.stmp; @:
+$(common-objpfx)gnu/option-groups.stmp:					\
+		$(..)scripts/option-groups.awk				\
+		$(..)option-groups.defaults				\
+		$(wildcard $(common-objpfx)option-groups.config)
+	$(make-target-directory)
+	@rm -f ${@:stmp=T} $@
+	LC_ALL=C $(AWK) -f $^ > ${@:stmp=T}
+	$(move-if-change) ${@:stmp=T} ${@:stmp=h}
+	touch $@
+
+
 # These are the subdirectories containing the library source.  The order
 # is more or less arbitrary.  The sorting step will take care of the
 # dependencies.
Index: nss/getnssent_r.c
===================================================================
--- nss/getnssent_r.c	(revision 4012)
+++ nss/getnssent_r.c	(working copy)
@@ -17,6 +17,7 @@
    02111-1307 USA.  */
 
 #include <errno.h>
+#include <gnu/option-groups.h>
 #include <netdb.h>
 #include "nsswitch.h"
 
@@ -60,13 +61,13 @@
   } fct;
   int no_more;
 
-#if OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
   if (res && __res_maybe_init (&_res, 0) == -1)
     {
       __set_h_errno (NETDB_INTERNAL);
       return;
     }
-#endif /* OPTION_EGLIBC_INET */
+#endif /* __OPTION_EGLIBC_INET */
 
   /* Cycle through the services and run their `setXXent' functions until
      we find an available service.  */
@@ -105,13 +106,13 @@
   } fct;
   int no_more;
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
   if (res && __res_maybe_init (&_res, 0) == -1)
     {
       __set_h_errno (NETDB_INTERNAL);
       return;
     }
-#endif /* OPTION_EGLIBC_INET */
+#endif /* __OPTION_EGLIBC_INET */
 
   /* Cycle through all the services and run their endXXent functions.  */
   no_more = setup (func_name, lookup_fct, &fct.ptr, nip, startp, 1);
@@ -147,14 +148,14 @@
   int no_more;
   enum nss_status status;
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
   if (res && __res_maybe_init (&_res, 0) == -1)
     {
       *h_errnop = NETDB_INTERNAL;
       *result = NULL;
       return errno;
     }
-#endif /* OPTION_EGLIBC_INET */
+#endif /* __OPTION_EGLIBC_INET */
 
   /* Initialize status to return if no more functions are found.  */
   status = NSS_STATUS_NOTFOUND;
Index: nss/Makefile
===================================================================
--- nss/Makefile	(revision 4012)
+++ nss/Makefile	(working copy)
@@ -130,15 +130,3 @@
 # a statically-linked program that hasn't already loaded it.
 $(services:%=$(objpfx)libnss_%.so): $(common-objpfx)libc.so \
 				    $(common-objpfx)libc_nonshared.a
-
-OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DOPTION_EGLIBC_INET=1
-OPTION_EGLIBC_NSSWITCH-CFLAGS-$(OPTION_EGLIBC_NSSWITCH) \
-	= -DOPTION_EGLIBC_NSSWITCH=1
-OPTION_EGLIBC_DB_ALIASES-CFLAGS-$(OPTION_EGLIBC_DB_ALIASES) \
-	= -DOPTION_EGLIBC_DB_ALIASES=1
-
-CFLAGS-nsswitch.c    = $(OPTION_EGLIBC_INET-CFLAGS-y) \
-		       $(OPTION_EGLIBC_NSSWITCH-CFLAGS-y)
-CFLAGS-getnssent_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
-CFLAGS-getent.c      = $(OPTION_EGLIBC_INET-CFLAGS-y) \
-		       $(OPTION_EGLIBC_DB_ALIASES-y)
Index: nss/nsswitch.c
===================================================================
--- nss/nsswitch.c	(revision 4012)
+++ nss/nsswitch.c	(working copy)
@@ -27,6 +27,7 @@
 #include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
+#include <gnu/option-groups.h>
 
 #include <aliases.h>
 #include <grp.h>
@@ -48,7 +49,7 @@
    - We never add databases or service libraries, or look up functions
      at runtime, so there's no need for a lock to protect our tables.
    See ../option-groups.def for the details.  */
-#ifdef OPTION_EGLIBC_NSSWITCH
+#if __OPTION_EGLIBC_NSSWITCH
 
 /* Prototypes for the local functions.  */
 static name_database *nss_parse_file (const char *fname) internal_function;
@@ -94,7 +95,7 @@
 /* The root of the whole data base.  */
 static name_database *service_table;
 
-#else /* OPTION_EGLIBC_NSSWITCH */
+#else /* __OPTION_EGLIBC_NSSWITCH */
 
 /* Bring in the statically initialized service table we generated at
    build time.  */
@@ -106,7 +107,7 @@
 #define lock_nsswitch (0)
 #define unlock_nsswitch (0)
 
-#endif /* OPTION_EGLIBC_NSSWITCH */
+#endif /* __OPTION_EGLIBC_NSSWITCH */
 
 
 /* -1 == database not found
@@ -126,7 +127,7 @@
       return 0;
     }
 
-#ifdef OPTION_EGLIBC_NSSWITCH
+#if __OPTION_EGLIBC_NSSWITCH
   /* Are we initialized yet?  */
   if (service_table == NULL)
     /* Read config file.  */
@@ -153,7 +154,7 @@
 	    *ni = entry->service;
     }
 
-#ifdef OPTION_EGLIBC_NSSWITCH
+#if __OPTION_EGLIBC_NSSWITCH
   /* No configuration data is available, either because nsswitch.conf
      doesn't exist or because it doesn't has a line for this database.
 
@@ -244,7 +245,7 @@
 libc_hidden_def (__nss_next)
 
 
-#ifdef OPTION_EGLIBC_NSSWITCH
+#if __OPTION_EGLIBC_NSSWITCH
 int
 __nss_configure_lookup (const char *dbname, const char *service_line)
 {
@@ -458,7 +459,7 @@
 libc_hidden_def (__nss_lookup_function)
 
 
-#else /* below if ! defined (OPTION_EGLIBC_NSSWITCH) */
+#else /* below if ! __OPTION_EGLIBC_NSSWITCH */
 
 
 int
@@ -487,7 +488,7 @@
 #endif
 
 
-#ifdef OPTION_EGLIBC_NSSWITCH
+#if __OPTION_EGLIBC_NSSWITCH
 static name_database *
 internal_function
 nss_parse_file (const char *fname)
@@ -770,10 +771,10 @@
 
   return *currentp;
 }
-#endif /* OPTION_EGLIBC_NSSWITCH */
+#endif /* __OPTION_EGLIBC_NSSWITCH */
 
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
 /* Called by nscd and nscd alone.  */
 void
 __nss_disable_nscd (void)
@@ -784,10 +785,10 @@
   __nss_not_use_nscd_hosts = -1;
   __nss_not_use_nscd_services = -1;
 }
-#endif /* OPTION_EGLIBC_INET */
+#endif /* __OPTION_EGLIBC_INET */
 
 
-#ifdef OPTION_EGLIBC_NSSWITCH
+#if __OPTION_EGLIBC_NSSWITCH
 /* Free all resources if necessary.  */
 libc_freeres_fn (free_mem)
 {
@@ -837,4 +838,4 @@
 
   free (top);
 }
-#endif /* OPTION_EGLIBC_NSSWITCH */
+#endif /* __OPTION_EGLIBC_NSSWITCH */
Index: nss/getent.c
===================================================================
--- nss/getent.c	(revision 4012)
+++ nss/getent.c	(working copy)
@@ -38,6 +38,7 @@
 #include <netinet/ether.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
+#include <gnu/option-groups.h>
 
 /* Get libc version number.  */
 #include <version.h>
@@ -88,7 +89,7 @@
   fprintf (stream, gettext ("Written by %s.\n"), "Thorsten Kukuk");
 }
 
-#ifdef OPTION_EGLIBC_DB_ALIASES
+#if __OPTION_EGLIBC_DB_ALIASES
 /* This is for aliases */
 static inline void
 print_aliases (struct aliasent *alias)
@@ -133,9 +134,9 @@
 
   return result;
 }
-#endif /* OPTION_EGLIBC_DB_ALIASES */
+#endif /* __OPTION_EGLIBC_DB_ALIASES */
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
 /* This is for ethers */
 static int
 ethers_keys (int number, char *key[])
@@ -179,7 +180,7 @@
 
   return result;
 }
-#endif /* OPTION_EGLIBC_INET */
+#endif /* __OPTION_EGLIBC_INET */
 
 /* This is for group */
 static inline void
@@ -238,7 +239,7 @@
   return result;
 }
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
 /* This is for hosts */
 static void
 print_hosts (struct hostent *host)
@@ -474,7 +475,7 @@
 
   return result;
 }
-#endif /* OPTION_EGLIBC_INET */
+#endif /* __OPTION_EGLIBC_INET */
 
 /* Now is all for passwd */
 static inline void
@@ -527,7 +528,7 @@
   return result;
 }
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
 /* This is for protocols */
 static inline void
 print_protocols (struct protoent *proto)
@@ -679,7 +680,7 @@
 
   return result;
 }
-#endif /* OPTION_EGLIBC_INET */
+#endif /* __OPTION_EGLIBC_INET */
 
 /* This is for shadow */
 static void
@@ -747,13 +748,13 @@
   {
 #define D(name) { #name, name ## _keys },
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
 #define DN(name) D(name)
 #else
 #define DN(name)
 #endif
 
-#ifdef OPTION_EGLIBC_DB_ALIASES
+#if __OPTION_EGLIBC_DB_ALIASES
 #define DA(name) D(name)
 #else
 #define DA(name)
Index: string/Makefile
===================================================================
--- string/Makefile	(revision 4012)
+++ string/Makefile	(working copy)
@@ -67,11 +67,7 @@
 
 include ../Rules
 
-OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
-	= -DOPTION_EGLIBC_LOCALE_CODE
 
-CFLAGS-strerror_l.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-
 tester-ENV = LANGUAGE=C
 inl-tester-ENV = LANGUAGE=C
 noinl-tester-ENV = LANGUAGE=C
Index: string/strerror_l.c
===================================================================
--- string/strerror_l.c	(revision 4012)
+++ string/strerror_l.c	(working copy)
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/param.h>
+#include <gnu/option-groups.h>
 
 
 static __thread char *last_value;
@@ -30,7 +31,7 @@
 static const char *
 translate (const char *str, locale_t loc)
 {
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
   locale_t oldloc = __uselocale (loc);
   const char *res = _(str);
   __uselocale (oldloc);
Index: iconv/gconv_db.c
===================================================================
--- iconv/gconv_db.c	(revision 4012)
+++ iconv/gconv_db.c	(working copy)
@@ -27,6 +27,7 @@
 #include <sys/param.h>
 #include <bits/libc-lock.h>
 #include <locale/localeinfo.h>
+#include <gnu/option-groups.h>
 
 #include <dlfcn.h>
 #include <gconv_int.h>
@@ -827,7 +828,7 @@
 /* Free all resources if necessary.  */
 libc_freeres_fn (free_mem)
 {
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
   /* First free locale memory.  This needs to be done before freeing derivations,
      as ctype cleanup functions dereference steps arrays which we free below.  */
   _nl_locale_subfreeres ();
Index: iconv/Makefile
===================================================================
--- iconv/Makefile	(revision 4012)
+++ iconv/Makefile	(working copy)
@@ -38,20 +38,13 @@
 CFLAGS-gconv_simple.c = -DSTATIC_GCONV
 endif
 
-OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
-	= -DOPTION_EGLIBC_LOCALE_CODE
-
-CFLAGS-gconv_db.c += $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-CFLAGS-gconv_trans.c += $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-
 vpath %.c ../locale/programs ../intl
 
 iconv_prog-modules = iconv_charmap charmap charmap-dir linereader \
 		     dummy-repertoire simple-hash xstrdup xmalloc
 iconvconfig-modules = strtab xmalloc hash-string
 extra-objs	   = $(iconv_prog-modules:=.o) $(iconvconfig-modules:=.o)
-CFLAGS-iconv_prog.c = -I../locale/programs \
-		      $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
+CFLAGS-iconv_prog.c = -I../locale/programs
 CFLAGS-iconv_charmap.c = -I../locale/programs
 CFLAGS-dummy-repertoire.c = -I../locale/programs
 CFLAGS-charmap.c = -DCHARMAP_PATH='"$(i18ndir)/charmaps"' \
Index: iconv/iconv_prog.c
===================================================================
--- iconv/iconv_prog.c	(revision 4012)
+++ iconv/iconv_prog.c	(working copy)
@@ -36,6 +36,7 @@
 #ifdef _POSIX_MAPPED_FILES
 # include <sys/mman.h>
 #endif
+#include <gnu/option-groups.h>
 #include <charmap.h>
 #include <gconv_int.h>
 #include "iconv_prog.h"
@@ -230,7 +231,7 @@
 	      bool to_wrong =
 		(iconv_open (to_code, "UTF-8") == (iconv_t) -1
 		 && errno == EINVAL);
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
 	      const char *from_pretty =
 		(from_code[0] ? from_code : nl_langinfo (CODESET));
 	      const char *to_pretty =
Index: iconv/gconv_trans.c
===================================================================
--- iconv/gconv_trans.c	(revision 4012)
+++ iconv/gconv_trans.c	(working copy)
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <stdlib.h>
+#include <gnu/option-groups.h>
 
 #include <bits/libc-lock.h>
 #include "gconv_int.h"
@@ -60,7 +61,7 @@
     PTR_DEMANGLE (fct);
 #endif
 
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
   /* If there is no transliteration information in the locale don't do
      anything and return the error.  */
   size = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_TRANSLIT_TAB_SIZE);
Index: locale/xlocale.c
===================================================================
--- locale/xlocale.c	(revision 4012)
+++ locale/xlocale.c	(working copy)
@@ -19,6 +19,7 @@
    02111-1307 USA.  */
 
 #include <locale.h>
+#include <gnu/option-groups.h>
 #include "localeinfo.h"
 
 #define DEFINE_CATEGORY(category, category_name, items, a) \
@@ -32,7 +33,7 @@
    strong reference to the 'class', 'toupper', and 'tolower' tables
    will cause C-ctype.o to be brought in, as it should be, even when
    the reference to _nl_C_LC_CTYPE will be weak.)  */
-#ifndef OPTION_EGLIBC_LOCALE_CODE
+#if ! __OPTION_EGLIBC_LOCALE_CODE
 # define DEFINE_CATEGORY(category, category_name, items, a) \
   weak_extern (_nl_C_##category)
 # include "categories.def"
@@ -68,7 +69,7 @@
   };
 
 
-#ifndef OPTION_EGLIBC_LOCALE_CODE
+#if ! __OPTION_EGLIBC_LOCALE_CODE
 /* When locale code is enabled, these are each defined in the
    appropriate lc-CATEGORY.c file, so that static links (when __thread
    is supported) bring in only those lc-CATEGORY.o files for
@@ -77,7 +78,7 @@
 
    When locale code is disabled, the _nl_C_CATEGORY objects are the
    only possible referents.  At the moment, there isn't a way to get
-   OPTION_EGLIBC_LOCALE_CODE defined in every compilation unit that
+   __OPTION_EGLIBC_LOCALE_CODE defined in every compilation unit that
    #includes localeinfo.h, so we can't just turn off
    NL_CURRENT_INDIRECT.  So we'll define the _nl_current_CATEGORY
    pointers here.  */
@@ -88,4 +89,4 @@
 #include "categories.def"
 #undef DEFINE_CATEGORY
 #endif
-#endif /* OPTION_EGLIBC_LOCALE_CODE */
+#endif /* __OPTION_EGLIBC_LOCALE_CODE */
Index: locale/Makefile
===================================================================
--- locale/Makefile	(revision 4012)
+++ locale/Makefile	(working copy)
@@ -114,20 +114,12 @@
 		   -DLOCSRCDIR='"$(i18ndir)/locales"' -DHAVE_CONFIG_H \
 		   -Iprograms
 
-OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
-	= -DOPTION_EGLIBC_LOCALE_CODE
-OPTION_POSIX_REGEXP-CFLAGS-$(OPTION_POSIX_REGEXP) \
-	= -DOPTION_POSIX_REGEXP
-
-CFLAGS-C-ctype.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-CFLAGS-xlocale.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
 CFLAGS-charmap.c = -Wno-write-strings -Wno-char-subscripts
 CFLAGS-locfile.c = -Wno-write-strings -Wno-char-subscripts
 CFLAGS-charmap-dir.c = -Wno-write-strings
 ifneq (y,$(OPTION_EGLIBC_SPAWN))
 CFLAGS-charmap-dir.c += -DNO_UNCOMPRESS
 endif
-CFLAGS-ld-messages.c = $(OPTION_POSIX_REGEXP-CFLAGS-y)
 
 # This makes sure -DNOT_IN_libc is passed for all these modules.
 cpp-srcs-left := $(addsuffix .c,$(localedef-modules) $(localedef-aux) \
Index: locale/C-ctype.c
===================================================================
--- locale/C-ctype.c	(revision 4012)
+++ locale/C-ctype.c	(working copy)
@@ -19,8 +19,9 @@
 
 #include "localeinfo.h"
 #include <endian.h>
+#include <gnu/option-groups.h>
 
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
 #include "C-translit.h"
 #endif
 
@@ -649,7 +650,7 @@
     { .word = L'7' },
     { .word = L'8' },
     { .word = L'9' },
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
     /* _NL_CTYPE_TRANSLIT_TAB_SIZE */
     { .word = NTRANSLIT },
     /* _NL_CTYPE_TRANSLIT_FROM_IDX */
Index: locale/programs/ld-messages.c
===================================================================
--- locale/programs/ld-messages.c	(revision 4012)
+++ locale/programs/ld-messages.c	(working copy)
@@ -25,6 +25,7 @@
 #include <regex.h>
 #include <string.h>
 #include <sys/uio.h>
+#include <gnu/option-groups.h>
 
 #include <assert.h>
 
@@ -124,7 +125,7 @@
     }
   else
     {
-#ifdef OPTION_POSIX_REGEXP
+#if __OPTION_POSIX_REGEXP
       int result;
       regex_t re;
 
@@ -160,7 +161,7 @@
     }
   else
     {
-#ifdef OPTION_POSIX_REGEXP
+#if __OPTION_POSIX_REGEXP
       int result;
       regex_t re;
 
Index: argp/argp-help.c
===================================================================
--- argp/argp-help.c	(revision 4012)
+++ argp/argp-help.c	(working copy)
@@ -52,6 +52,7 @@
 #ifdef _LIBC
 # include <../libio/libioP.h>
 # include <wchar.h>
+# include <gnu/option-groups.h>
 #endif
 
 #ifndef _
@@ -1877,7 +1878,7 @@
 #ifdef USE_IN_LIBIO
 	  if (_IO_fwide (stream, 0) > 0)
             {
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if ! _LIBC || __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
               putwc_unlocked (L'\n', stream);
 #else
               abort ();
Index: argp/argp-fmtstream.c
===================================================================
--- argp/argp-fmtstream.c	(revision 4012)
+++ argp/argp-fmtstream.c	(working copy)
@@ -43,6 +43,7 @@
 #if defined _LIBC && defined USE_IN_LIBIO
 # include <wchar.h>
 # include <libio/libioP.h>
+# include <gnu/option-groups.h>
 # define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
 #endif
 
@@ -153,7 +154,7 @@
 #ifdef USE_IN_LIBIO
 		  if (_IO_fwide (fs->stream, 0) > 0)
                     {
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if ! _LIBC || __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
                       putwc_unlocked (L' ', fs->stream);
 #else
                       abort ();
Index: argp/Makefile
===================================================================
--- argp/Makefile	(revision 4012)
+++ argp/Makefile	(working copy)
@@ -30,13 +30,9 @@
 
 tests		= argp-test tst-argp1 bug-argp1 tst-argp2
 
-OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-$(OPTION_POSIX_WIDE_CHAR_DEVICE_IO) \
-	= -DOPTION_POSIX_WIDE_CHAR_DEVICE_IO
-
-CFLAGS-argp-help.c = $(uses-callbacks) -fexceptions \
-	             $(OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-y)
+CFLAGS-argp-help.c = $(uses-callbacks) -fexceptions
 CFLAGS-argp-parse.c = $(uses-callbacks)
-CFLAGS-argp-fmtstream.c = -fexceptions $(OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-y)
+CFLAGS-argp-fmtstream.c = -fexceptions
 
 bug-argp1-ARGS = -- --help
 
Index: nptl/Makefile
===================================================================
--- nptl/Makefile	(revision 4012)
+++ nptl/Makefile	(working copy)
@@ -158,9 +158,6 @@
 CFLAGS-cancellation.c = -fasynchronous-unwind-tables
 CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
 
-OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) := -DOPTION_EGLIBC_INET
-CFLAGS-pthread_create.c := $(OPTION_EGLIBC_INET-CFLAGS-y)
-
 # Calling pthread_exit() must cause the registered cancel handlers to
 # be executed.  Therefore exceptions have to be thrown through this
 # function.
Index: nptl/pthread_create.c
===================================================================
--- nptl/pthread_create.c	(revision 4012)
+++ nptl/pthread_create.c	(working copy)
@@ -28,6 +28,7 @@
 #include <libc-internal.h>
 #include <resolv.h>
 #include <kernel-features.h>
+#include <gnu/option-groups.h>
 
 #include <shlib-compat.h>
 
@@ -236,7 +237,7 @@
   THREAD_SETMEM (pd, cpuclock_offset, now);
 #endif
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
   /* Initialize resolver state pointer.  */
   __resp = &pd->res;
 #endif
@@ -305,7 +306,7 @@
   /* Run the destructor for the thread-local data.  */
   __nptl_deallocate_tsd ();
 
-#ifdef OPTION_EGLIBC_INET
+#if __OPTION_EGLIBC_INET
   /* Clean up any state libc stored in thread-local variables.  */
   __libc_thread_freeres ();
 #endif
Index: posix/glob.c
===================================================================
--- posix/glob.c	(revision 4012)
+++ posix/glob.c	(working copy)
@@ -27,6 +27,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stddef.h>
+#ifdef _LIBC
+# include <gnu/option-groups.h>
+#endif
 
 /* Outcomment the following line for production quality code.  */
 /* #define NDEBUG 1 */
@@ -566,7 +569,7 @@
 	  if (home_dir == NULL || home_dir[0] == '\0')
             home_dir = "c:/users/default"; /* poor default */
 #  else
-#   if OPTION_EGLIBC_GETLOGIN
+#   if ! _LIBC || __OPTION_EGLIBC_GETLOGIN
 	  if (home_dir == NULL || home_dir[0] == '\0')
 	    {
 	      int success;
@@ -621,7 +624,7 @@
 		    home_dir = p->pw_dir;
 		}
 	    }
-#   endif /* OPTION_EGLIBC_GETLOGIN */
+#   endif /* ! _LIBC || __OPTION_EGLIBC_GETLOGIN */
 	  if (home_dir == NULL || home_dir[0] == '\0')
 	    {
 	      if (flags & GLOB_TILDE_CHECK)
Index: posix/bug-regex1.c
===================================================================
--- posix/bug-regex1.c	(revision 4012)
+++ posix/bug-regex1.c	(working copy)
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <regex.h>
 #include <wchar.h>
+#include <gnu/option-groups.h>
 
 int
 main (void)
@@ -17,7 +18,7 @@
   memset (&regex, '\0', sizeof (regex));
 
   setlocale (LC_ALL, "de_DE.ISO-8859-1");
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
   fwide (stdout, -1);
 #endif
 
Index: posix/Makefile
===================================================================
--- posix/Makefile	(revision 4013)
+++ posix/Makefile	(working copy)
@@ -155,10 +155,6 @@
 # eglibc: endif
 
 OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
-OPTION_EGLIBC_GETLOGIN-CFLAGS-$(OPTION_EGLIBC_GETLOGIN) \
-	= -DOPTION_EGLIBC_GETLOGIN
-OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-$(OPTION_POSIX_WIDE_CHAR_DEVICE_IO) \
-	= -DOPTION_POSIX_WIDE_CHAR_DEVICE_IO
 
 CFLAGS-regex.c = -Wno-strict-prototypes
 CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions $(OPTION_EGLIBC_INET-CFLAGS-y)
@@ -183,8 +179,7 @@
 CFLAGS-spawni.c = -fexceptions
 CFLAGS-spawni.os = -fomit-frame-pointer
 CFLAGS-pause.c = -fexceptions
-CFLAGS-glob.c = $(uses-callbacks) -fexceptions \
-		$(OPTION_EGLIBC_GETLOGIN-CFLAGS-y)
+CFLAGS-glob.c = $(uses-callbacks) -fexceptions
 CFLAGS-glob64.c = $(uses-callbacks) -fexceptions
 CFLAGS-getconf.c = -DGETCONF_DIR='"$(libexecdir)/getconf"'
 CFLAGS-execve.os = -fomit-frame-pointer
@@ -194,7 +189,6 @@
 CFLAGS-execl.os = -fomit-frame-pointer
 CFLAGS-execvp.os = -fomit-frame-pointer
 CFLAGS-execlp.os = -fomit-frame-pointer
-CFLAGS-bug-regex1.c = $(OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-y)
 
 tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
 		--none random --col --color --colour
Index: stdio-common/printf_fp.c
===================================================================
--- stdio-common/printf_fp.c	(revision 4012)
+++ stdio-common/printf_fp.c	(working copy)
@@ -39,6 +39,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <wchar.h>
+#include <gnu/option-groups.h>
 
 #ifdef COMPILE_WPRINTF
 # define CHAR_T        wchar_t
@@ -262,7 +263,7 @@
 
 
   /* Figure out the decimal point character.  */
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
   if (info->extra == 0)
     {
       decimal = _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
@@ -288,7 +289,7 @@
   decimalwc = L'.';
 #endif
 
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
   if (info->group)
     {
       if (info->extra == 0)
Index: stdio-common/printf_fphex.c
===================================================================
--- stdio-common/printf_fphex.c	(revision 4012)
+++ stdio-common/printf_fphex.c	(working copy)
@@ -29,6 +29,7 @@
 #include "_itoa.h"
 #include "_itowa.h"
 #include <locale/localeinfo.h>
+#include <gnu/option-groups.h>
 
 /* #define NDEBUG 1*/		/* Undefine this for debugging assertions.  */
 #include <assert.h>
@@ -148,7 +149,7 @@
 
 
   /* Figure out the decimal point character.  */
-#ifdef OPTION_EGLIBC_LOCALE_CODE
+#if __OPTION_EGLIBC_LOCALE_CODE
   if (info->extra == 0)
     {
       decimal = _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT);
Index: stdio-common/tst-popen.c
===================================================================
--- stdio-common/tst-popen.c	(revision 4012)
+++ stdio-common/tst-popen.c	(working copy)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <wchar.h>
+#include <gnu/option-groups.h>
 
 static int
 do_test (void)
@@ -35,7 +36,7 @@
       return 1;
     }
 
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
   /* POSIX says that pipe streams are byte-oriented.  */
   if (fwide (f, 0) >= 0)
     {
Index: stdio-common/Makefile
===================================================================
--- stdio-common/Makefile	(revision 4012)
+++ stdio-common/Makefile	(working copy)
@@ -85,11 +85,6 @@
 	$(SHELL) -e tst-printf.sh $(common-objpfx) '$(run-program-prefix)'
 # eglibc: endif
 
-OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
-	= -DOPTION_EGLIBC_LOCALE_CODE
-OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-$(OPTION_POSIX_WIDE_CHAR_DEVICE_IO) \
-	= -DOPTION_POSIX_WIDE_CHAR_DEVICE_IO
-
 CFLAGS-vfprintf.c = -Wno-uninitialized
 CFLAGS-vfwprintf.c = -Wno-uninitialized
 CFLAGS-tst-printf.c = -Wno-format
@@ -97,9 +92,6 @@
 CFLAGS-scanf4.c = -Wno-format
 CFLAGS-scanf7.c = -Wno-format
 CFLAGS-tst-printfsz.c = -Wno-format
-CFLAGS-printf_fp.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-CFLAGS-printf_fphex.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)
-CFLAGS-fxprintf.c = $(OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-y)
 
 CFLAGS-tmpfile.c = -fexceptions
 CFLAGS-tmpfile64.c = -fexceptions
@@ -122,7 +114,6 @@
 CFLAGS-isoc99_scanf.c += $(exceptions)
 CFLAGS-errlist.c = $(fno-unit-at-a-time)
 CFLAGS-siglist.c = $(fno-unit-at-a-time)
-CFLAGS-tst-popen.c = $(OPTION_POSIX_WIDE_CHAR_DEVICE_IO-CFLAGS-y)
 
 # The following is a hack since we must compile scanf15.c without any
 # GNU extension.  The latter are needed, though, when internal headers
Index: stdio-common/fxprintf.c
===================================================================
--- stdio-common/fxprintf.c	(revision 4012)
+++ stdio-common/fxprintf.c	(working copy)
@@ -24,6 +24,7 @@
 #include <wchar.h>
 #include <string.h>
 #include <libioP.h>
+#include <gnu/option-groups.h>
 
 
 int
@@ -38,7 +39,7 @@
   int res;
   if (_IO_fwide (fp, 0) > 0)
     {
-#ifdef OPTION_POSIX_WIDE_CHAR_DEVICE_IO
+#if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO
       size_t len = strlen (fmt) + 1;
       wchar_t wfmt[len];
       for (size_t i = 0; i < len; ++i)
Index: libidn/toutf8.c
===================================================================
--- libidn/toutf8.c	(revision 4012)
+++ libidn/toutf8.c	(working copy)
@@ -35,6 +35,11 @@
 /* Get strlen. */
 #include <string.h>
 
+/* Get __OPTION_EGLIBC_LOCALE_CODE.  */
+#ifdef _LIBC
+# include <gnu/option-groups.h>
+#endif
+
 /* Get iconv_string. */
 #include "iconvme.h"
 
@@ -49,7 +54,7 @@
 #endif
 
 #ifdef _LIBC
-# ifdef OPTION_EGLIBC_LOCALE_CODE
+# if __OPTION_EGLIBC_LOCALE_CODE
 #  define stringprep_locale_charset() nl_langinfo (CODESET)
 # else
 #  define stringprep_locale_charset() "ANSI_X3.4-1968"
Index: libidn/Makefile
===================================================================
--- libidn/Makefile	(revision 4012)
+++ libidn/Makefile	(working copy)
@@ -39,8 +39,3 @@
 include $(..)Rules
 
 $(objpfx)libcidn.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
-
-OPTION_EGLIBC_LOCALE_CODE-CFLAGS-$(OPTION_EGLIBC_LOCALE_CODE) \
-	= -DOPTION_EGLIBC_LOCALE_CODE
-
-CFLAGS-toutf8.c = $(OPTION_EGLIBC_LOCALE_CODE-CFLAGS-y)