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