summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/ChangeLog.eglibc90
-rw-r--r--libc/Makerules10
-rw-r--r--libc/extra-lib.mk6
-rw-r--r--libc/grp/Makefile10
-rw-r--r--libc/hesiod/Makefile6
-rw-r--r--libc/inet/Makefile7
-rw-r--r--libc/misc/Makefile4
-rw-r--r--libc/nis/Makefile24
-rw-r--r--libc/nptl/Makefile9
-rw-r--r--libc/nptl/pthread_create.c4
-rw-r--r--libc/nscd/Makefile13
-rw-r--r--libc/nss/Makefile29
-rw-r--r--libc/nss/getent.c33
-rw-r--r--libc/nss/getnssent_r.c8
-rw-r--r--libc/nss/nsswitch.c2
-rw-r--r--libc/option-groups.def125
-rw-r--r--libc/option-groups.defaults1
-rw-r--r--libc/option-groups.mak22
-rw-r--r--libc/posix/Makefile25
-rw-r--r--libc/pwd/Makefile8
-rw-r--r--libc/resolv/Makefile19
-rw-r--r--libc/sunrpc/Makefile27
-rw-r--r--libc/sysdeps/unix/sysv/linux/Makefile5
-rw-r--r--libc/sysdeps/unix/sysv/linux/gethostid.c5
24 files changed, 405 insertions, 87 deletions
diff --git a/libc/ChangeLog.eglibc b/libc/ChangeLog.eglibc
index 13ccc7f99..11f0cd1ac 100644
--- a/libc/ChangeLog.eglibc
+++ b/libc/ChangeLog.eglibc
@@ -1,3 +1,93 @@
+2007-05-13 Jim Blandy <jimb@codesourcery.com>
+
+ 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, xtests): 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.
+
+ * EGLIBC.cross-building: doc fix.
+
2007-05-01 Daniel Jacobowitz <dan@debian.org>
* sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_discover_osversion):
diff --git a/libc/Makerules b/libc/Makerules
index 0b99ac781..bdb345666 100644
--- a/libc/Makerules
+++ b/libc/Makerules
@@ -406,16 +406,18 @@ endef
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
diff --git a/libc/extra-lib.mk b/libc/extra-lib.mk
index 775eb23cd..b2a2fe60b 100644
--- a/libc/extra-lib.mk
+++ b/libc/extra-lib.mk
@@ -25,7 +25,9 @@ install-lib := $(install-lib)
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
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
diff --git a/libc/grp/Makefile b/libc/grp/Makefile
index 1bdf28a87..75eabf0b1 100644
--- a/libc/grp/Makefile
+++ b/libc/grp/Makefile
@@ -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 @@ endif
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
diff --git a/libc/hesiod/Makefile b/libc/hesiod/Makefile
index 77bb5488b..2efa0350f 100644
--- a/libc/hesiod/Makefile
+++ b/libc/hesiod/Makefile
@@ -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
diff --git a/libc/inet/Makefile b/libc/inet/Makefile
index 5823b69e9..d847d5aa8 100644
--- a/libc/inet/Makefile
+++ b/libc/inet/Makefile
@@ -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 @@ headers := netinet/ether.h netinet/in.h netinet/in_systm.h \
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 @@ routines := htonl htons \
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 test-inet6_opt
diff --git a/libc/misc/Makefile b/libc/misc/Makefile
index bb88b6f3b..749187e89 100644
--- a/libc/misc/Makefile
+++ b/libc/misc/Makefile
@@ -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 \
diff --git a/libc/nis/Makefile b/libc/nis/Makefile
index 8083ee804..f185ab050 100644
--- a/libc/nis/Makefile
+++ b/libc/nis/Makefile
@@ -19,6 +19,8 @@
#
# Makefile for NIS/NIS+ part.
#
+include ../option-groups.mak
+
subdir := nis
aux := nis_hash
@@ -33,15 +35,21 @@ databases = proto service hosts network grp pwd rpc ethers \
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-$(OPTION_EGLIBC_INET) += libnsl
+extra-libs-y += $(services-y:%=libnss_%)
-extra-libs = libnsl $(services:%=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 @@ $(objpfx)libnss_nisplus.so: $(objpfx)libnsl.so$(libnsl.so-version)
# 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
diff --git a/libc/nptl/Makefile b/libc/nptl/Makefile
index e64a2aaa5..a7b41cc78 100644
--- a/libc/nptl/Makefile
+++ b/libc/nptl/Makefile
@@ -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 @@ libpthread-routines = init vars events version \
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 @@ libpthread-routines = init vars events version \
# 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-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
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.
diff --git a/libc/nptl/pthread_create.c b/libc/nptl/pthread_create.c
index 79729ced0..2e8015788 100644
--- a/libc/nptl/pthread_create.c
+++ b/libc/nptl/pthread_create.c
@@ -235,8 +235,10 @@ start_thread (void *arg)
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 @@ start_thread (void *arg)
/* 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
diff --git a/libc/nscd/Makefile b/libc/nscd/Makefile
index ef3ce184f..21c99321a 100644
--- a/libc/nscd/Makefile
+++ b/libc/nscd/Makefile
@@ -20,11 +20,14 @@
#
# 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 \
+routines-$(OPTION_EGLIBC_INET) += \
+ nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai \
nscd_initgroups nscd_getserv_r
-aux := nscd_helper
+aux-$(OPTION_EGLIBC_INET) += nscd_helper
include ../Makeconfig
@@ -40,11 +43,11 @@ nscd-modules := nscd connections pwdcache getpwnam_r getpwuid_r grpcache \
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
diff --git a/libc/nss/Makefile b/libc/nss/Makefile
index 320fbbd9f..0936faa65 100644
--- a/libc/nss/Makefile
+++ b/libc/nss/Makefile
@@ -19,6 +19,8 @@
#
# Makefile for name service switch.
#
+include ../option-groups.mak
+
subdir := nss
headers := nss.h
@@ -26,21 +28,24 @@ distribute := nsswitch.h XXX-lookup.c getXXbyYY.c getXXbyYY_r.c \
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 @@ subdir-dirs = $(services:%=nss_%)
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 @@ endif
# 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)
diff --git a/libc/nss/getent.c b/libc/nss/getent.c
index 8b9a9030f..d74bf08d8 100644
--- a/libc/nss/getent.c
+++ b/libc/nss/getent.c
@@ -88,6 +88,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
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 @@ ethers_keys (int number, char *key[])
return result;
}
+#endif /* OPTION_EGLIBC_INET */
/* This is for group */
static inline void
@@ -234,6 +236,7 @@ group_keys (int number, char *key[])
return result;
}
+#ifdef OPTION_EGLIBC_INET
/* This is for hosts */
static void
print_hosts (struct hostent *host)
@@ -469,6 +472,7 @@ networks_keys (int number, char *key[])
return result;
}
+#endif /* OPTION_EGLIBC_INET */
/* Now is all for passwd */
static inline void
@@ -521,6 +525,7 @@ passwd_keys (int number, char *key[])
return result;
}
+#ifdef OPTION_EGLIBC_INET
/* This is for protocols */
static inline void
print_protocols (struct protoent *proto)
@@ -672,6 +677,7 @@ services_keys (int number, char *key[])
return result;
}
+#endif /* OPTION_EGLIBC_INET */
/* This is for shadow */
static void
@@ -738,19 +744,24 @@ struct
} 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 }
diff --git a/libc/nss/getnssent_r.c b/libc/nss/getnssent_r.c
index a0cfa72bd..1e871bfab 100644
--- a/libc/nss/getnssent_r.c
+++ b/libc/nss/getnssent_r.c
@@ -60,11 +60,13 @@ __nss_setent (const char *func_name, db_lookup_function lookup_fct,
} 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 @@ __nss_endent (const char *func_name, db_lookup_function lookup_fct,
} 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 @@ __nss_getent_r (const char *getent_func_name,
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 @@ __nss_getent_r (const char *getent_func_name,
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
diff --git a/libc/nss/nsswitch.c b/libc/nss/nsswitch.c
index 756204bd3..8d86e887f 100644
--- a/libc/nss/nsswitch.c
+++ b/libc/nss/nsswitch.c
@@ -699,6 +699,7 @@ nss_new_service (name_database *database, const char *name)
}
+#ifdef OPTION_EGLIBC_INET
/* Called by nscd and nscd alone. */
void
__nss_disable_nscd (void)
@@ -709,6 +710,7 @@ __nss_disable_nscd (void)
__nss_not_use_nscd_hosts = -1;
__nss_not_use_nscd_services = -1;
}
+#endif /* OPTION_EGLIBC_INET */
/* Free all resources if necessary. */
diff --git a/libc/option-groups.def b/libc/option-groups.def
index a43d1b9a5..7e615752f 100644
--- a/libc/option-groups.def
+++ b/libc/option-groups.def
@@ -67,3 +67,128 @@ config OPTION_EGLIBC_LIBM
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.
diff --git a/libc/option-groups.defaults b/libc/option-groups.defaults
index 1773f8363..335bd3ed3 100644
--- a/libc/option-groups.defaults
+++ b/libc/option-groups.defaults
@@ -11,3 +11,4 @@
OPTION_EGLIBC_CATGETS = y
OPTION_EGLIBC_LOCALES = y
OPTION_EGLIBC_LIBM = y
+OPTION_EGLIBC_INET = y
diff --git a/libc/option-groups.mak b/libc/option-groups.mak
index 7866e3321..2ade410a7 100644
--- a/libc/option-groups.mak
+++ b/libc/option-groups.mak
@@ -15,12 +15,16 @@ include $(firstword $(..) ../)option-groups.defaults
# 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 :=
diff --git a/libc/posix/Makefile b/libc/posix/Makefile
index bac225417..663783ea2 100644
--- a/libc/posix/Makefile
+++ b/libc/posix/Makefile
@@ -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 @@ routines := \
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 @@ routines := \
posix_madvise \
get_child_max sched_cpucount
+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 \
@@ -84,14 +88,17 @@ tests := tstgetopt testfnm runtests runptests \
bug-regex25 bug-regex26 bug-regex27 bug-regex28 \
tst-nice tst-nanosleep tst-regex2 \
transbug tst-rxspencer tst-pcre tst-boost \
- bug-ga1 tst-vfork1 tst-vfork2 tst-vfork3 tst-waitid \
- tst-getaddrinfo2 bug-glob1 bug-glob2 tst-sysconf \
+ tst-vfork1 tst-vfork2 tst-vfork3 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 tst-fnmatch2 tst-cpucount
-xtests := bug-ga2
+ tst-execvp3 tst-execvp4 \
+ tst-fnmatch2 tst-cpucount
+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
@@ -135,8 +142,10 @@ $(objpfx)wordexp-tst.out: wordexp-tst.sh $(objpfx)wordexp-test
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
diff --git a/libc/pwd/Makefile b/libc/pwd/Makefile
index 83fb565c5..c2ef81004 100644
--- a/libc/pwd/Makefile
+++ b/libc/pwd/Makefile
@@ -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 @@ include ../Rules
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
diff --git a/libc/resolv/Makefile b/libc/resolv/Makefile
index a7a13c6f3..3575e0e28 100644
--- a/libc/resolv/Makefile
+++ b/libc/resolv/Makefile
@@ -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 @@ headers := resolv.h \
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 tst-inet_ntop
-xtests = tst-leaks2
+tests-$(OPTION_EGLIBC_INET) += tst-aton tst-leaks tst-inet_ntop
+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 @@ ifneq ($(build-static-nss),yes)
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
diff --git a/libc/sunrpc/Makefile b/libc/sunrpc/Makefile
index 45a38bc62..9ccaab4d2 100644
--- a/libc/sunrpc/Makefile
+++ b/libc/sunrpc/Makefile
@@ -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 @@ headers = $(addprefix rpc/,auth.h auth_unix.h clnt.h netdb.h pmap_clnt.h \
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 @@ routines := auth_none auth_unix authuxprot bindrsvprt \
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 @@ rpcgen-objs = rpc_main.o rpc_hout.o rpc_cout.o rpc_parse.o \
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 @@ ifeq (no,$(cross-compiling))
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)
diff --git a/libc/sysdeps/unix/sysv/linux/Makefile b/libc/sysdeps/unix/sysv/linux/Makefile
index 1a59b37a0..cd25b359f 100644
--- a/libc/sysdeps/unix/sysv/linux/Makefile
+++ b/libc/sysdeps/unix/sysv/linux/Makefile
@@ -15,7 +15,10 @@ ifeq ($(subdir),misc)
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 \
diff --git a/libc/sysdeps/unix/sysv/linux/gethostid.c b/libc/sysdeps/unix/sysv/linux/gethostid.c
index de98fb3d7..492484bcf 100644
--- a/libc/sysdeps/unix/sysv/linux/gethostid.c
+++ b/libc/sysdeps/unix/sysv/linux/gethostid.c
@@ -91,6 +91,7 @@ gethostid ()
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 @@ gethostid ()
/* 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