ce426f
This patch backports the makefile changes related to the support/
ce426f
framework.  It is based on upstream commits
ce426f
c23de0aacbeaa7a091609b35764bed931475a16d (support: Introduce new
ce426f
subdirectory for test infrastructure) and
ce426f
76dcbf42df83c970c13c786d287f1ec69e1b91eb (Expose linking against
ce426f
libsupport as make dependency).
ce426f
ce426f
The actual contents of the support/ subdirectory is kept in a separate
ce426f
patch, so that it can be updated separately.
ce426f
ce426f
Index: b/Makeconfig
ce426f
===================================================================
ce426f
--- a/Makeconfig
ce426f
+++ b/Makeconfig
ce426f
@@ -384,6 +384,9 @@ LDFLAGS.so += $(hashstyle-LDFLAGS)
ce426f
 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
ce426f
 endif
ce426f
 
ce426f
+# Additional libraries to link into every test.
ce426f
+link-extra-libs-tests = $(libsupport)
ce426f
+
ce426f
 # Command for linking PIE programs with the C library.
ce426f
 ifndef +link-pie
ce426f
 +link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
ce426f
@@ -464,7 +467,7 @@ link-libc-before-gnulib = -Wl,-rpath-lin
ce426f
 link-libc = $(link-libc-before-gnulib) $(gnulib)
ce426f
 link-libc-tests = $(link-libc-before-gnulib) $(gnulib-tests)
ce426f
 # This is how to find at build-time things that will be installed there.
ce426f
-rpath-dirs = math elf dlfcn nss nis rt resolv crypt
ce426f
+rpath-dirs = math elf dlfcn nss nis rt resolv crypt support
ce426f
 rpath-link = \
ce426f
 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
ce426f
 else
ce426f
@@ -732,7 +735,7 @@ libio-include = -I$(..)libio
ce426f
 # List of non-library modules that we build.
ce426f
 built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
ce426f
 		libSegFault libpcprofile librpcsvc locale-programs \
ce426f
-		memusagestat nonlib nscd extramodules libnldbl
ce426f
+		memusagestat nonlib nscd extramodules libnldbl libsupport
ce426f
 
ce426f
 in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
ce426f
 				    $(libof-$(
ce426f
@@ -1022,6 +1025,12 @@ else
ce426f
 libm = $(common-objpfx)math/libm.a
ce426f
 endif
ce426f
 
ce426f
+ifeq ($(build-shared),yes)
ce426f
+libsupport = $(common-objpfx)support/libsupport_nonshared.a
ce426f
+else
ce426f
+libsupport = $(common-objpfx)support/libsupport.a
ce426f
+endif
ce426f
+
ce426f
 # These are the subdirectories containing the library source.  The order
ce426f
 # is more or less arbitrary.  The sorting step will take care of the
ce426f
 # dependencies.
ce426f
@@ -1029,7 +1038,7 @@ all-subdirs = csu assert ctype locale in
ce426f
 	      stdlib stdio-common libio malloc string wcsmbs time dirent    \
ce426f
 	      grp pwd posix io termios resource misc socket sysvipc gmon    \
ce426f
 	      gnulib iconv iconvdata wctype manual shadow gshadow po argp   \
ce426f
-	      crypt nss localedata timezone rt conform debug		    \
ce426f
+	      crypt nss localedata timezone rt conform debug support	    \
ce426f
 	      $(add-on-subdirs) dlfcn elf
ce426f
 
ce426f
 ifndef avoid-generated
ce426f
Index: b/Rules
ce426f
===================================================================
ce426f
--- a/Rules
ce426f
+++ b/Rules
ce426f
@@ -142,6 +142,7 @@ endif
ce426f
 
ce426f
 ifneq "$(strip $(binaries-shared-tests))" ""
ce426f
 $(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \
ce426f
+  $(link-extra-libs-tests) \
ce426f
   $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
ce426f
   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
ce426f
 	$(+link-tests)
ce426f
@@ -163,6 +164,7 @@ endif
ce426f
 
ce426f
 ifneq "$(strip $(binaries-static-tests))" ""
ce426f
 $(addprefix $(objpfx),$(binaries-static-tests)): %: %.o \
ce426f
+  $(link-extra-libs-tests) \
ce426f
   $(sort $(filter $(common-objpfx)lib%,$(link-libc-static-tests))) \
ce426f
   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
ce426f
 	$(+link-static-tests)
ce426f
Index: b/extra-lib.mk
ce426f
===================================================================
ce426f
--- a/extra-lib.mk
ce426f
+++ b/extra-lib.mk
ce426f
@@ -5,6 +5,9 @@
ce426f
 # The variable $($(lib)-routines) defines the list of modules
ce426f
 # to be included in that library.  A sysdep Makefile can add to
ce426f
 # $(lib)-sysdep_routines to include additional modules.
ce426f
+#
ce426f
+# Libraries listed in $(extra-libs-noinstall) are built, but not
ce426f
+# installed.
ce426f
 
ce426f
 lib := $(firstword $(extra-libs-left))
ce426f
 extra-libs-left := $(filter-out $(lib),$(extra-libs-left))
ce426f
@@ -28,7 +31,9 @@ extra-objs := $(extra-objs)
ce426f
 all-$(lib)-routines := $($(lib)-routines) $($(lib)-sysdep_routines)
ce426f
 
ce426f
 # Add each flavor of library to the lists of things to build and install.
ce426f
+ifeq (,$(filter $(lib), $(extra-libs-noinstall)))
ce426f
 install-lib += $(foreach o,$(object-suffixes-$(lib)),$(lib:lib%=$(libtype$o)))
ce426f
+endif
ce426f
 extra-objs += $(foreach o,$(filter-out .os .oS,$(object-suffixes-$(lib))),\
ce426f
 			$(patsubst %,%$o,$(filter-out \
ce426f
 					   $($(lib)-shared-only-routines),\