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