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