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

[patches] OPTION_EGLIBC_INET option group committed



After some more testing, I've committed the following:

ChangeLog.eglibc:
2007-04-20  Jim Blandy  <jimb@xxxxxxxxxxxxxxxx>

	Add the OPTION_EGLIBC_INET option group.

	* option-groups.def (OPTION_EGLIBC_INET): New entry.
	* option-groups.defaults (OPTION_EGLIBC_INET): Initialize.
	* option-groups.mak: Add initializer for aux-y.
	* Makerules (aux): Add in contents of aux-y.
	* extra-lib.mk (all-$(lib)-routines): Include $($(lib)-routines-y)
	in the list.
	(cpp-srcs-left): Refer $(all-$(lib)-routines) instead of spelling
	its value out.
	* nscd/Makefile: include option-groups.mak.
	(routines, aux, others, install-sbin, extra-objs): Place
	everything here in the option group.
	* pwd/Makefile: include option-groups.mak.
	(CFLAGS-getpwuid_r.c, CFLAGS-getpwnam_r.c): Define USE_NSCD only
	if OPTION_EGLIBC_INET is enabled.
	* misc/Makefile: include option-groups.mak.
	* sysdeps/unix/sysv/linux/gethostid.c [!OPTION_EGLIBC_INET]: Don't
	try to look up our IP address; just return a dummy value.
	* sysdeps/unix/sysv/linux/Makefile: #define OPTION_EGLIBC_INET
	appropriately when compiling gethostid.c.
	* inet/Makefile: include option-groups.mak.
	(routines, aux): Place all routines in the option group.
	* nss/Makefile: include option-groups.mak.
	(databases): Put proto, service, hosts, network, rpc, ethers,
	netgrp, key, and aliases database in option group.  Move
	assignment to 'databases' above assignment to 'routines', since we
	generate some of the latter from the former.
	(routines): Put digits_dots in option group.
	(tests): Put test-netdb in option group.
	(xtests): Put bug-erange in option group.
	(CFLAGS-nsswitch.c, CFLAGS-getnssent_r.c, CFLAGS-getent.c): #define
	OPTION_EGLIBC_INET as appropriate.
	* nss/getnssent_r.c (__nss_setent, __nss_endent, __nss_getent_r):
	Don't try to initialize resolver state unless the option group is
	enabled.
	* nss/nssswitch.c (__nss_disable_nscd): Define this only if
	the option group is enabled.
	* nss/getent.c (print_aliases, aliases_keys, ethers_keys,
	print_hosts, hosts_keys, ahosts_keys_int, ahosts_keys,
	ahostsv4_keys, ahostsv6_keys, netgroup_keys, print_networks,
	networks_keys, print_protocols, protocols_keys, print_rpc,
	rpc_keys, print_services, services_keys): Define only #if
	OPTION_EGLIBC_INET.
	(DN): New macro.
	(databases): Make entries for ahosts, ahostsv4, ahostsv6, aliases,
	ethers, hosts, netgroup, networks, protocols, rpc, and services
	present only if option group is enabled.
	* hesiod/Makefile (extra-libs, extra-libs-others): Place all
	libraries in option group.
	* grp/Makefile: include option-groups.mak.
	(CFLAGS-getgruid_r.c, CFLAGS-getgrnam_r.c, CFLAGS-initgroups.c):
	Define USE_NSCD only if OPTION_EGLIBC_INET is enabled.
	* nptl/Makefile: include option-groups.mak.
	(libpthread-routines): Move 'herrno' and 'res' into the option
	group.
	(CFLAGS-pthread_create.c): Define OPTION_EGLIBC_INET as
	appropriate.
	* nptl/pthread_create.c (start_thread): Initialize and free
	__resp only when OPTION_EGLIBC_INET is #defined.
	* posix/Makefile: include option-groups.mak.
	(routines): Put getaddrinfo and gai_strerror in the option group.
	(tests): Move tst-getaddrinfo, bug-ga1, tst-getaddrinfo2,
	tst-rfc3484, tst-rfc3484-2, tst-getaddrinfo3, and bug-ga2 into the
	option group.
	(CFLAGS-getaddrinfo.c): #define USE_NSCD only if the option group
	is enabled.
	* resolv/Makefile: include option-groups.mak.
	(routines, tests, xtests, extra-libs, extra-libs-others): Move
	everything into the option group.
	(tests): Only add ga_test as a dependency if the option group is
	enabled.
	* sunrpc/Makefile: include option-groups.mak.
	(install-others, routines, others, install-bin, install-sbin)
	(extra-objs, tests, xtests, extra-libs, extra-libs-others): Move
	everything into the option group.
	* nis/Makefile: include option-groups.mak.
	(services, extra-libs, extra-libs-others): Move everything into
	the option group.

	* option-groups.mak (extra-libs-y, extra-libs-others-y): Add
	missing initializers.

	* nss/getnssent_r.c (__nss_getent_r): Pass h_errnop through to the
	getent function, not &h_errno.

Index: nscd/Makefile
===================================================================
--- nscd/Makefile	(revision 2089)
+++ nscd/Makefile	(revision 2090)
@@ -20,10 +20,13 @@
 #
 #	Sub-makefile for nscd portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= nscd
 
