test-container: add "su" command to run test as root, add unshare hints
[glibc.git] / Makerules
blob8e49a7334251c1672874c5c9410653223a241244
1 # Copyright (C) 1991-2018 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <http://www.gnu.org/licenses/>.
19 #       Common rules for making the GNU C library.  This file is included
20 #       by the top-level Makefile and by all subdirectory makefiles
21 #       (through Rules).
23 ifneq (,)
24 This makefile requires GNU Make.
25 endif
27 REQUIRED_MAKE_VERSION = 3.74
28 REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION))
30 ifneq ($(REQUIRED_MAKE_VERSION), \
31        $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION))))
32 Wrong GNU Make version.  See above for the version needed.
33 endif
36 ifdef   subdir
37 ..      := ../
38 endif   # subdir
40 # If `sources' was defined by the parent makefile, undefine it so
41 # we will later get it from wildcard search in this directory.
42 ifneq   "$(findstring env,$(origin sources))" ""
43 sources :=
44 endif
46 oPATH := $(PATH)
47 PATH := this definition should take precedence over $(oPATH)
48 ifeq ($(PATH),$(oPATH))
49 You must not use the -e flag when building the GNU C library.
50 else
51 PATH := $(oPATH)
52 endif
54 ifndef +included-Makeconfig
55 include $(..)Makeconfig
56 endif
58 # This variable is used in ``include $(o-iterator)'' after defining
59 # $(o-iterator-doit) to produce some desired rule using $o for the object
60 # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
61 # is produced for each object suffix in use.
62 o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left))
64 # Include any system-specific makefiles.
66 # This is here so things in sysdep Makefiles can easily depend on foo.h as
67 # appropriate and not worry about where foo.h comes from, which may be
68 # system dependent and not known by that Makefile.
69 vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
70                                       $(+sysdep_dirs) $(..)))
72 # The same is true for RPC source files.
73 vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
74                                       $(+sysdep_dirs) $(..)))
76 # Some sysdep makefiles use this to distinguish being included here from
77 # being included individually by a subdir makefile (hurd/Makefile needs this).
78 in-Makerules := yes
80 sysdep-makefiles := $(wildcard $(sysdirs:=/Makefile))
81 ifneq (,$(sysdep-makefiles))
82 include $(sysdep-makefiles)
83 endif
86 # Reorder before-compile so that mach things come first, and hurd things
87 # second, before all else.  The mach and hurd subdirectories have many
88 # generated header files which the much of rest of the library depends on,
89 # so it is best to build them first (and mach before hurd, at that).
90 before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\
91                            $(before-compile)) \
92                   $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\
93                                $(before-compile))
95 # Even before that, we need abi-versions.h which is generated right here.
96 ifeq ($(build-shared),yes)
97 ifndef avoid-generated
98 before-compile := $(common-objpfx)abi-versions.h $(before-compile)
99 $(common-objpfx)abi-versions.h: $(..)scripts/abi-versions.awk \
100                                 $(common-objpfx)Versions.all
101         LC_ALL=C $(AWK) -f $^ > $@T
102         mv -f $@T $@
104 $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
105         sed -n '/ VERSION_$*_/{s/^.*_\([A-Z0-9_]*\).*$$/\1/;h;};$${g;p;}' \
106             $(common-objpfx)abi-versions.h > $@T
107         mv -f $@T $@
109 # first-versions.h and ldbl-compat-choose.h provide macros used in
110 # various symbol versioning macro calls.
111 before-compile := $(common-objpfx)first-versions.h \
112                   $(common-objpfx)ldbl-compat-choose.h $(before-compile)
113 $(common-objpfx)first-versions.h: $(common-objpfx)versions.stmp
114 $(common-objpfx)ldbl-compat-choose.h: $(common-objpfx)versions.stmp
115 endif # avoid-generated
116 endif # $(build-shared) = yes
118 ifndef avoid-generated
119 ifneq (,$(CXX))
120 # If C++ headers <cstdlib> or <cmath> are used, GCC 6 will include
121 # /usr/include/stdlib.h or /usr/include/math.h from "#include_next"
122 # (instead of stdlib/stdlib.h or math/math.h in the glibc source
123 # directory), and this turns up as a make dependency.  An implicit
124 # rule will kick in and make will try to install stdlib/stdlib.h or
125 # math/math.h as /usr/include/stdlib.h or /usr/include/math.h because
126 # the target is out of date.  We make a copy of <cstdlib> and <cmath>
127 # in the glibc build directory so that stdlib/stdlib.h and math/math.h
128 # will be used instead of /usr/include/stdlib.h and /usr/include/math.h.
129 before-compile := $(common-objpfx)cstdlib $(common-objpfx)cmath \
130                   $(before-compile)
131 $(common-objpfx)cstdlib: $(c++-cstdlib-header)
132         $(INSTALL_DATA) $< $@T
133         $(move-if-change) $@T $@
134 $(common-objpfx)cmath: $(c++-cmath-header)
135         $(INSTALL_DATA) $< $@T
136         $(move-if-change) $@T $@
137 ifneq (,$(c++-bits-std_abs-h))
138 # Also make a copy of <bits/std_abs.h> from GCC 7 to prevent it from
139 # including /usr/include/stdlib.h.
140 before-compile := $(common-objpfx)bits/std_abs.h $(before-compile)
141 $(common-objpfx)bits/std_abs.h: $(c++-bits-std_abs-h)
142         $(INSTALL_DATA) $< $@T
143         $(move-if-change) $@T $@
144 endif
145 endif
147 before-compile := $(common-objpfx)libc-abis.h $(before-compile)
148 $(common-objpfx)libc-abis.h: $(common-objpfx)libc-abis.stamp; @:
149 $(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \
150                              $(firstword $(wildcard $(sysdirs:=/libc-abis)) \
151                                          $(..)libc-abis) \
152                              $(..)Makerules
153         $(SHELL) $< \
154                  $(base-machine)-$(config-vendor)-$(config-os) \
155                  < $(word 2,$^) > $(@:.stamp=.h)T
156         $(move-if-change) $(@:.stamp=.h)T $(@:.stamp=.h)
157         touch $@
158 common-generated += $(common-objpfx)libc-abis.h
159 endif # avoid-generated
161 ifeq (yes,$(build-shared))
162 $(common-objpfx)runtime-linker.h: $(common-objpfx)runtime-linker.stamp; @:
163 $(common-objpfx)runtime-linker.stamp: $(common-objpfx)config.make
164         $(make-target-directory)
165         echo '#define RUNTIME_LINKER "$(rtlddir)/$(rtld-installed-name)"' \
166                 > ${@:stamp=T}
167         $(move-if-change) ${@:stamp=T} ${@:stamp=h}
168         touch $@
169 endif
171 # Make sure the subdirectory for object files gets created.
172 ifdef objpfx
173 ifeq (,$(wildcard $(objpfx).))
174 before-compile += $(objpfx).
175 $(objpfx).:
176         $(make-target-directory)
177 endif
178 endif
180 # Remove existing files from `before-compile'.  Things are added there when
181 # they must exist for dependency generation to work right, but once they
182 # exist there is no further need for every single file to depend on them,
183 # and those gratuitous dependencies result in many gratuitous
184 # recompilations.
185 before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile))
187 # Don't let any before-compile file be an intermediate and get removed.
188 ifdef before-compile
189 $(before-compile):
190 endif
192 # We don't want $(common-objpfx) files to depend on miscellaneous stuff
193 # in subdirs.
194 ifdef subdir
195 common-before-compile := $(filter-out $(objpfx)%,$(before-compile))
196 else
197 common-before-compile = $(before-compile)
198 endif
200 ifndef subdir
201 # If a makefile needs to do something conditional on something that
202 # can only be figured out from headers, write a FOO.make.c input
203 # file that uses cpp contructs and contains @@@ LINE @@@ for each LINE
204 # to emit in the generated makefile, and use -include $(common-objpfx)FOO.make.
206 # We only generate these in the top-level makefile, to avoid any weirdness
207 # from subdir-specific makefile tweaks creeping in on an update.
208 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
209         rm -f $@T $@.dT
210         (echo '# Generated from $*.make.c by Makerules.'; \
211          $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
212                -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
213          | sed -n '/@@@/{s/@@@[  ]*\(.*\)@@@/\1/;s/[     ]*$$//p;}'; \
214          echo 'common-generated += $(@F)'; \
215          sed $(sed-remove-objpfx) $(sed-remove-dotdot) $@.dT; \
216          rm -f $@.dT) > $@T
217         mv -f $@T $@
218 endif
220 ifdef subdir
221 sed-remove-dotdot := -e 's@  *\.\.\/\([^        \]*\)@ $$(..)\1@g' \
222                      -e 's@^\.\.\/\([^  \]*\)@$$(..)\1@g'
223 else
224 sed-remove-dotdot := -e 's@  *\([^      \/$$][^         \]*\)@ $$(..)\1@g' \
225                      -e 's@^\([^        \/$$][^         \]*\)@$$(..)\1@g'
226 endif
228 ifdef gen-py-const-headers
229 # We'll use a static pattern rule to match .pysym files with their
230 # corresponding generated .py files.
231 # The generated .py files go in the submodule's dir in the glibc build dir.
232 py-const-files := $(patsubst %.pysym,%.py,$(gen-py-const-headers))
233 py-const-dir := $(objpfx)
234 py-const := $(addprefix $(py-const-dir),$(py-const-files))
235 py-const-script := $(..)scripts/gen-py-const.awk
237 # This is a hack we use to generate .py files with constants for Python
238 # pretty printers.  It works the same way as gen-as-const.
239 # See scripts/gen-py-const.awk for details on how the awk | gcc mechanism
240 # works.
242 # $@.tmp and $@.tmp2 are temporary files we use to store the partial contents
243 # of the target file.  We do this instead of just writing on $@ because, if the
244 # build process terminates prematurely, re-running Make wouldn't run this rule
245 # since Make would see that the target file already exists (despite it being
246 # incomplete).
248 # The sed line replaces "@name@SOME_NAME@value@SOME_VALUE@" strings from the
249 # output of 'gcc -S' with "SOME_NAME = SOME_VALUE" strings.
250 # The '-n' option, combined with the '/p' command, makes sed output only the
251 # modified lines instead of the whole input file.  The output is redirected
252 # to a .py file; we'll import it in the pretty printers file to read
253 # the constants generated by gen-py-const.awk.
254 # The regex has two capturing groups, for SOME_NAME and SOME_VALUE
255 # respectively.  Notice SOME_VALUE may be prepended by a special character,
256 # depending on the assembly syntax (e.g. immediates are prefixed by a '$'
257 # in AT&T x86, and by a '#' in ARM).  We discard it using a complemented set
258 # before the second capturing group.
259 $(py-const): $(py-const-dir)%.py: %.pysym $(py-const-script) \
260              $(common-before-compile)
261         $(make-target-directory)
262         $(AWK) -f $(py-const-script) $< \
263                | $(CC) -S -o $@.tmp $(CFLAGS) $(CPPFLAGS) -x c -
264         echo '# GENERATED FILE\n' > $@.tmp2
265         echo '# Constant definitions for pretty printers.' >> $@.tmp2
266         echo '# See gen-py-const.awk for details.\n' >> $@.tmp2
267         sed -n -r 's/^.*@name@([^@]+)@value@[^[:xdigit:]Xx-]*([[:xdigit:]Xx-]+)@.*/\1 = \2/p' \
268             $@.tmp >> $@.tmp2
269         mv -f $@.tmp2 $@
270         rm -f $@.tmp
272 generated += $(py-const)
273 endif  # gen-py-const-headers
275 ifdef gen-as-const-headers
276 # Generating headers for assembly constants.
277 # We need this defined early to get into before-compile before
278 # it's used in sysd-rules, below.
279 # Define GEN_AS_CONST_HEADERS to avoid circular dependency [BZ #22792].
280 # NB: <tcb-offsets.h> is generated from tcb-offsets.sym to define
281 # offsets and sizes of types in <tls.h> and maybe <pthread.h> which
282 # may include <tcb-offsets.h>.  Target header files can check if
283 # GEN_AS_CONST_HEADERS is defined to avoid circular dependency which
284 # may lead to build hang on a many-core machine.
285 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.py \
286                                            %.sym $(common-before-compile)
287         $(PYTHON) $< --cc="$(CC) $(CFLAGS) $(CPPFLAGS) -DGEN_AS_CONST_HEADERS \
288                            -MD -MP -MF $(@:.h=.h.d)T \
289                            -MT '$(@:.h=.h.d) $(@:.h.d=.h)'" \
290                   $(filter %.sym,$^) > $(@:.h.d=.h)T
291         sed $(sed-remove-objpfx) $(sed-remove-dotdot) \
292             $(@:.h=.h.d)T > $(@:.h=.h.d)T2
293         rm -f $(@:.h=.h.d)T
294         mv -f $(@:.h=.h.d)T2 $(@:.h=.h.d)
295         mv -f $(@:.h.d=.h)T $(@:.h.d=.h)
296 vpath %.sym $(sysdirs)
297 before-compile += $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
299 tests-internal += $(gen-as-const-headers:%.sym=test-as-const-%)
300 generated += $(gen-as-const-headers:%.sym=test-as-const-%.c)
301 $(objpfx)test-as-const-%.c: $(..)scripts/gen-as-const.py $(..)Makerules \
302                             %.sym $(common-objpfx)%.h
303         ($(AWK) '{ sub(/^/, "asconst_", $$2); print; }' $(filter %.h,$^); \
304          $(PYTHON) $< --test $(filter %.sym,$^)) > $@T
305         mv -f $@T $@
306 endif
308 ifeq (yes,$(build-shared))
309 # Generate the header containing the names of all shared libraries.
310 # We use a stamp file to avoid unnecessary recompilations.
311 before-compile += $(common-objpfx)gnu/lib-names.h
312 ifeq ($(soversions.mk-done),t)
313 ifndef abi-variants
314 lib-names-h-abi = gnu/lib-names.h
315 lib-names-stmp-abi = gnu/lib-names.stmp
316 else
317 lib-names-h-abi = gnu/lib-names-$(default-abi).h
318 lib-names-stmp-abi = gnu/lib-names-$(default-abi).stmp
319 before-compile += $(common-objpfx)$(lib-names-h-abi)
320 common-generated += gnu/lib-names.h
321 install-others-nosubdir: $(inst_includedir)/$(lib-names-h-abi)
322 $(common-objpfx)gnu/lib-names.h:
323         $(make-target-directory)
324         { \
325          echo '/* This file is automatically generated.';\
326          echo '   It defines macros to allow user program to find the shared'; \
327          echo '   library files which come as part of GNU libc.  */'; \
328          echo '#ifndef __GNU_LIB_NAMES_H'; \
329          echo '#define __GNU_LIB_NAMES_H        1'; \
330          echo ''; \
331          $(if $(abi-includes), \
332           $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
333           echo '';) \
334          $(foreach v,$(abi-variants),\
335          $(if $(abi-$(v)-condition),\
336          echo '#if $(abi-$(v)-condition)'; \
337          echo '# include <gnu/lib-names-$(v).h>'); \
338          $(if $(abi-$(v)-condition),echo '#endif';)) \
339          echo ''; \
340          echo '#endif   /* gnu/lib-names.h */'; \
341         } >  $@
342 endif
343 $(common-objpfx)$(lib-names-h-abi): $(common-objpfx)$(lib-names-stmp-abi); @:
344 $(common-objpfx)$(lib-names-stmp-abi): $(..)scripts/lib-names.awk \
345                                        $(common-objpfx)soversions.i
346         $(make-target-directory)
347         { \
348          $(if $(abi-variants), \
349          echo '/* This file is automatically generated.  */';\
350          echo '#ifndef __GNU_LIB_NAMES_H'; \
351          echo '# error "Never use <$(lib-names-h-abi)> directly; include <gnu/lib-names.h> instead."'; \
352          echo '#endif';, \
353          echo '/* This file is automatically generated.';\
354          echo '   It defines macros to allow user program to find the shared'; \
355          echo '   library files which come as part of GNU libc.  */'; \
356          echo '#ifndef __GNU_LIB_NAMES_H'; \
357          echo '#define __GNU_LIB_NAMES_H        1';) \
358          echo ''; \
359          ($(foreach s,$(all-sonames), echo $(s);)) \
360          | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort; \
361          $(if $(abi-variants),, \
362          echo ''; \
363          echo '#endif   /* gnu/lib-names.h */';) \
364         } >  ${@:stmp=T}
365         $(move-if-change) ${@:stmp=T} ${@:stmp=h}
366         touch $@
367 endif
368 common-generated += $(lib-names-h-abi) $(lib-names-stmp-abi)
369 endif
371 ###############################################################################
372 # NOTE!  Everything adding to before-compile needs to come before this point! #
373 ###############################################################################
375 # Generate an ordered list of implicit rules which find the source files in
376 # each sysdep directory.  The old method was to use vpath to search all the
377 # sysdep directories.  However, that had the problem that a .S file in a
378 # later directory would be chosen over a .c file in an earlier directory,
379 # which does not preserve the desired sysdeps ordering behavior.
381 # System-dependent makefiles can put in `inhibit-sysdep-asm' regexps
382 # matching sysdep directories whose assembly source files should be
383 # suppressed.
385 -include $(common-objpfx)sysd-rules
386 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
387 # The value of $(+sysdep_dirs) the sysd-rules was computed for
388 # differs from the one we are using now.  So force a rebuild of sysd-rules.
389 sysd-rules-force = FORCE
390 FORCE:
391 endif
392 $(common-objpfx)sysd-rules: $(..)scripts/sysd-rules.awk \
393                             $(common-objpfx)config.make $(..)Makerules \
394                             $(sysdep-makefiles) $(sysdep-makeconfigs) \
395                             $(sysd-rules-force)
396         -@rm -f $@T
397         LC_ALL=C $(AWK) -f $< > $@T \
398                         -v all_object_suffixes='$(all-object-suffixes)' \
399                         -v inhibit_sysdep_asm='$(inhibit-sysdep-asm)' \
400                         -v sysd_rules_patterns='$(sysd-rules-patterns)' \
401                         -v config_sysdirs='$(config-sysdirs)'
402         mv -f $@T $@
404 ifndef sysd-rules-done
405 # Don't do deps until this exists, because it provides rules to make the deps.
406 no_deps=t
407 endif
409 define o-iterator-doit
410 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
411 endef
412 object-suffixes-left := $(all-object-suffixes)
413 include $(o-iterator)
415 define o-iterator-doit
416 $(objpfx)%$o: %.c $(before-compile); $$(compile-command.c)
417 endef
418 object-suffixes-left := $(all-object-suffixes)
419 include $(o-iterator)
421 define o-iterator-doit
422 $(objpfx)%$o: %.cc $(before-compile); $$(compile-command.cc)
423 endef
424 object-suffixes-left := $(all-object-suffixes)
425 include $(o-iterator)
427 # Omit the objpfx rules when building in the source tree, because
428 # objpfx is empty and so these rules just override the ones above.
429 ifdef objpfx
430 # Define first rules to find the source files in $(objpfx).
431 # Generated source files will end up there.
432 define o-iterator-doit
433 $(objpfx)%$o: $(objpfx)%.S $(before-compile); $$(compile-command.S)
434 endef
435 object-suffixes-left := $(all-object-suffixes)
436 include $(o-iterator)
438 define o-iterator-doit
439 $(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
440 endef
441 object-suffixes-left := $(all-object-suffixes)
442 include $(o-iterator)
443 endif
445 # Generate .dT files as we compile.
446 compile-mkdep-flags = -MD -MP -MF $@.dt -MT $@
447 compile-command.S = $(compile.S) $(OUTPUT_OPTION) $(compile-mkdep-flags)
448 compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
449 compile-command.cc = $(compile.cc) $(OUTPUT_OPTION) $(compile-mkdep-flags)
451 # Like compile-mkdep-flags, but for use with $(BUILD_CC).  We don't want to
452 # track system includes here, they may spuriously trigger an install rule,
453 # and would cause the check-local-headers test to fail.
454 native-compile-mkdep-flags = -MMD -MP -MF $@.dt -MT $@
456 # GCC can grok options after the file name, and it looks nicer that way.
457 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
458 compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS)
459 compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \
460                   $(ASFLAGS) $(ASFLAGS-$(suffix $@))
461 COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS)
462 COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \
463                   $(ASFLAGS) $(ASFLAGS-$(suffix $@))
465 # We need this for the output to go in the right place.  It will default to
466 # empty if make was configured to work with a cc that can't grok -c and -o
467 # together.  You can't compile the C library with such a compiler.
468 OUTPUT_OPTION = -o $@
470 # This is the end of the pipeline for compiling generated C code.
471 compile-stdin.c = $(COMPILE.c) -o $@ -x c - $(compile-mkdep-flags)
473 # We need the $(CFLAGS) to be in there to have the right predefines during
474 # the dependency run for C sources.  But having it for assembly sources can
475 # get the wrong predefines.
476 S-CPPFLAGS = -DASSEMBLER $(asm-CPPFLAGS)
478 define +make-deps
479 $(make-target-directory)
480 $(+mkdep) $< $(if $(filter %.c,$<),$(CFLAGS)) \
481              $(CPPFLAGS) $($(patsubst .%,%,$(suffix $(<F)))-CPPFLAGS) | sed -e\
482 's,$(subst .,\.,$(@F:.d=.o)),$(foreach o,$(all-object-suffixes),$(@:.d=$o)) $@,' \
483 $(sed-remove-objpfx) $(sed-remove-dotdot) > $(@:.d=.T)
484 mv -f $(@:.d=.T) $@ $(generate-md5)
485 endef
487 ifneq (,$(objpfx))
488 # Continuation lines here are dangerous because they introduce spaces!
489 define sed-remove-objpfx
490 -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
491 -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
492 endef
493 endif
495 # Modify the list of routines we build for different targets
497 ifeq (yes,$(build-shared))
498 ifndef libc.so-version
499 # Undefine this because it can't work when we libc.so is unversioned.
500 static-only-routines =
501 endif
502 endif
504 elide-routines.oS += $(filter-out $(static-only-routines),\
505                                   $(routines) $(aux) $(sysdep_routines))
506 elide-routines.os += $(static-only-routines)
508 # If we have versioned code we don't need the old versions in any of the
509 # static libraries.
510 elide-routines.o  += $(shared-only-routines)
511 elide-routines.op += $(shared-only-routines)
513 # Shared library building.
515 ifeq (yes,$(build-shared))
517 # Reference map file only when shared libraries are built and a map file name
518 # is given.
519 ifeq ($(build-shared),yes)
520 map-file = $(firstword $($(@F:.so=-map)) \
521                        $(addprefix $(common-objpfx), \
522                                    $(filter $(@F:.so=.map),$(version-maps))))
523 load-map-file = $(map-file:%=-Wl,--version-script=%)
524 endif
526 # Compiler arguments to use to link a shared object with libc and
527 # ld.so.  This is intended to be as similar as possible to a default
528 # link with an installed libc.
529 link-libc-args = -Wl,--start-group \
530                  $(libc-for-link) \
531                  $(common-objpfx)libc_nonshared.a \
532                  $(as-needed) $(elf-objpfx)ld.so $(no-as-needed) \
533                  -Wl,--end-group
535 # The corresponding shared libc to use.  This may be modified for a
536 # particular target.
537 libc-for-link = $(common-objpfx)libc.so
539 # The corresponding dependencies.  As these are used in dependencies,
540 # not just commands, they cannot use target-specific variables so need
541 # to name both possible libc.so objects.
542 link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
543                  $(common-objpfx)libc_nonshared.a $(elf-objpfx)ld.so
545 # Pattern rule to build a shared object from an archive of PIC objects.
546 # This must come after the installation rules so Make doesn't try to
547 # build shared libraries in place from the installed *_pic.a files.
548 # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies
549 # on other shared objects.  The linking with libc and ld.so is intended
550 # to be as similar as possible to a default link with an installed libc.
551 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(link-libc-deps)
552         $(build-shlib) $(link-libc-args)
553         $(call after-link,$@)
555 define build-shlib-helper
556 $(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \
557           $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(rtld-LDFLAGS) \
558           $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
559           $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
560           -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
561           $(LDFLAGS.so) $(LDFLAGS-lib.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
562           -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
563 endef
565 ifeq (yes,$(use-default-link))
566 # If the linker is good enough, we can let it use its default linker script.
567 shlib-lds =
568 shlib-lds-flags =
569 else
570 # binutils only position loadable notes into the first page for binaries,
571 # not for shared objects
572 $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
573         $(LINK.o) -shared -Wl,-O1 \
574                   -nostdlib -nostartfiles \
575                   $(sysdep-LDFLAGS) $(rtld-LDFLAGS) $(LDFLAGS.so) \
576                   -Wl,--verbose 2>&1 | \
577           sed > $@T \
578               -e '/^=========/,/^=========/!d;/^=========/d' \
579               $(if $(filter yes,$(have-hash-style)), \
580                    -e 's/^.*\.gnu\.hash[        ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
581                    -e '/^[      ]*\.hash[       ]*:.*$$/{h;d;}' \
582                    -e '/DATA_SEGMENT_ALIGN/{H;g}' \
583                 , \
584                    -e 's/^.*\.hash[     ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
585                ) \
586               -e 's/^.*\*(\.dynbss).*$$/& \
587                  PROVIDE(__start___libc_freeres_ptrs = .); \
588                  *(__libc_freeres_ptrs) \
589                  PROVIDE(__stop___libc_freeres_ptrs = .);/'\
590               -e 's@^.*\*(\.jcr).*$$@& \
591                  PROVIDE(__start___libc_subfreeres = .);\
592                  __libc_subfreeres : { *(__libc_subfreeres) }\
593                  PROVIDE(__stop___libc_subfreeres = .);\
594                  PROVIDE(__start___libc_atexit = .);\
595                  __libc_atexit : { *(__libc_atexit) }\
596                  PROVIDE(__stop___libc_atexit = .);\
597                  PROVIDE(__start___libc_IO_vtables = .);\
598                  __libc_IO_vtables : { *(__libc_IO_vtables) }\
599                  PROVIDE(__stop___libc_IO_vtables = .);\
600                  /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
601         test -s $@T
602         mv -f $@T $@
603 common-generated += shlib.lds
605 shlib-lds = $(common-objpfx)shlib.lds
606 shlib-lds-flags = -T $(shlib-lds)
607 endif
609 define build-shlib
610 $(build-shlib-helper) -o $@ $(shlib-lds-flags) \
611           $(csu-objpfx)abi-note.o $(build-shlib-objlist)
612 endef
614 define build-module-helper
615 $(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
616           $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
617           -B$(csu-objpfx) $(load-map-file) \
618           $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
619           -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
620 endef
622 # This macro is similar to build-shlib but it does not define a soname
623 # and it does not depend on the destination name to start with `lib'.
624 # binutils only position loadable notes into the first page for binaries,
625 # not for shared objects
626 define build-module
627 $(build-module-helper) -o $@ $(shlib-lds-flags) \
628           $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
629 $(call after-link,$@)
630 endef
631 define build-module-asneeded
632 $(build-module-helper) -o $@ $(shlib-lds-flags) \
633           $(csu-objpfx)abi-note.o \
634           -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
635           $(link-libc-args)
636 $(call after-link,$@)
637 endef
639 # sofini.os must be placed last since it terminates .eh_frame section.
640 build-module-helper-objlist = \
641         $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\
642                    $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \
643                                 $(elf-objpfx)sofini.os \
644                                 $(link-libc-deps),$^))
646 build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so)
647 build-shlib-objlist = $(build-module-helper-objlist) \
648                       $(LDLIBS-$(@F:lib%.so=%).so) \
649                       $(filter $(elf-objpfx)sofini.os,$^)
651 # Don't try to use -lc when making libc.so itself.
652 # Also omits crti.o and crtn.o, which we do not want
653 # since we define our own `.init' section specially.
654 LDFLAGS-c.so = -nostdlib -nostartfiles
655 # But we still want to link libc.so against $(libc.so-gnulib).
656 LDLIBS-c.so += $(libc.so-gnulib)
657 # Give libc.so an entry point and make it directly runnable itself.
658 LDFLAGS-c.so += -e __libc_main
659 # Pre-link the objects of libc_pic.a so that we can locally resolve
660 # COMMON symbols before we link against ld.so.  This is because ld.so
661 # contains some of libc_pic.a already, which will prevent the COMMONs
662 # from being allocated in libc.so, which introduces evil dependencies
663 # between libc.so and ld.so, which can make it impossible to upgrade.
664 $(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
665         $(LINK.o) -nostdlib -nostartfiles -r -o $@ \
666         $(LDFLAGS-c_pic.os) -Wl,-d $(whole-archive) $^ -o $@
668 ifeq (,$(strip $(shlib-lds-flags)))
669 # Generate a list of -R options to excise .gnu.glibc-stub.* sections.
670 $(common-objpfx)libc_pic.opts: $(common-objpfx)libc_pic.os
671         $(OBJDUMP) -h $< | \
672         $(AWK) '$$2 ~ /\.gnu\.glibc-stub\./ { print "-R", $$2 }' \
673                 > $@T
674         mv -f $@T $@
675 # Apply those -R options.
676 $(common-objpfx)libc_pic.os.clean: $(common-objpfx)libc_pic.opts \
677                                    $(common-objpfx)libc_pic.os
678         $(OBJCOPY) @$^ $@
679 generated += libc_pic.opts libc_pic.os.clean
681 libc_pic_clean := .clean
682 endif
684 # Build a possibly-modified version of libc_pic.a for use in building
685 # linkobj/libc.so.
686 ifeq (,$(filter sunrpc,$(subdirs)))
687 $(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a
688         $(make-target-directory)
689         ln -f $< $@
690 else
691 $(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a \
692                                     $(common-objpfx)sunrpc/librpc_compat_pic.a
693         $(make-target-directory)
694         (cd $(common-objpfx)linkobj; \
695          $(AR) x ../libc_pic.a; \
696          rm $$($(AR) t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//'); \
697          $(AR) x ../sunrpc/librpc_compat_pic.a; \
698          $(AR) cr libc_pic.a *.os; \
699          rm *.os)
700 endif # $(subdirs) contains sunrpc
702 # Clear link-libc-deps for the libc.so libraries so build-shlibs does not
703 # filter ld.so out of the list of linked objects.
704 $(common-objpfx)libc.so: link-libc-deps = # empty
705 $(common-objpfx)linkobj/libc.so: link-libc-deps = # empty
707 # Use our own special initializer and finalizer files for the libc.so
708 # libraries.
709 $(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
710                          $(common-objpfx)libc_pic.os$(libc_pic_clean) \
711                          $(elf-objpfx)sofini.os \
712                          $(elf-objpfx)interp.os \
713                          $(elf-objpfx)ld.so \
714                          $(shlib-lds)
715         $(build-shlib)
716         $(call after-link,$@)
718 $(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \
719                          $(common-objpfx)linkobj/libc_pic.a \
720                          $(elf-objpfx)sofini.os \
721                          $(elf-objpfx)interp.os \
722                          $(elf-objpfx)ld.so \
723                          $(shlib-lds)
724         $(build-shlib)
725         $(call after-link,$@)
727 ifeq ($(build-shared),yes)
728 $(common-objpfx)libc.so: $(common-objpfx)libc.map
729 endif
730 common-generated += libc.so libc_pic.os
731 ifdef libc.so-version
732 $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so
733         $(make-link)
734 common-generated += libc.so$(libc.so-version)
735 endif
736 endif
738 # Figure out the source filenames in this directory.
740 override sources := $(addsuffix .c,\
741                         $(filter-out $(elided-routines),\
742                             $(routines) $(aux) \
743                             $(sysdep_routines)))
744 sysdep_routines := $(sysdep_routines)
746 headers := $(headers) $(sysdep_headers)
748 # This is the list of all object files, gotten by
749 # replacing every ".c" in `sources' with a ".o".
750 override objects := $(addprefix $(objpfx),$(sources:.c=.o))
753 # The makefile may define $(extra-libs) with `libfoo libbar'
754 # to build libfoo.a et al from the modules listed in $(libfoo-routines).
755 ifdef extra-libs
756 # extra-lib.mk is included once for each extra lib to define rules
757 # to build it, and to add its objects to the various variables.
758 # During its evaluation, $(lib) is set to the name of the library.
759 extra-libs-left := $(extra-libs)
760 include $(patsubst %,$(..)extra-lib.mk,$(extra-libs))
761 endif
764 # The makefile may define $(modules-names) to build additional modules.
765 # These are built with $(build-module), except any in $(modules-names-nobuild).
766 # MODULE_NAME=extramodules, except any in $(modules-names-tests).
767 ifdef modules-names
768 cpp-srcs-left := $(filter-out $(modules-names-tests),$(modules-names))
769 ifneq (,$(cpp-srcs-left))
770 lib := extramodules
771 include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
772 endif
774 ifdef modules-names-tests
775 cpp-srcs-left := $(filter $(modules-names-tests),$(modules-names))
776 ifneq (,$(cpp-srcs-left))
777 lib := testsuite
778 include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
779 endif
780 endif
782 extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names))
783 $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \
784                 $(objpfx)%.os $(shlib-lds) $(link-libs-deps)
785         $(build-module)
786 endif
788 +depfiles := $(sources:.c=.d) \
789              $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
790              $(patsubst %.oS,%.d,$(filter %.oS,$(extra-objs))) \
791              $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
792              $(addsuffix .d,$(tests) $(tests-internal) $(xtests) $(test-srcs))
793 ifeq ($(build-programs),yes)
794 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
795 endif
796 +depfiles := $(addprefix $(objpfx),\
797                          $(filter-out $(addsuffix .d,$(omit-deps)),\
798                                       $(+depfiles)))
799 all-dt-files := $(foreach o,$(object-suffixes-for-libc),$(+depfiles:.d=$o.dt))
800 +depfiles := $(patsubst %.dt,%.d,$(wildcard $(all-dt-files))) \
801              $(wildcard $(all-dt-files:.dt=.d))
803 # This is a funny rule in that it removes its input file.
804 %.d: %.dt
805         @sed $(sed-remove-objpfx) $< > $(@:.d=.T) && \
806          mv -f $(@:.d=.T) $@ && \
807          rm -f $<
809 # Avoid the .h.d files for any .sym files whose .h files don't exist yet.
810 # They will be generated when they're needed, and trying too early won't work.
811 +gen-as-const := $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
812 +depfiles += $(addsuffix .d,$(filter $(wildcard $(+gen-as-const)),\
813                                                 $(+gen-as-const)))
815 ifdef +depfiles
816 ifneq ($(no_deps),t)
817 -include $(+depfiles)
818 endif
819 endif
820 \f\f
821 # Maximize efficiency by minimizing the number of rules.
822 .SUFFIXES:      # Clear the suffix list.  We don't use suffix rules.
823 # Don't define any builtin rules.
824 MAKEFLAGS := $(MAKEFLAGS)r
826 # Generic rule for making directories.
828 # mkdir isn't smart enough to strip a trailing /.
829 # We always require a mkdir which supports the -p option to avoid error
830 # messages in case of races.
831         mkdir -p $(@:%/=%)
833 # Make sure that object files are not removed
834 # when they are intermediates between sources and library members.
835 .PRECIOUS: $(addprefix $(objpfx)%,$(all-object-suffixes))
837 # Make sure that the parent library archive is never removed.
838 .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
840 # Use the verbose option of ar and tar when not running silently.
841 ifeq    "$(findstring s,$(MAKEFLAGS))" ""       # if not -s
842 verbose := v
843 else                                            # -s
844 verbose :=
845 endif                                           # not -s
847 ARFLAGS := r$(verbose)
848 CREATE_ARFLAGS := cru$(verbose)
850 # This makes all the object files in the parent library archive.
852 .PHONY: lib lib-noranlib
853 lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c))
854 lib-noranlib: libobjs
856 # For object-suffix $o, the list of objects with that suffix.
857 # Makefiles can define `elide-routines.so = foo' to leave foo.so out.
858 o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\
859                                                        $(elide-routines$o)),\
860                                             $(objects))) \
861             $(addprefix $(objpfx),$(o-objects$o))
863 others: $(addprefix $(objpfx),$(install-lib))
865 ifndef objects
867 # Create the stamp$o files to keep the parent makefile happy.
868 subdir_lib: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
869 $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o):
870         $(make-target-directory)
871         rm -f $@; > $@
872 else
874 # Define explicit rules to update each $(objpfx)stamp.SUFFIX
875 # timestamp file; these rules (one explicit rule is generated for each
876 # object suffix) write a list of objects to update in the stamp file.
877 # The parent will then actually add them all to the archive in the
878 # archive rule, below.
879 define o-iterator-doit
880 $(objpfx)stamp$o: $(o-objects); $$(do-stamp)
881 endef
882 define do-stamp
883 $(make-target-directory)
884 echo '$(patsubst $(objpfx)%,$(addsuffix /,$(subdir))%,$^)' > $@T
885 mv -f $@T $@
886 endef
887 object-suffixes-left := $(object-suffixes-for-libc)
888 include $(o-iterator)
890 endif
892 # Now define explicit rules to build the library archives; these depend
893 # on the stamp files built above.
894 define o-iterator-doit
895 $(common-objpfx)$(patsubst %,$(libtype$o),c): \
896                 $(subdirs-stamp-o) $(common-objpfx)stamp$o; $$(do-makelib)
897 endef
898 define do-makelib
899 cd $(common-objdir) && \
900 $(AR) $(CREATE_ARFLAGS) $(@F) `cat $(patsubst $(common-objpfx)%,%,$^)`
901 endef
902 subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%)
903 subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
904 ifndef subdir
905 $(subdirs-stamps): subdir_lib;
906 endif
907 object-suffixes-left = $(object-suffixes-for-libc)
908 include $(o-iterator)
911 # This makes all the object files.
912 .PHONY: objects objs libobjs extra-objs
913 objects objs: libobjs extra-objs
914 libobjs: $(foreach o,$(object-suffixes-for-libc),$(objpfx)stamp$o)
915 extra-objs: $(addprefix $(objpfx),$(extra-objs))
917 # Canned sequence for building an extra library archive.
918 define build-extra-lib
919 $(patsubst %/,cd % &&,$(objpfx)) \
920 $(AR) $(CREATE_ARFLAGS) $(@:$(objpfx)%=%) \
921       $(patsubst $(objpfx)%,%,$^)
922 endef
924 # Installation.
926 .PHONY: force-install
927 force-install:
929 # $(install-lib) are installed from the object directory into $(libdir);
930 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
931 # unless they also appear in $(non-lib.a).  $(install-data) are installed as
932 # they are into $(datadir).  $(headers) are installed as they are in
933 # $(includedir).  $(install-bin), $(install-bin-script) and $(install-sbin)
934 # are installed from the object directory into $(bindir), $(bindir) and
935 # $(sbindir), respectively.  $(install-others) and $(install-others-programs)
936 # are absolute path names of files to install; rules to install them are
937 # defined elsewhere.
939 # The simple library name to install libc.a under.
940 # This could be defined by a sysdep Makefile.
941 ifndef libc-name
942 libc-name := c
943 endif
945 define do-install
946 $(make-target-directory)
947 $(INSTALL_DATA) $< $@
948 endef
950 # Make the target directory if it doesn't exist, using the `mkinstalldirs'
951 # script that does `mkdir -p' even if `mkdir' doesn't support that flag.
952 define make-target-directory
953 $(addprefix $(..)./scripts/mkinstalldirs ,\
954             $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%)))
955 endef
957 # Any directory (parent or subdir) should install libc.a; this way
958 # "make install" in a subdir is guaranteed to install everything it changes.
959 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
960                              $(inst_libdir)/$(patsubst %,$(libtype$o),\
961                                                      $(libprefix)$(libc-name)))
963 .PHONY: check-install-supported
964 check-install-supported:
966 # Check to see if the prefix or exec_prefix GNU standard variable
967 # has been overridden on the command line and, if so, fail with
968 # an error message since doing so is not supported (set DESTDIR
969 # instead).
970 ifeq ($(origin prefix),command line)
971 check-install-supported:
972         $(error Overriding prefix is not supported. Set DESTDIR instead.)
973 endif
975 ifeq ($(origin exec_prefix),command line)
976 check-install-supported:
977         $(error Overriding exec_prefix is not supported. Set DESTDIR instead.)
978 endif
980 install: check-install-supported
982 install: $(installed-libcs)
983 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
984         $(make-target-directory)
985         $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@
987 define do-install-program
988 $(make-target-directory)
989 $(INSTALL_PROGRAM) $< $@.new
990 mv -f $@.new $@
991 endef
993 define do-install-script
994 $(make-target-directory)
995 $(INSTALL_SCRIPT) $< $@.new
996 mv -f $@.new $@
997 endef
999 install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
1000 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
1002 ifeq (yes,$(build-shared))
1003 # Find which .so's have versions.
1004 versioned := $(strip $(foreach so,$(install-lib.so),\
1005                                $(patsubst %,$(so),$($(so)-version))))
1007 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
1008 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
1010 # For versioned libraries, we install three files:
1011 #       $(inst_libdir)/libfoo.so        -- for linking, symlink or ld script
1012 #       $(inst_slibdir)/libfoo.so.NN    -- for loading by SONAME, symlink
1013 #       $(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
1014 lib-version := $(firstword $($(subdir)-version) $(version))
1015 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
1016                       $(foreach L,$(install-lib.so-versioned),\
1017                                 $(inst_libdir)/$L \
1018                                 $(inst_slibdir)/$(L:.so=)-$(lib-version).so \
1019                                 $(inst_slibdir)/$L$($L-version))
1021 # Install all the unversioned shared libraries.
1022 $(install-lib.so-unversioned:%=$(inst_slibdir)/%): $(inst_slibdir)/%.so: \
1023     $(objpfx)%.so $(+force)
1024         $(do-install-program)
1026 ifneq ($(findstring -s,$(LN_S)),)
1027 define make-link
1028 rm -f $@.new
1029 $(SHELL) $(..)scripts/rellns-sh $< $@.new
1030 mv -f $@.new $@
1031 endef
1032 define make-link-multidir
1033 $(patsubst %/,cd %,$(objpfx)); \
1034   $(addprefix $(abspath $(..)scripts/mkinstalldirs) ,$(dir $(multidir))); \
1035   $(LN_S) . $(multidir) 2> /dev/null; \
1036   test -L $(multidir)
1037 endef
1038 else
1039 # If we have no symbolic links don't bother with rellns-sh.
1040 define make-link
1041 rm -f $@.new
1042 $(LN_S) $< $@.new
1043 mv -f $@.new $@
1044 endef
1045 define make-link-multidir
1046 $(make-target-directory)
1047 ln -f $(objpfx)/$(@F) $@
1048 endef
1049 endif
1051 ifeq (yes,$(build-shared))
1052 ifeq (no,$(cross-compiling))
1053 symbolic-link-prog := $(elf-objpfx)sln
1054 symbolic-link-list := $(elf-objpfx)symlink.list
1055 define make-shlib-link
1056 echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
1057 endef
1058 else # cross-compiling
1059 # We need a definition that can be used by elf/Makefile's install rules.
1060 symbolic-link-prog = $(LN_S)
1061 endif
1062 endif
1063 ifndef make-shlib-link
1064 define make-shlib-link
1065 rm -f $@
1066 $(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
1067 endef
1068 endif
1070 ifdef libc.so-version
1071 # For a library specified to be version N, install three files:
1072 # libc.so       ->      libc.so.N       (e.g. libc.so.6)
1073 # libc.so.6     ->      libc-VERSION.so (e.g. libc-1.10.so)
1075 $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
1076                                            $(+force)
1077         $(make-shlib-link)
1078 $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
1079         $(do-install-program)
1080 install: $(inst_slibdir)/libc.so$(libc.so-version)
1082 # This fragment of linker script gives the OUTPUT_FORMAT statement
1083 # for the configuration we are building.  We put this statement into
1084 # the linker scripts we install for -lc et al so that they will not be
1085 # used by a link for a different format on a multi-architecture system.
1086 $(common-objpfx)format.lds: $(..)scripts/output-format.sed \
1087                             $(common-objpfx)config.make \
1088                             $(common-objpfx)config.h $(..)Makerules
1089 ifneq (unknown,$(output-format))
1090         echo > $@.new 'OUTPUT_FORMAT($(output-format))'
1091 else
1092         $(LINK.o) -shared $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
1093                   $(LDFLAGS.so) $(LDFLAGS-lib.so) \
1094                   -x c /dev/null -o $@.so -Wl,--verbose -v 2>&1 \
1095         | sed -n -f $< > $@.new
1096         test -s $@.new
1097         rm -f $@.so
1098 endif
1099         mv -f $@.new $@
1100 common-generated += format.lds
1102 ifndef subdir
1103 # What we install as libc.so for programs to link against is in fact a
1104 # link script.  It contains references for the various libraries we need.
1105 # The libc.so object is not complete since some functions are only defined
1106 # in libc_nonshared.a.
1107 # We need to use absolute paths since otherwise local copies (if they exist)
1108 # of the files are taken by the linker.
1109 install: $(inst_libdir)/libc.so
1110 $(inst_libdir)/libc.so: $(common-objpfx)format.lds \
1111                         $(common-objpfx)libc.so$(libc.so-version) \
1112                         $(inst_libdir)/$(patsubst %,$(libtype.oS),\
1113                                                   $(libprefix)$(libc-name)) \
1114                         $(+force)
1115         (echo '/* GNU ld script';\
1116          echo '   Use the shared library, but some functions are only in';\
1117          echo '   the static library, so try that secondarily.  */';\
1118          cat $<; \
1119          echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \
1120               '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\
1121               ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \
1122         ) > $@.new
1123         mv -f $@.new $@
1125 endif
1127 else
1128 install: $(inst_slibdir)/libc.so
1129 $(inst_slibdir)/libc.so: $(common-objpfx)libc.so $(+force)
1130         $(do-install-program)
1131 endif
1133 ifneq (,$(versioned))
1134 # Produce three sets of rules as above for all the smaller versioned libraries.
1136 define o-iterator-doit
1137 $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version) $(+force); $$(make-link)
1138 endef
1139 object-suffixes-left := $(filter-out $(install-lib-ldscripts),$(versioned))
1140 ifneq (,$(object-suffixes-left))
1141 include $(o-iterator)
1142 endif
1144 # Make symlinks in the build directory, because the versioned names might
1145 # be referenced by a DT_NEEDED in another library.
1146 define o-iterator-doit
1147 $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link)
1148 endef
1149 object-suffixes-left := $(versioned)
1150 include $(o-iterator)
1152 generated += $(foreach o,$(versioned),$o$($o-version))
1154 ifeq (,$($(subdir)-version))
1155 define o-iterator-doit
1156 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
1157                                  $(+force);
1158         $$(make-shlib-link)
1159 endef
1160 object-suffixes-left := $(versioned)
1161 include $(o-iterator)
1163 define o-iterator-doit
1164 $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
1165         $$(do-install-program)
1166 endef
1167 object-suffixes-left := $(versioned)
1168 include $(o-iterator)
1169 else
1170 define o-iterator-doit
1171 $(inst_slibdir)/$o$($o-version): \
1172   $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
1173         $$(make-shlib-link)
1174 endef
1175 object-suffixes-left := $(versioned)
1176 include $(o-iterator)
1178 define o-iterator-doit
1179 $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
1180         $$(do-install-program)
1181 endef
1182 object-suffixes-left := $(versioned)
1183 include $(o-iterator)
1184 endif
1185 endif
1187 define do-install-so
1188 $(do-install-program)
1189 $(patsubst %,$(LN_S) -f $(@F) \
1190                         $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
1191            $(filter-out %.so,$@))
1192 endef
1194 so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version)))
1195 $(foreach v,$(so-versions),\
1196           $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so \
1197                                                $(+force)
1198         $(do-install-so)
1199 $(foreach v,$(so-versions),\
1200           $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so $(+force)
1201         $(do-install-so)
1202 endif
1204 ifdef install-bin
1205 $(addprefix $(inst_bindir)/,$(install-bin)): \
1206     $(inst_bindir)/%: $(objpfx)% $(+force)
1207         $(do-install-program)
1208 endif
1209 ifdef install-bin-script
1210 $(addprefix $(inst_bindir)/,$(install-bin-script)): \
1211     $(inst_bindir)/%: $(objpfx)% $(+force)
1212         $(do-install-script)
1213 endif
1214 ifdef install-rootsbin
1215 $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): \
1216    $(inst_rootsbindir)/%: $(objpfx)% $(+force)
1217         $(do-install-program)
1218 endif
1219 ifdef install-sbin
1220 $(addprefix $(inst_sbindir)/,$(install-sbin)): \
1221     $(inst_sbindir)/%: $(objpfx)% $(+force)
1222         $(do-install-program)
1223 endif
1224 ifdef install-lib
1225 install-lib.a := $(filter lib%.a,$(install-lib))
1226 install-lib.a := $(filter-out $(install-lib-ldscripts),$(install-lib.a))
1227 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
1228 ifdef install-lib-non.a
1229 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
1230   $(inst_libdir)/$(libprefix)%: $(objpfx)% $(+force)
1231         $(do-install)
1232 endif
1233 ifdef install-lib.a
1234 $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \
1235   $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a $(+force)
1236         $(do-install)
1237 endif
1238 endif
1239 ifdef install-data
1240 $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
1241         $(do-install)
1242 endif
1243 headers := $(strip $(headers))
1244 ifdef headers
1245 # This implicit rule installs headers from the source directory.
1246 # It may be ignored in preference to rules from sysd-rules to find
1247 # headers in the sysdeps tree.
1248 $(inst_includedir)/%.h: $(objpfx)%.h $(+force)
1249         $(do-install)
1250 $(inst_includedir)/%.h: $(common-objpfx)%.h $(+force)
1251         $(do-install)
1252 $(inst_includedir)/%.h: %.h $(+force)
1253         $(do-install)
1254 $(inst_includedir)/%.h: $(..)include/%.h $(+force)
1255         $(do-install)
1256 headers-nonh := $(filter-out %.h,$(headers))
1257 ifdef headers-nonh
1258 $(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
1259                                                  % $(+force)
1260         $(do-install)
1261 endif   # headers-nonh
1262 endif   # headers
1264 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
1265         install-rootsbin-nosubdir install-sbin-nosubdir install-lib-nosubdir \
1266         install-data-nosubdir install-headers-nosubdir
1267 install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin))
1268 install-bin-script-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin-script))
1269 install-rootsbin-nosubdir: \
1270         $(addprefix $(inst_rootsbindir)/,$(install-rootsbin))
1271 install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin))
1272 install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
1273                        $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \
1274                        $(addprefix $(libprefix),$(install-lib-non.a)))
1275 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
1276 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
1277 install-others-nosubdir: $(install-others)
1278 install-others-programs-nosubdir: $(install-others-programs)
1280 # We need all the `-nosubdir' targets so that `install' in the parent
1281 # doesn't depend on several things which each iterate over the subdirs.
1282 # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a
1283 # subroutine.  Then in the parent `install-FOO' also causes subdir makes.
1284 install-%:: install-%-nosubdir ;
1286 .PHONY: install install-no-libc.a-nosubdir
1287 install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
1288                             install-lib-nosubdir install-others-nosubdir
1289 ifeq ($(build-programs),yes)
1290 install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
1291                             install-rootsbin-nosubdir install-sbin-nosubdir \
1292                             install-others-programs-nosubdir
1293 endif
1294 install: install-no-libc.a-nosubdir
1296 # Command to compile $< using the native libraries.
1297 define native-compile
1298 $(make-target-directory)
1299 $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
1300             $< $(OUTPUT_OPTION) $(BUILD_LDFLAGS)
1301 endef
1303 # We always want to use configuration definitions.
1304 ALL_BUILD_CFLAGS = $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -D_GNU_SOURCE \
1305                    -DIS_IN_build -include $(common-objpfx)config.h
1307 # Support the GNU standard name for this target.
1308 .PHONY: check
1309 check: tests
1310 # Special target to run tests which cannot be run unconditionally.
1311 # Maintainers should use this target.
1312 .PHONY: xcheck
1313 xcheck: xtests
1315 # The only difference between MODULE_NAME=testsuite and MODULE_NAME=nonlib is
1316 # that almost all internal declarations from config.h, libc-symbols.h, and
1317 # include/*.h are not available to 'testsuite' code, but are to 'nonlib' code.
1318 all-testsuite := $(strip $(tests) $(xtests) $(test-srcs) $(test-extras) \
1319                  $(tests-container))
1320 ifneq (,$(all-testsuite))
1321 cpp-srcs-left = $(all-testsuite)
1322 lib := testsuite
1323 include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
1324 endif
1326 all-nonlib := $(strip $(tests-internal) $(test-internal-extras) \
1327                       $(others) $(others-extras))
1328 ifneq (,$(all-nonlib))
1329 cpp-srcs-left = $(all-nonlib)
1330 lib := nonlib
1331 include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
1332 endif
1335 ifeq ($(build-shared),yes)
1336 # Generate normalized lists of symbols, versions, and data sizes.
1337 # This is handy for checking against existing library binaries.
1339 %.symlist: $(..)scripts/abilist.awk %.dynsym
1340         LC_ALL=C $(AWK) -f $^ > $@T
1341         mv -f $@T $@
1343 %.dynsym: %.so
1344         LC_ALL=C $(OBJDUMP) --dynamic-syms $< > $@T
1345         mv -f $@T $@
1347 # A sysdeps/.../Makefile can set abilist-pattern to something like
1348 # %-foo.abilist to look for libc-foo.abilist instead of libc.abilist.
1349 # This makes sense if multiple ABIs can be most cleanly supported by a
1350 # configuration without using separate sysdeps directories for each.
1351 ifdef abilist-pattern
1352 vpath $(abilist-pattern) $(+sysdep_dirs)
1353 endif
1355 vpath %.abilist $(+sysdep_dirs)
1357 # The .PRECIOUS rule prevents the files built by an implicit rule whose
1358 # target pattern is %.symlist from being considered "intermediate files"
1359 # and automatically removed.  We only want these files to be removed by
1360 # 'make clean', which is handled by the 'generated' variable.
1361 .PRECIOUS: %.symlist
1362 generated += $(extra-libs:=.symlist)
1364 ifdef abilist-pattern
1365 $(objpfx)check-abi-%.out: $(common-objpfx)config.make $(abilist-pattern) \
1366                           $(objpfx)%.symlist
1367         $(check-abi-pattern); \
1368         $(evaluate-test)
1369 $(objpfx)check-abi-%.out: $(common-objpfx)config.make $(abilist-pattern) \
1370                           $(common-objpfx)%.symlist
1371         $(check-abi-pattern); \
1372         $(evaluate-test)
1373 endif
1374 $(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
1375                           $(objpfx)%.symlist
1376         $(check-abi); \
1377         $(evaluate-test)
1378 $(objpfx)check-abi-%.out: $(common-objpfx)config.make %.abilist \
1379                           $(common-objpfx)%.symlist
1380         $(check-abi); \
1381         $(evaluate-test)
1382 define check-abi-pattern
1383         diff -p -U 0 $(filter $(abilist-pattern),$^) $(filter %.symlist,$^) \
1384              > $@
1385 endef
1386 define check-abi
1387         diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^) > $@
1388 endef
1390 ifdef abilist-pattern
1391 update-abi-%: $(objpfx)%.symlist $(abilist-pattern)
1392         $(update-abi-pattern)
1393 update-abi-%: $(common-objpfx)%.symlist $(abilist-pattern)
1394         $(update-abi-pattern)
1395 endif
1396 update-abi-%: $(objpfx)%.symlist %.abilist
1397         $(update-abi)
1398 update-abi-%: $(common-objpfx)%.symlist %.abilist
1399         $(update-abi)
1400 define update-abi-pattern
1401 @if cmp -s $^ 2> /dev/null; \
1402  then \
1403       echo '+++ $(filter $(abilist-pattern),$^) is unchanged'; \
1404  else cp -f $^; \
1405       echo '*** Now check $(filter $(abilist-pattern),$^) changes for correctness ***'; \
1406  fi
1407 endef
1408 define update-abi
1409 @if cmp -s $^ 2> /dev/null; \
1410  then \
1411       echo '+++ $(filter %.abilist,$^) is unchanged'; \
1412  else cp -f $^; \
1413       echo '*** Now check $(filter %.abilist,$^) changes for correctness ***'; \
1414  fi
1415 endef
1417 # Patch all .abilist files for one DSO.  The find command locates
1418 # abilist files for all architectures.  The regular expression in the
1419 # find invocation is needed to separate libc.abilist and
1420 # libcrypt.abilist, for example.  It assumes that abilist-pattern, if
1421 # set, is of the form "%-SUFFIX", and not "%SUFFIX", that is, there is
1422 # a non-alphanumeric seperator between the pattern and the suffix
1423 # added.  The abilist files in /generic/ are filtered out because
1424 # these are expected to remain empty.
1425 define update-all-abi
1426 $(SHELL) $(..)scripts/update-abilist.sh $^ \
1427   $$(find $(..)sysdeps \
1428     -regextype posix-egrep -regex '.*/$*([^a-z0-9].*)?\.abilist$$' \
1429     \! -regex '.*/generic/.*')
1430 endef
1431 ifdef abilist-pattern
1432 update-all-abi-%: $(abilist-pattern) $(objpfx)%.symlist
1433         $(update-all-abi)
1434 update-all-abi-%: $(abilist-pattern) $(common-objpfx)%.symlist
1435         $(update-all-abi)
1436 endif
1437 update-all-abi-%: %.abilist $(objpfx)%.symlist
1438         $(update-all-abi)
1439 update-all-abi-%: %.abilist $(common-objpfx)%.symlist
1440         $(update-all-abi)
1442 .PHONY: update-abi update-all-abi check-abi
1443 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
1444 update-all-abi: $(patsubst %.so,update-all-abi-%,$(install-lib.so-versioned))
1445 check-abi-list = $(patsubst %.so,$(objpfx)check-abi-%.out, \
1446                                  $(install-lib.so-versioned))
1447 check-abi: $(check-abi-list)
1448 ifdef subdir
1449 subdir_check-abi: check-abi
1450 subdir_update-abi: update-abi
1451 subdir_update-all-abi: update-all-abi
1452 else
1453 check-abi: subdir_check-abi
1454         if grep -q '^FAIL:' $(objpfx)*/check-abi*.test-result; then \
1455                 cat $(objpfx)*/check-abi*.out && exit 1; fi
1456 update-abi: subdir_update-abi
1457 update-all-abi: subdir_update-all-abi
1458 endif
1460 ifeq ($(subdir),elf)
1461 check-abi: $(objpfx)check-abi-libc.out
1462 tests-special += $(objpfx)check-abi-libc.out
1463 update-abi: update-abi-libc
1464 update-all-abi: update-all-abi-libc
1465 common-generated += libc.symlist
1466 endif
1468 ifeq ($(build-shared),yes)
1469 ifdef subdir
1470 tests-special += $(check-abi-list)
1471 endif
1472 endif
1474 endif
1476 # These will have been set by sysdeps/posix/Makefile.
1477 L_tmpnam  ?= 1
1478 TMP_MAX   ?= 0
1479 L_ctermid ?= 1
1480 L_cuserid ?= 1
1482 stdio_lim = $(common-objpfx)bits/stdio_lim.h
1484 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
1485 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
1486                    $(common-objpfx)config.make
1487         $(make-target-directory)
1488         { echo '#include "$(..)posix/bits/posix1_lim.h"';               \
1489         } |                                                             \
1490         $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)'   \
1491               $(CPPUNDEFS) $(+includes) -xc - -o $(@:st=hT)
1492         sed $(sed-remove-objpfx) $(sed-remove-dotdot)                   \
1493             $(@:st=dT) > $(@:st=dt)
1494         mv -f $(@:st=dt) $(@:st=d)
1495         fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`;       \
1496         filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`;    \
1497         fopen_max=$${fopen_max:-16};                                    \
1498         filename_max=$${filename_max:-1024};                            \
1499         sed -e "s/@FOPEN_MAX@/$$fopen_max/"                             \
1500             -e "s/@FILENAME_MAX@/$$filename_max/"                       \
1501             -e "s/@L_tmpnam@/$(L_tmpnam)/"                              \
1502             -e "s/@TMP_MAX@/$(TMP_MAX)/"                                \
1503             -e "s/@L_ctermid@/$(L_ctermid)/"                            \
1504             -e "s/@L_cuserid@/$(L_cuserid)/"                            \
1505             $< > $(@:st=h.new)
1506         $(move-if-change) $(@:st=h.new) $(@:st=h)
1507 # Remove these last so that they can be examined if something went wrong.
1508         rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
1509         touch $@
1510 # Get dependencies.
1511 ifndef no_deps
1512 -include $(stdio_lim:h=d)
1513 endif
1514 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
1516 FORCE:
1518 .PHONY: echo-headers
1519 echo-headers:
1520         @echo $(headers)
1522 %.bz2: %; bzip2 -9vk $<
1523 %.gz: %; gzip -9vnc $< > $@.new && mv -f $@.new $@
1524 %.xz: %; xz -9evk $<
1526 # Common cleaning targets.
1528 .PHONY: common-mostlyclean common-clean mostlyclean clean do-tests-clean
1529 clean: common-clean
1530 mostlyclean: common-mostlyclean
1532 do-tests-clean:
1533         -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) \
1534                                                       $(tests-internal) \
1535                                                       $(xtests) \
1536                                                       $(test-srcs)) \
1537                                      $(addsuffix .test-result,$(tests) \
1538                                                               $(tests-internal) \
1539                                                               $(xtests) \
1540                                                               $(test-srcs)))
1542 # Remove the object files.
1543 common-mostlyclean:
1544         -rm -f $(addprefix $(objpfx),$(tests) $(tests-internal) $(xtests) \
1545                                      $(test-srcs) \
1546                                      $(others) $(sysdep-others) stubs \
1547                                      $(addsuffix .o,$(tests) \
1548                                                     $(tests-internal) \
1549                                                     $(xtests) \
1550                                                     $(test-srcs) \
1551                                                     $(others) \
1552                                                     $(sysdep-others)) \
1553                                      $(addsuffix .out,$(tests) \
1554                                                       $(tests-internal) \
1555                                                       $(xtests) \
1556                                                       $(test-srcs)) \
1557                                      $(addsuffix .test-result,$(tests) \
1558                                                               $(tests-internal) \
1559                                                               $(xtests) \
1560                                                               $(test-srcs)))
1561         -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
1562                                      $(install-lib) $(install-lib.so) \
1563                                      $(install-lib.so:%.so=%_pic.a))
1564         -rm -f core
1565         -rm -f $(objpfx)rtld-*.os
1566         $(rmobjs)
1567 define rmobjs
1568 $(foreach o,$(object-suffixes-for-libc),
1569 -rm -f $(objpfx)stamp$o $(o-objects))
1570 endef
1572 # Also remove the dependencies and generated source files.
1573 common-clean: common-mostlyclean
1574         -rm -f $(addprefix $(objpfx),$(generated))
1575         -rm -f $(objpfx)*.d $(objpfx)*.dt
1576         -rm -fr $(addprefix $(objpfx),$(generated-dirs))
1577         -rm -f $(addprefix $(common-objpfx),$(common-generated))
1578         -rm -f $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
1580 # Produce a file `stubs' which contains `#define __stub_FUNCTION'
1581 # for each function which is a stub.
1583 ifdef objpfx
1584 .PHONY: stubs # The parent Makefile calls this target.
1585 stubs: $(objpfx)stubs
1586 endif
1587 objs-for-stubs := $(foreach o,$(object-suffixes-for-libc),$(o-objects)) \
1588                   $(addprefix $(objpfx),$(extra-objs))
1589 $(objpfx)stubs: $(objs-for-stubs)
1590 ifneq (,$(strip $(objs-for-stubs)))
1591         (cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
1592         $(AWK) '/\.gnu\.glibc-stub\./ { \
1593                   sub(/\.gnu\.glibc-stub\./, "", $$2); \
1594                   stubs[$$2] = 1; } \
1595                 END { for (s in stubs) print "#define __stub_" s }' > $@T
1596         mv -f $@T $@
1597 else
1598         > $@
1599 endif
1601 ifneq (,$(strip $(gpl2lgpl)))
1602 ifneq (,$(wildcard $(..)gpl2lgpl.sed))
1603 # Snarf from the master source and frob the copying notice.
1604 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
1605         sed -f $^ > $@-tmp
1606 # So I don't edit them by mistake.
1607         chmod a-w $@-tmp
1608         mv -f $@-tmp $@
1609 endif
1610 endif
1612 # Local Variables:
1613 # mode: makefile
1614 # End: