]>
Commit | Line | Data |
---|---|---|
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 | # Makefile configuration options for the GNU C library. | |
20 | # | |
21 | ifneq (,) | |
22 | This makefile requires GNU Make. | |
23 | endif | |
24 | ||
25 | all: # Make this the default goal | |
26 | ||
27 | ifneq "$(origin +included-Makeconfig)" "file" | |
28 | ||
29 | +included-Makeconfig := yes | |
30 | ||
31 | ifdef subdir | |
32 | .. := ../ | |
33 | endif | |
34 | ||
35 | # $(common-objdir) is the place to put objects and | |
36 | # such that are not specific to a single subdir. | |
37 | ifdef objdir | |
38 | objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/) | |
39 | common-objpfx = $(objdir)/ | |
40 | common-objdir = $(objdir) | |
41 | else | |
42 | objdir must be defined by the build-directory Makefile. | |
43 | endif | |
44 | ||
45 | # Root of the sysdeps tree. | |
46 | sysdep_dir := $(..)sysdeps | |
47 | export sysdep_dir := $(sysdep_dir) | |
48 | ||
49 | # Get the values defined by options to `configure'. | |
50 | include $(common-objpfx)config.make | |
51 | ||
52 | # What flags to give to sources which call user provided callbacks | |
53 | uses-callbacks = -fexceptions | |
54 | ||
55 | # What flags to give to tests which test stack alignment | |
56 | stack-align-test-flags = | |
57 | ||
58 | # Complete path to sysdep dirs. | |
59 | # `configure' writes a definition of `config-sysdirs' in `config.make'. | |
60 | sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D)) | |
61 | ||
62 | # Add-ons that contribute sysdeps trees get added to the include list | |
63 | # after sysdeps/generic. This makes #include <sysdeps/...> work right | |
64 | # to find specific add-on files without assuming the add-on directory name. | |
65 | # It also means that headers can go into an add-on's base directory | |
66 | # instead of the add-on needing a sysdeps/generic of its own. | |
67 | sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\ | |
68 | $(firstword $(filter /%,$(add-on)) \ | |
69 | $(..)$(add-on))) | |
70 | +sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs) | |
71 | ifdef objdir | |
72 | +sysdep_dirs := $(objdir) $(+sysdep_dirs) | |
73 | endif | |
74 | ||
75 | # Run config.status to update config.make and config.h. We don't show the | |
76 | # dependence of config.h to Make, because it is only touched when it | |
77 | # changes and so config.status would be run every time; the dependence of | |
78 | # config.make should suffice to force regeneration and re-exec, and the new | |
79 | # image will notice if config.h changed. | |
80 | $(common-objpfx)config.make: $(common-objpfx)config.status \ | |
81 | $(..)config.make.in $(..)config.h.in | |
82 | cd $(<D); $(SHELL) $(<F) | |
83 | ||
84 | # Find all the add-on and sysdeps configure fragments, to make sure we | |
85 | # re-run configure when any of them changes. | |
86 | $(common-objpfx)config.status: $(..)version.h $(..)configure \ | |
87 | $(foreach dir,$(sysdirs),\ | |
88 | $(wildcard $(dir)/Implies) \ | |
89 | $(patsubst %.ac,%,\ | |
90 | $(firstword $(wildcard \ | |
91 | $(addprefix $(dir)/,configure configure.ac))))) \ | |
92 | $(patsubst %.ac,%,\ | |
93 | $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac)) \ | |
94 | $(patsubst %.ac,%,\ | |
95 | $(foreach add-on,$(add-ons),\ | |
96 | $(firstword $(wildcard \ | |
97 | $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\ | |
98 | configure configure.ac))) \ | |
99 | $(wildcard $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\ | |
100 | sysdeps/*/preconfigure sysdeps/*/preconfigure.ac)))) | |
101 | @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \ | |
102 | echo The GNU C library has not been configured. >&2; \ | |
103 | echo Run \`configure\' to configure it before building. >&2; \ | |
104 | echo Try \`configure --help\' for more details. >&2; \ | |
105 | exit 1; fi | |
106 | ||
107 | # We don't want CPPFLAGS to be exported to the command running configure. | |
108 | unexport CPPFLAGS | |
109 | ||
110 | # Get the user's configuration parameters. | |
111 | ifneq ($(wildcard $(..)configparms),) | |
112 | include $(..)configparms | |
113 | endif | |
114 | ifneq ($(objpfx),) | |
115 | ifneq ($(wildcard $(common-objpfx)configparms),) | |
116 | include $(common-objpfx)configparms | |
117 | endif | |
118 | endif | |
119 | \f | |
120 | #### | |
121 | #### These are the configuration variables. You can define values for | |
122 | #### the variables below in the file `configparms'. | |
123 | #### Do NOT edit this file. | |
124 | #### | |
125 | ||
126 | ||
127 | # Common prefix for machine-independent installation directories. | |
128 | ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value. | |
129 | prefix = /usr/local | |
130 | endif | |
131 | ||
132 | # Decide whether we shall build the programs or not. We always do this | |
133 | # unless the user tells us (in configparms) or we are building for a | |
134 | # standalone target. | |
135 | ifndef build-programs | |
136 | ifneq ($(config-os),none) | |
137 | build-programs=yes | |
138 | else | |
139 | build-programs=no | |
140 | endif | |
141 | endif | |
142 | ||
143 | # Common prefix for machine-dependent installation directories. | |
144 | ifeq ($(origin exec_prefix),undefined) | |
145 | exec_prefix = $(prefix) | |
146 | endif | |
147 | ||
148 | # Where to install the library and object files. | |
149 | ifndef libdir | |
150 | libdir = $(exec_prefix)/lib | |
151 | endif | |
152 | inst_libdir = $(install_root)$(libdir) | |
153 | ||
154 | # Where to install the shared library. | |
155 | ifndef slibdir | |
156 | slibdir = $(exec_prefix)/lib | |
157 | endif | |
158 | inst_slibdir = $(install_root)$(slibdir) | |
159 | ||
160 | # Where to install the dynamic linker. | |
161 | ifndef rtlddir | |
162 | rtlddir = $(slibdir) | |
163 | endif | |
164 | inst_rtlddir = $(install_root)$(rtlddir) | |
165 | ||
166 | # Prefix to put on files installed in $(libdir). For libraries `libNAME.a', | |
167 | # the prefix is spliced between `lib' and the name, so the linker switch | |
168 | # `-l$(libprefix)NAME' finds the library; for other files the prefix is | |
169 | # just prepended to the whole file name. | |
170 | ifeq ($(origin libprefix),undefined) | |
171 | libprefix = | |
172 | endif | |
173 | ||
174 | # Where to install the header files. | |
175 | ifndef includedir | |
176 | includedir = $(prefix)/include | |
177 | endif | |
178 | inst_includedir = $(install_root)$(includedir) | |
179 | ||
180 | # Where to install machine-independent data files. | |
181 | # These are the timezone database, and the locale database. | |
182 | ifndef datadir | |
183 | datadir = $(prefix)/share | |
184 | endif | |
185 | inst_datadir = $(install_root)$(datadir) | |
186 | ||
187 | # Where to install the timezone data files (which are machine-independent). | |
188 | ifndef zonedir | |
189 | zonedir = $(datadir)/zoneinfo | |
190 | endif | |
191 | inst_zonedir = $(install_root)$(zonedir) | |
192 | ||
193 | # Where to install the compiled binary locale archive and compiled | |
194 | # binary locale files. | |
195 | ifndef complocaledir | |
196 | complocaledir = $(libdir)/locale | |
197 | endif | |
198 | inst_complocaledir = $(install_root)$(complocaledir) | |
199 | ||
200 | # Where to install the message catalog data files (which are | |
201 | # machine-independent). | |
202 | ifndef localedir | |
203 | localedir = $(datadir)/locale | |
204 | endif | |
205 | inst_localedir = $(install_root)$(localedir) | |
206 | ||
207 | # Where to install the locale charmap source files. | |
208 | ifndef i18ndir | |
209 | i18ndir = $(datadir)/i18n | |
210 | endif | |
211 | inst_i18ndir = $(install_root)$(i18ndir) | |
212 | ||
213 | # Where to install the shared object for charset transformation. | |
214 | ifndef gconvdir | |
215 | gconvdir = $(libdir)/gconv | |
216 | endif | |
217 | inst_gconvdir = $(install_root)$(gconvdir) | |
218 | ||
219 | # Where to install programs. | |
220 | ifndef bindir | |
221 | bindir = $(exec_prefix)/bin | |
222 | endif | |
223 | inst_bindir = $(install_root)$(bindir) | |
224 | ||
225 | # Where to install internal programs. | |
226 | ifndef libexecdir | |
227 | libexecdir = $(exec_prefix)/libexec | |
228 | endif | |
229 | inst_libexecdir = $(install_root)$(libexecdir) | |
230 | ||
231 | # Where to install administrative programs. | |
232 | ifndef rootsbindir | |
233 | rootsbindir = $(exec_prefix)/sbin | |
234 | endif | |
235 | inst_rootsbindir = $(install_root)$(rootsbindir) | |
236 | ||
237 | ifndef sbindir | |
238 | sbindir = $(exec_prefix)/sbin | |
239 | endif | |
240 | inst_sbindir = $(install_root)$(sbindir) | |
241 | ||
242 | # Where to install the Info files. | |
243 | ifndef infodir | |
244 | infodir = $(prefix)/info | |
245 | endif | |
246 | inst_infodir = $(install_root)$(infodir) | |
247 | ||
248 | # Where to install audit libraries. | |
249 | ifndef auditdir | |
250 | auditdir = $(libdir)/audit | |
251 | endif | |
252 | inst_auditdir = $(install_root)$(auditdir) | |
253 | ||
254 | # Where to install default configuration files. These include the local | |
255 | # timezone specification and network data base files. | |
256 | ifndef sysconfdir | |
257 | sysconfdir = $(prefix)/etc | |
258 | endif | |
259 | inst_sysconfdir = $(install_root)$(sysconfdir) | |
260 | ||
261 | # Directory for the database files and Makefile for nss_db. | |
262 | ifndef vardbdir | |
263 | vardbdir = $(localstatedir)/db | |
264 | endif | |
265 | inst_vardbdir = $(install_root)$(vardbdir) | |
266 | ||
267 | # Where to install the "localtime" timezone file; this is the file whose | |
268 | # contents $(localtime) specifies. If this is a relative pathname, it is | |
269 | # relative to $(zonedir). It is a good idea to put this somewhere | |
270 | # other than there, so the zoneinfo directory contains only universal data, | |
271 | # localizing the configuration data elsewhere. | |
272 | ifndef localtime-file | |
273 | localtime-file = $(sysconfdir)/localtime | |
274 | endif | |
275 | ||
276 | # What to use for leap second specifications in compiling the default | |
277 | # timezone files. Set this to `/dev/null' for no leap second handling as | |
278 | # 1003.1 requires, or to `leapseconds' for proper leap second handling. | |
279 | # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'. | |
280 | # This variable determines the default: if it's `/dev/null', | |
281 | # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE. | |
282 | ifndef leapseconds | |
283 | leapseconds = /dev/null | |
284 | endif | |
285 | ||
286 | # What timezone's DST rules should be used when a POSIX-style TZ | |
287 | # environment variable doesn't specify any rules. For 1003.1 compliance | |
288 | # this timezone must use rules that are as U.S. federal law defines DST. | |
289 | # Run `make -C time echo-zonenames' to see a list of available zone names. | |
290 | # This setting can be changed with `zic -p TIMEZONE' at any time. | |
291 | # If you want POSIX.1 compatibility, use `America/New_York'. | |
292 | ifndef posixrules | |
293 | posixrules = America/New_York | |
294 | endif | |
295 | ||
296 | # Where to install the "posixrules" timezone file; this is file | |
297 | # whose contents $(posixrules) specifies. If this is a relative | |
298 | # pathname, it is relative to $(zonedir). | |
299 | ifndef posixrules-file | |
300 | posixrules-file = posixrules | |
301 | endif | |
302 | ||
303 | ||
304 | # Directory where your system's native header files live. | |
305 | # This is used on Unix systems to generate some GNU libc header files. | |
306 | ifndef sysincludedir | |
307 | sysincludedir = /usr/include | |
308 | endif | |
309 | ||
310 | ||
311 | # Commands to install files. | |
312 | ifndef INSTALL_DATA | |
313 | INSTALL_DATA = $(INSTALL) -m 644 | |
314 | endif | |
315 | ifndef INSTALL_SCRIPT | |
316 | INSTALL_SCRIPT = $(INSTALL) | |
317 | endif | |
318 | ifndef INSTALL_PROGRAM | |
319 | INSTALL_PROGRAM = $(INSTALL) | |
320 | endif | |
321 | ifndef INSTALL | |
322 | INSTALL = install | |
323 | endif | |
324 | ||
325 | ||
326 | # The name of the C compiler. | |
327 | # If you've got GCC, and it works, use it. | |
328 | ifeq ($(origin CC),default) | |
329 | CC := gcc | |
330 | endif | |
331 | ||
332 | # The name of the C compiler to use for compilations of programs to run on | |
333 | # the host that is building the library. If you set CC to a | |
334 | # cross-compiler, you must set this to the normal compiler. | |
335 | ifndef BUILD_CC | |
336 | BUILD_CC = $(CC) | |
337 | endif | |
338 | ||
339 | # Default flags to pass the C compiler. | |
340 | ifndef default_cflags | |
341 | ifeq ($(release),stable) | |
342 | default_cflags := -g -O2 | |
343 | else | |
344 | default_cflags := -g -O | |
345 | endif | |
346 | endif | |
347 | ||
348 | # Flags to pass the C compiler when assembling preprocessed assembly code | |
349 | # (`.S' files). | |
350 | ifndef asm-CPPFLAGS | |
351 | asm-CPPFLAGS = | |
352 | endif | |
353 | ||
354 | as-needed := -Wl,--as-needed | |
355 | no-as-needed := -Wl,--no-as-needed | |
356 | ||
357 | # Must be supported by the linker. | |
358 | no-whole-archive = -Wl,--no-whole-archive | |
359 | whole-archive = -Wl,--whole-archive | |
360 | ||
361 | # Installed name of the startup code. | |
362 | # The ELF convention is that the startfile is called crt1.o | |
363 | start-installed-name = crt1.o | |
364 | # On systems that do not need a special startfile for statically linked | |
365 | # binaries, simply set it to the normal name. | |
366 | ifndef static-start-installed-name | |
367 | static-start-installed-name = $(start-installed-name) | |
368 | endif | |
369 | ||
370 | ifeq (yesyes,$(build-shared)$(have-z-combreloc)) | |
371 | combreloc-LDFLAGS = -Wl,-z,combreloc | |
372 | LDFLAGS.so += $(combreloc-LDFLAGS) | |
373 | LDFLAGS-rtld += $(combreloc-LDFLAGS) | |
374 | endif | |
375 | ||
376 | relro-LDFLAGS = -Wl,-z,relro | |
377 | LDFLAGS.so += $(relro-LDFLAGS) | |
378 | LDFLAGS-rtld += $(relro-LDFLAGS) | |
379 | ||
380 | ifeq (yes,$(have-hash-style)) | |
381 | # For the time being we unconditionally use 'both'. At some time we | |
382 | # should declare statically linked code as 'out of luck' and compile | |
383 | # with --hash-style=gnu only. | |
384 | hashstyle-LDFLAGS = -Wl,--hash-style=both | |
385 | LDFLAGS.so += $(hashstyle-LDFLAGS) | |
386 | LDFLAGS-rtld += $(hashstyle-LDFLAGS) | |
387 | endif | |
388 | ||
389 | # Command to run after every final link (executable or shared object). | |
390 | # This is invoked with $(call after-link,...), so it should operate on | |
391 | # the file $1. This can be set to do some sort of post-processing on | |
392 | # binaries, or to perform some sort of static sanity check. | |
393 | ifndef after-link | |
394 | after-link = | |
395 | endif | |
396 | ||
397 | # Command for linking PIE programs with the C library. | |
398 | ifndef +link-pie | |
399 | +link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \ | |
400 | $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ | |
401 | $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ | |
402 | $(addprefix $(csu-objpfx),S$(start-installed-name)) \ | |
403 | $(+preinit) $(+prectorS) \ | |
404 | $(filter-out $(addprefix $(csu-objpfx),start.o \ | |
405 | S$(start-installed-name))\ | |
406 | $(+preinit) $(link-extra-libs) \ | |
407 | $(common-objpfx)libc% $(+postinit),$^) \ | |
408 | $(link-extra-libs) | |
409 | +link-pie-after-libc = $(+postctorS) $(+postinit) | |
410 | define +link-pie | |
411 | $(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-pie-after-libc) | |
412 | $(call after-link,$@) | |
413 | endef | |
414 | define +link-pie-tests | |
415 | $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \ | |
416 | $(+link-pie-after-libc) | |
417 | $(call after-link,$@) | |
418 | endef | |
419 | endif | |
420 | # Command for statically linking programs with the C library. | |
421 | ifndef +link-static | |
422 | +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \ | |
423 | $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ | |
424 | $(addprefix $(csu-objpfx),$(static-start-installed-name)) \ | |
425 | $(+preinit) $(+prectorT) \ | |
426 | $(filter-out $(addprefix $(csu-objpfx),start.o \ | |
427 | $(start-installed-name))\ | |
428 | $(+preinit) $(link-extra-libs-static) \ | |
429 | $(common-objpfx)libc% $(+postinit),$^) \ | |
430 | $(link-extra-libs-static) | |
431 | +link-static-after-libc = $(+postctorT) $(+postinit) | |
432 | define +link-static | |
433 | $(+link-static-before-libc) $(link-libc-static) $(+link-static-after-libc) | |
434 | $(call after-link,$@) | |
435 | endef | |
436 | define +link-static-tests | |
437 | $(+link-static-before-libc) $(link-libc-static-tests) $(+link-static-after-libc) | |
438 | $(call after-link,$@) | |
439 | endef | |
440 | endif | |
441 | # Commands for linking programs with the C library. | |
442 | ifndef +link | |
443 | ifeq (yes,$(build-shared)) | |
444 | ifeq (yes,$(build-pie-default)) | |
445 | no-pie-ldflag = -no-pie | |
446 | +link = $(+link-pie) | |
447 | +link-tests = $(+link-pie-tests) | |
448 | else | |
449 | +link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \ | |
450 | $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ | |
451 | $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ | |
452 | $(addprefix $(csu-objpfx),$(start-installed-name)) \ | |
453 | $(+preinit) $(+prector) \ | |
454 | $(filter-out $(addprefix $(csu-objpfx),start.o \ | |
455 | $(start-installed-name))\ | |
456 | $(+preinit) $(link-extra-libs) \ | |
457 | $(common-objpfx)libc% $(+postinit),$^) \ | |
458 | $(link-extra-libs) | |
459 | +link-after-libc = $(+postctor) $(+postinit) | |
460 | define +link | |
461 | $(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-after-libc) | |
462 | $(call after-link,$@) | |
463 | endef | |
464 | define +link-tests | |
465 | $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \ | |
466 | $(+link-after-libc) | |
467 | $(call after-link,$@) | |
468 | endef | |
469 | endif | |
470 | else | |
471 | +link = $(+link-static) | |
472 | +link-tests = $(+link-static-tests) | |
473 | endif | |
474 | endif | |
475 | ifeq (yes,$(build-shared)) | |
476 | ifndef rtld-LDFLAGS | |
477 | rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name) | |
478 | endif | |
479 | ifndef rtld-tests-LDFLAGS | |
480 | ifeq (yes,$(build-hardcoded-path-in-tests)) | |
481 | rtld-tests-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so | |
482 | else | |
483 | rtld-tests-LDFLAGS = $(rtld-LDFLAGS) | |
484 | endif | |
485 | endif | |
486 | endif | |
487 | ifndef link-libc | |
488 | ifeq (yes,$(build-shared)) | |
489 | # We need the versioned name of libc.so in the deps of $(others) et al | |
490 | # so that the symlink to libc.so is created before anything tries to | |
491 | # run the linked programs. | |
492 | link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link) | |
493 | ifeq (yes,$(build-hardcoded-path-in-tests)) | |
494 | link-libc-tests-rpath-link = -Wl,-rpath=$(rpath-link) | |
495 | else | |
496 | link-libc-tests-rpath-link = $(link-libc-rpath-link) | |
497 | endif | |
498 | link-libc-before-gnulib = $(common-objpfx)libc.so$(libc.so-version) \ | |
499 | $(common-objpfx)$(patsubst %,$(libtype.oS),c) \ | |
500 | $(as-needed) $(elf-objpfx)ld.so \ | |
501 | $(no-as-needed) | |
502 | link-libc = $(link-libc-rpath-link) $(link-libc-before-gnulib) $(gnulib) | |
503 | link-libc-tests = $(link-libc-tests-rpath-link) \ | |
504 | $(link-libc-before-gnulib) $(gnulib-tests) | |
505 | # This is how to find at build-time things that will be installed there. | |
506 | rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec | |
507 | rpath-link = \ | |
508 | $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))) | |
509 | else | |
510 | link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib) | |
511 | link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests) | |
512 | endif | |
513 | endif | |
514 | ||
515 | # Differences in the linkers on the various platforms. | |
516 | LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN' | |
517 | LDFLAGS-soname-fname = -Wl,-soname,$(@F) | |
518 | LDFLAGS-rdynamic = -rdynamic | |
519 | LDFLAGS-Bsymbolic = -Bsymbolic | |
520 | ||
521 | # Choose the default search path for the dynamic linker based on | |
522 | # where we will install libraries. | |
523 | ifneq ($(libdir),$(slibdir)) | |
524 | default-rpath = $(slibdir):$(libdir) | |
525 | else | |
526 | default-rpath = $(libdir) | |
527 | endif | |
528 | ||
529 | ifndef link-extra-libs | |
530 | link-extra-libs = $(LDLIBS-$(@F)) | |
531 | link-extra-libs-static = $(link-extra-libs) | |
532 | endif | |
533 | ||
534 | # The static libraries. | |
535 | link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group | |
536 | link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group | |
537 | ||
538 | # How to link against libgcc. Some libgcc functions, such as those | |
539 | # for "long long" arithmetic or software floating point, can always be | |
540 | # built without use of C library headers and do not have any global | |
541 | # state so can safely be linked statically into any executable or | |
542 | # shared library requiring them; these functions are in libgcc.a. | |
543 | # Other functions, relating to exception handling, may require C | |
544 | # library headers to build and it may not be safe to have more than | |
545 | # one copy of them in a process; these functions are only in | |
546 | # libgcc_s.so and libgcc_eh.a. | |
547 | # | |
548 | # To avoid circular dependencies when bootstrapping, it is desirable | |
549 | # to avoid use of libgcc_s and libgcc_eh in building glibc. Where any | |
550 | # glibc functionality (in particular, thread cancellation) requires | |
551 | # exception handling, this is implemented through dlopen of libgcc_s | |
552 | # to avoid unnecessary dependencies on libgcc_s by programs not using | |
553 | # that functionality; executables built with glibc do not use | |
554 | # exception handling other than through thread cancellation. | |
555 | # | |
556 | # Undefined references to functions from libgcc_eh or libgcc_s may | |
557 | # arise for code built with -fexceptions. In the case of statically | |
558 | # linked programs installed by glibc, unwinding will never actually | |
559 | # occur at runtime and the use of elf/static-stubs.c to resolve these | |
560 | # references is safe. In the case of statically linked test programs | |
561 | # and test programs built with -fexceptions, unwinding may occur in | |
562 | # some cases and it is preferable to link with libgcc_eh or libgcc_s | |
563 | # so that the testing is as similar as possible to how programs will | |
564 | # be built with the installed glibc. | |
565 | # | |
566 | # Some architectures have architecture-specific systems for exception | |
567 | # handling that may involve undefined references to | |
568 | # architecture-specific functions. On those architectures, | |
569 | # gnulib-arch and static-gnulib-arch may be defined in sysdeps | |
570 | # makefiles to use additional libraries for linking executables and | |
571 | # shared libraries built by glibc. | |
572 | ifndef gnulib | |
573 | ifneq ($(have-cc-with-libunwind),yes) | |
574 | libunwind = | |
575 | else | |
576 | libunwind = -lunwind | |
577 | endif | |
578 | libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed | |
579 | gnulib-arch = | |
580 | gnulib = -lgcc $(gnulib-arch) | |
581 | gnulib-tests := -lgcc $(libgcc_eh) | |
582 | static-gnulib-arch = | |
583 | # By default, elf/static-stubs.o, instead of -lgcc_eh, is used to | |
584 | # statically link programs. When --disable-shared is used, we use | |
585 | # -lgcc_eh since elf/static-stubs.o isn't sufficient. | |
586 | ifeq (yes,$(build-shared)) | |
587 | static-gnulib = -lgcc $(static-gnulib-arch) | |
588 | else | |
589 | static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch) | |
590 | endif | |
591 | static-gnulib-tests := -lgcc -lgcc_eh $(libunwind) | |
592 | libc.so-gnulib := -lgcc | |
593 | endif | |
594 | +preinit = $(addprefix $(csu-objpfx),crti.o) | |
595 | +postinit = $(addprefix $(csu-objpfx),crtn.o) | |
596 | +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o` | |
597 | +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` | |
598 | # Variants of the two previous definitions for linking PIE programs. | |
599 | +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o` | |
600 | +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o` | |
601 | # Variants of the two previous definitions for statically linking programs. | |
602 | +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o` | |
603 | +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` | |
604 | csu-objpfx = $(common-objpfx)csu/ | |
605 | elf-objpfx = $(common-objpfx)elf/ | |
606 | ||
607 | # A command that, prepended to the name and arguments of a program, | |
608 | # and run on the build system, causes that program with those | |
609 | # arguments to be run on the host for which the library is built. | |
610 | ifndef test-wrapper | |
611 | test-wrapper = | |
612 | endif | |
613 | # Likewise, but the name of the program is preceded by | |
614 | # <variable>=<value> assignments for environment variables. | |
615 | ifndef test-wrapper-env | |
616 | test-wrapper-env = $(test-wrapper) env | |
617 | endif | |
618 | # Likewise, but the program's environment will be empty except for any | |
619 | # explicit <variable>=<value> assignments preceding the program name. | |
620 | ifndef test-wrapper-env-only | |
621 | test-wrapper-env-only = $(test-wrapper) env -i | |
622 | endif | |
623 | ||
624 | # Whether to run test programs built for the library's host system. | |
625 | ifndef run-built-tests | |
626 | ifeq (yes|,$(cross-compiling)|$(test-wrapper)) | |
627 | run-built-tests = no | |
628 | else | |
629 | run-built-tests = yes | |
630 | endif | |
631 | endif | |
632 | ||
633 | # Whether to stop immediately when a test fails. Nonempty means to | |
634 | # stop, empty means not to stop. | |
635 | ifndef stop-on-test-failure | |
636 | stop-on-test-failure = | |
637 | endif | |
638 | ||
639 | # How to run a program we just linked with our library. | |
640 | # The program binary is assumed to be $(word 2,$^). | |
641 | built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^)) | |
642 | rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \ | |
643 | --library-path \ | |
644 | $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) | |
645 | ifeq (yes,$(build-shared)) | |
646 | comma = , | |
647 | sysdep-library-path = \ | |
648 | $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\ | |
649 | $(filter -Wl$(comma)-rpath-link=%,\ | |
650 | $(sysdep-LDFLAGS))))) | |
651 | # $(run-via-rtld-prefix) is a command that, when prepended to the name | |
652 | # of a program built with the newly built library, produces a command | |
653 | # that, executed on the host for which the library is built, runs that | |
654 | # program. For tests listed in tests-static or xtests-static, it is | |
655 | # empty. | |
656 | run-via-rtld-prefix = \ | |
657 | $(if $(strip $(filter $(notdir $(built-program-file)), \ | |
658 | $(tests-static) $(xtests-static))),, $(rtld-prefix)) | |
659 | else | |
660 | run-via-rtld-prefix = | |
661 | endif | |
662 | # $(run-program-env) is the default environment variable settings to | |
663 | # use when running a program built with the newly built library. | |
664 | run-program-env = GCONV_PATH=$(common-objpfx)iconvdata \ | |
665 | LOCPATH=$(common-objpfx)localedata LC_ALL=C | |
666 | # $(run-program-prefix) is a command that, when prepended to the name | |
667 | # of a program built with the newly built library, produces a command | |
668 | # that, executed on the build system on which "make" is run, runs that | |
669 | # program. $(run-program-prefix-before-env) and | |
670 | # $(run-program-prefix-after-env) are similar, but separate parts | |
671 | # before and after a list of environment variables. | |
672 | run-program-prefix-before-env = $(test-wrapper-env) | |
673 | run-program-prefix-after-env = $(run-via-rtld-prefix) | |
674 | run-program-prefix = $(run-program-prefix-before-env) $(run-program-env) \ | |
675 | $(run-program-prefix-after-env) | |
676 | # $(built-program-cmd) is a command that, executed on the build system | |
677 | # on which "make" is run, runs the newly built program that is the | |
678 | # second dependency of the makefile target in which | |
679 | # $(built-program-cmd) is used. $(built-program-cmd-before-env) and | |
680 | # $(built-program-cmd-after-env) are similar, before and after a list | |
681 | # of environment variables. | |
682 | built-program-cmd-before-env = $(test-wrapper-env) | |
683 | built-program-cmd-after-env = $(run-via-rtld-prefix) $(built-program-file) | |
684 | built-program-cmd = $(built-program-cmd-before-env) $(run-program-env) \ | |
685 | $(built-program-cmd-after-env) | |
686 | # $(host-built-program-cmd) is a command that, executed on the host | |
687 | # for which the library is built, runs the newly built program that is | |
688 | # the second dependency of the makefile target in which | |
689 | # $(host-built-program-cmd) is used. | |
690 | host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file) | |
691 | ||
692 | ifndef LD | |
693 | LD := ld -X | |
694 | endif | |
695 | ||
696 | # $(test-via-rtld-prefix) is a command that, when prepended to the name | |
697 | # of a test program built with the newly built library, produces a command | |
698 | # that, executed on the host for which the library is built, runs that | |
699 | # program. For tests listed in tests-static or xtests-static as well | |
700 | # as when test programs are hardcoded to the newly built libraries, it | |
701 | # is empty. | |
702 | ||
703 | # $(test-program-prefix) is a command that, when prepended to the name | |
704 | # of a test program built with the newly built library, produces a command | |
705 | # that, executed on the build system on which "make" is run, runs that | |
706 | # test program. $(test-program-prefix-before-env) and | |
707 | # $(test-program-prefix-after-env) are similar, before and after a | |
708 | # list of environment variables. | |
709 | ||
710 | # $(test-program-cmd) is a command that, executed on the build system | |
711 | # on which "make" is run, runs the newly built test program that is the | |
712 | # second dependency of the makefile target in which | |
713 | # $(test-program-cmd) is used. $(test-program-cmd-before-env) and | |
714 | # $(test-program-cmd-after-env) are similar, before and after a list | |
715 | # of environment variables. | |
716 | ||
717 | # $(host-test-program-cmd) is a command that, executed on the host | |
718 | # for which the library is built, runs the newly built test program that | |
719 | # is the second dependency of the makefile target in which | |
720 | # $(host-test-program-cmd) is used. | |
721 | ||
722 | ifeq (yes,$(build-hardcoded-path-in-tests)) | |
723 | test-via-rtld-prefix = | |
724 | test-program-prefix-before-env = $(test-wrapper-env) | |
725 | test-program-prefix-after-env = | |
726 | test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \ | |
727 | $(test-program-prefix-after-env) | |
728 | test-program-cmd-before-env = $(test-wrapper-env) | |
729 | test-program-cmd-after-env = $(built-program-file) | |
730 | test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \ | |
731 | $(test-program-cmd-after-env) | |
732 | host-test-program-cmd = $(built-program-file) | |
733 | else | |
734 | test-via-rtld-prefix = $(run-via-rtld-prefix) | |
735 | test-program-prefix-before-env = $(run-program-prefix-before-env) | |
736 | test-program-prefix-after-env = $(run-program-prefix-after-env) | |
737 | test-program-prefix = $(run-program-prefix) | |
738 | test-program-cmd-before-env = $(built-program-cmd-before-env) | |
739 | test-program-cmd-after-env = $(built-program-cmd-after-env) | |
740 | test-program-cmd = $(built-program-cmd) | |
741 | host-test-program-cmd = $(host-built-program-cmd) | |
742 | endif | |
743 | ||
744 | # Extra flags to pass to GCC. | |
745 | ifeq ($(all-warnings),yes) | |
746 | +gccwarn := -Wall -Wwrite-strings -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar | |
747 | else | |
748 | +gccwarn := -Wall -Wwrite-strings | |
749 | endif | |
750 | +gccwarn += -Wundef | |
751 | ifeq ($(enable-werror),yes) | |
752 | +gccwarn += -Werror | |
753 | endif | |
754 | +gccwarn-c = -Wstrict-prototypes -Wold-style-definition | |
755 | ||
756 | # We do not depend on the address of constants in different files to be | |
757 | # actually different, so allow the compiler to merge them all. | |
758 | +merge-constants = -fmerge-all-constants | |
759 | ||
760 | # We have to assume that glibc functions are called in any rounding | |
761 | # mode and also change the rounding mode in a few functions. So, | |
762 | # disable any optimization that assume default rounding mode. | |
763 | +math-flags = -frounding-math | |
764 | ||
765 | # This is the program that generates makefile dependencies from C source files. | |
766 | # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy | |
767 | # targets for headers so that removed headers don't break the build. | |
768 | ifndef +mkdep | |
769 | +mkdep = $(CC) -M -MP | |
770 | endif | |
771 | ||
772 | # The program that makes Emacs-style TAGS files. | |
773 | ETAGS := etags | |
774 | ||
775 | # The `xgettext' program for producing .pot files from sources. | |
776 | ifndef XGETTEXT | |
777 | XGETTEXT = xgettext | |
778 | endif | |
779 | ||
780 | # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and | |
781 | # perhaps others) to preprocess assembly code in some cases. | |
782 | M4 = m4 | |
783 | ||
784 | # To force installation of files even if they are older than the | |
785 | # installed files. This variable is included in the dependency list | |
786 | # of all installation targets. | |
787 | ifeq ($(force-install),yes) | |
788 | +force = force-install | |
789 | else | |
790 | +force = | |
791 | endif | |
792 | ||
793 | #### | |
794 | #### End of configuration variables. | |
795 | #### | |
796 | \f | |
797 | # This tells some versions of GNU make before 3.63 not to export all variables. | |
798 | .NOEXPORT: | |
799 | ||
800 | # We want to echo the commands we're running without | |
801 | # umpteen zillion filenames along with it (we use `...' instead) | |
802 | # but we don't want this echoing done when the user has said | |
803 | # he doesn't want to see commands echoed by using -s. | |
804 | ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s | |
805 | +cmdecho := echo >/dev/null | |
806 | else # not -s | |
807 | +cmdecho := echo | |
808 | endif # -s | |
809 | ||
810 | # These are the flags given to the compiler to tell | |
811 | # it what sort of optimization and/or debugging output to do. | |
812 | ifndef +cflags | |
813 | # If `CFLAGS' was defined, use that. | |
814 | ifdef CFLAGS | |
815 | +cflags := $(filter-out -I%,$(CFLAGS)) | |
816 | endif # CFLAGS | |
817 | endif # +cflags | |
818 | ||
819 | # If none of the above worked, default to "-g -O". | |
820 | ifeq "$(strip $(+cflags))" "" | |
821 | +cflags := $(default_cflags) | |
822 | endif # $(+cflags) == "" | |
823 | ||
824 | +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) | |
825 | +gcc-nowarn := -w | |
826 | ||
827 | # Don't duplicate options if we inherited variables from the parent. | |
828 | +cflags := $(sort $(+cflags)) | |
829 | ||
830 | # Each sysdeps directory can contain header files that both will be | |
831 | # used to compile and will be installed. Each can also contain an | |
832 | # include/ subdirectory, whose header files will be used to compile | |
833 | # but will not be installed, and will take precedence over the | |
834 | # installed files. This mirrors the top-level include/ subdirectory. | |
835 | +sysdep-includes := $(foreach dir,$(+sysdep_dirs),\ | |
836 | $(addprefix -I,$(wildcard $(dir)/include) $(dir))) | |
837 | ||
838 | # These are flags given to the C compiler to tell it to look for | |
839 | # include files (including ones given in angle brackets) in the parent | |
840 | # library source directory, in the include directory, and in the | |
841 | # current directory. | |
842 | +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \ | |
843 | $(+sysdep-includes) $(includes) \ | |
844 | $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes) | |
845 | ||
846 | # Since libio has several internal header files, we use a -I instead | |
847 | # of many little headers in the include directory. | |
848 | libio-include = -I$(..)libio | |
849 | ||
850 | # List of non-library modules that we build. | |
851 | built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \ | |
852 | libSegFault libpcprofile librpcsvc locale-programs \ | |
853 | memusagestat nonlib nscd extramodules libnldbl | |
854 | ||
855 | in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \ | |
856 | $(libof-$(<F)) \ | |
857 | $(libof-$(@F)) \ | |
858 | libc)) | |
859 | ||
860 | # Build ld.so, libc.so and libpthread.so with -ftls-model=initial-exec | |
861 | tls-model = $(if $(filter libpthread rtld \ | |
862 | libc,$(in-module)),-ftls-model=initial-exec,) | |
863 | ||
864 | module-cppflags-real = -include $(common-objpfx)libc-modules.h \ | |
865 | -DMODULE_NAME=$(in-module) | |
866 | ||
867 | # We don't need libc-modules.h and the MODULE_NAME definition for .v.i | |
868 | # files. These targets don't (and will likely never need to) use the IS_IN | |
869 | # facility. In fact, shlib-versions should not use it because that will | |
870 | # create a circular dependency as libc-modules.h is generated from | |
871 | # shlib-versions. | |
872 | module-cppflags = $(if $(filter %.v.i,$(@F)),,$(module-cppflags-real)) | |
873 | ||
874 | # These are the variables that the implicit compilation rules use. | |
875 | # Note that we can't use -std=* in CPPFLAGS, because it overrides | |
876 | # the implicit -lang-asm and breaks cpp behavior for .S files--notably | |
877 | # it causes cpp to stop predefining __ASSEMBLER__. | |
878 | CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \ | |
879 | $($(subdir)-CPPFLAGS) \ | |
880 | $(+includes) $(defines) $(module-cppflags) \ | |
881 | -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \ | |
882 | $(CPPFLAGS-$(suffix $@)) \ | |
883 | $(foreach lib,$(libof-$(basename $(@F))) \ | |
884 | $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \ | |
885 | $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F))) | |
886 | override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \ | |
887 | $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \ | |
888 | $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \ | |
889 | $(CFLAGS-$(@F)) $(tls-model) \ | |
890 | $(foreach lib,$(libof-$(basename $(@F))) \ | |
891 | $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib))) | |
892 | # Use our copies of cstdlib and cmath. | |
893 | override CXXFLAGS = -I$(common-objpfx) $(c++-sysincludes) \ | |
894 | $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \ | |
895 | $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F)) | |
896 | ||
897 | # If everything is compiled with -fPIC (implicitly) we must tell this by | |
898 | # defining the PIC symbol. | |
899 | ifeq (yes,$(build-pic-default)) | |
900 | pic-default = -DPIC | |
901 | endif | |
902 | ||
903 | # Enable object files for different versions of the library. | |
904 | # Various things use $(object-suffixes) to know what all to make. | |
905 | # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX}) | |
906 | # to pass different flags for each flavor. | |
907 | libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o)) | |
908 | all-object-suffixes := .o .os .op .og .oS | |
909 | object-suffixes := | |
910 | CPPFLAGS-.o = $(pic-default) | |
911 | CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) | |
912 | libtype.o := lib%.a | |
913 | object-suffixes += .o | |
914 | ifeq (yes,$(build-shared)) | |
915 | # Under --enable-shared, we will build a shared library of PIC objects. | |
916 | # The PIC object files are named foo.os. | |
917 | object-suffixes += .os | |
918 | CPPFLAGS-.os = -DPIC -DSHARED | |
919 | CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag) | |
920 | libtype.os := lib%_pic.a | |
921 | # This can be changed by a sysdep makefile | |
922 | pic-ccflag = -fPIC | |
923 | # This one should always stay like this unless there is a very good reason. | |
924 | PIC-ccflag = -fPIC | |
925 | endif | |
926 | # This can be changed by a sysdep makefile | |
927 | pie-ccflag = -fpie | |
928 | # This one should always stay like this unless there is a very good reason. | |
929 | PIE-ccflag = -fPIE | |
930 | ifeq (yes,$(build-profile)) | |
931 | # Under --enable-profile, we will build a static library of profiled objects. | |
932 | # The profiled object files are named foo.op. | |
933 | object-suffixes += .op | |
934 | CPPFLAGS-.op = -DPROF $(pic-default) | |
935 | CFLAGS-.op = -pg | |
936 | libtype.op = lib%_p.a | |
937 | endif | |
938 | ||
939 | # Convenience variable for when we want to treat shared-library cases | |
940 | # differently from the rest. | |
941 | object-suffixes-noshared := $(filter-out .os,$(object-suffixes)) | |
942 | ||
943 | object-suffixes-for-libc := $(object-suffixes) | |
944 | ||
945 | ifeq (yes,$(build-shared)) | |
946 | # Build special library that contains the static-only routines for libc. | |
947 | object-suffixes-for-libc += .oS | |
948 | ||
949 | # Must build the routines as PIC, though, because they can end up in (users') | |
950 | # shared objects. We don't want to use CFLAGS-os because users may, for | |
951 | # example, make that processor-specific. | |
952 | CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) | |
953 | CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1 | |
954 | libtype.oS = lib%_nonshared.a | |
955 | endif | |
956 | ||
957 | # The assembler can generate debug information too. | |
958 | ifndef ASFLAGS | |
959 | ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS)) | |
960 | endif | |
961 | ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu) | |
962 | ||
963 | ifndef BUILD_CC | |
964 | BUILD_CC = $(CC) | |
965 | endif | |
966 | ||
967 | move-if-change = $(SHELL) $(..)scripts/move-if-change | |
968 | \f | |
969 | -include $(common-objpfx)sysd-sorted | |
970 | subdirs = $(sorted-subdirs) | |
971 | subdir-srcdirs = $(foreach dir,$(subdirs),\ | |
972 | $(firstword $($(dir)-srcdir) $(..)$(dir))) | |
973 | ||
974 | # This is a pair of implicit rules to preprocess a file with # comments, | |
975 | # %ifdef et al, based on config.h settings or other %include'd files. | |
976 | # We use chained rules instead of a pipeline here so that we can properly | |
977 | # check the exit status of cpp rather than using its bad output when there | |
978 | # is a preprocessing error. Another rule should depend on the output file | |
979 | # `FOO.v', and along with that `FOO.v.i' should be given dependencies | |
980 | # listing both its input files, and any header files that it may reference | |
981 | # (but no commands). | |
982 | %.v.i: $(common-objpfx)config.h $(..)Makeconfig | |
983 | sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \ | |
984 | $(filter-out FORCE %.h $(..)Makeconfig,$^) \ | |
985 | | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \ | |
986 | > $@T | |
987 | mv -f $@T $@ | |
988 | %.v: %.v.i | |
989 | sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T | |
990 | mv -f $@T $@ | |
991 | ||
992 | ifeq (yes, $(build-shared)) | |
993 | ||
994 | # To generate a header to support more than one ABI for different | |
995 | # architecture variants, the CPU/Makefile defines abi-variants to be a | |
996 | # list of names for those variants (e.g. 32 64), and, for each variant, | |
997 | # defines abi-$(variant)-condition to be the condition for those options | |
998 | # to use in a C #if condition. abi-includes may be defined to a list of | |
999 | # headers to include in the generated header, if the default does not | |
1000 | # suffice. default-abi is defined to be the ABI for the current glibc | |
1001 | # build. | |
1002 | ||
1003 | ifndef abi-includes | |
1004 | abi-includes := bits/wordsize.h | |
1005 | endif | |
1006 | ||
1007 | # Process the shlib-versions file, which tells us what shared library | |
1008 | # version numbers to use when we install shared objects on this system. | |
1009 | # We need to wait until $(subdirs) is complete. | |
1010 | ifeq ($(sysd-sorted-done),t) | |
1011 | -include $(common-objpfx)soversions.mk | |
1012 | ifndef avoid-generated | |
1013 | # This lets add-ons give more-specific matches that override defaults | |
1014 | # in the top-level file. | |
1015 | $(common-objpfx)shlib-versions.v.i: \ | |
1016 | $(wildcard $(+sysdep_dirs:=/shlib-versions) \ | |
1017 | $(subdir-srcdirs:=/shlib-versions)) \ | |
1018 | $(..)shlib-versions | |
1019 | ||
1020 | $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \ | |
1021 | $(common-objpfx)shlib-versions.v | |
1022 | $(AWK) -f $^ > $@T | |
1023 | mv -f $@T $@ | |
1024 | $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig | |
1025 | (while read which lib number setname; do \ | |
1026 | eval seen_$$which=1; \ | |
1027 | test x"$$which" = xDEFAULT || continue; \ | |
1028 | case $$number in \ | |
1029 | [0-9]*) echo "$$lib.so-version=.$$number"; \ | |
1030 | echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\ | |
1031 | *) echo "$$lib.so-version=$$number"; \ | |
1032 | echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\ | |
1033 | esac; \ | |
1034 | done; \ | |
1035 | echo soversions.mk-done = t;) < $< > $@T; exit 0 | |
1036 | mv -f $@T $@ | |
1037 | endif | |
1038 | endif | |
1039 | ||
1040 | postclean-generated += soversions.mk soversions.i \ | |
1041 | shlib-versions.v shlib-versions.v.i | |
1042 | ||
1043 | before-compile += $(common-objpfx)libc-modules.h | |
1044 | ifeq ($(soversions.mk-done),t) | |
1045 | # Generate a header with macro definitions for use with the IS_IN macro. | |
1046 | # These are the possible values for the MODULE_NAME macro defined when building | |
1047 | # sources, to identify which module the translation unit is going to be built | |
1048 | # into. | |
1049 | $(common-objpfx)libc-modules.h: $(common-objpfx)libc-modules.stmp; @: | |
1050 | $(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \ | |
1051 | $(common-objpfx)soversions.i | |
1052 | $(AWK) -v buildlist="$(subst -,_,$(built-modules))" -f $^ > ${@:stmp=T} | |
1053 | $(move-if-change) ${@:stmp=T} ${@:stmp=h} | |
1054 | touch $@ | |
1055 | ||
1056 | endif | |
1057 | ||
1058 | common-generated += libc-modules.h libc-modules.stmp | |
1059 | ||
1060 | # The name under which the run-time dynamic linker is installed. | |
1061 | # We are currently going for the convention that `/lib/ld.so.1' | |
1062 | # names the SVR4/ELF ABI-compliant dynamic linker. | |
1063 | ifndef rtld-installed-name | |
1064 | ifdef ld.so-version | |
1065 | rtld-installed-name = $(ld.so-version) | |
1066 | else | |
1067 | rtld-installed-name = ld.so.1 | |
1068 | endif | |
1069 | endif | |
1070 | ||
1071 | ifndef rtld-version-installed-name | |
1072 | rtld-version-installed-name = ld-$(version).so | |
1073 | endif | |
1074 | ||
1075 | endif # build-shared | |
1076 | ||
1077 | ||
1078 | ifeq ($(build-shared),yes) | |
1079 | libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version) | |
1080 | else | |
1081 | libdl = $(common-objpfx)dlfcn/libdl.a | |
1082 | endif | |
1083 | ||
1084 | ifeq ($(build-shared),yes) | |
1085 | libm = $(common-objpfx)math/libm.so$(libm.so-version) | |
1086 | libmvec = $(common-objpfx)mathvec/libmvec.so$(libmvec.so-version) | |
1087 | else | |
1088 | libm = $(common-objpfx)math/libm.a | |
1089 | libmvec = $(common-objpfx)mathvec/libmvec.a | |
1090 | endif | |
1091 | ||
1092 | # These are the subdirectories containing the library source. The order | |
1093 | # is more or less arbitrary. The sorting step will take care of the | |
1094 | # dependencies. | |
1095 | all-subdirs = csu assert ctype locale intl catgets math setjmp signal \ | |
1096 | stdlib stdio-common libio malloc string wcsmbs time dirent \ | |
1097 | grp pwd posix io termios resource misc socket sysvipc gmon \ | |
1098 | gnulib iconv iconvdata wctype manual shadow gshadow po argp \ | |
1099 | crypt localedata timezone rt conform debug mathvec \ | |
1100 | $(add-on-subdirs) dlfcn elf | |
1101 | ||
1102 | ifndef avoid-generated | |
1103 | # sysd-sorted itself will contain rules making the sysd-sorted target | |
1104 | # depend on Depend files. But if you just added a Depend file to an | |
1105 | # existing directory not in all-subdirs, then sysd-sorted needs to | |
1106 | # be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files. | |
1107 | all-Depend-files := $(wildcard $(sort \ | |
1108 | $(foreach dir,$(all-subdirs),\ | |
1109 | $(firstword $($(dir)-srcdir) \ | |
1110 | $(..)$(dir))/Depend) \ | |
1111 | $(sorted-subdirs:=/Depend))) | |
1112 | $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \ | |
1113 | $(common-objpfx)config.make $(..)Makeconfig \ | |
1114 | $(wildcard $(sysdirs:=/Subdirs)) \ | |
1115 | $(all-Depend-files) | |
1116 | $(AWK) -f $< \ | |
1117 | -v subdirs='$(all-subdirs)' \ | |
1118 | -v srcpfx='$(..)' \ | |
1119 | $(filter %/Subdirs %/Depend,$^) > $@-tmp | |
1120 | mv -f $@-tmp $@ | |
1121 | $(all-Depend-files): ; | |
1122 | endif | |
1123 | ||
1124 | # This gives partial TARGET:SOURCE pattern pairs to have rules | |
1125 | # emitted into sysd-rules. A sysdeps Makeconfig fragment can | |
1126 | # add its own special object file prefix to this list with e.g. foo-%:% | |
1127 | # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS). | |
1128 | sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_% | |
1129 | ||
1130 | # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here. | |
1131 | sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig)) | |
1132 | ifneq (,$(sysdep-makeconfigs)) | |
1133 | include $(sysdep-makeconfigs) | |
1134 | endif | |
1135 | ||
1136 | # Compute just the target patterns. Makeconfig has set sysd-rules-patterns. | |
1137 | sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\ | |
1138 | $(firstword $(subst :, ,$p)))) | |
1139 | ||
1140 | # A sysdeps Makeconfig fragment may set libc-reentrant to yes. | |
1141 | ifeq (yes,$(libc-reentrant)) | |
1142 | defines += -D_LIBC_REENTRANT | |
1143 | ||
1144 | libio-mtsafe = -D_IO_MTSAFE_IO | |
1145 | endif | |
1146 | ||
1147 | # The name to give to a test in test results summaries. | |
1148 | test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@))) | |
1149 | ||
1150 | # Likewise, in XFAIL variable names. | |
1151 | test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@))) | |
1152 | ||
1153 | # Command to output a test status line (such as PASS: test-name). If | |
1154 | # test-xfail-$(test-xfail-name) has a nonempty value, the status will be | |
1155 | # XPASS or XFAIL rather than PASS or FAIL. | |
1156 | evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \ | |
1157 | $(if $(test-xfail-$(test-xfail-name)),true,false) \ | |
1158 | $(if $(stop-on-test-failure),true,false) \ | |
1159 | > $(common-objpfx)$(test-name).test-result | |
1160 | ||
1161 | endif # Makeconfig not yet included | |
1162 | ||
1163 | # Local Variables: | |
1164 | # mode: makefile | |
1165 | # End: |