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