-routines := nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai nscd_initgroups
-aux	:= nscd_helper
+routines-$(OPTION_EGLIBC_INET) += \
+	   nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai nscd_initgroups
+aux-$(OPTION_EGLIBC_INET) += nscd_helper
 
 include ../Makeconfig
 
@@ -38,11 +41,11 @@
 ifeq ($(have-thread-library),yes)
 
 ifneq (yesyes,$(have-fpie)$(build-shared))
-others += nscd
+others-$(OPTION_EGLIBC_INET) += nscd
 endif
-install-sbin := nscd
+install-sbin-$(OPTION_EGLIBC_INET) += nscd
 
-extra-objs := $(nscd-modules:=.o)
+extra-objs-$(OPTION_EGLIBC_INET) += $(nscd-modules:=.o)
 
 endif
 
Index: sysdeps/unix/sysv/linux/Makefile
===================================================================
--- sysdeps/unix/sysv/linux/Makefile	(revision 2089)
+++ sysdeps/unix/sysv/linux/Makefile	(revision 2090)
@@ -15,8 +15,11 @@
 sysdep_routines += sysctl clone llseek umount umount2 readahead \
 		   setfsuid setfsgid makedev
 
-CFLAGS-gethostid.c = -fexceptions
 
+inet-CFLAGS-$(OPTION_EGLIBC_INET) = -DOPTION_EGLIBC_INET
+
+CFLAGS-gethostid.c = -fexceptions $(inet-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/gethostid.c
===================================================================
--- sysdeps/unix/sysv/linux/gethostid.c	(revision 2089)
+++ sysdeps/unix/sysv/linux/gethostid.c	(revision 2090)
@@ -91,6 +91,7 @@
 	return id;
     }
 
+#ifdef 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')
@@ -117,5 +118,9 @@
   /* For the return value to be not exactly the IP address we do some
      bit fiddling.  */
   return (int32_t) (in.s_addr << 16 | in.s_addr >> 16);
+#else
+  /* Return an arbitrary value.  */
+  return 0;
+#endif
 }
 #endif
Index: pwd/Makefile
===================================================================
--- pwd/Makefile	(revision 2089)
+++ pwd/Makefile	(revision 2090)
@@ -19,6 +19,8 @@
 #
 #	Sub-makefile for pwd portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= pwd
 headers := pwd.h
 
@@ -32,8 +34,10 @@
 
 ifeq ($(have-thread-library),yes)
 
-CFLAGS-getpwuid_r.c = -DUSE_NSCD=1
-CFLAGS-getpwnam_r.c = -DUSE_NSCD=1
+OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+
+CFLAGS-getpwuid_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
+CFLAGS-getpwnam_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
 CFLAGS-getpwent_r.c = -fexceptions
 CFLAGS-getpwent.c = -fexceptions
 CFLAGS-getpw.c = -fexceptions
Index: misc/Makefile
===================================================================
--- misc/Makefile	(revision 2089)
+++ misc/Makefile	(revision 2090)
@@ -20,6 +20,10 @@
 #	Sub-makefile for misc portion of the library.
 #
 
+# Some system-dependent implementations of these functions use option
+# groups (see sysdeps/unix/sysv/linux/Makefile, for example).
+include ../option-groups.mak
+
 subdir	:= misc
 
 headers	:= sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \
Index: inet/Makefile
===================================================================
--- inet/Makefile	(revision 2089)
+++ inet/Makefile	(revision 2090)
@@ -19,6 +19,8 @@
 #
 #	Sub-makefile for inet portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= inet
 
 headers	:= netinet/ether.h netinet/in.h netinet/in_systm.h \
@@ -28,7 +30,8 @@
 
 distribute := netgroup.h
 
-routines := htonl htons		\
+routines-$(OPTION_EGLIBC_INET) \
+	 += htonl htons \
 	    inet_lnaof inet_mkadr	\
 	    inet_netof inet_ntoa inet_net herrno herrno-loc \
 	    gethstbyad gethstbyad_r gethstbynm gethstbynm2 gethstbynm2_r \
@@ -49,7 +52,7 @@
 	    getipv4sourcefilter setipv4sourcefilter \
 	    getsourcefilter setsourcefilter inet6_opt inet6_rth
 
-aux := check_pf ifreq
+aux-$(OPTION_EGLIBC_INET) += check_pf ifreq
 
 tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \
 	 tst-gethnm test-ifaddrs bug-if1
Index: nss/getnssent_r.c
===================================================================
--- nss/getnssent_r.c	(revision 2089)
+++ nss/getnssent_r.c	(revision 2090)
@@ -60,11 +60,13 @@
   } fct;
   int no_more;
 
+#if OPTION_EGLIBC_INET
   if (res && __res_maybe_init (&_res, 0) == -1)
     {
       __set_h_errno (NETDB_INTERNAL);
       return;
     }
+#endif /* OPTION_EGLIBC_INET */
 
   /* Cycle through the services and run their `setXXent' functions until
      we find an available service.  */
@@ -103,11 +105,13 @@
   } fct;
   int no_more;
 
+#ifdef OPTION_EGLIBC_INET
   if (res && __res_maybe_init (&_res, 0) == -1)
     {
       __set_h_errno (NETDB_INTERNAL);
       return;
     }
+#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);
@@ -143,12 +147,14 @@
   int no_more;
   enum nss_status status;
 
