* manual/pipe.texi: Document MTASC-safety properties.
[jlayton/glibc.git] / Makerules
index 5e7d205aad99048ae9f1cbdc10bfe5d1a62bf959..b7e556ff5f18fcdf448dc71a514cc8ce467974ec 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2013 Free Software Foundation, Inc.
+# Copyright (C) 1991-2014 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -93,7 +93,7 @@ before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
                               $(before-compile))
 
 # Even before that, we need abi-versions.h which is generated right here.
-ifeq ($(versioning),yes)
+ifeq ($(build-shared),yes)
 ifndef avoid-generated
 before-compile := $(common-objpfx)abi-versions.h $(before-compile)
 $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
@@ -106,7 +106,7 @@ $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
            $(common-objpfx)abi-versions.h > $@T
        mv -f $@T $@
 endif # avoid-generated
-endif # $(versioning) = yes
+endif # $(build-shared) = yes
 
 ifndef avoid-generated
 before-compile := $(common-objpfx)libc-abis.h $(before-compile)
@@ -217,14 +217,9 @@ endif
 # later directory would be chosen over a .c file in an earlier directory,
 # which does not preserve the desired sysdeps ordering behavior.
 
-# System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
-# patterns matching sysdep directories whose assembly source files should
-# be suppressed.
-ifdef inhibit-sysdep-asm
-define check-inhibit-asm
-case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) asm= ;; esac;
-endef
-endif
+# System-dependent makefiles can put in `inhibit-sysdep-asm' regexps
+# matching sysdep directories whose assembly source files should be
+# suppressed.
 
 -include $(common-objpfx)sysd-rules
 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
@@ -233,34 +228,16 @@ ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
 sysd-rules-force = FORCE
 FORCE:
 endif
-$(common-objpfx)sysd-rules: $(common-objpfx)config.make $(..)Makerules \
+$(common-objpfx)sysd-rules: $(..)scripts/sysd-rules.awk \
+                           $(common-objpfx)config.make $(..)Makerules \
                            $(sysdep-makefiles) $(sysdep-makeconfigs) \
                            $(sysd-rules-force)
        -@rm -f $@T
