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