+#ifdef OPTION_EGLIBC_INET
   if (res && __res_maybe_init (&_res, 0) == -1)
     {
       *h_errnop = NETDB_INTERNAL;
       *result = NULL;
       return errno;
     }
+#endif /* OPTION_EGLIBC_INET */
 
   /* Initialize status to return if no more functions are found.  */
   status = NSS_STATUS_NOTFOUND;
@@ -163,7 +169,7 @@
       int is_last_nip = *nip == *last_nip;
 
       status = DL_CALL_FCT (fct.f,
-			    (resbuf, buffer, buflen, &errno, &h_errno));
+			    (resbuf, buffer, buflen, &errno, h_errnop));
 
       /* The the status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
 	 provided buffer is too small.  In this case we should give
Index: nss/Makefile
===================================================================
--- nss/Makefile	(revision 2089)
+++ nss/Makefile	(revision 2090)
@@ -19,6 +19,8 @@
 #
 #	Makefile for name service switch.
 #
+include ../option-groups.mak
+
 subdir	:= nss
 
 headers			:= nss.h
@@ -26,21 +28,24 @@
 			   getXXent.c getXXent_r.c databases.def \
 			   nsswitch.conf digits_dots.c function.def
 
-# This is the trivial part which goes into libc itself.
-routines		= nsswitch getnssent getnssent_r digits_dots \
-			  $(addsuffix -lookup,$(databases))
-
 # These are the databases that go through nss dispatch.
 # Caution: if you add a database here, you must add its real name
 # in databases.def, too.
-databases		= proto service hosts network grp pwd rpc ethers \
-			  spwd netgrp key alias
+databases-y		= grp pwd spwd 
+databases-$(OPTION_EGLIBC_INET) \
+			+= proto service hosts network rpc ethers \
+			   netgrp key alias
 
+# This is the trivial part which goes into libc itself.
+routines-y		+= nsswitch getnssent getnssent_r \
+			  $(addsuffix -lookup,$(databases-y))
+routines-$(OPTION_EGLIBC_INET) += digits_dots
+
 others                  := getent
 install-bin             := getent
 
-tests			= test-netdb
-xtests			= bug-erange
+tests-$(OPTION_EGLIBC_INET) += test-netdb
+xtests-$(OPTION_EGLIBC_INET) += bug-erange
 
 include ../Makeconfig
 
@@ -62,7 +67,7 @@
 vpath %.c $(subdir-dirs)
 
 
-libnss_files-routines	:= $(addprefix files-,$(databases))
+libnss_files-routines	:= $(addprefix files-,$(databases-y))
 distribute		+= files-XXX.c files-parse.c
 
 
@@ -83,3 +88,9 @@
 # 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
+
+CFLAGS-nsswitch.c    = $(OPTION_EGLIBC_INET-CFLAGS-y)
+CFLAGS-getnssent_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y)
+CFLAGS-getent.c      = $(OPTION_EGLIBC_INET-CFLAGS-y)
Index: nss/nsswitch.c
===================================================================
--- nss/nsswitch.c	(revision 2089)
+++ nss/nsswitch.c	(revision 2090)
@@ -700,6 +700,7 @@
 }
 
 
+#ifdef OPTION_EGLIBC_INET
 /* Called by nscd and nscd alone.  */
 void
 __nss_disable_nscd (void)
@@ -709,6 +710,7 @@
   __nss_not_use_nscd_group = -1;
   __nss_not_use_nscd_hosts = -1;
 }
+#endif /* OPTION_EGLIBC_INET */
 
 
 /* Free all resources if necessary.  */
Index: nss/getent.c
===================================================================
--- nss/getent.c	(revision 2089)
+++ nss/getent.c	(revision 2090)
@@ -88,6 +88,7 @@
   fprintf (stream, gettext ("Written by %s.\n"), "Thorsten Kukuk");
 }
 
+#ifdef OPTION_EGLIBC_INET
 /* This is for aliases */
 static inline void
 print_aliases (struct aliasent *alias)
@@ -176,6 +177,7 @@
 
   return result;
 }
+#endif /* OPTION_EGLIBC_INET */
 
 /* This is for group */
 static inline void
@@ -234,6 +236,7 @@
   return result;
 }
 
+#ifdef OPTION_EGLIBC_INET
 /* This is for hosts */
 static void
 print_hosts (struct hostent *host)
@@ -469,6 +472,7 @@
 
   return result;
 }
+#endif /* OPTION_EGLIBC_INET */
 
 /* Now is all for passwd */
 static inline void
@@ -521,6 +525,7 @@
   return result;
 }
 
+#ifdef OPTION_EGLIBC_INET
 /* This is for protocols */
 static inline void
 print_protocols (struct protoent *proto)
@@ -672,6 +677,7 @@
 
   return result;
 }
+#endif /* OPTION_EGLIBC_INET */
 
 /* This is for shadow */
 static void
