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