-       (echo 'sysd-rules-sysdirs := $(config-sysdirs)';                      \
-        for dir in $(config-sysdirs); do                                     \
-          case "$$dir" in                                                    \
-          /*) ;;                                                             \
-          *) dir="\$$(..)$$dir" ;;                                           \
-          esac;                                                              \
-          asm='.S';                                                          \
-          $(check-inhibit-asm)                                               \
-          for o in $(all-object-suffixes); do                                \
-            set $(subst :, ,$(sysd-rules-patterns));                         \
-            while [ $$# -ge 2 ]; do                                          \
-              t=$$1; shift;                                                  \
-              d=$$1; shift;                                                  \
-              v=$${t%%%}; [ x"$$v" = x ] || v="\$$($${v}CPPFLAGS)";          \
-              for s in $$asm .c; do                                          \
-                echo "\$$(objpfx)$$t$$o: $$dir/$$d$$s \$$(before-compile)";  \
-                echo " \$$(compile-command$$s) $$v";                         \
-              done;                                                          \
-            done;                                                            \
-          done;                                                              \
-          echo "\$$(inst_includedir)/%.h: $$dir/%.h \$$(+force)";            \
-          echo "       \$$(do-install)";                                     \
-        done;                                                                \
-        echo 'sysd-rules-done = t') > $@T
+       LC_ALL=C $(AWK) -f $< > $@T \
+                       -v all_object_suffixes='$(all-object-suffixes)' \
+                       -v inhibit_sysdep_asm='$(inhibit-sysdep-asm)' \
+                       -v sysd_rules_patterns='$(sysd-rules-patterns)' \
+                       -v config_sysdirs='$(config-sysdirs)'
        mv -f $@T $@
 
 ifndef sysd-rules-done
@@ -306,7 +283,7 @@ endif
 
 # Generate version maps, but wait until sysdep-subdirs is known
 ifeq ($(sysd-sorted-done),t)
-ifeq ($(versioning),yes)
+ifeq ($(build-shared),yes)
 -include $(common-objpfx)sysd-versions
 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
 common-generated += $(version-maps)
@@ -347,7 +324,7 @@ $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
        ) > $@T
        mv -f $@T $@
 endif # avoid-generated
-endif # $(versioning) = yes
+endif # $(build-shared) = yes
 endif # sysd-sorted-done
 
 # Generate .dT files as we compile.
@@ -418,28 +395,47 @@ elide-routines.os += $(static-only-routines)
 elide-routines.o  += $(shared-only-routines)
 elide-routines.op += $(shared-only-routines)
 elide-routines.og += $(shared-only-routines)
-elide-routines.ob += $(shared-only-routines)
 \f
 # Shared library building.
 
 ifeq (yes,$(build-shared))
 
-# Reference map file only when versioning is selected and a map file name
+# Reference map file only when shared libraries are built and a map file name
 # is given.
-ifeq ($(versioning),yes)
+ifeq ($(build-shared),yes)
 map-file = $(firstword $($(@F:.so=-map)) \
                       $(addprefix $(common-objpfx), \
                                   $(filter $(@F:.so=.map),$(version-maps))))
 load-map-file = $(map-file:%=-Wl,--version-script=%)
 endif
 
+# Compiler arguments to use to link a shared object with libc and
+# ld.so.  This is intended to be as similar as possible to a default
+# link with an installed libc.
+link-libc-args = -Wl,--start-group \
+                $(libc-for-link) \
+                $(common-objpfx)libc_nonshared.a \
+                $(as-needed) $(elfobjdir)/ld.so $(no-as-needed) \
+                -Wl,--end-group
+
+# The corresponding shared libc to use.  This may be modified for a
+# particular target.
+libc-for-link = $(common-objpfx)libc.so
+
+# The corresponding dependencies.  As these are used in dependencies,
+# not just commands, they cannot use target-specific variables so need
+# to name both possible libc.so objects.
+link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
+                $(common-objpfx)libc_nonshared.a $(elfobjdir)/ld.so
+
 # Pattern rule to build a shared object from an archive of PIC objects.
 # This must come after the installation rules so Make doesn't try to
 # build shared libraries in place from the installed *_pic.a files.
 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
-# on other shared objects.
-lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
-       $(build-shlib)
+# on other shared objects.  The linking with libc and ld.so is intended
+# to be as similar as possible to a default link with an installed libc.
+lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) $(link-libc-deps)
+       $(build-shlib) $(link-libc-args)
 
 define build-shlib-helper
 $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
@@ -514,17 +510,19 @@ endef
 # not for shared objects
 define build-module
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
-         $(csu-objpfx)abi-note.o $(build-module-objlist)
+         $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
 endef
 define build-module-asneeded
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
          $(csu-objpfx)abi-note.o \
-         -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
+         -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
+         $(link-libc-args)
 endef
 
 build-module-helper-objlist = \
        $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
-                  $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^))
+                  $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \
+                               $(link-libc-deps),$^))
 
 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
 build-shlib-objlist = $(build-module-helper-objlist) \
@@ -567,14 +565,48 @@ generated += libc_pic.opts libc_pic.os.clean
 libc_pic_clean := .clean
 endif
 
-# Use our own special initializer and finalizer files for libc.so.
+# Build a possibly-modified version of libc_pic.a for use in building
+# linkobj/libc.so.
+ifeq (,$(filter sunrpc,$(subdirs)))
+$(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a
+       $(make-target-directory)
+       ln -f $< $@
+else
+$(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a \
+                                   $(common-objpfx)sunrpc/librpc_compat_pic.a
+       $(make-target-directory)
+       (cd $(common-objpfx)linkobj; \
+        $(AR) x ../libc_pic.a; \
+        rm $$($(AR) t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//'); \
+        $(AR) x ../sunrpc/librpc_compat_pic.a; \
+        $(AR) cr libc_pic.a *.os; \
+        rm *.os)
+endif # $(subdirs) contains sunrpc
+
+# Clear link-libc-deps for the libc.so libraries so build-shlibs does not
+# filter ld.so out of the list of linked objects.
+$(common-objpfx)libc.so: link-libc-deps = # empty
+$(common-objpfx)linkobj/libc.so: link-libc-deps = # empty
+
+# Use our own special initializer and finalizer files for the libc.so
+# libraries.
 $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
                         $(common-objpfx)libc_pic.os$(libc_pic_clean) \
                         $(elfobjdir)/sofini.os \
-                        $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
+                        $(elfobjdir)/interp.os \
+                        $(elfobjdir)/ld.so \
                         $(shlib-lds)
        $(build-shlib)
-ifeq ($(versioning),yes)
+
+$(common-objpfx)linkobj/libc.so: $(elfobjdir)/soinit.os \
+                        $(common-objpfx)linkobj/libc_pic.a \
+                        $(elfobjdir)/sofini.os \
+                        $(elfobjdir)/interp.os \
+                        $(elfobjdir)/ld.so \
+                        $(shlib-lds)
+       $(build-shlib)
+
+ifeq ($(build-shared),yes)
 $(common-objpfx)libc.so: $(common-objpfx)libc.map
 endif
 common-generated += libc.so libc_pic.os
@@ -622,8 +654,7 @@ include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
 
 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
-               $(objpfx)%.os $(shlib-lds) \
-               $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
+               $(objpfx)%.os $(shlib-lds) $(link-libs-deps)
        $(build-module)
 endif
 \f
@@ -865,7 +896,7 @@ ifeq (no,$(cross-compiling))
 symbolic-link-prog := $(common-objpfx)elf/sln
 symbolic-link-list := $(common-objpfx)elf/symlink.list
 define make-shlib-link
-echo $(<F) $@ >> $(symbolic-link-list)
+echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
 endef
 else # cross-compiling
 # We need a definition that can be used by elf/Makefile's install rules.
@@ -875,7 +906,7 @@ endif
 ifndef make-shlib-link
 define make-shlib-link
 rm -f $@
-$(LN_S) $(<F) $@
+$(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
 endef
 endif
 
@@ -929,7 +960,7 @@ $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
         cat $<; \
         echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
              '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
-             ' AS_NEEDED (' $(slibdir)/$(rtld-installed-name) ') )' \
+             ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \
        ) > $@.new
        mv -f $@.new $@
 
@@ -1132,7 +1163,7 @@ endif
 CPPFLAGS-nonlib = -DNOT_IN_libc=1
 
 
-ifeq ($(versioning),yes)
+ifeq ($(build-shared),yes)
 # Generate normalized lists of symbols, versions, and data sizes.
 # This is handy for checking against existing library binaries.
 
@@ -1265,9 +1296,7 @@ mostlyclean: common-mostlyclean
 
 do-tests-clean:
        -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) $(xtests) \
-                                                     $(test-srcs)) \
-                                    $(addsuffix -bp.out,$(tests) $(xtests) \
-                                                        $(test-srcs)))
+                                                     $(test-srcs)))
 
 # Remove the object files.
 common-mostlyclean:
@@ -1276,12 +1305,8 @@ common-mostlyclean:
                                     $(addsuffix .o,$(tests) $(xtests) \
                                                    $(test-srcs) $(others) \
                                                    $(sysdep-others)) \
-                                    $(addsuffix -bp,$(tests) $(xtests) \
-                                                    $(test-srcs)) \
                                     $(addsuffix .out,$(tests) $(xtests) \
-                                                     $(test-srcs)) \
-                                    $(addsuffix -bp.out,$(tests) $(xtests) \
-                                                        $(test-srcs)))
+                                                     $(test-srcs)))
        -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
                                     $(install-lib) $(install-lib.so) \
                                     $(install-lib.so:%.so=%_pic.a))