@@ -738,19 +744,24 @@
   } databases[] =
   {
 #define D(name) { #name, name ## _keys },
-D(ahosts)
-D(ahostsv4)
-D(ahostsv6)
-D(aliases)
-D(ethers)
+#ifdef OPTION_EGLIBC_INET
+#define DN(name) D(name)
+#else
+#define DN(name)
+#endif
+DN(ahosts)
+DN(ahostsv4)
+DN(ahostsv6)
+DN(aliases)
+DN(ethers)
 D(group)
-D(hosts)
-D(netgroup)
-D(networks)
+DN(hosts)
+DN(netgroup)
+DN(networks)
 D(passwd)
-D(protocols)
-D(rpc)
-D(services)
+DN(protocols)
+DN(rpc)
+DN(services)
 D(shadow)
 #undef D
     { NULL, NULL }
Index: hesiod/Makefile
===================================================================
--- hesiod/Makefile	(revision 2089)
+++ hesiod/Makefile	(revision 2090)
@@ -19,12 +19,14 @@
 #
 #	Sub-makefile for hesiod portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= hesiod
 
 distribute := hesiod.h hesiod_p.h README.hesiod nss_hesiod/nss_hesiod.h
 
-extra-libs := libnss_hesiod
-extra-libs-others = $(extra-libs)
+extra-libs-$(OPTION_EGLIBC_INET) += libnss_hesiod
+extra-libs-others-y += $(extra-libs-y)
 
 subdir-dirs = nss_hesiod
 vpath %.c nss_hesiod
Index: grp/Makefile
===================================================================
--- grp/Makefile	(revision 2089)
+++ grp/Makefile	(revision 2090)
@@ -19,6 +19,8 @@
 #
 #	Sub-makefile for grp portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= grp
 headers := grp.h
 
@@ -47,14 +49,16 @@
 
 ifeq ($(have-thread-library),yes)
 
-CFLAGS-getgrgid_r.c = -DUSE_NSCD=1 -fexceptions
-CFLAGS-getgrnam_r.c = -DUSE_NSCD=1 -fexceptions
+OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+
+CFLAGS-getgrgid_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
+CFLAGS-getgrnam_r.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
 CFLAGS-getgrent_r.c = -fexceptions
 CFLAGS-getgrent.c = -fexceptions
 CFLAGS-fgetgrent.c = -fexceptions
 CFLAGS-fgetgrent_r.c = -fexceptions -D_IO_MTSAFE_IO
 CFLAGS-putgrent.c = -fexceptions -D_IO_MTSAFE_IO
-CFLAGS-initgroups.c = -DUSE_NSCD=1 -fexceptions
+CFLAGS-initgroups.c = $(OPTION_EGLIBC_INET-CFLAGS-y) -fexceptions
 CFLAGS-getgrgid.c = -fexceptions
 
 endif
Index: option-groups.mak
===================================================================
--- option-groups.mak	(revision 2089)
+++ option-groups.mak	(revision 2090)
@@ -15,12 +15,16 @@
 # defaults from option-groups.defaults.
 -include $(option_group_config_file)
 
-# Establish 'routines-y', etc. as simply expanded variables.
-routines-y     :=
-others-y       :=
-install-bin-y  :=
-install-sbin-y :=
-extra-objs-y   :=
-tests-y        :=
-xtests-y       :=
-test-srcs-y    :=
+# Establish 'routines-y', etc. as simply-expanded variables.
+aux-y	       	    :=
+extra-libs-others-y :=
+extra-libs-y   	    :=
+extra-objs-y   	    :=
+install-bin-y  	    :=
+install-others-y    :=
+install-sbin-y 	    :=
+others-y       	    :=
+routines-y     	    :=
+test-srcs-y    	    :=   
+tests-y        	    :=
+xtests-y       	    :=
Index: Makerules
===================================================================
--- Makerules	(revision 2089)
+++ Makerules	(revision 2090)
@@ -406,16 +406,18 @@
 endif
 
 # Include targets in the selected option groups.
-routines     	  += $(routines-y)
-others       	  += $(others-y)
+aux		  += $(aux-y)
 extra-libs   	  += $(extra-libs-y)
 extra-libs-others += $(extra-libs-others-y)
+extra-objs   	  += $(extra-objs-y)
 install-bin  	  += $(install-bin-y)
+install-others    += $(install-others-y)
 install-sbin 	  += $(install-sbin-y)
-extra-objs   	  += $(extra-objs-y)
+others       	  += $(others-y)
+routines     	  += $(routines-y)
+test-srcs    	  += $(test-srcs-y)
 tests        	  += $(tests-y)
 xtests       	  += $(xtests-y)
-test-srcs    	  += $(test-srcs-y)
 
 
 # Modify the list of routines we build for different targets
Index: option-groups.defaults
===================================================================
--- option-groups.defaults	(revision 2089)
+++ option-groups.defaults	(revision 2090)
@@ -11,3 +11,4 @@
 OPTION_EGLIBC_CATGETS = y
 OPTION_EGLIBC_LOCALES = y
 OPTION_EGLIBC_LIBM = y
+OPTION_EGLIBC_INET = y
Index: extra-lib.mk
===================================================================
--- extra-lib.mk	(revision 2089)
+++ extra-lib.mk	(revision 2090)
@@ -25,7 +25,9 @@
 extra-objs := $(extra-objs)
 
 # The modules that go in $(lib).
-all-$(lib)-routines := $($(lib)-routines) $($(lib)-sysdep_routines)
+all-$(lib)-routines := $($(lib)-routines)		\
+	               $($(lib)-routines-y)		\
+		       $($(lib)-sysdep_routines)
 
 # Add each flavor of library to the lists of things to build and install.
 install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
@@ -96,7 +98,7 @@
 endif
 
 # This will define `libof-ROUTINE := LIB' for each of the routines.
-cpp-srcs-left := $($(lib)-routines) $($(lib)-sysdep_routines)
+cpp-srcs-left := $(all-$(lib)-routines)
 ifneq (,$(cpp-srcs-left))
 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
 endif
Index: nptl/Makefile
===================================================================
--- nptl/Makefile	(revision 2089)
+++ nptl/Makefile	(revision 2090)
@@ -19,6 +19,8 @@
 #
 #	Sub-makefile for NPTL portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= nptl
 
 headers := pthread.h semaphore.h bits/semaphore.h
@@ -112,7 +114,7 @@
 		      pt-raise pt-system \
 		      flockfile ftrylockfile funlockfile \
 		      sigaction \
-		      herrno res pt-allocrtsig \
+		      pt-allocrtsig \
 		      pthread_kill_other_threads \
 		      pthread_getaffinity pthread_setaffinity \
 		      pthread_attr_getaffinity pthread_attr_setaffinity \
@@ -129,6 +131,8 @@
 #		      pthread_setgid pthread_setegid pthread_setregid \
 #		      pthread_setresgid
 
+libpthread-routines-$(OPTION_EGLIBC_INET) := herrno res 
+
 libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
 libpthread-static-only-routines = pthread_atfork
 
@@ -154,6 +158,9 @@
 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 2089)
