~ubuntu-branches/ubuntu/utopic/eglibc/utopic

« back to all changes in this revision

Viewing changes to .pc/hurd-i386/tg-hooks.diff/Makerules

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2012-10-26 05:14:58 UTC
  • mfrom: (1.5.1) (4.4.22 experimental)
  • Revision ID: package-import@ubuntu.com-20121026051458-oryotr4i03ob5pab
Tags: 2.16-0ubuntu1
* Merge with unreleased 2.16 in Debian experimental, remaining changes:
  - Drop the Breaks line from libc6, which refers to a Debian transition
  - Remove the libc6 recommends on libc6-i686, which we don't build
  - Enable libc6{,-dev}-armel on armhf and libc6{-dev}-armhf on armel
  - Ship update-locale and validlocale in /usr/sbin in libc-bin
  - Don't build locales or locales-all in Ubuntu, we rely on langpacks
  - Heavily mangle the way we do service restarting on major upgrades
  - Use different MIN_KERNEL_SUPPORTED versions than Debian, due to
    buildd needs.  This should be universally bumped to 3.2.0 once all
    our buildds (including the PPA guests) are running precise kernels
  - Build i386 variants as -march=i686, build amd64 with -O3, and build
    ppc64 variants (both 64-bit and 32-bit) with -O3 -fno-tree-vectorize
  - Re-enable unsubmitted-ldconfig-cache-abi.diff and rebuild the cache
    on upgrades from previous versions that used a different constant
  - debian/patches/any/local-CVE-2012-3406.diff: switch to malloc when
    array grows too large to handle via alloca extension (CVE-2012-3406)
  - Build generic i386/i686 flavour with -mno-tls-direct-seg-refs
* Changes added/dropped with this merge while reducing our delta:
  - Stop building glibc docs from the eglibc source, and instead make
    the glibc-docs stub have a hard dependency on glibc-doc-reference
  - Remove outdated conflicts against ancient versions of ia32-libs
  - Drop the tzdata dependency from libc6, it's in required and minimal
  - Use gcc-4.7/g++-4.7 by default on all our supported architectures
  - Save our historical changelog as changelog.ubuntu in the source
  - Drop nscd's libaudit build-dep for now, as libaudit is in universe
  - Drop the unnecessary Breaks from libc6 to locales and locales-all
  - Ship xen's ld.so.conf.d snippet as /etc/ld.so.conf.d/libc6-xen.conf
* Disable hard failures on the test suite for the first upload to raring

Show diffs side-by-side

added added

removed removed

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