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