+++ nptl/pthread_create.c	(revision 2090)
@@ -235,8 +235,10 @@
   THREAD_SETMEM (pd, cpuclock_offset, now);
 #endif
 
+#ifdef OPTION_EGLIBC_INET
   /* Initialize resolver state pointer.  */
   __resp = &pd->res;
+#endif
 
 #ifdef __NR_set_robust_list
 # ifndef __ASSUME_SET_ROBUST_LIST
@@ -302,8 +304,10 @@
   /* Run the destructor for the thread-local data.  */
   __nptl_deallocate_tsd ();
 
+#ifdef OPTION_EGLIBC_INET
   /* Clean up any state libc stored in thread-local variables.  */
   __libc_thread_freeres ();
+#endif
 
   /* If this is the last thread we terminate the process now.  We
      do not notify the debugger, it might just irritate it if there
Index: option-groups.def
===================================================================
--- option-groups.def	(revision 2089)
+++ option-groups.def	(revision 2090)
@@ -67,3 +67,128 @@
        EGLIBC's math library 'libm'.  If you disable this option
        group, you will not be able to build 'libstdc++' against the
        resulting EGLIBC installation.
+
+config OPTION_EGLIBC_INET
+   bool "Networking support"
+   help
+       This option group includes networking-specific functions and
+       data.  With OPTION_EGLIBC_INET disabled, the EGLIBC
+       installation and API changes as follows:
+
+       - The following libraries are not installed:
+
+         libanl
+         libnsl
+         libnss_compat
+         libnss_dns
+         libnss_hesiod
+         libnss_nis
+         libnss_nisplus
+         libresolv
+         
+       - The following functions and variables are omitted from libc:
+
+         authdes_create           hstrerror              svc_fdset
+         authdes_getucred         htonl                  svc_getreq
+         authdes_pk_create        htons                  svc_getreq_common
+         authnone_create          if_freenameindex       svc_getreq_poll
+         authunix_create          if_indextoname         svc_getreqset
+         authunix_create_default  if_nameindex           svc_max_pollfd
+         bindresvport             if_nametoindex         svc_pollfd
+         callrpc                  in6addr_any            svcraw_create
+         cbc_crypt                in6addr_loopback       svc_register
+         clnt_broadcast           inet6_opt_append       svc_run
+         clnt_create              inet6_opt_find         svc_sendreply
+         clnt_pcreateerror        inet6_opt_finish       svctcp_create
+         clnt_perrno              inet6_opt_get_val      svcudp_bufcreate
+         clnt_perror              inet6_opt_init         svcudp_create
+         clntraw_create           inet6_option_alloc     svcudp_enablecache
+         clnt_spcreateerror       inet6_option_append    svcunix_create
+         clnt_sperrno             inet6_option_find      svcunixfd_create
+         clnt_sperror             inet6_option_init      svc_unregister
+         clnttcp_create           inet6_option_next      user2netname
+         clntudp_bufcreate        inet6_option_space     xdecrypt
+         clntudp_create           inet6_opt_next         xdr_accepted_reply
+         clntunix_create          inet6_opt_set_val      xdr_array
+         des_setparity            inet6_rth_add          xdr_authdes_cred
+         ecb_crypt                inet6_rth_getaddr      xdr_authdes_verf
+         endaliasent              inet6_rth_init         xdr_authunix_parms
+         endhostent               inet6_rth_reverse      xdr_bool
+         endnetent                inet6_rth_segments     xdr_bytes
+         endnetgrent              inet6_rth_space        xdr_callhdr
+         endprotoent              inet_addr              xdr_callmsg
+         endrpcent                inet_aton              xdr_char
+         endservent               inet_lnaof             xdr_cryptkeyarg
+         ether_aton               inet_makeaddr          xdr_cryptkeyarg2
+         ether_aton_r             inet_netof             xdr_cryptkeyres
+         ether_hostton            inet_network           xdr_des_block
+         ether_line               inet_nsap_addr         xdr_double
+         ether_ntoa               inet_nsap_ntoa         xdr_enum
+         ether_ntoa_r             inet_ntoa              xdr_float
+         ether_ntohost            inet_ntop              xdr_free
+         freeaddrinfo             inet_pton              xdr_getcredres
+         freeifaddrs              innetgr                xdr_hyper
+         gai_strerror             iruserok               xdr_int
+         getaddrinfo              iruserok_af            xdr_int16_t
+         getaliasbyname           key_decryptsession     xdr_int32_t
+         getaliasbyname_r         key_decryptsession_pk  xdr_int64_t
+         getaliasent              key_encryptsession     xdr_int8_t
+         getaliasent_r            key_encryptsession_pk  xdr_keybuf
+         gethostbyaddr            key_gendes             xdr_key_netstarg
+         gethostbyaddr_r          key_get_conv           xdr_key_netstres
+         gethostbyname            key_secretkey_is_set   xdr_keystatus
+         gethostbyname2           key_setnet             xdr_long
+         gethostbyname2_r         key_setsecret          xdr_longlong_t
+         gethostbyname_r          netname2host           xdrmem_create
+         gethostent               netname2user           xdr_netnamestr
+         gethostent_r             ntohl                  xdr_netobj
+         getifaddrs               ntohs                  xdr_opaque
+         getipv4sourcefilter      passwd2des             xdr_opaque_auth
+         get_myaddress            pmap_getmaps           xdr_pmap
+         getnameinfo              pmap_getport           xdr_pmaplist
+         getnetbyaddr             pmap_rmtcall           xdr_pointer
+         getnetbyaddr_r           pmap_set               xdr_quad_t
+         getnetbyname             pmap_unset             xdrrec_create
+         getnetbyname_r           rcmd                   xdrrec_endofrecord
+         getnetent                rcmd_af                xdrrec_eof
+         getnetent_r              registerrpc            xdrrec_skiprecord
+         getnetgrent              res_init               xdr_reference
+         getnetgrent_r            rexec                  xdr_rejected_reply
+         getnetname               rexec_af               xdr_replymsg
+         getprotobyname           rexecoptions           xdr_rmtcall_args
+         getprotobyname_r         rpc_createerr          xdr_rmtcallres
+         getprotobynumber         rresvport              xdr_short
+         getprotobynumber_r       rresvport_af           xdr_sizeof
+         getprotoent              rtime                  xdrstdio_create
+         getprotoent_r            ruserok                xdr_string
+         getpublickey             ruserok_af             xdr_u_char
+         getrpcbyname             ruserpass              xdr_u_hyper
+         getrpcbyname_r           setaliasent            xdr_u_int
+         getrpcbynumber           sethostent             xdr_uint16_t
+         getrpcbynumber_r         setipv4sourcefilter    xdr_uint32_t
+         getrpcent                setnetent              xdr_uint64_t
+         getrpcent_r              setnetgrent            xdr_uint8_t
+         getrpcport               setprotoent            xdr_u_long
+         getsecretkey             setrpcent              xdr_u_longlong_t
+         getservbyname            setservent             xdr_union
+         getservbyname_r          setsourcefilter        xdr_unixcred
+         getservbyport            svcauthdes_stats       xdr_u_quad_t
+         getservbyport_r          svcerr_auth            xdr_u_short
+         getservent               svcerr_decode          xdr_vector
+         getservent_r             svcerr_noproc          xdr_void
+         getsourcefilter          svcerr_noprog          xdr_wrapstring
+         h_errlist                svcerr_progvers        xencrypt
+         h_errno                  svcerr_systemerr       xprt_register
+         herror                   svcerr_weakauth        xprt_unregister
+         h_nerr                   svc_exit
+         host2netname             svcfd_create
+
+       - The rpcgen, nscd, and rpcinfo commands are not installed.
+
+       - The 'rpc' file (a text file listing RPC services) is not installed.
+
+       Socket-related system calls do not fall in this option group,
+       because many are also used for other inter-process
+       communication mechanisms.  For example, the 'syslog' routines
+       use Unix-domain sockets to communicate with the syslog daemon;
+       syslog is valuable in non-networked contexts.
Index: posix/Makefile
===================================================================
--- posix/Makefile	(revision 2089)
+++ posix/Makefile	(revision 2090)
@@ -19,6 +19,8 @@
 #
 #	Sub-makefile for POSIX portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= posix
 
 headers	:= sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h	      \
@@ -55,7 +57,7 @@
 	getopt getopt1 getopt_init					      \
 	sched_setp sched_getp sched_sets sched_gets sched_yield sched_primax  \
 	sched_primin sched_rr_gi sched_getaffinity sched_setaffinity	      \
-	getaddrinfo gai_strerror wordexp				      \
+	wordexp								      \
 	pread pwrite pread64 pwrite64					      \
 	spawn_faction_init spawn_faction_destroy spawn_faction_addclose	      \
 	spawn_faction_addopen spawn_faction_adddup2			      \
@@ -68,12 +70,14 @@
 	posix_madvise							      \
 	get_child_max
 
+routines-$(OPTION_EGLIBC_INET) += getaddrinfo gai_strerror 
+
 include ../Makeconfig
 
 aux		:= init-posix environ
 tests		:= tstgetopt testfnm runtests runptests	     \
 		   tst-preadwrite tst-preadwrite64 test-vfork regexbug1 \
-		   tst-getlogin tst-mmap tst-getaddrinfo tst-truncate \
+		   tst-getlogin tst-mmap tst-truncate \
 		   tst-truncate64 tst-fork tst-fnmatch tst-regexloc tst-dir \
 		   tst-chmod bug-regex1 bug-regex2 bug-regex3 bug-regex4 \
 		   tst-gnuglob tst-regex bug-regex5 bug-regex6 bug-regex7 \
@@ -83,14 +87,16 @@
 		   bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
 		   bug-regex25 bug-regex26 tst-nice tst-nanosleep tst-regex2 \
 		   transbug tst-rxspencer tst-pcre tst-boost \
-		   bug-ga1 tst-vfork1 tst-vfork2 tst-waitid \
-		   tst-getaddrinfo2 bug-glob1 bug-glob2 tst-sysconf \
+		   tst-vfork1 tst-vfork2 tst-waitid \
+		   bug-glob1 bug-glob2 tst-sysconf \
 		   tst-execvp1 tst-execvp2 tst-execlp1 tst-execlp2 \
 		   tst-execv1 tst-execv2 tst-execl1 tst-execl2 \
 		   tst-execve1 tst-execve2 tst-execle1 tst-execle2 \
-		   tst-execvp3 tst-execvp4 tst-rfc3484 tst-rfc3484-2 \
-		   tst-getaddrinfo3
-xtests		:= bug-ga2
+		   tst-execvp3 tst-execvp4 
+tests-$(OPTION_EGLIBC_INET) \
+	        += tst-getaddrinfo bug-ga1 tst-getaddrinfo2 \
+		   tst-rfc3484 tst-rfc3484-2 tst-getaddrinfo3
+xtests-$(OPTION_EGLIBC_INET) += bug-ga2
 ifeq (yes,$(build-shared))
 test-srcs	:= globtest
 tests           += wordexp-test tst-exec tst-spawn
@@ -133,8 +139,10 @@
 endif
 # eglibc: endif
 
+OPTION_EGLIBC_INET-CFLAGS-$(OPTION_EGLIBC_INET) = -DUSE_NSCD=1
+
 CFLAGS-regex.c = -Wno-strict-prototypes
-CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions -DUSE_NSCD
+CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions $(OPTION_EGLIBC_INET-CFLAGS-y)
 CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
Index: sunrpc/Makefile
===================================================================
--- sunrpc/Makefile	(revision 2089)
+++ sunrpc/Makefile	(revision 2090)
@@ -19,6 +19,8 @@
 #
 #	Sub-makefile for sunrpc portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= sunrpc
 
 # The code in this subdirectory is taken from Sun's RPCSRC-4.0
@@ -52,12 +54,12 @@
 			   svc_auth.h types.h xdr.h auth_des.h \
 			   des_crypt.h key_prot.h rpc_des.h) \
 	  $(rpcsvc:%=rpcsvc/%) rpcsvc/bootparam.h
-install-others = $(inst_sysconfdir)/rpc
 generated = $(rpcsvc:%.x=rpcsvc/%.h) $(rpcsvc:%.x=x%.c) $(rpcsvc:%.x=x%.stmp) \
 	    $(rpcsvc:%.x=rpcsvc/%.stmp) rpcgen
 generated-dirs := rpcsvc
 
-routines := auth_none auth_unix authuxprot bindrsvprt \
+routines-$(OPTION_EGLIBC_INET) \
+         += auth_none auth_unix authuxprot bindrsvprt \
 	    clnt_gen clnt_perr clnt_raw clnt_simp clnt_tcp \
 	    clnt_udp rpc_dtable get_myaddr getrpcport \
 	    pmap_clnt pm_getmaps pm_getport pmap_prot \
@@ -69,9 +71,9 @@
 	    key_call key_prot netname openchild rtime svcauth_des xcrypt\
 	    clnt_unix svc_unix create_xid xdr_intXX_t
 
-others := rpcinfo
-install-bin := rpcgen
-install-sbin := rpcinfo
+others-$(OPTION_EGLIBC_INET) += rpcinfo
+install-bin-$(OPTION_EGLIBC_INET) += rpcgen
+install-sbin-$(OPTION_EGLIBC_INET) += rpcinfo
 rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
 	      rpc_scan.o rpc_util.o rpc_svcout.o rpc_clntout.o \
 	      rpc_tblout.o rpc_sample.o
@@ -79,17 +81,19 @@
 distribute := proto.h rpc_util.h rpc_parse.h rpc_scan.h \
 	      $(rpcgen-objs:.o=.c) etc.rpc \
 	      errqueue.h
-extra-objs = $(rpcgen-objs)
+extra-objs-$(OPTION_EGLIBC_INET) += $(rpcgen-objs)
 
 all: # Make this the default target; it will be defined in Rules.
 
 include ../Makeconfig
 
-tests = tst-xdrmem tst-xdrmem2
-xtests := tst-getmyaddr
+install-others-$(OPTION_EGLIBC_INET) += $(inst_sysconfdir)/rpc
 
+tests-$(OPTION_EGLIBC_INET) = tst-xdrmem tst-xdrmem2
+xtests-$(OPTION_EGLIBC_INET) := tst-getmyaddr
+
 ifeq ($(have-thread-library),yes)
-xtests += thrsvc
+xtests-$(OPTION_EGLIBC_INET) += thrsvc
 endif
 distribute += thrsvc.c
 
@@ -102,8 +106,9 @@
 ifneq (yes,$(install-bootstrap-headers))
 # We can only build this library if we can run the rpcgen we build.
 headers += $(rpcsvc:%.x=rpcsvc/%.h)
-extra-libs := librpcsvc
-extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
+extra-libs-$(OPTION_EGLIBC_INET) += librpcsvc
+# Make it in `others' pass, not `lib' pass.
+extra-libs-others-y += $(extra-libs-y)
 librpcsvc-routines = $(rpcsvc:%.x=x%)
 librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
 omit-deps = $(librpcsvc-routines)
Index: resolv/Makefile
===================================================================
--- resolv/Makefile	(revision 2089)
+++ resolv/Makefile	(revision 2090)
@@ -20,6 +20,8 @@
 #
 #	Sub-makefile for resolv portion of the library.
 #
+include ../option-groups.mak
+
 subdir	:= resolv
 
 headers	:= resolv.h \
@@ -29,22 +31,23 @@
 distribute := ../conf/portability.h mapv4v6addr.h mapv4v6hostent.h \
 	      Banner res_hconf.h res_debug.h README gai_misc.h ga_test.c
 
-routines := herror inet_addr inet_ntop inet_pton nsap_addr res_init \
+routines-$(OPTION_EGLIBC_INET) \
+	 += herror inet_addr inet_ntop inet_pton nsap_addr res_init \
 	    res_hconf res_libc res-state
 
-tests = tst-aton tst-leaks
-xtests = tst-leaks2
+tests-$(OPTION_EGLIBC_INET) += tst-aton tst-leaks
+xtests-$(OPTION_EGLIBC_INET) += tst-leaks2
 
 generate := mtrace-tst-leaks tst-leaks.mtrace tst-leaks2.mtrace
 
 include ../Makeconfig
 
-extra-libs := libresolv libnss_dns
+extra-libs-$(OPTION_EGLIBC_INET) += libresolv libnss_dns
 ifeq ($(have-thread-library),yes)
-extra-libs += libanl
-routines += gai_sigqueue
+extra-libs-$(OPTION_EGLIBC_INET) += libanl
+routines-$(OPTION_EGLIBC_INET) += gai_sigqueue
 endif
-extra-libs-others = $(extra-libs)
+extra-libs-others-y += $(extra-libs-y)
 libresolv-routines := gethnamaddr res_comp res_debug	\
 		      res_data res_mkquery res_query res_send		\
 		      inet_net_ntop inet_net_pton inet_neta base64	\
@@ -62,7 +65,7 @@
 libnss_dns-inhibit-o	= $(filter-out .os,$(object-suffixes))
 endif
 
-ifeq (yesyes,$(build-shared)$(have-thread-library))
+ifeq (yesyesy,$(build-shared)$(have-thread-library)$(OPTION_EGLIBC_INET))
 tests: $(objpfx)ga_test
 endif
 
Index: nis/Makefile
===================================================================
--- nis/Makefile	(revision 2089)
+++ nis/Makefile	(revision 2090)
@@ -19,6 +19,8 @@
 #
 #	Makefile for NIS/NIS+ part.
 #
+include ../option-groups.mak
+
 subdir	:= nis
 
 aux			:= nis_hash
@@ -33,15 +35,21 @@
 			  spwd netgrp alias publickey
 
 # Specify rules for the nss_* modules.
-services		:= nis nisplus compat
+# The 'compat' module includes nis support, and the 'nss' directory
+# includes a bare-bones "files" library, so we'll include 'compat' in
+# OPTION_EGLIBC_INET.
+services-y		:=
+services-$(OPTION_EGLIBC_INET) += nis nisplus compat
 
-extra-libs		= libnsl $(services:%=libnss_%)
+extra-libs-$(OPTION_EGLIBC_INET) += libnsl
+extra-libs-y		+= $(services-y:%=libnss_%)
+
 # These libraries will be built in the `others' pass rather than
 # the `lib' pass, because they depend on libc.so being built already.
-extra-libs-others	= $(extra-libs)
+extra-libs-others-y	+= $(extra-libs-y)
 
 # The sources are found in the appropriate subdir.
-subdir-dirs = $(services:%=nss_%)
+subdir-dirs = $(services-y:%=nss_%)
 vpath %.c $(subdir-dirs)
 
 libnsl-routines = yp_xdr ypclnt ypupdate_xdr \
@@ -78,12 +86,12 @@
 # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
 # This ensures they will load libc.so for needed symbols if loaded by
 # a statically-linked program that hasn't already loaded it.
-$(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: $(common-objpfx)libc.so\
-					       $(common-objpfx)libc_nonshared.a
+$(services-y:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: \
+	$(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
 
 
 ifeq ($(build-shared),yes)
-$(others:%=$(objpfx)%): $(objpfx)libnsl.so$(libnsl.so-version)
+$(others-y:%=$(objpfx)%): $(objpfx)libnsl.so$(libnsl.so-version)
 else
-$(others:%=$(objpfx)%): $(objpfx)libnsl.a
+$(others-y:%=$(objpfx)%): $(objpfx)libnsl.a
 endif