]>
Commit | Line | Data |
---|---|---|
581c785b | 1 | # Copyright (C) 1991-2022 Free Software Foundation, Inc. |
72e4a717 | 2 | # Copyright The GNU Toolchain Authors. |
28f540f4 RM |
3 | # This file is part of the GNU C Library. |
4 | ||
5 | # The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | # modify it under the terms of the GNU Lesser General Public |
7 | # License as published by the Free Software Foundation; either | |
8 | # version 2.1 of the License, or (at your option) any later version. | |
28f540f4 RM |
9 | |
10 | # The GNU C Library is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | # Lesser General Public License for more details. |
28f540f4 | 14 | |
41bdb6e2 | 15 | # You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 16 | # License along with the GNU C Library; if not, see |
5a82c748 | 17 | # <https://www.gnu.org/licenses/>. |
28f540f4 RM |
18 | |
19 | # | |
20 | # Makefile configuration options for the GNU C library. | |
21 | # | |
22 | ifneq (,) | |
23 | This makefile requires GNU Make. | |
24 | endif | |
25 | ||
3e5f5557 UD |
26 | all: # Make this the default goal |
27 | ||
28f540f4 RM |
28 | ifneq "$(origin +included-Makeconfig)" "file" |
29 | ||
30 | +included-Makeconfig := yes | |
31 | ||
32 | ifdef subdir | |
33 | .. := ../ | |
34 | endif | |
35 | ||
094bacdb | 36 | # $(common-objdir) is the place to put objects and |
28f540f4 RM |
37 | # such that are not specific to a single subdir. |
38 | ifdef objdir | |
6e953631 UD |
39 | objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/) |
40 | common-objpfx = $(objdir)/ | |
28f540f4 RM |
41 | common-objdir = $(objdir) |
42 | else | |
9207e30d | 43 | $(error objdir must be defined by the build-directory Makefile) |
28f540f4 RM |
44 | endif |
45 | ||
2d7ed98a ST |
46 | # Did we request 'make -s' run? "yes" or "no". |
47 | # Starting from make-4.4 MAKEFLAGS now contains long | |
48 | # options like '--shuffle'. To detect presence of 's' | |
49 | # we pick first word with short options. Long options | |
50 | # are guaranteed to come after whitespace. We use '-' | |
51 | # prefix to always have a word before long options | |
52 | # even if no short options were passed. | |
53 | # Typical MAKEFLAGS values to watch for: | |
54 | # "rs --shuffle=42" (silent) | |
55 | # " --shuffle" (not silent) | |
56 | ifeq ($(findstring s, $(firstword -$(MAKEFLAGS))),) | |
57 | silent-make := no | |
58 | else | |
59 | silent-make := yes | |
60 | endif | |
61 | ||
f332db02 RM |
62 | # Root of the sysdeps tree. |
63 | sysdep_dir := $(..)sysdeps | |
64 | export sysdep_dir := $(sysdep_dir) | |
65 | ||
28f540f4 RM |
66 | # Get the values defined by options to `configure'. |
67 | include $(common-objpfx)config.make | |
68 | ||
e07bb02a | 69 | # What flags to give to sources which call user provided callbacks |
56ab3869 | 70 | uses-callbacks = -fexceptions |
e07bb02a | 71 | |
a4db3439 UD |
72 | # What flags to give to tests which test stack alignment |
73 | stack-align-test-flags = | |
74 | ||
57ba7bb4 | 75 | # Complete path to sysdep dirs. |
e0a3ed4f RM |
76 | # `configure' writes a definition of `config-sysdirs' in `config.make'. |
77 | sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D)) | |
78 | ||
644d3857 | 79 | +sysdep_dirs = $(sysdirs) |
e0a3ed4f RM |
80 | ifdef objdir |
81 | +sysdep_dirs := $(objdir) $(+sysdep_dirs) | |
82 | endif | |
57ba7bb4 | 83 | |
273d56ce RM |
84 | # Run config.status to update config.make and config.h. We don't show the |
85 | # dependence of config.h to Make, because it is only touched when it | |
86 | # changes and so config.status would be run every time; the dependence of | |
87 | # config.make should suffice to force regeneration and re-exec, and the new | |
88 | # image will notice if config.h changed. | |
19361cb7 UD |
89 | $(common-objpfx)config.make: $(common-objpfx)config.status \ |
90 | $(..)config.make.in $(..)config.h.in | |
273d56ce RM |
91 | cd $(<D); $(SHELL) $(<F) |
92 | ||
644d3857 JM |
93 | # Find all the sysdeps configure fragments, to make sure we re-run |
94 | # configure when any of them changes. | |
5290baf0 | 95 | $(common-objpfx)config.status: $(..)version.h $(..)configure \ |
e0a3ed4f RM |
96 | $(foreach dir,$(sysdirs),\ |
97 | $(wildcard $(dir)/Implies) \ | |
95afbbe5 | 98 | $(patsubst %.ac,%,\ |
f332db02 | 99 | $(firstword $(wildcard \ |
cb8a6dbd | 100 | $(addprefix $(dir)/,configure configure.ac))))) \ |
95afbbe5 | 101 | $(patsubst %.ac,%,\ |
644d3857 | 102 | $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac)) |
273d56ce RM |
103 | @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \ |
104 | echo The GNU C library has not been configured. >&2; \ | |
105 | echo Run \`configure\' to configure it before building. >&2; \ | |
106 | echo Try \`configure --help\' for more details. >&2; \ | |
107 | exit 1; fi | |
28f540f4 | 108 | |
74015205 UD |
109 | # We don't want CPPFLAGS to be exported to the command running configure. |
110 | unexport CPPFLAGS | |
111 | ||
28f540f4 RM |
112 | # Get the user's configuration parameters. |
113 | ifneq ($(wildcard $(..)configparms),) | |
114 | include $(..)configparms | |
115 | endif | |
116 | ifneq ($(objpfx),) | |
6e953631 UD |
117 | ifneq ($(wildcard $(common-objpfx)configparms),) |
118 | include $(common-objpfx)configparms | |
28f540f4 RM |
119 | endif |
120 | endif | |
28f540f4 RM |
121 | \f |
122 | #### | |
123 | #### These are the configuration variables. You can define values for | |
124 | #### the variables below in the file `configparms'. | |
125 | #### Do NOT edit this file. | |
126 | #### | |
127 | ||
128 | ||
129 | # Common prefix for machine-independent installation directories. | |
487253ea | 130 | ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value. |
28f540f4 RM |
131 | prefix = /usr/local |
132 | endif | |
133 | ||
0413b54c UD |
134 | # Decide whether we shall build the programs or not. We always do this |
135 | # unless the user tells us (in configparms) or we are building for a | |
136 | # standalone target. | |
137 | ifndef build-programs | |
138 | ifneq ($(config-os),none) | |
139 | build-programs=yes | |
140 | else | |
141 | build-programs=no | |
142 | endif | |
143 | endif | |
144 | ||
28f540f4 | 145 | # Common prefix for machine-dependent installation directories. |
487253ea | 146 | ifeq ($(origin exec_prefix),undefined) |
28f540f4 RM |
147 | exec_prefix = $(prefix) |
148 | endif | |
149 | ||
150 | # Where to install the library and object files. | |
151 | ifndef libdir | |
152 | libdir = $(exec_prefix)/lib | |
153 | endif | |
8d57beea | 154 | inst_libdir = $(install_root)$(libdir) |
28f540f4 | 155 | |
aaa8cb4b | 156 | # Where to install the shared library. |
094bacdb RM |
157 | ifndef slibdir |
158 | slibdir = $(exec_prefix)/lib | |
159 | endif | |
8d57beea | 160 | inst_slibdir = $(install_root)$(slibdir) |
094bacdb | 161 | |
aaa8cb4b AS |
162 | # Where to install the dynamic linker. |
163 | ifndef rtlddir | |
164 | rtlddir = $(slibdir) | |
165 | endif | |
166 | inst_rtlddir = $(install_root)$(rtlddir) | |
167 | ||
28f540f4 RM |
168 | # Prefix to put on files installed in $(libdir). For libraries `libNAME.a', |
169 | # the prefix is spliced between `lib' and the name, so the linker switch | |
170 | # `-l$(libprefix)NAME' finds the library; for other files the prefix is | |
171 | # just prepended to the whole file name. | |
487253ea | 172 | ifeq ($(origin libprefix),undefined) |
28f540f4 RM |
173 | libprefix = |
174 | endif | |
175 | ||
176 | # Where to install the header files. | |
177 | ifndef includedir | |
25c751d0 | 178 | includedir = $(prefix)/include |
28f540f4 | 179 | endif |
8d57beea | 180 | inst_includedir = $(install_root)$(includedir) |
28f540f4 | 181 | |
28f540f4 | 182 | # Where to install machine-independent data files. |
a2fe9c76 | 183 | # These are the timezone database, and the locale database. |
28f540f4 RM |
184 | ifndef datadir |
185 | datadir = $(prefix)/share | |
186 | endif | |
8d57beea | 187 | inst_datadir = $(install_root)$(datadir) |
28f540f4 RM |
188 | |
189 | # Where to install the timezone data files (which are machine-independent). | |
190 | ifndef zonedir | |
191 | zonedir = $(datadir)/zoneinfo | |
192 | endif | |
8d57beea | 193 | inst_zonedir = $(install_root)$(zonedir) |
28f540f4 | 194 | |
90fe682d CD |
195 | # Where to install the compiled binary locale archive and compiled |
196 | # binary locale files. | |
197 | ifndef complocaledir | |
198 | complocaledir = $(libdir)/locale | |
a2fe9c76 | 199 | endif |
90fe682d | 200 | inst_complocaledir = $(install_root)$(complocaledir) |
a2fe9c76 | 201 | |
4a33c2f5 UD |
202 | # Where to install the message catalog data files (which are |
203 | # machine-independent). | |
314f6dee CD |
204 | ifndef localedir |
205 | localedir = $(datadir)/locale | |
4a33c2f5 | 206 | endif |
314f6dee | 207 | inst_localedir = $(install_root)$(localedir) |
4a33c2f5 | 208 | |
3ec41e03 | 209 | # Where to install the locale charmap source files. |
19bc17a9 RM |
210 | ifndef i18ndir |
211 | i18ndir = $(datadir)/i18n | |
a2fe9c76 | 212 | endif |
8d57beea | 213 | inst_i18ndir = $(install_root)$(i18ndir) |
a2fe9c76 | 214 | |
6973fc01 UD |
215 | # Where to install the shared object for charset transformation. |
216 | ifndef gconvdir | |
217 | gconvdir = $(libdir)/gconv | |
218 | endif | |
219 | inst_gconvdir = $(install_root)$(gconvdir) | |
220 | ||
28f540f4 RM |
221 | # Where to install programs. |
222 | ifndef bindir | |
223 | bindir = $(exec_prefix)/bin | |
224 | endif | |
8d57beea | 225 | inst_bindir = $(install_root)$(bindir) |
28f540f4 | 226 | |
7f0ff1b0 UD |
227 | # Where to install internal programs. |
228 | ifndef libexecdir | |
229 | libexecdir = $(exec_prefix)/libexec | |
230 | endif | |
231 | inst_libexecdir = $(install_root)$(libexecdir) | |
232 | ||
28f540f4 | 233 | # Where to install administrative programs. |
1ef32c3d UD |
234 | ifndef rootsbindir |
235 | rootsbindir = $(exec_prefix)/sbin | |
236 | endif | |
8d57beea | 237 | inst_rootsbindir = $(install_root)$(rootsbindir) |
1ef32c3d | 238 | |
28f540f4 RM |
239 | ifndef sbindir |
240 | sbindir = $(exec_prefix)/sbin | |
241 | endif | |
8d57beea | 242 | inst_sbindir = $(install_root)$(sbindir) |
28f540f4 RM |
243 | |
244 | # Where to install the Info files. | |
245 | ifndef infodir | |
246 | infodir = $(prefix)/info | |
247 | endif | |
8d57beea | 248 | inst_infodir = $(install_root)$(infodir) |
28f540f4 | 249 | |
a9171047 UD |
250 | # Where to install audit libraries. |
251 | ifndef auditdir | |
252 | auditdir = $(libdir)/audit | |
253 | endif | |
254 | inst_auditdir = $(install_root)$(auditdir) | |
255 | ||
28f540f4 RM |
256 | # Where to install default configuration files. These include the local |
257 | # timezone specification and network data base files. | |
258 | ifndef sysconfdir | |
259 | sysconfdir = $(prefix)/etc | |
260 | endif | |
8d57beea | 261 | inst_sysconfdir = $(install_root)$(sysconfdir) |
28f540f4 | 262 | |
77fb9117 UD |
263 | # Directory for the database files and Makefile for nss_db. |
264 | ifndef vardbdir | |
4248b1b1 | 265 | vardbdir = $(localstatedir)/db |
77fb9117 UD |
266 | endif |
267 | inst_vardbdir = $(install_root)$(vardbdir) | |
268 | ||
28f540f4 RM |
269 | # Where to install the "localtime" timezone file; this is the file whose |
270 | # contents $(localtime) specifies. If this is a relative pathname, it is | |
271 | # relative to $(zonedir). It is a good idea to put this somewhere | |
272 | # other than there, so the zoneinfo directory contains only universal data, | |
273 | # localizing the configuration data elsewhere. | |
274 | ifndef localtime-file | |
0d8733c4 | 275 | localtime-file = $(sysconfdir)/localtime |
28f540f4 RM |
276 | endif |
277 | ||
59dd8641 RM |
278 | # What to use for leap second specifications in compiling the default |
279 | # timezone files. Set this to `/dev/null' for no leap second handling as | |
280 | # 1003.1 requires, or to `leapseconds' for proper leap second handling. | |
281 | # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'. | |
282 | # This variable determines the default: if it's `/dev/null', | |
283 | # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE. | |
284 | ifndef leapseconds | |
285 | leapseconds = /dev/null | |
286 | endif | |
287 | ||
28f540f4 RM |
288 | # What timezone's DST rules should be used when a POSIX-style TZ |
289 | # environment variable doesn't specify any rules. For 1003.1 compliance | |
290 | # this timezone must use rules that are as U.S. federal law defines DST. | |
291 | # Run `make -C time echo-zonenames' to see a list of available zone names. | |
292 | # This setting can be changed with `zic -p TIMEZONE' at any time. | |
293 | # If you want POSIX.1 compatibility, use `America/New_York'. | |
294 | ifndef posixrules | |
295 | posixrules = America/New_York | |
296 | endif | |
297 | ||
298 | # Where to install the "posixrules" timezone file; this is file | |
299 | # whose contents $(posixrules) specifies. If this is a relative | |
300 | # pathname, it is relative to $(zonedir). | |
301 | ifndef posixrules-file | |
302 | posixrules-file = posixrules | |
303 | endif | |
304 | ||
305 | ||
306 | # Directory where your system's native header files live. | |
307 | # This is used on Unix systems to generate some GNU libc header files. | |
308 | ifndef sysincludedir | |
309 | sysincludedir = /usr/include | |
310 | endif | |
311 | ||
312 | ||
313 | # Commands to install files. | |
314 | ifndef INSTALL_DATA | |
315 | INSTALL_DATA = $(INSTALL) -m 644 | |
316 | endif | |
07627f49 UD |
317 | ifndef INSTALL_SCRIPT |
318 | INSTALL_SCRIPT = $(INSTALL) | |
319 | endif | |
28f540f4 RM |
320 | ifndef INSTALL_PROGRAM |
321 | INSTALL_PROGRAM = $(INSTALL) | |
322 | endif | |
323 | ifndef INSTALL | |
324 | INSTALL = install | |
325 | endif | |
326 | ||
327 | ||
328 | # The name of the C compiler. | |
329 | # If you've got GCC, and it works, use it. | |
330 | ifeq ($(origin CC),default) | |
331 | CC := gcc | |
332 | endif | |
333 | ||
334 | # The name of the C compiler to use for compilations of programs to run on | |
335 | # the host that is building the library. If you set CC to a | |
336 | # cross-compiler, you must set this to the normal compiler. | |
337 | ifndef BUILD_CC | |
338 | BUILD_CC = $(CC) | |
339 | endif | |
340 | ||
341 | # Default flags to pass the C compiler. | |
342 | ifndef default_cflags | |
1d5c2feb UD |
343 | ifeq ($(release),stable) |
344 | default_cflags := -g -O2 | |
345 | else | |
a8922de8 | 346 | default_cflags := -g -O |
28f540f4 | 347 | endif |
1d5c2feb | 348 | endif |
28f540f4 RM |
349 | |
350 | # Flags to pass the C compiler when assembling preprocessed assembly code | |
e4f5eae8 | 351 | # (`.S' files). |
28f540f4 RM |
352 | ifndef asm-CPPFLAGS |
353 | asm-CPPFLAGS = | |
354 | endif | |
355 | ||
3ce1f295 UD |
356 | # Must be supported by the linker. |
357 | no-whole-archive = -Wl,--no-whole-archive | |
358 | whole-archive = -Wl,--whole-archive | |
359 | ||
779ae82e | 360 | # Installed name of the startup code. |
26ecc33a | 361 | # The ELF convention is that the startfile is called crt1.o |
779ae82e | 362 | start-installed-name = crt1.o |
af09bfb5 RM |
363 | # On systems that do not need a special startfile for statically linked |
364 | # binaries, simply set it to the normal name. | |
365 | ifndef static-start-installed-name | |
366 | static-start-installed-name = $(start-installed-name) | |
367 | endif | |
779ae82e | 368 | |
9d7a3741 L |
369 | ifeq (yes,$(enable-static-pie)) |
370 | # Link with rcrt1.o, instead of crt1.o, to call _dl_relocate_static_pie | |
371 | # to relocate static PIE. | |
372 | real-static-start-installed-name = r$(static-start-installed-name) | |
373 | else | |
374 | real-static-start-installed-name = $(static-start-installed-name) | |
375 | endif | |
376 | ||
1c563add UD |
377 | relro-LDFLAGS = -Wl,-z,relro |
378 | LDFLAGS.so += $(relro-LDFLAGS) | |
379 | LDFLAGS-rtld += $(relro-LDFLAGS) | |
1c563add | 380 | |
2d5ec669 L |
381 | # Linker options to enable and disable DT_RELR. |
382 | ifeq ($(have-dt-relr),yes) | |
383 | dt-relr-ldflag = -Wl,-z,pack-relative-relocs | |
384 | no-dt-relr-ldflag = -Wl,-z,nopack-relative-relocs | |
385 | else | |
386 | dt-relr-ldflag = | |
387 | no-dt-relr-ldflag = | |
388 | endif | |
389 | ||
23645707 SP |
390 | ifeq (no,$(build-pie-default)) |
391 | pie-default = $(no-pie-ccflag) | |
392 | else # build-pie-default | |
9d7a3741 L |
393 | pic-default = -DPIC |
394 | # Compile libc.a and libc_p.a with -fPIE/-fpie for static PIE. | |
395 | pie-default = $(pie-ccflag) | |
23645707 SP |
396 | |
397 | ifeq (yes,$(enable-static-pie)) | |
2d5ec669 | 398 | static-pie-dt-relr-ldflag = $(dt-relr-ldflag) |
9d7a3741 | 399 | ifeq (yes,$(have-static-pie)) |
23645707 | 400 | static-pie-ldflag = -static-pie |
9d7a3741 L |
401 | else |
402 | # Static PIE can't have dynamic relocations in read-only segments since | |
403 | # static PIE is mapped into memory by kernel. --eh-frame-hdr is needed | |
404 | # for PIE to support exception. | |
23645707 SP |
405 | static-pie-ldflag = -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text |
406 | endif # have-static-pie | |
407 | endif # enable-static-pie | |
408 | endif # build-pie-default | |
9d7a3741 | 409 | |
2d6ab5df FW |
410 | # If lazy relocations are disabled, add the -z now flag. Use |
411 | # LDFLAGS-lib.so instead of LDFLAGS.so, to avoid adding the flag to | |
412 | # test modules. | |
413 | ifeq ($(bind-now),yes) | |
414 | LDFLAGS-lib.so += -Wl,-z,now | |
94a4e9e4 FW |
415 | # Extra flags for dynamically linked non-test main programs. |
416 | link-extra-flags += -Wl,-z,now | |
2d6ab5df FW |
417 | endif |
418 | ||
04f5a636 RM |
419 | # Command to run after every final link (executable or shared object). |
420 | # This is invoked with $(call after-link,...), so it should operate on | |
421 | # the file $1. This can be set to do some sort of post-processing on | |
422 | # binaries, or to perform some sort of static sanity check. | |
423 | ifndef after-link | |
424 | after-link = | |
425 | endif | |
426 | ||
c23de0aa FW |
427 | # Additional libraries to link into every test. |
428 | link-extra-libs-tests = $(libsupport) | |
429 | ||
435aa54b L |
430 | # Command for linking PIE programs with the C library. |
431 | ifndef +link-pie | |
f3eef963 | 432 | +link-pie-before-inputs = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \ |
2d5ec669 | 433 | $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(dt-relr-ldflag)) \ |
f3eef963 | 434 | -Wl,-O1 -nostdlib -nostartfiles \ |
740b3dbe | 435 | $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ |
3ee318c9 | 436 | $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ |
34d6a3cb | 437 | $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \ |
f3eef963 JM |
438 | $(+preinit) $(+prectorS) |
439 | +link-pie-before-libc = -o $@ $(+link-pie-before-inputs) \ | |
435aa54b | 440 | $(filter-out $(addprefix $(csu-objpfx),start.o \ |
da62f81b AS |
441 | S$(start-installed-name))\ |
442 | $(+preinit) $(link-extra-libs) \ | |
443 | $(common-objpfx)libc% $(+postinit),$^) \ | |
740b3dbe L |
444 | $(link-extra-libs) |
445 | +link-pie-after-libc = $(+postctorS) $(+postinit) | |
04f5a636 | 446 | define +link-pie |
a8ff215e FW |
447 | $(CC) $(link-libc-rpath-link) $(+link-pie-before-libc) $(rtld-LDFLAGS) \ |
448 | $(link-extra-flags) $(link-libc) $(+link-pie-after-libc) | |
04f5a636 RM |
449 | $(call after-link,$@) |
450 | endef | |
451 | define +link-pie-tests | |
e30fb31c FW |
452 | $(CC) $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \ |
453 | $(+link-pie-after-libc) | |
04f5a636 RM |
454 | $(call after-link,$@) |
455 | endef | |
23b5cae1 | 456 | define +link-pie-printers-tests |
e30fb31c FW |
457 | $(CC) $(+link-pie-before-libc) $(built-rtld-LDFLAGS) \ |
458 | $(link-libc-printers-tests) $(+link-pie-after-libc) | |
23b5cae1 MG |
459 | $(call after-link,$@) |
460 | endef | |
435aa54b | 461 | endif |
e1586792 UD |
462 | # Command for statically linking programs with the C library. |
463 | ifndef +link-static | |
f3eef963 | 464 | +link-static-before-inputs = -nostdlib -nostartfiles -static \ |
23645707 | 465 | $(if $($(@F)-no-pie),$(no-pie-ldflag),$(static-pie-ldflag)) \ |
2d5ec669 | 466 | $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(static-pie-dt-relr-ldflag)) \ |
9f0d7b6d | 467 | $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ |
9d7a3741 | 468 | $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \ |
f3eef963 JM |
469 | $(+preinit) $(+prectorT) |
470 | +link-static-before-libc = -o $@ $(+link-static-before-inputs) \ | |
e1586792 UD |
471 | $(filter-out $(addprefix $(csu-objpfx),start.o \ |
472 | $(start-installed-name))\ | |
473 | $(+preinit) $(link-extra-libs-static) \ | |
474 | $(common-objpfx)libc% $(+postinit),$^) \ | |
d173d12e | 475 | $(link-extra-libs-static) |
a5055ad1 | 476 | +link-static-after-libc = $(+postctorT) $(+postinit) |
04f5a636 | 477 | define +link-static |
e30fb31c FW |
478 | $(CC) $(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) \ |
479 | $(+link-static-after-libc) | |
04f5a636 RM |
480 | $(call after-link,$@) |
481 | endef | |
482 | define +link-static-tests | |
e30fb31c FW |
483 | $(CC) $(+link-static-before-libc) $(link-libc-static-tests) \ |
484 | $(+link-static-after-libc) | |
04f5a636 RM |
485 | $(call after-link,$@) |
486 | endef | |
e1586792 | 487 | endif |
94b32c39 L |
488 | # Commands for linking programs with the C library. |
489 | ifndef +link | |
490 | ifeq (yes,$(build-shared)) | |
00c714df | 491 | ifeq (yes,$(cc-pie-default)) |
cc08749b | 492 | no-pie-ldflag = -no-pie |
00c714df L |
493 | endif |
494 | ifeq (yes,$(build-pie-default)) | |
cc08749b L |
495 | +link = $(+link-pie) |
496 | +link-tests = $(+link-pie-tests) | |
f3eef963 JM |
497 | +link-tests-before-inputs = $(+link-pie-before-inputs) $(rtld-tests-LDFLAGS) |
498 | +link-tests-after-inputs = $(link-libc-tests) $(+link-pie-after-libc) | |
23b5cae1 MG |
499 | +link-printers-tests = $(+link-pie-printers-tests) |
500 | else # not build-pie-default | |
23645707 | 501 | +link-before-inputs = -nostdlib -nostartfiles $(no-pie-ldflag) \ |
740b3dbe | 502 | $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ |
3ee318c9 | 503 | $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ |
6014c65d | 504 | $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \ |
f3eef963 JM |
505 | $(+preinit) $(+prector) |
506 | +link-before-libc = -o $@ $(+link-before-inputs) \ | |
94b32c39 L |
507 | $(filter-out $(addprefix $(csu-objpfx),start.o \ |
508 | $(start-installed-name))\ | |
509 | $(+preinit) $(link-extra-libs) \ | |
510 | $(common-objpfx)libc% $(+postinit),$^) \ | |
511 | $(link-extra-libs) | |
512 | +link-after-libc = $(+postctor) $(+postinit) | |
04f5a636 | 513 | define +link |
a8ff215e FW |
514 | $(CC) $(link-libc-rpath-link) $(+link-before-libc) $(rtld-LDFLAGS) \ |
515 | $(link-extra-flags) $(link-libc) $(+link-after-libc) | |
04f5a636 RM |
516 | $(call after-link,$@) |
517 | endef | |
f3eef963 JM |
518 | +link-tests-before-inputs = $(+link-before-inputs) $(rtld-tests-LDFLAGS) |
519 | +link-tests-after-inputs = $(link-libc-tests) $(+link-after-libc) | |
04f5a636 | 520 | define +link-tests |
e30fb31c | 521 | $(CC) $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \ |
76dcbf42 | 522 | $(+link-after-libc) |
04f5a636 RM |
523 | $(call after-link,$@) |
524 | endef | |
23b5cae1 | 525 | define +link-printers-tests |
e30fb31c | 526 | $(CC) $(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \ |
23b5cae1 MG |
527 | $(+link-after-libc) |
528 | $(call after-link,$@) | |
529 | endef | |
530 | endif # build-pie-default | |
531 | else # build-static | |
94b32c39 L |
532 | +link = $(+link-static) |
533 | +link-tests = $(+link-static-tests) | |
f3eef963 JM |
534 | +link-tests-before-inputs = $(+link-static-before-inputs) |
535 | +link-tests-after-inputs = $(link-libc-static-tests) $(+link-static-after-libc) | |
23b5cae1 MG |
536 | +link-printers-tests = $(+link-static-tests) |
537 | endif # build-shared | |
538 | endif # +link | |
539 | ||
540 | # The pretty printer test programs need to be compiled without optimizations | |
541 | # so they won't confuse gdb. We could use either the 'GCC optimize' pragma | |
542 | # or the 'optimize' function attribute to achieve this; however, at least on | |
543 | # ARM, gcc always produces different debugging symbols when invoked with | |
544 | # a -O greater than 0 than when invoked with -O0, regardless of anything else | |
545 | # we're using to suppress optimizations. Therefore, we need to explicitly pass | |
546 | # -O0 to it through CFLAGS. | |
547 | # Additionally, the build system will try to -include $(common-objpfx)/config.h | |
548 | # when compiling the tests, which will throw an error if some special macros | |
549 | # (such as __OPTIMIZE__ and IS_IN_build) aren't defined. To avoid this, we | |
550 | # tell gcc to define IS_IN_build. | |
551 | CFLAGS-printers-tests := -O0 -ggdb3 -DIS_IN_build | |
552 | ||
0269750c | 553 | ifeq (yes,$(build-shared)) |
23b5cae1 MG |
554 | # These indicate whether to link using the built ld.so or the installed one. |
555 | installed-rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name) | |
556 | built-rtld-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so | |
557 | ||
740b3dbe | 558 | ifndef rtld-LDFLAGS |
23b5cae1 | 559 | rtld-LDFLAGS = $(installed-rtld-LDFLAGS) |
740b3dbe | 560 | endif |
23b5cae1 | 561 | |
740b3dbe L |
562 | ifndef rtld-tests-LDFLAGS |
563 | ifeq (yes,$(build-hardcoded-path-in-tests)) | |
23b5cae1 | 564 | rtld-tests-LDFLAGS = $(built-rtld-LDFLAGS) |
740b3dbe | 565 | else |
23b5cae1 MG |
566 | rtld-tests-LDFLAGS = $(installed-rtld-LDFLAGS) |
567 | endif # build-hardcoded-path-in-tests | |
568 | endif # rtld-tests-LDFLAGS | |
569 | ||
570 | endif # build-shared | |
571 | ||
3fe9de0d RM |
572 | ifndef link-libc |
573 | ifeq (yes,$(build-shared)) | |
aa1075ea RM |
574 | # We need the versioned name of libc.so in the deps of $(others) et al |
575 | # so that the symlink to libc.so is created before anything tries to | |
576 | # run the linked programs. | |
23b5cae1 | 577 | link-libc-rpath = -Wl,-rpath=$(rpath-link) |
740b3dbe | 578 | link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link) |
23b5cae1 | 579 | |
a8ff215e FW |
580 | # For programs which are not tests, $(link-libc-rpath-link) is added |
581 | # directly in $(+link), $(+link-pie) above, so that -Wl,-rpath-link | |
582 | # comes before the expansion of LDLIBS-* and affects libraries added | |
583 | # there. For shared objects, -Wl,-rpath-link is added via | |
584 | # $(build-shlib-helper) and $(build-module-helper) in Makerules (also | |
585 | # before the expansion of LDLIBS-* variables). | |
586 | ||
587 | # Tests use -Wl,-rpath instead of -Wl,-rpath-link for | |
588 | # build-hardcoded-path-in-tests. | |
740b3dbe | 589 | ifeq (yes,$(build-hardcoded-path-in-tests)) |
23b5cae1 | 590 | link-libc-tests-rpath-link = $(link-libc-rpath) |
114d07fd | 591 | link-test-modules-rpath-link = $(link-libc-rpath) |
740b3dbe L |
592 | else |
593 | link-libc-tests-rpath-link = $(link-libc-rpath-link) | |
114d07fd | 594 | link-test-modules-rpath-link = |
23b5cae1 MG |
595 | endif # build-hardcoded-path-in-tests |
596 | ||
3618e5fe PM |
597 | link-libc-between-gnulib = $(common-objpfx)libc.so$(libc.so-version) \ |
598 | $(common-objpfx)$(patsubst %,$(libtype.oS),c) \ | |
599 | -Wl,--as-needed $(elf-objpfx)ld.so \ | |
600 | -Wl,--no-as-needed | |
601 | link-libc = $(link-libc-between-gnulib) $(gnulib) | |
23b5cae1 | 602 | |
3618e5fe | 603 | link-libc-tests-after-rpath-link = $(gnulib-tests) $(link-libc-between-gnulib) $(gnulib-tests) |
740b3dbe | 604 | link-libc-tests = $(link-libc-tests-rpath-link) \ |
23b5cae1 MG |
605 | $(link-libc-tests-after-rpath-link) |
606 | # Pretty printer test programs always require rpath instead of rpath-link. | |
607 | link-libc-printers-tests = $(link-libc-rpath) \ | |
608 | $(link-libc-tests-after-rpath-link) | |
609 | ||
4d6acc61 | 610 | # This is how to find at build-time things that will be installed there. |
e69d994a | 611 | rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support |
e72bfd87 UD |
612 | rpath-link = \ |
613 | $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))) | |
23b5cae1 | 614 | else # build-static |
4ac5087b | 615 | link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib) |
95f5a9a8 | 616 | link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests) |
23b5cae1 MG |
617 | endif # build-shared |
618 | endif # link-libc | |
900bec85 | 619 | |
ad10cac8 | 620 | # Differences in the linkers on the various platforms. |
ad10cac8 UD |
621 | LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN' |
622 | LDFLAGS-soname-fname = -Wl,-soname,$(@F) | |
623 | LDFLAGS-rdynamic = -rdynamic | |
624 | LDFLAGS-Bsymbolic = -Bsymbolic | |
ad10cac8 | 625 | |
f01010de UD |
626 | # Choose the default search path for the dynamic linker based on |
627 | # where we will install libraries. | |
628 | ifneq ($(libdir),$(slibdir)) | |
629 | default-rpath = $(slibdir):$(libdir) | |
630 | else | |
631 | default-rpath = $(libdir) | |
632 | endif | |
633 | ||
57ba7bb4 | 634 | ifndef link-extra-libs |
1d038b6b RM |
635 | link-extra-libs = $(LDLIBS-$(@F)) |
636 | link-extra-libs-static = $(link-extra-libs) | |
57ba7bb4 | 637 | endif |
e1586792 UD |
638 | |
639 | # The static libraries. | |
b9af1301 | 640 | link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group |
95f5a9a8 | 641 | link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group |
e1586792 | 642 | |
95f5a9a8 JM |
643 | # How to link against libgcc. Some libgcc functions, such as those |
644 | # for "long long" arithmetic or software floating point, can always be | |
645 | # built without use of C library headers and do not have any global | |
646 | # state so can safely be linked statically into any executable or | |
647 | # shared library requiring them; these functions are in libgcc.a. | |
648 | # Other functions, relating to exception handling, may require C | |
649 | # library headers to build and it may not be safe to have more than | |
650 | # one copy of them in a process; these functions are only in | |
651 | # libgcc_s.so and libgcc_eh.a. | |
652 | # | |
653 | # To avoid circular dependencies when bootstrapping, it is desirable | |
654 | # to avoid use of libgcc_s and libgcc_eh in building glibc. Where any | |
655 | # glibc functionality (in particular, thread cancellation) requires | |
656 | # exception handling, this is implemented through dlopen of libgcc_s | |
657 | # to avoid unnecessary dependencies on libgcc_s by programs not using | |
658 | # that functionality; executables built with glibc do not use | |
659 | # exception handling other than through thread cancellation. | |
660 | # | |
661 | # Undefined references to functions from libgcc_eh or libgcc_s may | |
662 | # arise for code built with -fexceptions. In the case of statically | |
663 | # linked programs installed by glibc, unwinding will never actually | |
664 | # occur at runtime and the use of elf/static-stubs.c to resolve these | |
665 | # references is safe. In the case of statically linked test programs | |
666 | # and test programs built with -fexceptions, unwinding may occur in | |
667 | # some cases and it is preferable to link with libgcc_eh or libgcc_s | |
668 | # so that the testing is as similar as possible to how programs will | |
669 | # be built with the installed glibc. | |
670 | # | |
671 | # Some architectures have architecture-specific systems for exception | |
672 | # handling that may involve undefined references to | |
673 | # architecture-specific functions. On those architectures, | |
674 | # gnulib-arch and static-gnulib-arch may be defined in sysdeps | |
675 | # makefiles to use additional libraries for linking executables and | |
676 | # shared libraries built by glibc. | |
28f540f4 | 677 | ifndef gnulib |
cbdb12de UD |
678 | ifneq ($(have-cc-with-libunwind),yes) |
679 | libunwind = | |
feca5e0b | 680 | else |
cbdb12de | 681 | libunwind = -lunwind |
feca5e0b | 682 | endif |
a3cc4f48 | 683 | libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed |
95f5a9a8 JM |
684 | gnulib-arch = |
685 | gnulib = -lgcc $(gnulib-arch) | |
686 | gnulib-tests := -lgcc $(libgcc_eh) | |
687 | static-gnulib-arch = | |
94b32c39 L |
688 | # By default, elf/static-stubs.o, instead of -lgcc_eh, is used to |
689 | # statically link programs. When --disable-shared is used, we use | |
690 | # -lgcc_eh since elf/static-stubs.o isn't sufficient. | |
691 | ifeq (yes,$(build-shared)) | |
95f5a9a8 | 692 | static-gnulib = -lgcc $(static-gnulib-arch) |
94b32c39 L |
693 | else |
694 | static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch) | |
695 | endif | |
95f5a9a8 | 696 | static-gnulib-tests := -lgcc -lgcc_eh $(libunwind) |
cbdb12de | 697 | libc.so-gnulib := -lgcc |
28f540f4 | 698 | endif |
e75154a6 RM |
699 | +preinit = $(addprefix $(csu-objpfx),crti.o) |
700 | +postinit = $(addprefix $(csu-objpfx),crtn.o) | |
35e65999 RA |
701 | +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o` |
702 | +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` | |
435aa54b | 703 | # Variants of the two previous definitions for linking PIE programs. |
35e65999 RA |
704 | +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o` |
705 | +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o` | |
a5055ad1 | 706 | # Variants of the two previous definitions for statically linking programs. |
9d7a3741 L |
707 | ifeq (yes,$(enable-static-pie)) |
708 | # Static PIE must use PIE variants. | |
709 | +prectorT = $(+prectorS) | |
710 | +postctorT = $(+postctorS) | |
711 | else | |
a5055ad1 | 712 | +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o` |
189e935b | 713 | +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o` |
9d7a3741 | 714 | endif |
6e953631 UD |
715 | csu-objpfx = $(common-objpfx)csu/ |
716 | elf-objpfx = $(common-objpfx)elf/ | |
28f540f4 | 717 | |
cc1290d0 JM |
718 | # A command that, prepended to the name and arguments of a program, |
719 | # and run on the build system, causes that program with those | |
720 | # arguments to be run on the host for which the library is built. | |
721 | ifndef test-wrapper | |
722 | test-wrapper = | |
723 | endif | |
724 | # Likewise, but the name of the program is preceded by | |
725 | # <variable>=<value> assignments for environment variables. | |
726 | ifndef test-wrapper-env | |
727 | test-wrapper-env = $(test-wrapper) env | |
728 | endif | |
9162c01d RM |
729 | # Likewise, but the program's environment will be empty except for any |
730 | # explicit <variable>=<value> assignments preceding the program name. | |
731 | ifndef test-wrapper-env-only | |
732 | test-wrapper-env-only = $(test-wrapper) env -i | |
733 | endif | |
cc1290d0 | 734 | |
03ac099f JM |
735 | # Whether to run test programs built for the library's host system. |
736 | ifndef run-built-tests | |
cc1290d0 | 737 | ifeq (yes|,$(cross-compiling)|$(test-wrapper)) |
03ac099f JM |
738 | run-built-tests = no |
739 | else | |
740 | run-built-tests = yes | |
741 | endif | |
742 | endif | |
743 | ||
d6fe5e58 JM |
744 | # Whether to stop immediately when a test fails. Nonempty means to |
745 | # stop, empty means not to stop. | |
746 | ifndef stop-on-test-failure | |
747 | stop-on-test-failure = | |
748 | endif | |
749 | ||
03a75825 RM |
750 | # How to run a program we just linked with our library. |
751 | # The program binary is assumed to be $(word 2,$^). | |
752 | built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^)) | |
01dc6df9 SP |
753 | rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \ |
754 | --library-path \ | |
755 | $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) | |
0269750c | 756 | ifeq (yes,$(build-shared)) |
196980f5 | 757 | comma = , |
11336c16 UD |
758 | sysdep-library-path = \ |
759 | $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\ | |
760 | $(filter -Wl$(comma)-rpath-link=%,\ | |
761 | $(sysdep-LDFLAGS))))) | |
88866099 JM |
762 | # $(run-via-rtld-prefix) is a command that, when prepended to the name |
763 | # of a program built with the newly built library, produces a command | |
764 | # that, executed on the host for which the library is built, runs that | |
daaa7713 JM |
765 | # program. For tests listed in tests-static or xtests-static, it is |
766 | # empty. | |
88866099 JM |
767 | run-via-rtld-prefix = \ |
768 | $(if $(strip $(filter $(notdir $(built-program-file)), \ | |
01dc6df9 | 769 | $(tests-static) $(xtests-static))),, $(rtld-prefix)) |
8658ceda | 770 | else |
88866099 JM |
771 | run-via-rtld-prefix = |
772 | endif | |
8540f6d2 JM |
773 | # $(run-program-env) is the default environment variable settings to |
774 | # use when running a program built with the newly built library. | |
775 | run-program-env = GCONV_PATH=$(common-objpfx)iconvdata \ | |
776 | LOCPATH=$(common-objpfx)localedata LC_ALL=C | |
25fe8932 | 777 | # $(run-program-prefix) is a command that, when prepended to the name |
88866099 JM |
778 | # of a program built with the newly built library, produces a command |
779 | # that, executed on the build system on which "make" is run, runs that | |
8540f6d2 JM |
780 | # program. $(run-program-prefix-before-env) and |
781 | # $(run-program-prefix-after-env) are similar, but separate parts | |
782 | # before and after a list of environment variables. | |
783 | run-program-prefix-before-env = $(test-wrapper-env) | |
784 | run-program-prefix-after-env = $(run-via-rtld-prefix) | |
785 | run-program-prefix = $(run-program-prefix-before-env) $(run-program-env) \ | |
786 | $(run-program-prefix-after-env) | |
88866099 JM |
787 | # $(built-program-cmd) is a command that, executed on the build system |
788 | # on which "make" is run, runs the newly built program that is the | |
789 | # second dependency of the makefile target in which | |
8540f6d2 JM |
790 | # $(built-program-cmd) is used. $(built-program-cmd-before-env) and |
791 | # $(built-program-cmd-after-env) are similar, before and after a list | |
792 | # of environment variables. | |
793 | built-program-cmd-before-env = $(test-wrapper-env) | |
794 | built-program-cmd-after-env = $(run-via-rtld-prefix) $(built-program-file) | |
795 | built-program-cmd = $(built-program-cmd-before-env) $(run-program-env) \ | |
796 | $(built-program-cmd-after-env) | |
166bca24 JB |
797 | # $(host-built-program-cmd) is a command that, executed on the host |
798 | # for which the library is built, runs the newly built program that is | |
799 | # the second dependency of the makefile target in which | |
800 | # $(host-built-program-cmd) is used. | |
801 | host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file) | |
3dbbd2ff ST |
802 | # $(ld-library-path) is the common content to be set in LD_LIBRARY_PATH |
803 | # for running static binaries that may load dynamic objects. | |
804 | ld-library-path = $(objpfx):$(common-objpfx)$(addprefix :,$(sysdep-ld-library-path)) | |
03a75825 | 805 | |
28f540f4 RM |
806 | ifndef LD |
807 | LD := ld -X | |
808 | endif | |
809 | ||
740b3dbe L |
810 | # $(test-via-rtld-prefix) is a command that, when prepended to the name |
811 | # of a test program built with the newly built library, produces a command | |
812 | # that, executed on the host for which the library is built, runs that | |
daaa7713 JM |
813 | # program. For tests listed in tests-static or xtests-static as well |
814 | # as when test programs are hardcoded to the newly built libraries, it | |
815 | # is empty. | |
740b3dbe L |
816 | |
817 | # $(test-program-prefix) is a command that, when prepended to the name | |
818 | # of a test program built with the newly built library, produces a command | |
819 | # that, executed on the build system on which "make" is run, runs that | |
8540f6d2 JM |
820 | # test program. $(test-program-prefix-before-env) and |
821 | # $(test-program-prefix-after-env) are similar, before and after a | |
822 | # list of environment variables. | |
740b3dbe L |
823 | |
824 | # $(test-program-cmd) is a command that, executed on the build system | |
825 | # on which "make" is run, runs the newly built test program that is the | |
826 | # second dependency of the makefile target in which | |
8540f6d2 JM |
827 | # $(test-program-cmd) is used. $(test-program-cmd-before-env) and |
828 | # $(test-program-cmd-after-env) are similar, before and after a list | |
829 | # of environment variables. | |
740b3dbe L |
830 | |
831 | # $(host-test-program-cmd) is a command that, executed on the host | |
832 | # for which the library is built, runs the newly built test program that | |
833 | # is the second dependency of the makefile target in which | |
834 | # $(host-test-program-cmd) is used. | |
835 | ||
836 | ifeq (yes,$(build-hardcoded-path-in-tests)) | |
837 | test-via-rtld-prefix = | |
8540f6d2 JM |
838 | test-program-prefix-before-env = $(test-wrapper-env) |
839 | test-program-prefix-after-env = | |
840 | test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \ | |
841 | $(test-program-prefix-after-env) | |
842 | test-program-cmd-before-env = $(test-wrapper-env) | |
843 | test-program-cmd-after-env = $(built-program-file) | |
844 | test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \ | |
845 | $(test-program-cmd-after-env) | |
740b3dbe L |
846 | host-test-program-cmd = $(built-program-file) |
847 | else | |
848 | test-via-rtld-prefix = $(run-via-rtld-prefix) | |
8540f6d2 JM |
849 | test-program-prefix-before-env = $(run-program-prefix-before-env) |
850 | test-program-prefix-after-env = $(run-program-prefix-after-env) | |
740b3dbe | 851 | test-program-prefix = $(run-program-prefix) |
8540f6d2 JM |
852 | test-program-cmd-before-env = $(built-program-cmd-before-env) |
853 | test-program-cmd-after-env = $(built-program-cmd-after-env) | |
740b3dbe L |
854 | test-program-cmd = $(built-program-cmd) |
855 | host-test-program-cmd = $(host-built-program-cmd) | |
856 | endif | |
857 | ||
28f540f4 | 858 | # Extra flags to pass to GCC. |
6cc7d725 | 859 | ifeq ($(all-warnings),yes) |
ed159672 | 860 | +gccwarn := -Wall -Wwrite-strings -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar |
6cc7d725 | 861 | else |
ed159672 | 862 | +gccwarn := -Wall -Wwrite-strings |
6cc7d725 | 863 | endif |
498a2233 | 864 | +gccwarn += -Wundef |
a4ecc9eb | 865 | ifeq ($(enable-werror),yes) |
48bb14bd | 866 | +gccwarn += -Werror |
a4ecc9eb | 867 | endif |
8e2f7c68 | 868 | +gccwarn-c = -Wstrict-prototypes -Wold-style-definition |
28f540f4 | 869 | |
dec36b4f UD |
870 | # We do not depend on the address of constants in different files to be |
871 | # actually different, so allow the compiler to merge them all. | |
872 | +merge-constants = -fmerge-all-constants | |
873 | ||
29ba805c AJ |
874 | # We have to assume that glibc functions are called in any rounding |
875 | # mode and also change the rounding mode in a few functions. So, | |
876 | # disable any optimization that assume default rounding mode. | |
877 | +math-flags = -frounding-math | |
878 | ||
2ef42716 AJ |
879 | # Logically only "libnldbl", "nonlib" and "testsuite" should be using |
880 | # -fno-math-errno. However due to GCC bug #88576, only "libm" can use | |
881 | # -fno-math-errno. | |
882 | +extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno) | |
1294b189 | 883 | |
a6d2f948 | 884 | # Use 64 bit time_t support for installed programs |
36676f5e | 885 | installed-modules = nonlib nscd ldconfig locale_programs \ |
a6d2f948 | 886 | iconvprogs libnss_files libnss_compat libnss_db libnss_hesiod \ |
11306df7 | 887 | libutil libpcprofile |
a6d2f948 AZ |
888 | +extra-time-flags = $(if $(filter $(installed-modules),\ |
889 | $(in-module)),-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64) | |
890 | ||
cecbc796 NA |
891 | # We might want to compile with some stack-protection flag. |
892 | ifneq ($(stack-protector),) | |
893 | +stack-protector=$(stack-protector) | |
894 | endif | |
895 | ||
8b8f13b6 SP |
896 | # Some routines are unsafe to build with stack-protection since they're called |
897 | # before the stack check guard is set up. Provide a way to disable stack | |
898 | # protector. The first argument is the extension (.o, .os, .oS) and the second | |
899 | # is a list of routines that this path should be applied to. | |
900 | define elide-stack-protector | |
901 | $(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector)) | |
902 | endef | |
903 | ||
28f540f4 | 904 | # The program that makes Emacs-style TAGS files. |
78759725 | 905 | ETAGS := etags |
28f540f4 | 906 | |
9de06f3c RM |
907 | # The `xgettext' program for producing .pot files from sources. |
908 | ifndef XGETTEXT | |
909 | XGETTEXT = xgettext | |
910 | endif | |
911 | ||
28f540f4 RM |
912 | # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and |
913 | # perhaps others) to preprocess assembly code in some cases. | |
914 | M4 = m4 | |
915 | ||
73237de3 UD |
916 | # To force installation of files even if they are older than the |
917 | # installed files. This variable is included in the dependency list | |
918 | # of all installation targets. | |
919 | ifeq ($(force-install),yes) | |
920 | +force = force-install | |
921 | else | |
922 | +force = | |
923 | endif | |
924 | ||
28f540f4 RM |
925 | #### |
926 | #### End of configuration variables. | |
927 | #### | |
928 | \f | |
929 | # This tells some versions of GNU make before 3.63 not to export all variables. | |
930 | .NOEXPORT: | |
931 | ||
932 | # We want to echo the commands we're running without | |
6d52618b | 933 | # umpteen zillion filenames along with it (we use `...' instead) |
28f540f4 RM |
934 | # but we don't want this echoing done when the user has said |
935 | # he doesn't want to see commands echoed by using -s. | |
2d7ed98a | 936 | ifeq ($(silent-make),yes) # if -s |
28f540f4 RM |
937 | +cmdecho := echo >/dev/null |
938 | else # not -s | |
939 | +cmdecho := echo | |
940 | endif # -s | |
941 | ||
942 | # These are the flags given to the compiler to tell | |
943 | # it what sort of optimization and/or debugging output to do. | |
944 | ifndef +cflags | |
945 | # If `CFLAGS' was defined, use that. | |
946 | ifdef CFLAGS | |
947 | +cflags := $(filter-out -I%,$(CFLAGS)) | |
948 | endif # CFLAGS | |
949 | endif # +cflags | |
950 | ||
fd26970f | 951 | # If none of the above worked, default to "-g -O". |
28f540f4 RM |
952 | ifeq "$(strip $(+cflags))" "" |
953 | +cflags := $(default_cflags) | |
954 | endif # $(+cflags) == "" | |
955 | ||
7c241325 FW |
956 | # Force building with -fno-common because hidden_def, compat_symbol |
957 | # and other constructs do not work for common symbols (and would | |
958 | # otherwise require specifying __attribute__ ((nocommon)) on a | |
959 | # case-by-case basis). | |
cecbc796 | 960 | +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \ |
7c241325 | 961 | $(+stack-protector) -fno-common |
28f540f4 | 962 | +gcc-nowarn := -w |
28f540f4 | 963 | |
b84660a8 RM |
964 | # Each sysdeps directory can contain header files that both will be |
965 | # used to compile and will be installed. Each can also contain an | |
966 | # include/ subdirectory, whose header files will be used to compile | |
967 | # but will not be installed, and will take precedence over the | |
968 | # installed files. This mirrors the top-level include/ subdirectory. | |
969 | +sysdep-includes := $(foreach dir,$(+sysdep_dirs),\ | |
970 | $(addprefix -I,$(wildcard $(dir)/include) $(dir))) | |
971 | ||
b6ab06ce UD |
972 | # These are flags given to the C compiler to tell it to look for |
973 | # include files (including ones given in angle brackets) in the parent | |
974 | # library source directory, in the include directory, and in the | |
975 | # current directory. | |
e0a3ed4f | 976 | +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \ |
4ae73ca0 RM |
977 | $(+sysdep-includes) $(includes) \ |
978 | $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes) | |
28f540f4 | 979 | |
96aa2d94 | 980 | # Since libio has several internal header files, we use a -I instead |
762a2918 | 981 | # of many little headers in the include directory. |
96aa2d94 | 982 | libio-include = -I$(..)libio |
28f540f4 | 983 | |
130ac68c | 984 | # List of non-library modules that we build. |
36676f5e | 985 | built-modules = iconvprogs iconvdata ldconfig libmemusage \ |
11306df7 | 986 | libpcprofile librpcsvc locale-programs \ |
7c3018f9 | 987 | memusagestat nonlib nscd extramodules libnldbl libsupport \ |
a6d2f948 | 988 | testsuite testsuite-internal |
130ac68c | 989 | |
9cd47470 SP |
990 | in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \ |
991 | $(libof-$(<F)) \ | |
992 | $(libof-$(@F)) \ | |
993 | libc)) | |
994 | ||
e400f3cc SP |
995 | # Build ld.so, libc.so and libpthread.so with -ftls-model=initial-exec |
996 | tls-model = $(if $(filter libpthread rtld \ | |
997 | libc,$(in-module)),-ftls-model=initial-exec,) | |
998 | ||
130ac68c | 999 | module-cppflags-real = -include $(common-objpfx)libc-modules.h \ |
279bc5b3 | 1000 | -DMODULE_NAME=$(in-module) |
130ac68c | 1001 | |
8a257e2c RM |
1002 | # We don't need libc-modules.h and the MODULE_NAME definition for .v.i |
1003 | # files. These targets don't (and will likely never need to) use the IS_IN | |
1004 | # facility. In fact, shlib-versions should not use it because that will | |
1005 | # create a circular dependency as libc-modules.h is generated from | |
1006 | # shlib-versions. | |
6b229222 | 1007 | module-cppflags = $(if $(filter %.mk.i %.v.i,$(@F)),,$(module-cppflags-real)) |
130ac68c | 1008 | |
28f540f4 | 1009 | # These are the variables that the implicit compilation rules use. |
ce460d04 RM |
1010 | # Note that we can't use -std=* in CPPFLAGS, because it overrides |
1011 | # the implicit -lang-asm and breaks cpp behavior for .S files--notably | |
1012 | # it causes cpp to stop predefining __ASSEMBLER__. | |
7ffa9423 AZ |
1013 | CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \ |
1014 | $($(subdir)-CPPFLAGS) \ | |
130ac68c | 1015 | $(+includes) $(defines) $(module-cppflags) \ |
ae8b36f7 | 1016 | -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \ |
130ac68c | 1017 | $(CPPFLAGS-$(suffix $@)) \ |
d29724f8 | 1018 | $(foreach lib,$(libof-$(basename $(@F))) \ |
bc96fbda | 1019 | $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \ |
0a951d0e | 1020 | $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F))) |
67e58f39 | 1021 | |
6765d5d3 | 1022 | ifneq (no,$(have-tunables)) |
67e58f39 SP |
1023 | CPPFLAGS += -DTOP_NAMESPACE=glibc |
1024 | endif | |
1025 | ||
783dd2d3 | 1026 | override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \ |
7735afa2 | 1027 | $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \ |
a6d2f948 | 1028 | $(+extra-math-flags) $(+extra-time-flags) \ |
7735afa2 | 1029 | $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \ |
e400f3cc | 1030 | $(CFLAGS-$(@F)) $(tls-model) \ |
44f0a71e UD |
1031 | $(foreach lib,$(libof-$(basename $(@F))) \ |
1032 | $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib))) | |
83212868 L |
1033 | # Use our copies of cstdlib and cmath. |
1034 | override CXXFLAGS = -I$(common-objpfx) $(c++-sysincludes) \ | |
ef226fec | 1035 | $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \ |
7735afa2 | 1036 | $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F)) |
28f540f4 | 1037 | |
cc3fa755 UD |
1038 | # If everything is compiled with -fPIC (implicitly) we must tell this by |
1039 | # defining the PIC symbol. | |
1040 | ifeq (yes,$(build-pic-default)) | |
1041 | pic-default = -DPIC | |
1042 | endif | |
1043 | ||
f0bf9cb9 RM |
1044 | # Enable object files for different versions of the library. |
1045 | # Various things use $(object-suffixes) to know what all to make. | |
1046 | # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX}) | |
1047 | # to pass different flags for each flavor. | |
91641c65 | 1048 | libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o)) |
612148c6 FW |
1049 | # .op may be added to all-object-suffixes below. |
1050 | all-object-suffixes := .o .os .oS | |
650425ce | 1051 | object-suffixes := |
cc3fa755 | 1052 | CPPFLAGS-.o = $(pic-default) |
9d7a3741 L |
1053 | # libc.a must be compiled with -fPIE/-fpie for static PIE. |
1054 | CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) $(pie-default) | |
f0bf9cb9 | 1055 | libtype.o := lib%.a |
650425ce | 1056 | object-suffixes += .o |
f0bf9cb9 RM |
1057 | ifeq (yes,$(build-shared)) |
1058 | # Under --enable-shared, we will build a shared library of PIC objects. | |
40a55d20 UD |
1059 | # The PIC object files are named foo.os. |
1060 | object-suffixes += .os | |
900fa257 AZ |
1061 | pic-cppflags = -DPIC -DSHARED |
1062 | CPPFLAGS-.os = $(pic-cppflags) | |
14e9dd67 | 1063 | CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag) |
40a55d20 | 1064 | libtype.os := lib%_pic.a |
26b4d766 UD |
1065 | # This can be changed by a sysdep makefile |
1066 | pic-ccflag = -fPIC | |
231e88a4 UD |
1067 | # This one should always stay like this unless there is a very good reason. |
1068 | PIC-ccflag = -fPIC | |
f0bf9cb9 | 1069 | endif |
7b91359b | 1070 | # This can be changed by a sysdep makefile |
51231c46 | 1071 | pie-ccflag = -fPIE |
23645707 | 1072 | no-pie-ccflag = -fno-pie |
7b91359b UD |
1073 | # This one should always stay like this unless there is a very good reason. |
1074 | PIE-ccflag = -fPIE | |
f0bf9cb9 RM |
1075 | ifeq (yes,$(build-profile)) |
1076 | # Under --enable-profile, we will build a static library of profiled objects. | |
40a55d20 | 1077 | # The profiled object files are named foo.op. |
612148c6 | 1078 | all-object-suffixes += .op |
40a55d20 | 1079 | object-suffixes += .op |
cc3fa755 | 1080 | CPPFLAGS-.op = -DPROF $(pic-default) |
9d7a3741 L |
1081 | # libc_p.a must be compiled with -fPIE/-fpie for static PIE. |
1082 | CFLAGS-.op = -pg $(pie-default) | |
40a55d20 | 1083 | libtype.op = lib%_p.a |
f0bf9cb9 | 1084 | endif |
ab95290c | 1085 | |
c1487492 RM |
1086 | # Convenience variable for when we want to treat shared-library cases |
1087 | # differently from the rest. | |
1088 | object-suffixes-noshared := $(filter-out .os,$(object-suffixes)) | |
1089 | ||
9afc8a59 UD |
1090 | object-suffixes-for-libc := $(object-suffixes) |
1091 | ||
1092 | ifeq (yes,$(build-shared)) | |
1093 | # Build special library that contains the static-only routines for libc. | |
1094 | object-suffixes-for-libc += .oS | |
1095 | ||
1096 | # Must build the routines as PIC, though, because they can end up in (users') | |
1097 | # shared objects. We don't want to use CFLAGS-os because users may, for | |
1098 | # example, make that processor-specific. | |
6413fcde | 1099 | CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags) |
06b31ad3 | 1100 | CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1 |
9afc8a59 UD |
1101 | libtype.oS = lib%_nonshared.a |
1102 | endif | |
1103 | ||
073e82bf RM |
1104 | # The assembler can generate debug information too. |
1105 | ifndef ASFLAGS | |
2e7c805d | 1106 | ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS)) |
073e82bf | 1107 | endif |
93a2584c | 1108 | override ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu) |
9afc8a59 | 1109 | |
96bda0ea RM |
1110 | ifndef BUILD_CC |
1111 | BUILD_CC = $(CC) | |
1112 | endif | |
e72bfd87 UD |
1113 | |
1114 | move-if-change = $(SHELL) $(..)scripts/move-if-change | |
a641835a | 1115 | \f |
281e6031 UD |
1116 | -include $(common-objpfx)sysd-sorted |
1117 | subdirs = $(sorted-subdirs) | |
e0a3ed4f RM |
1118 | subdir-srcdirs = $(foreach dir,$(subdirs),\ |
1119 | $(firstword $($(dir)-srcdir) $(..)$(dir))) | |
9a0a462c | 1120 | |
f3787738 RM |
1121 | # This is a pair of implicit rules to preprocess a file with # comments, |
1122 | # %ifdef et al, based on config.h settings or other %include'd files. | |
1123 | # We use chained rules instead of a pipeline here so that we can properly | |
1124 | # check the exit status of cpp rather than using its bad output when there | |
1125 | # is a preprocessing error. Another rule should depend on the output file | |
1126 | # `FOO.v', and along with that `FOO.v.i' should be given dependencies | |
1127 | # listing both its input files, and any header files that it may reference | |
1128 | # (but no commands). | |
8744841f RM |
1129 | %.v.i: $(common-objpfx)config.h $(..)Makeconfig |
1130 | sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \ | |
90f42071 | 1131 | $(filter-out FORCE %.h $(..)Makeconfig,$^) \ |
02838201 | 1132 | | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \ |
f3787738 RM |
1133 | > $@T |
1134 | mv -f $@T $@ | |
1135 | %.v: %.v.i | |
1136 | sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T | |
1137 | mv -f $@T $@ | |
480d827b | 1138 | |
7e80ddb8 RM |
1139 | ifeq (yes, $(build-shared)) |
1140 | ||
0ab0291b L |
1141 | # To generate a header to support more than one ABI for different |
1142 | # architecture variants, the CPU/Makefile defines abi-variants to be a | |
1143 | # list of names for those variants (e.g. 32 64), and, for each variant, | |
1144 | # defines abi-$(variant)-condition to be the condition for those options | |
1145 | # to use in a C #if condition. abi-includes may be defined to a list of | |
1146 | # headers to include in the generated header, if the default does not | |
88a4576f JM |
1147 | # suffice. default-abi is defined to be the ABI for the current glibc |
1148 | # build. | |
0ab0291b L |
1149 | |
1150 | ifndef abi-includes | |
1151 | abi-includes := bits/wordsize.h | |
1152 | endif | |
1153 | ||
4de1d597 RM |
1154 | # Process the shlib-versions file, which tells us what shared library |
1155 | # version numbers to use when we install shared objects on this system. | |
281e6031 UD |
1156 | # We need to wait until $(subdirs) is complete. |
1157 | ifeq ($(sysd-sorted-done),t) | |
4de1d597 | 1158 | -include $(common-objpfx)soversions.mk |
eca3eb3b | 1159 | ifndef avoid-generated |
f3787738 | 1160 | $(common-objpfx)shlib-versions.v.i: \ |
e0a3ed4f RM |
1161 | $(wildcard $(+sysdep_dirs:=/shlib-versions) \ |
1162 | $(subdir-srcdirs:=/shlib-versions)) \ | |
9632aaee | 1163 | $(..)shlib-versions |
6d864d15 | 1164 | |
6d864d15 RM |
1165 | $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \ |
1166 | $(common-objpfx)shlib-versions.v | |
af296fcd | 1167 | $(AWK) -f $^ > $@T |
ba7e89ec | 1168 | mv -f $@T $@ |
3e1e123d | 1169 | $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig |
0ab0291b | 1170 | (while read which lib number setname; do \ |
3e1e123d | 1171 | eval seen_$$which=1; \ |
91adb529 | 1172 | test x"$$which" = xDEFAULT || continue; \ |
1bc777b8 UD |
1173 | case $$number in \ |
1174 | [0-9]*) echo "$$lib.so-version=.$$number"; \ | |
1175 | echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\ | |
93ae1eba | 1176 | *) echo "$$lib.so-version=$$number"; \ |
1bc777b8 UD |
1177 | echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\ |
1178 | esac; \ | |
1179 | done; \ | |
1180 | echo soversions.mk-done = t;) < $< > $@T; exit 0 | |
4de1d597 | 1181 | mv -f $@T $@ |
eca3eb3b | 1182 | endif |
281e6031 | 1183 | endif |
eca3eb3b | 1184 | |
f3787738 RM |
1185 | postclean-generated += soversions.mk soversions.i \ |
1186 | shlib-versions.v shlib-versions.v.i | |
4de1d597 | 1187 | |
130ac68c | 1188 | before-compile += $(common-objpfx)libc-modules.h |
65b6d8b7 | 1189 | common-generated += libc-modules.h libc-modules.stmp |
130ac68c SP |
1190 | ifeq ($(soversions.mk-done),t) |
1191 | # Generate a header with macro definitions for use with the IS_IN macro. | |
279bc5b3 | 1192 | # These are the possible values for the MODULE_NAME macro defined when building |
130ac68c SP |
1193 | # sources, to identify which module the translation unit is going to be built |
1194 | # into. | |
1195 | $(common-objpfx)libc-modules.h: $(common-objpfx)libc-modules.stmp; @: | |
1196 | $(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \ | |
1197 | $(common-objpfx)soversions.i | |
1198 | $(AWK) -v buildlist="$(subst -,_,$(built-modules))" -f $^ > ${@:stmp=T} | |
1199 | $(move-if-change) ${@:stmp=T} ${@:stmp=h} | |
1200 | touch $@ | |
1201 | ||
1202 | endif | |
1203 | ||
67e58f39 SP |
1204 | # Build the tunables list header early since it could be used by any module in |
1205 | # glibc. | |
6765d5d3 | 1206 | ifneq (no,$(have-tunables)) |
67e58f39 | 1207 | before-compile += $(common-objpfx)dl-tunable-list.h |
65b6d8b7 ZW |
1208 | common-generated += dl-tunable-list.h dl-tunable-list.stmp |
1209 | ||
1210 | $(common-objpfx)dl-tunable-list.h: $(common-objpfx)dl-tunable-list.stmp; @: | |
1211 | $(common-objpfx)dl-tunable-list.stmp: \ | |
1212 | $(..)scripts/gen-tunables.awk \ | |
1213 | $(..)elf/dl-tunables.list \ | |
1214 | $(wildcard $(subdirs:%=$(..)%/dl-tunables.list)) \ | |
1215 | $(wildcard $(sysdirs:%=%/dl-tunables.list)) | |
1216 | $(AWK) -f $^ > ${@:stmp=T} | |
1217 | $(move-if-change) ${@:stmp=T} ${@:stmp=h} | |
1218 | touch $@ | |
67e58f39 SP |
1219 | endif |
1220 | ||
ef7c6d42 FW |
1221 | # Dump the GCC macros used by the default compiler flags to a header |
1222 | # file, so that they can be inspected when using different compiler | |
1223 | # flags. Add the GCCMACRO prefix to make these macro names unique. | |
1224 | $(common-objpfx)gcc-macros.h.in: $(common-objpfx)config.status | |
1225 | $(CC) $(CFLAGS) $(CPPFLAGS) -E -dM -x c -o $@ /dev/null | |
1226 | $(common-objpfx)gcc-macros.h: $(common-objpfx)gcc-macros.h.in | |
1227 | sed 's/^#define /#define GCCMACRO/' < $< > $@ | |
1228 | before-compile += $(common-objpfx)gcc-macros.h | |
1229 | ||
462d348c AS |
1230 | # Generate version maps, but wait until sysdep-subdirs is known |
1231 | ifeq ($(sysd-sorted-done),t) | |
1232 | ifeq ($(build-shared),yes) | |
1233 | -include $(common-objpfx)sysd-versions | |
1234 | -include $(common-objpfx)Versions.mk | |
1235 | $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions | |
1236 | common-generated += $(version-maps) | |
1237 | postclean-generated += sysd-versions Versions.all abi-versions.h \ | |
1238 | Versions.def Versions.v.i Versions.v Versions.mk | |
1239 | ||
1240 | ifndef avoid-generated | |
1241 | ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs)) | |
1242 | sysd-versions-force = FORCE | |
1243 | FORCE: | |
1244 | endif | |
1245 | ||
1246 | $(common-objpfx)Versions.def: $(..)scripts/versionlist.awk \ | |
1247 | $(common-objpfx)Versions.v | |
1248 | LC_ALL=C $(AWK) -f $^ > $@T | |
1249 | mv -f $@T $@ | |
1250 | ||
1251 | $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \ | |
1252 | $(common-objpfx)soversions.i \ | |
1253 | $(common-objpfx)Versions.def | |
1254 | { while read which lib version setname; do \ | |
1255 | test x"$$which" = xDEFAULT || continue; \ | |
1256 | test -z "$$setname" || echo "$$lib : $$setname"; \ | |
1257 | done < $(word 2,$^); \ | |
1258 | cat $(word 3,$^); \ | |
1259 | } | LC_ALL=C $(AWK) -f $< > $@T | |
1260 | mv -f $@T $@ | |
1261 | $(common-objpfx)Versions.mk: $(..)scripts/haveversions.awk \ | |
1262 | $(common-objpfx)Versions.all | |
1263 | $(AWK) -f $^ > $@T | |
1264 | mv -f $@T $@ | |
1265 | # See %.v/%.v.i implicit rules in Makeconfig. | |
1266 | $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \ | |
1267 | $(wildcard $(sysdirs:%=%/Versions)) \ | |
1268 | $(sysd-versions-force) | |
1269 | $(common-objpfx)sysd-versions: $(common-objpfx)versions.stmp | |
1270 | $(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \ | |
1271 | $(common-objpfx)Versions.v \ | |
1272 | $(..)scripts/versions.awk | |
1273 | ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \ | |
1274 | cat $(word 2,$^) \ | |
1275 | | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \ | |
1276 | -v move_if_change='$(move-if-change)' \ | |
1277 | -f $(word 3,$^); \ | |
1278 | ) > $(common-objpfx)sysd-versionsT | |
1279 | mv -f $(common-objpfx)sysd-versionsT $(common-objpfx)sysd-versions | |
1280 | touch $@ | |
1281 | endif # avoid-generated | |
1282 | endif # $(build-shared) = yes | |
088d3291 AZ |
1283 | |
1284 | -include $(common-objpfx)time64-compat.mk | |
1285 | postclean-generated += time64-compat.mk | |
1286 | ||
6b229222 SP |
1287 | $(common-objpfx)time64-compat.mk: $(common-objpfx)time64-compat.mk.i \ |
1288 | $(sysd-versions-force) | |
088d3291 AZ |
1289 | sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T |
1290 | mv -f $@T $@ | |
6b229222 | 1291 | $(common-objpfx)time64-compat.mk.i: $(..)Makeconfig |
088d3291 AZ |
1292 | printf "#include <time64-compat.h>\n#ifdef TIME64_NON_DEFAULT\nhave-time64-compat = yes\n#endif" \ |
1293 | | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - > $@T | |
1294 | mv -f $@T $@ | |
1295 | ||
1296 | ||
462d348c AS |
1297 | endif # sysd-sorted-done |
1298 | ||
d41c6f61 UD |
1299 | # The name under which the run-time dynamic linker is installed. |
1300 | # We are currently going for the convention that `/lib/ld.so.1' | |
1301 | # names the SVR4/ELF ABI-compliant dynamic linker. | |
1302 | ifndef rtld-installed-name | |
1303 | ifdef ld.so-version | |
1304 | rtld-installed-name = $(ld.so-version) | |
1305 | else | |
1306 | rtld-installed-name = ld.so.1 | |
1307 | endif | |
1308 | endif | |
1309 | ||
1ef32c3d UD |
1310 | ifndef rtld-version-installed-name |
1311 | rtld-version-installed-name = ld-$(version).so | |
1312 | endif | |
1313 | ||
f649c201 UD |
1314 | endif # build-shared |
1315 | ||
cbdee279 | 1316 | |
6ee65ed6 UD |
1317 | ifeq ($(build-shared),yes) |
1318 | libm = $(common-objpfx)math/libm.so$(libm.so-version) | |
5695d46f | 1319 | libmvec = $(common-objpfx)mathvec/libmvec.so$(libmvec.so-version) |
6ee65ed6 UD |
1320 | else |
1321 | libm = $(common-objpfx)math/libm.a | |
5695d46f | 1322 | libmvec = $(common-objpfx)mathvec/libmvec.a |
6ee65ed6 UD |
1323 | endif |
1324 | ||
c23de0aa FW |
1325 | ifeq ($(build-shared),yes) |
1326 | libsupport = $(common-objpfx)support/libsupport_nonshared.a | |
1327 | else | |
1328 | libsupport = $(common-objpfx)support/libsupport.a | |
1329 | endif | |
1330 | ||
354e4c1a TMQMF |
1331 | # This is a partial list of subdirectories containing the library source. |
1332 | # The order is more or less arbitrary. The sorting step will take care of the | |
1333 | # dependencies and generate sorted-subdirs dynamically. | |
8d6f1731 | 1334 | all-subdirs = csu assert ctype locale intl catgets math setjmp signal \ |
e0a3ed4f | 1335 | stdlib stdio-common libio malloc string wcsmbs time dirent \ |
b0b67c47 | 1336 | grp pwd posix io termios resource misc socket sysvipc gmon \ |
829fea46 | 1337 | gnulib iconv iconvdata wctype manual shadow gshadow po argp \ |
e69d994a | 1338 | localedata timezone rt conform debug mathvec support \ |
644d3857 | 1339 | dlfcn elf |
b22fc5f5 | 1340 | |
e69d994a ZW |
1341 | ifeq ($(build-crypt),yes) |
1342 | all-subdirs += crypt | |
1343 | rpath-dirs += crypt | |
1344 | endif | |
1345 | ||
b7e2d9a5 | 1346 | ifndef avoid-generated |
7bd642f5 RM |
1347 | # sysd-sorted itself will contain rules making the sysd-sorted target |
1348 | # depend on Depend files. But if you just added a Depend file to an | |
1349 | # existing directory not in all-subdirs, then sysd-sorted needs to | |
1350 | # be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files. | |
1351 | all-Depend-files := $(wildcard $(sort \ | |
95afbbe5 | 1352 | $(foreach dir,$(all-subdirs),\ |
7bd642f5 RM |
1353 | $(firstword $($(dir)-srcdir) \ |
1354 | $(..)$(dir))/Depend) \ | |
1355 | $(sorted-subdirs:=/Depend))) | |
e0a3ed4f RM |
1356 | $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \ |
1357 | $(common-objpfx)config.make $(..)Makeconfig \ | |
1358 | $(wildcard $(sysdirs:=/Subdirs)) \ | |
1359 | $(all-Depend-files) | |
1360 | $(AWK) -f $< \ | |
1361 | -v subdirs='$(all-subdirs)' \ | |
1362 | -v srcpfx='$(..)' \ | |
1363 | $(filter %/Subdirs %/Depend,$^) > $@-tmp | |
bb41a976 | 1364 | mv -f $@-tmp $@ |
9de06f3c | 1365 | $(all-Depend-files): ; |
b7e2d9a5 | 1366 | endif |
bb41a976 | 1367 | |
16cd816f RM |
1368 | # This gives partial TARGET:SOURCE pattern pairs to have rules |
1369 | # emitted into sysd-rules. A sysdeps Makeconfig fragment can | |
1370 | # add its own special object file prefix to this list with e.g. foo-%:% | |
1371 | # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS). | |
bc96fbda | 1372 | sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_% |
16cd816f | 1373 | |
083973f3 | 1374 | # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here. |
e0a3ed4f | 1375 | sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig)) |
083973f3 | 1376 | ifneq (,$(sysdep-makeconfigs)) |
e0a3ed4f | 1377 | include $(sysdep-makeconfigs) |
083973f3 RM |
1378 | endif |
1379 | ||
363a641b | 1380 | # Compute just the target patterns. Makeconfig has set sysd-rules-patterns. |
bc96fbda AS |
1381 | sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\ |
1382 | $(firstword $(subst :, ,$p)))) | |
083973f3 | 1383 | |
ad201afe FW |
1384 | # $(libpthread-routines-var) and $(librt-routines-var) are the make |
1385 | # variable to which pthread routines need to be added to land in the | |
1386 | # right library. | |
1387 | ifeq ($(pthread-in-libc),yes) | |
1388 | libpthread-routines-var = routines | |
1389 | librt-routines-var = routines | |
dbb949f5 | 1390 | libanl-routines-var = routines |
ad201afe FW |
1391 | else |
1392 | libpthread-routines-var = libpthread-routines | |
a2014d31 | 1393 | librt-routines-var = librt-routines |
dbb949f5 | 1394 | libanl-routines-var = libanl-routines |
ad201afe FW |
1395 | endif |
1396 | ||
c75ccd4c RM |
1397 | # A sysdeps Makeconfig fragment may set libc-reentrant to yes. |
1398 | ifeq (yes,$(libc-reentrant)) | |
1399 | defines += -D_LIBC_REENTRANT | |
1400 | ||
1401 | libio-mtsafe = -D_IO_MTSAFE_IO | |
1402 | endif | |
1403 | ||
591aeaf7 TD |
1404 | # The name to give to a test in test results summaries. |
1405 | test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@))) | |
1406 | ||
54ee292d JM |
1407 | # Likewise, in XFAIL variable names. |
1408 | test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@))) | |
1409 | ||
f8c17e79 | 1410 | # Command to output a test status line (such as PASS: test-name). If |
54ee292d | 1411 | # test-xfail-$(test-xfail-name) has a nonempty value, the status will be |
f8c17e79 | 1412 | # XPASS or XFAIL rather than PASS or FAIL. |
591aeaf7 | 1413 | evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \ |
54ee292d | 1414 | $(if $(test-xfail-$(test-xfail-name)),true,false) \ |
d6fe5e58 | 1415 | $(if $(stop-on-test-failure),true,false) \ |
591aeaf7 TD |
1416 | > $(common-objpfx)$(test-name).test-result |
1417 | ||
28f540f4 | 1418 | endif # Makeconfig not yet included |
c238ecf7 UD |
1419 | |
1420 | # Local Variables: | |
1421 | # mode: makefile | |
1422 | # End: |