(linenum→info "unix/slp.c:2238")

glibc/2.7/Makerules

    1: # Copyright (C) 1991-2006, 2007 Free Software Foundation, Inc.
    2: # This file is part of the GNU C Library.
    3: 
    4: # The GNU C Library is free software; you can redistribute it and/or
    5: # modify it under the terms of the GNU Lesser General Public
    6: # License as published by the Free Software Foundation; either
    7: # version 2.1 of the License, or (at your option) any later version.
    8: 
    9: # The GNU C Library is distributed in the hope that it will be useful,
   10: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   11: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12: # Lesser General Public License for more details.
   13: 
   14: # You should have received a copy of the GNU Lesser General Public
   15: # License along with the GNU C Library; if not, write to the Free
   16: # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   17: # 02111-1307 USA.
   18: 
   19: #
   20: #       Common rules for making the GNU C library.  This file is included
   21: #       by the top-level Makefile and by all subdirectory makefiles
   22: #       (through Rules).
   23: #
   24: ifneq (,)
   25: This makefile requires GNU Make.
   26: endif
   27: 
   28: REQUIRED_MAKE_VERSION = 3.74
   29: REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
   30: 
   31: ifneq ($(REQUIRED_MAKE_VERSION), \
   32:        $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION))))
   33: Wrong GNU Make version.  See above for the version needed.
   34: endif
   35: 
   36: 
   37: ifdef   subdir
   38: ..      := ../
   39: endif   # subdir
   40: 
   41: # If `sources' was defined by the parent makefile, undefine it so
   42: # we will later get it from wildcard search in this directory.
   43: ifneq   "$(findstring env,$(origin sources))" ""
   44: sources :=
   45: endif
   46: 
   47: oPATH := $(PATH)
   48: PATH := this definition should take precedence over $(oPATH)
   49: ifeq ($(PATH),$(oPATH))
   50: You must not use the -e flag when building the GNU C library.
   51: else
   52: PATH := $(oPATH)
   53: endif
   54: ^L
   55: ifndef +included-Makeconfig
   56: include $(..)Makeconfig
   57: endif
   58: 
   59: # This variable is used in ``include $(o-iterator)'' after defining
   60: # $(o-iterator-doit) to produce some desired rule using $o for the object
   61: # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
   62: # is produced for each object suffix in use.
   63: o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
   64: ^L
   65: # Include any system-specific makefiles.
   66: 
   67: # This is here so things in sysdep Makefiles can easily depend on foo.h as
   68: # appropriate and not worry about where foo.h comes from, which may be
   69: # system dependent and not known by that Makefile.
   70: vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
   71:                                       $(+sysdep_dirs) $(..)))
   72: 
   73: # The same is true for RPC source files.
   74: vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
   75:                                       $(+sysdep_dirs) $(..)))
   76: 
   77: # Some sysdep makefiles use this to distinguish being included here from
   78: # being included individually by a subdir makefile (hurd/Makefile needs this).
   79: in-Makerules := yes
   80: 
   81: sysdep-makefiles := $(wildcard $(sysdirs:=/Makefile))
   82: ifneq (,$(sysdep-makefiles))
   83: include $(sysdep-makefiles)
   84: endif
   85: 
   86: 
   87: # Reorder before-compile so that mach things come first, and hurd things
   88: # second, before all else.  The mach and hurd subdirectories have many
   89: # generated header files which the much of rest of the library depends on,
   90: # so it is best to build them first (and mach before hurd, at that).
   91: before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
   92:                            $(before-compile)) \
   93:                   $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
   94:                                $(before-compile))
   95: 
   96: # Even before that, we need abi-versions.h which is generated right here.
   97: ifeq ($(versioning),yes)
   98: ifndef avoid-generated
   99: before-compile := $(common-objpfx)abi-versions.h $(before-compile)
  100: $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
  101:                                 $(common-objpfx)Versions.all
  102:         LC_ALL=C $(AWK) -v oldest_abi=$(oldest-abi) -f $^ > $@T
  103:         mv -f $@T $@
  104: 
  105: $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
  106:         sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
  107:             $(common-objpfx)abi-versions.h > $@T
  108:         mv -f $@T $@
  109: endif # avoid-generated
  110: endif # $(versioning) = yes
  111: 
  112: # Make sure the subdirectory for object files gets created.
  113: ifdef objpfx
  114: ifeq (,$(wildcard $(objpfx).))
  115: before-compile += $(objpfx).
  116: $(objpfx).:
  117:         $(make-target-directory)
  118: endif
  119: endif
  120: 
  121: # Remove existing files from `before-compile'.  Things are added there when
  122: # they must exist for dependency generation to work right, but once they
  123: # exist there is no further need for every single file to depend on them,
  124: # and those gratuitous dependencies result in many gratuitous
  125: # recompilations.
  126: before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
  127: 
  128: # Don't let any before-compile file be an intermediate and get removed.
  129: ifdef before-compile
  130: $(before-compile):
  131: endif
  132: 
  133: # We don't want $(common-objpfx) files to depend on miscellaneous stuff
  134: # in subdirs.
  135: ifdef subdir
  136: common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
  137: else
  138: common-before-compile = $(before-compile)
  139: endif
  140: 
  141: ifndef subdir
  142: # If a makefile needs to do something conditional on something that
  143: # can only be figured out from headers, write a FOO.make.c input
  144: # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
  145: # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
  146: #
  147: # We only generate these in the top-level makefile, to avoid any weirdness
  148: # from subdir-specific makefile tweaks creeping in on an update.
  149: $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
  150:         rm -f $@T $@.dT
  151:         (echo '# Generated from $*.make.c by Makerules.'; \
  152:          $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
  153:                -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
  154:          | sed -n '/@@@/{s/@@@[         ]*\(.*\)@@@/\1/;s/[    ]*$$//p;}'; \
  155:          echo 'common-generated += $(@F)'; \
  156:          sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
  157:          rm -f $@.dT) > $@T
  158:         mv -f $@T $@
  159: endif
  160: 
  161: ifdef subdir
  162: sed-remove-dotdot := -e 's@  *\.\.\/\([^        \]*\)@ $$(..)\1@g' \
  163:                      -e 's@^\.\.\/\([^        \]*\)@$$(..)\1@g'
  164: else
  165: sed-remove-dotdot := -e 's@  *\([^      \/$$][^     \]*\)@ $$(..)\1@g' \
  166:                      -e 's@^\([^      \/$$][^     \]*\)@$$(..)\1@g'
  167: endif
  168: 
  169: 
  170: ifdef gen-as-const-headers
  171: # Generating headers for assembly constants.
  172: # We need this defined early to get into before-compile before
  173: # it's used in sysd-rules, below.
  174: $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
  175:                                            %.sym $(common-before-compile)
  176:         $(AWK) -f $< $(filter %.sym,$^) \
  177:         | $(CC) -S -o $(@:.h.d=.h)T3 $(CFLAGS) $(CPPFLAGS) -x c - \
  178:                 -MD -MP -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)'
  179:         sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' \
  180:                 $(@:.h.d=.h)T3 > $(@:.h.d=.h)T
  181:         rm -f $(@:.h.d=.h)T3
  182:         sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
  183:             $(@:.h=.h.d)T > $(@:.h=.h.d)T2
  184:         rm -f $(@:.h=.h.d)T
  185:         mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
  186:         mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
  187: vpath %.sym $(sysdirs)
  188: before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
  189: 
  190: tests += $(gen-as-const-headers:%.sym=test-as-const-%)
  191: generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
  192: $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.awk $(..)Makerules \
  193:                             %.sym $(common-objpfx)%.h
  194:         ($(AWK) '{ sub(/^/, "asconst_", $$2); print; }' $(filter %.h,$^); \
  195:          $(AWK) -v test=1 -f $< $(filter %.sym,$^); \
  196:          echo '#include "$(..)test-skeleton.c"') > $@T
  197:         mv -f $@T $@
  198: endif
  199: ^L
  200: # Generate an ordered list of implicit rules which find the source files in
  201: # each sysdep directory.  The old method was to use vpath to search all the
  202: # sysdep directories.  However, that had the problem that a .S file in a
  203: # later directory would be chosen over a .c file in an earlier directory,
  204: # which does not preserve the desired sysdeps ordering behavior.
  205: 
  206: # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard
  207: # patterns matching sysdep directories whose assembly source files should
  208: # be suppressed.
  209: ifdef inhibit-sysdep-asm
  210: define open-check-inhibit-asm
  211: case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *)
  212: endef
  213: close-check-inhibit-asm = ;; esac ;
  214: endif
  215: 
  216: -include $(common-objpfx)sysd-rules
  217: ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
  218: # The value of $(+sysdep_dirs) the sysd-rules was computed for
  219: # differs from the one we are using now.  So force a rebuild of sysd-rules.
  220: sysd-rules-force = FORCE
  221: FORCE:
  222: endif
  223: $(common-objpfx)sysd-rules: $(common-objpfx)config.make $(..)Makerules \
  224:                             $(sysdep-makefiles) $(sysd-rules-force)
  225:         -@rm -f $@T
  226:         (echo 'sysd-rules-sysdirs := $(config-sysdirs)';                     \
  227:          for dir in $(config-sysdirs); do                                    \
  228:            case "$$dir" in                                                   \
  229:            /*) ;;                                                            \
  230:            *) dir="\$$(..)$$dir" ;;                                          \
  231:            esac;                                                             \
  232:            for o in $(all-object-suffixes); do \
  233:              $(open-check-inhibit-asm) \
  234:              echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
  235:                   \$$(compile-command.S)";                                  \
  236:              echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \
  237:                   \$$(compile-command.s)";                                  \
  238:              echo "\$$(objpfx)rtld-%$$o: $$dir/%.S \$$(before-compile); \
  239:                   \$$(compile-command.S)";                                  \
  240:              echo "\$$(objpfx)rtld-%$$o: $$dir/%.s \$$(before-compile); \
  241:                   \$$(compile-command.s)";                                  \
  242:              echo "\$$(objpfx)ptw-%$$o: $$dir/%.S \$$(before-compile); \
  243:                   \$$(compile-command.S) -DPTW";                            \
  244:              echo "\$$(objpfx)ptw-%$$o: $$dir/%.s \$$(before-compile); \
  245:                   \$$(compile-command.s) -DPTW";                            \
  246:              echo "\$$(objpfx)m_%$$o: $$dir/s_%.S \$$(before-compile); \
  247:                   \$$(compile-command.S)";                                  \
  248:              echo "\$$(objpfx)m_%$$o: $$dir/s_%.s \$$(before-compile); \
  249:                   \$$(compile-command.s)";                                  \
  250:              $(close-check-inhibit-asm)        \
  251:              echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
  252:                   \$$(compile-command.c)";                                  \
  253:              echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \
  254:                   \$$(compile-command.c)";                                  \
  255:              echo "\$$(objpfx)ptw-%$$o: $$dir/%.c \$$(before-compile); \
  256:                   \$$(compile-command.c) -DPTW";                            \
  257:              echo "\$$(objpfx)m_%$$o: $$dir/s_%.c \$$(before-compile); \
  258:                   \$$(compile-command.c)";                                  \
  259:            done; \
  260:            echo "\$$(inst_includedir)/%.h: $$dir/%.h \$$(+force); \
  261:                   \$$(do-install)";                                      \
  262:          done;                                                               \
  263:          echo 'sysd-rules-done = t') > $@T
  264:         mv -f $@T $@
  265: 
  266: ifndef sysd-rules-done
  267: # Don't do deps until this exists, because it provides rules to make the deps.
  268: no_deps=t
  269: endif
  270: 
  271: define o-iterator-doit
  272: $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
  273: endef
  274: object-suffixes-left := $(all-object-suffixes)
  275: include $(o-iterator)
  276: 
  277: define o-iterator-doit
  278: $(objpfx)%$o: %.s $(before-compile); $$(compile-command.s)
  279: endef
  280: object-suffixes-left := $(all-object-suffixes)
  281: include $(o-iterator)
  282: 
  283: define o-iterator-doit
  284: $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
  285: endef
  286: object-suffixes-left := $(all-object-suffixes)
  287: include $(o-iterator)
  288: 
  289: define o-iterator-doit
  290: $(objpfx)%$o: %.cc $(before-compile); $$(compile-command.cc)
  291: endef
  292: object-suffixes-left := $(all-object-suffixes)
  293: include $(o-iterator)
  294: 
  295: # Omit the objpfx rules when building in the source tree, because
  296: # objpfx is empty and so these rules just override the ones above.
  297: ifdef objpfx
  298: # Define first rules to find the source files in $(objpfx).
  299: # Generated source files will end up there.
  300: define o-iterator-doit
  301: $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
  302: endef
  303: object-suffixes-left := $(all-object-suffixes)
  304: include $(o-iterator)
  305: 
  306: define o-iterator-doit
  307: $(objpfx)%$o: $(objpfx)%.s $(before-compile); $$(compile-command.s)
  308: endef
  309: object-suffixes-left := $(all-object-suffixes)
  310: include $(o-iterator)
  311: 
  312: define o-iterator-doit
  313: $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
  314: endef
  315: object-suffixes-left := $(all-object-suffixes)
  316: include $(o-iterator)
  317: endif
  318: 
  319: # Generate version maps, but wait until sysdep-subdirs is known
  320: ifeq ($(sysd-sorted-done),t)
  321: ifeq ($(versioning),yes)
  322: -include $(common-objpfx)sysd-versions
  323: $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
  324: common-generated += $(version-maps)
  325: postclean-generated += sysd-versions Versions.all abi-versions.h \
  326:                        Versions.def.v.i Versions.def.v Versions.v.i Versions.v
  327: 
  328: ifndef avoid-generated
  329: ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
  330: sysd-versions-force = FORCE
  331: FORCE:
  332: endif
  333: # See %.v/%.v.i implicit rules in Makeconfig.
  334: $(common-objpfx)Versions.def.v.i: $(..)Versions.def \
  335:                                   $(wildcard $(add-ons:%=$(..)%/Versions.def))
  336: $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
  337:                               $(common-objpfx)soversions.i \
  338:                               $(common-objpfx)Versions.def.v
  339:         { while read which lib version setname; do \
  340:             test x"$$which" = xDEFAULT || continue; \
  341:             test -z "$$setname" || echo "$$lib : $$setname"; \
  342:           done < $(word 2,$^); \
  343:           cat $(word 3,$^); \
  344:         } | LC_ALL=C $(AWK) -f $< > $@T
  345:         mv -f $@T $@
  346: # See %.v/%.v.i implicit rules in Makeconfig.
  347: $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
  348:                               $(wildcard $(sysdirs:%=%/Versions)) \
  349:                               $(common-objpfx)abi-versions.h \
  350:                               $(sysd-versions-force)
  351: $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
  352:                                $(common-objpfx)Versions.v \
  353:                                $(..)scripts/versions.awk
  354:         ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
  355:           cat $(word 2,$^) \
  356:           | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
  357:                             -v move_if_change='$(move-if-change)' \
  358:                             -f $(word 3,$^); \
  359:         ) > $@T
  360:         mv -f $@T $@
  361: endif # avoid-generated
  362: endif # $(versioning) = yes
  363: endif # sysd-sorted-done
  364: 
  365: # Generate .dT files as we compile.
  366: compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
  367: compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
  368: compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) $(compile-mkdep-flags)
  369: compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
  370: compile-command.cc = $(compile.cc) $(OUTPUT_OPTION) $(compile-mkdep-flags)
  371: 
  372: # GCC can grok options after the file name, and it looks nicer that way.
  373: compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
  374: compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
  375: compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
  376:                   $(ASFLAGS) $(ASFLAGS-$(suffix $@))
  377: COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
  378:                   $(ASFLAGS) $(ASFLAGS-$(suffix $@))
  379: COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS)
  380: 
  381: # We need this for the output to go in the right place.  It will default to
  382: # empty if make was configured to work with a cc that can't grok -c and -o
  383: # together.  You can't compile the C library with such a compiler.
  384: OUTPUT_OPTION = -o $@
  385: 
  386: # We need the $(CFLAGS) to be in there to have the right predefines during
  387: # the dependency run for C sources.  But having it for assembly sources can
  388: # get the wrong predefines.
  389: S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
  390: 
  391: define +make-deps
  392: $(make-target-directory)
  393: $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
  394:              $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
  395: 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
  396: $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
  397: mv -f $(@:.d=.T) $@ $(generate-md5)
  398: endef
  399: 
  400: ifneq (,$(objpfx))
  401: # Continuation lines here are dangerous because they introduce spaces!
  402: define sed-remove-objpfx
  403: -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
  404: -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
  405: endef
  406: endif
  407: ^L
  408: # Modify the list of routines we build for different targets
  409: 
  410: ifeq (yesyes,$(build-shared)$(elf))
  411: ifndef libc.so-version
  412: # Undefine this because it can't work when we libc.so is unversioned.
  413: static-only-routines =
  414: endif
  415: endif
  416: 
  417: # Bounded pointer thunks are only built for *.ob
  418: elide-bp-thunks = $(addprefix $(bppfx),$(bp-thunks))
  419: 
  420: elide-routines.oS += $(filter-out $(static-only-routines),\
  421:                                   $(routines) $(aux) $(sysdep_routines)) \
  422:                      $(elide-bp-thunks)
  423: elide-routines.os += $(static-only-routines) $(elide-bp-thunks)
  424: 
  425: # If we have versioned code we don't need the old versions in any of the
  426: # static libraries.
  427: elide-routines.o  += $(shared-only-routines) $(elide-bp-thunks)
  428: elide-routines.op += $(shared-only-routines) $(elide-bp-thunks)
  429: elide-routines.og += $(shared-only-routines) $(elide-bp-thunks)
  430: elide-routines.ob += $(shared-only-routines)
  431: ^L
  432: # Shared library building.
  433: 
  434: ifeq (yes,$(build-shared))
  435: 
  436: # Reference map file only when versioning is selected and a map file name
  437: # is given.
  438: ifeq ($(versioning),yes)
  439: map-file = $(firstword $($(@F:.so=-map)) \
  440:                        $(addprefix $(common-objpfx), \
  441:                                    $(filter $(@F:.so=.map),$(version-maps))))
  442: load-map-file = $(map-file:%=-Wl,--version-script=%)
  443: endif
  444: 
  445: # Pattern rule to build a shared object from an archive of PIC objects.
  446: # This must come after the installation rules so Make doesn't try to
  447: # build shared libraries in place from the installed *_pic.a files.
  448: # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
  449: # on other shared objects.
  450: lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp)
  451: ifneq (,$(findstring aix,$(config-os)))
  452:         (echo '#!'; \
  453:          dump -g $< | sed '1,6d' | cut -f2 | sort | uniq) > $(<:a=exp)
  454: endif
  455:         $(build-shlib)
  456: 
  457: ifeq ($(elf),yes)
  458: define build-shlib-helper
  459: $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
  460:           $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(config-LDFLAGS) \
  461:           $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
  462:           $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
  463:           -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
  464:           $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
  465:           -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
  466: endef
  467: else
  468: ifneq (,$(findstring aix,$(config-os)))
  469: define build-shlib-helper
  470: $(LINK.o) -Wl,-G,-bM:SRE,-bnoentry,-bE:$(<:a=exp) \
  471:           $(sysdep-LDFLAGS) $(config-LDFLAGS) $(extra-B-$(@F:lib%.so=%).so) \
  472:           $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
  473:           $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
  474:           -L$(subst :, -L,$(rpath-link))
  475: endef
  476: else
  477: endif
  478: endif
  479: 
  480: ifeq (yes,$(elf))
  481: # binutils only position loadable notes into the first page for binaries,
  482: # not for shared objects
  483: $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
  484:         $(LINK.o) -shared -Wl,-O1 \
  485:                   -nostdlib -nostartfiles \
  486:                   $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS.so) \
  487:                   -Wl,--verbose 2>&1 | \
  488:           sed > $@T \
  489:               -e '/^=========/,/^=========/!d;/^=========/d' \
  490:               $(if $(filter yes,$(have-hash-style)), \
  491:                    -e 's/^.*\.gnu\.hash[      ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
  492:                    -e '/^[    ]*\.hash[         ]*:.*$$/{h;d;}' \
  493:                    -e '/DATA_SEGMENT_ALIGN/{H;g}' \
  494:                 , \
  495:                    -e 's/^.*\.hash[   ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
  496:                ) \
  497:               -e 's/^.*\*(\.dynbss).*$$/& \
  498:                  PROVIDE(__start___libc_freeres_ptrs = .); \
  499:                  *(__libc_freeres_ptrs) \
  500:                  PROVIDE(__stop___libc_freeres_ptrs = .);/'\
  501:               -e 's@^.*\*(\.jcr).*$$@& \
  502:                  PROVIDE(__start___libc_subfreeres = .);\
  503:                  __libc_subfreeres : { *(__libc_subfreeres) }\
  504:                  PROVIDE(__stop___libc_subfreeres = .);\
  505:                  PROVIDE(__start___libc_atexit = .);\
  506:                  __libc_atexit : { *(__libc_atexit) }\
  507:                  PROVIDE(__stop___libc_atexit = .);\
  508:                  PROVIDE(__start___libc_thread_subfreeres = .);\
  509:                  __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
  510:                  PROVIDE(__stop___libc_thread_subfreeres = .);\
  511:                  /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
  512:         mv -f $@T $@
  513: common-generated += shlib.lds
  514: 
  515: define build-shlib
  516: $(build-shlib-helper) -o $@ -T $(common-objpfx)shlib.lds \
  517:           $(csu-objpfx)abi-note.o $(build-shlib-objlist)
  518: endef
  519: else
  520: ifneq (,$(findstring aix,$(config-os)))
  521: define build-shlib
  522: $(build-shlib-helper) \
  523:         -o $@ \
  524:         $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
  525:         $(no-whole-archive) $(LDLIBS-$(@F:lib%.so=%).so)
  526: endef
  527: define build-shlib
  528: $(build-shlib-helper) \
  529:           $(build-shlib-objlist)
  530: endef
  531: endif
  532: endif
  533: 
  534: ifneq (,$(findstring aix,$(config-os)))
  535: define build-module-helper
  536: $(LINK.o) -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall \
  537:           $(sysdep-LDFLAGS) $(config-LDFLAGS) \
  538:           $(load-map-file) \
  539:           $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
  540:           -L$(subst :, -L,$(rpath-link)) -Wl,-L=$(rpath-link)
  541: endef
  542: else
  543: define build-module-helper
  544: $(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(config-LDFLAGS) \
  545:           $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
  546:           -B$(csu-objpfx) $(load-map-file) \
  547:           $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
  548:           -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
  549: endef
  550: endif
  551: 
  552: # This macro is similar to build-shlib but it does not define a soname
  553: # and it does not depend on the destination name to start with `lib'.
  554: ifeq (yes,$(elf))
  555: # binutils only position loadable notes into the first page for binaries,
  556: # not for shared objects
  557: define build-module
  558: $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
  559:           $(csu-objpfx)abi-note.o $(build-module-objlist)
  560: endef
  561: define build-module-asneeded
  562: $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
  563:           $(csu-objpfx)abi-note.o \
  564:           -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
  565: endef
  566: else
  567: ifneq (,$(findstring aix,$(config-os)))
  568: define build-module
  569: $(build-module-helper) \
  570:           -o $@ \
  571:           $(filter-out $(map-file) $(+preinit) $(+postinit),$^) \
  572:           $(no-whole-archive) $(LDLIBS-$(@F:%.so=%).so)
  573: endef
  574: else
  575: define build-module
  576: define build-module
  577: $(build-module-helper) \
  578:           -o $@ \
  579:           $(build-module-objlist)
  580: endef
  581: endif
  582: endif
  583: 
  584: build-module-helper-objlist = \
  585:         $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
  586:                    $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^))
  587: whole-archive := -Wl,--whole-archive
  588: 
  589: build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
  590: build-shlib-objlist = $(build-module-helper-objlist) \
  591:                       $(LDLIBS-$(@F:lib%.so=%).so)
  592: 
  593: # Don't try to use -lc when making libc.so itself.
  594: # Also omits crti.o and crtn.o, which we do not want
  595: # since we define our own `.init' section specially.
  596: LDFLAGS-c.so = -nostdlib -nostartfiles
  597: # But we still want to link libc.so against $(libc.so-gnulib).
  598: LDLIBS-c.so += $(libc.so-gnulib)
  599: # Give libc.so an entry point and make it directly runnable itself.
  600: LDFLAGS-c.so += -e __libc_main
  601: # If lazy relocation is disabled add the -z now flag.
  602: ifeq ($(bind-now),yes)
  603: LDFLAGS-c.so += -Wl,-z,now
  604: endif
  605: # Pre-link the objects of libc_pic.a so that we can locally resolve
  606: # COMMON symbols before we link against ld.so.  This is because ld.so
  607: # contains some of libc_pic.a already, which will prevent the COMMONs
  608: # from being allocated in libc.so, which introduces evil dependencies
  609: # between libc.so and ld.so, which can make it impossible to upgrade.
  610: ifeq ($(elf),yes)
  611: $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
  612:         $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
  613:         $(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
  614: # Use our own special initializer and finalizer files for libc.so.
  615: $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \
  616:                          $(common-objpfx)libc_pic.os \
  617:                          $(elfobjdir)/sofini.os \
  618:                          $(elfobjdir)/interp.os $(elfobjdir)/ld.so \
  619:                          $(common-objpfx)shlib.lds
  620:         $(build-shlib)
  621: ifeq ($(versioning),yes)
  622: $(common-objpfx)libc.so: $(common-objpfx)libc.map
  623: endif
  624: common-generated += libc.so libc_pic.os
  625: ifdef libc.so-version
  626: $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
  627:         $(make-link)
  628: common-generated += libc.so$(libc.so-version)
  629: endif
  630: endif
  631: else
  632: ifneq (,$(findstring aix,$(config-os)))
  633: $(common-objpfx)libc.so: $(common-objpfx)libc_pic.a
  634:         @rm -f $@
  635:         (echo '#!'; \
  636:          dump -g $^ | sed '1,6d' | cut -f2 | sort | uniq) > $(^:a=exp)
  637:         sed '/__mulh/d;/__mull/d;/__divss/d;/__divus/d;/__quoss/d;/__quous/d' \
  638:             /lib/syscalls.exp > $(common-objpfx)syscalls.exp
  639:         $(LINK.o) -G -bM:SRE -bnoentry -bE:$(^:a=exp) \
  640:                   -bE:$(common-objpfx)syscalls.exp \
  641:                   -bI:$(common-objpfx)syscalls.exp \
  642:                   -L$(common-objpfx) -o $@ $^
  643: # AIX runtime ld wants libc.so to be libc.a(shr.o) hardwired
  644:         cp $@ $(common-objpfx)shr.o
  645:         $(AR) $(ARFLAGS) $(common-objpfx)libc.a $(common-objpfx)shr.o
  646: endif
  647: endif
  648: ^L
  649: # Figure out the source filenames in this directory.
  650: 
  651: override sources := $(addsuffix .c,\
  652:                         $(filter-out $(elided-routines),\
  653:                             $(routines) $(aux) \
  654:                             $(sysdep_routines)))
  655: sysdep_routines := $(sysdep_routines)
  656: 
  657: headers := $(headers) $(sysdep_headers)
  658: 
  659: # This is the list of all object files, gotten by
  660: # replacing every ".c" in `sources' with a ".o".
  661: # We also add bounded-pointer thunks, which are later
  662: # elided for all suffixes except for `.ob'.
  663: override objects := $(addprefix $(objpfx),$(sources:.c=.o) \
  664:                       $(patsubst %,$(bppfx)%.o,\
  665:                         $(filter $(routines) $(sysdep_routines),$(bp-thunks))))
  666: 
  667: 
  668: # The makefile may define $(extra-libs) with `libfoo libbar'
  669: # to build libfoo.a et al from the modules listed in $(libfoo-routines).
  670: ifdef extra-libs
  671: # extra-lib.mk is included once for each extra lib to define rules
  672: # to build it, and to add its objects to the various variables.
  673: # During its evaluation, $(lib) is set to the name of the library.
  674: extra-libs-left := $(extra-libs)
  675: include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
  676: endif
  677: 
  678: 
  679: # The makefile may define $(modules-names) to build additional modules.
  680: # These are built with $(build-module), except any in $(modules-names-nobuild).
  681: ifdef modules-names
  682: # extra-lib.mk is included once for each extra lib to define rules
  683: # to build it, and to add its objects to the various variables.
  684: # During its evaluation, $(lib) is set to the name of the library.
  685: extra-modules-left := $(modules-names)
  686: include $(patsubst %,$(..)extra-modules.mk,$(modules-names))
  687: 
  688: extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
  689: $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
  690:                 $(objpfx)%.os $(common-objpfx)shlib.lds \
  691:                 $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a
  692:         $(build-module)
  693: endif
  694: ^L
  695: +depfiles := $(sources:.c=.d) \
  696:              $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
  697:              $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
  698:              $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
  699: ifeq ($(build-programs),yes)
  700: +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
  701: endif
  702: +depfiles := $(addprefix $(objpfx),\
  703:                          $(filter-out $(addsuffix .d,$(omit-deps)),\
  704:                                       $(+depfiles)))
  705: all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
  706: +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
  707:              $(wildcard $(all-dt-files:.dt=.d))
  708: 
  709: # This is a funny rule in that it removes its input file.
  710: %.d: %.dt
  711:         @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
  712:          mv -f $(@:.d=.T) $@ && \
  713:          rm -f $<
  714: 
  715: # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
  716: # They will be generated when they're needed, and trying too early won't work.
  717: +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
  718: +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
  719:                                                 $(+gen-as-const)))
  720: 
  721: ifdef +depfiles
  722: ifneq ($(no_deps),t)
  723: -include $(+depfiles)
  724: endif
  725: endif
  726: ^L^L
  727: # Maximize efficiency by minimizing the number of rules.
  728: .SUFFIXES:      # Clear the suffix list.  We don't use suffix rules.
  729: # Don't define any builtin rules.
  730: MAKEFLAGS := $(MAKEFLAGS)r
  731: 
  732: # Generic rule for making directories.
  733: %/:
  734: # mkdir isn't smart enough to strip a trailing /.
  735: # We always require a mkdir which supports the -p option to avoid error
  736: # messages in case of races.
  737:         mkdir -p $(@:%/=%)
  738: ^L
  739: # Make sure that object files are not removed
  740: # when they are intermediates between sources and library members.
  741: .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
  742: 
  743: # Make sure that the parent library archive is never removed.
  744: .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
  745: ^L
  746: # Use the verbose option of ar and tar when not running silently.
  747: ifeq    "$(findstring s,$(MAKEFLAGS))" ""  # if not -s
  748: verbose := v
  749: else                                               # -s
  750: verbose :=
  751: endif                                           # not -s
  752: 
  753: ARFLAGS := r$(verbose)
  754: CREATE_ARFLAGS := cru$(verbose)
  755: ^L
  756: # This makes all the object files in the parent library archive.
  757: 
  758: .PHONY: lib lib-noranlib
  759: lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
  760: lib-noranlib: libobjs
  761: 
  762: # For object-suffix $o, the list of objects with that suffix.
  763: # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
  764: o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
  765:                                                        $(elide-routines$o)),\
  766:                                             $(objects))) \
  767:             $(addprefix $(objpfx),$(o-objects$o))
  768: 
  769: others: $(addprefix $(objpfx),$(install-lib))
  770: 
  771: ifndef objects
  772: 
  773: # Create the stamp$o files to keep the parent makefile happy.
  774: subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
  775: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
  776:         $(make-target-directory)
  777:         rm -f $@; > $@
  778: else
  779: 
  780: # Define explicit rules to update each $(objpfx)stamp.SUFFIX
  781: # timestamp file; these rules (one explicit rule is generated for each
  782: # object suffix) write a list of objects to update in the stamp file.
  783: # The parent will then actually add them all to the archive in the
  784: # archive rule, below.
  785: define o-iterator-doit
  786: $(objp