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