1 # Copyright (C) 1991-2014 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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 # <http://www.gnu.org/licenses/>.
19 # Makefile configuration options for the GNU C library.
22 This makefile requires GNU Make.
25 all: # Make this the default goal
27 ifneq "$(origin +included-Makeconfig)" "file"
29 +included-Makeconfig := yes
35 # $(common-objdir) is the place to put objects and
36 # such that are not specific to a single subdir.
38 objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
39 common-objpfx = $(objdir)/
40 common-objdir = $(objdir)
42 objdir must be defined by the build-directory Makefile.
45 # Root of the sysdeps tree.
46 sysdep_dir := $(..)sysdeps
47 export sysdep_dir := $(sysdep_dir)
49 # Get the values defined by options to `configure'.
50 include $(common-objpfx)config.make
52 # What flags to give to sources which call user provided callbacks
53 uses-callbacks = $(exceptions)
55 # What flags to give to tests which test stack alignment
56 stack-align-test-flags =
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))
62 # Add-ons that contribute sysdeps trees get added to the include list
63 # after sysdeps/generic. This makes #include <sysdeps/...> work right
64 # to find specific add-on files without assuming the add-on directory name.
65 # It also means that headers can go into an add-on's base directory
66 # instead of the add-on needing a sysdeps/generic of its own.
67 sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\
68 $(firstword $(filter /%,$(add-on)) \
70 +sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs)
72 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
75 # Run config.status to update config.make and config.h. We don't show the
76 # dependence of config.h to Make, because it is only touched when it
77 # changes and so config.status would be run every time; the dependence of
78 # config.make should suffice to force regeneration and re-exec, and the new
79 # image will notice if config.h changed.
80 $(common-objpfx)config.make: $(common-objpfx)config.status \
81 $(..)config.make.in $(..)config.h.in
82 cd $(<D); $(SHELL) $(<F)
84 # Find all the add-on and sysdeps configure fragments, to make sure we
85 # re-run configure when any of them changes.
86 $(common-objpfx)config.status: $(..)version.h $(..)configure \
87 $(foreach dir,$(sysdirs),\
88 $(wildcard $(dir)/Implies) \
90 $(firstword $(wildcard \
91 $(addprefix $(dir)/,configure configure.ac))))) \
93 $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac)) \
95 $(foreach add-on,$(add-ons),\
96 $(firstword $(wildcard \
97 $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
98 configure configure.ac))) \
99 $(wildcard $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
100 sysdeps/*/preconfigure sysdeps/*/preconfigure.ac))))
101 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
102 echo The GNU C library has not been configured. >&2; \
103 echo Run \`configure\' to configure it before building. >&2; \
104 echo Try \`configure --help\' for more details. >&2; \
107 # We don't want CPPFLAGS to be exported to the command running configure.
110 # Get the user's configuration parameters.
111 ifneq ($(wildcard $(..)configparms),)
112 include $(..)configparms
115 ifneq ($(wildcard $(common-objpfx)configparms),)
116 include $(common-objpfx)configparms
121 #### These are the configuration variables. You can define values for
122 #### the variables below in the file `configparms'.
123 #### Do NOT edit this file.
127 # Common prefix for machine-independent installation directories.
128 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
132 # Decide whether we shall build the programs or not. We always do this
133 # unless the user tells us (in configparms) or we are building for a
135 ifndef build-programs
136 ifneq ($(config-os),none)
143 # Common prefix for machine-dependent installation directories.
144 ifeq ($(origin exec_prefix),undefined)
145 exec_prefix = $(prefix)
148 # Where to install the library and object files.
150 libdir = $(exec_prefix)/lib
152 inst_libdir = $(install_root)$(libdir)
154 # Where to install the shared library.
156 slibdir = $(exec_prefix)/lib
158 inst_slibdir = $(install_root)$(slibdir)
160 # Where to install the dynamic linker.
164 inst_rtlddir = $(install_root)$(rtlddir)
166 # Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
167 # the prefix is spliced between `lib' and the name, so the linker switch
168 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
169 # just prepended to the whole file name.
170 ifeq ($(origin libprefix),undefined)
174 # Where to install the header files.
176 includedir = $(prefix)/include
178 inst_includedir = $(install_root)$(includedir)
180 # Where to install machine-independent data files.
181 # These are the timezone database, and the locale database.
183 datadir = $(prefix)/share
185 inst_datadir = $(install_root)$(datadir)
187 # Where to install the timezone data files (which are machine-independent).
189 zonedir = $(datadir)/zoneinfo
191 inst_zonedir = $(install_root)$(zonedir)
193 # Where to install the locale files.
195 localedir = $(libdir)/locale
197 inst_localedir = $(install_root)$(localedir)
199 # Where to install the message catalog data files (which are
200 # machine-independent).
202 msgcatdir = $(datadir)/locale
204 inst_msgcatdir = $(install_root)$(msgcatdir)
206 # Where to install the locale charmap source files.
208 i18ndir = $(datadir)/i18n
210 inst_i18ndir = $(install_root)$(i18ndir)
212 # Where to install the shared object for charset transformation.
214 gconvdir = $(libdir)/gconv
216 inst_gconvdir = $(install_root)$(gconvdir)
218 # Where to install programs.
220 bindir = $(exec_prefix)/bin
222 inst_bindir = $(install_root)$(bindir)
224 # Where to install internal programs.
226 libexecdir = $(exec_prefix)/libexec
228 inst_libexecdir = $(install_root)$(libexecdir)
230 # Where to install administrative programs.
232 rootsbindir = $(exec_prefix)/sbin
234 inst_rootsbindir = $(install_root)$(rootsbindir)
237 sbindir = $(exec_prefix)/sbin
239 inst_sbindir = $(install_root)$(sbindir)
241 # Where to install the Info files.
243 infodir = $(prefix)/info
245 inst_infodir = $(install_root)$(infodir)
247 # Where to install audit libraries.
249 auditdir = $(libdir)/audit
251 inst_auditdir = $(install_root)$(auditdir)
253 # Where to install default configuration files. These include the local
254 # timezone specification and network data base files.
256 sysconfdir = $(prefix)/etc
258 inst_sysconfdir = $(install_root)$(sysconfdir)
260 # Directory for the database files and Makefile for nss_db.
262 vardbdir = $(localstatedir)/db
264 inst_vardbdir = $(install_root)$(vardbdir)
266 # Where to install the "localtime" timezone file; this is the file whose
267 # contents $(localtime) specifies. If this is a relative pathname, it is
268 # relative to $(zonedir). It is a good idea to put this somewhere
269 # other than there, so the zoneinfo directory contains only universal data,
270 # localizing the configuration data elsewhere.
271 ifndef localtime-file
272 localtime-file = $(sysconfdir)/localtime
275 # What to use for leap second specifications in compiling the default
276 # timezone files. Set this to `/dev/null' for no leap second handling as
277 # 1003.1 requires, or to `leapseconds' for proper leap second handling.
278 # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
279 # This variable determines the default: if it's `/dev/null',
280 # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
282 leapseconds = /dev/null
285 # What timezone's DST rules should be used when a POSIX-style TZ
286 # environment variable doesn't specify any rules. For 1003.1 compliance
287 # this timezone must use rules that are as U.S. federal law defines DST.
288 # Run `make -C time echo-zonenames' to see a list of available zone names.
289 # This setting can be changed with `zic -p TIMEZONE' at any time.
290 # If you want POSIX.1 compatibility, use `America/New_York'.
292 posixrules = America/New_York
295 # Where to install the "posixrules" timezone file; this is file
296 # whose contents $(posixrules) specifies. If this is a relative
297 # pathname, it is relative to $(zonedir).
298 ifndef posixrules-file
299 posixrules-file = posixrules
303 # Directory where your system's native header files live.
304 # This is used on Unix systems to generate some GNU libc header files.
306 sysincludedir = /usr/include
310 # Commands to install files.
312 INSTALL_DATA = $(INSTALL) -m 644
314 ifndef INSTALL_SCRIPT
315 INSTALL_SCRIPT = $(INSTALL)
317 ifndef INSTALL_PROGRAM
318 INSTALL_PROGRAM = $(INSTALL)
325 # The name of the C compiler.
326 # If you've got GCC, and it works, use it.
327 ifeq ($(origin CC),default)
331 # The name of the C compiler to use for compilations of programs to run on
332 # the host that is building the library. If you set CC to a
333 # cross-compiler, you must set this to the normal compiler.
338 # Default flags to pass the C compiler.
339 ifndef default_cflags
340 ifeq ($(release),stable)
341 default_cflags := -g -O2
343 default_cflags := -g -O
347 # Flags to pass the C compiler when assembling preprocessed assembly code
348 # (`.S' files). On some systems the assembler doesn't understand the `#' line
349 # directives the preprocessor produces. If you have troubling compiling
350 # assembly code, try using -P here to suppress these directives.
355 as-needed := -Wl,--as-needed
356 no-as-needed := -Wl,--no-as-needed
358 # Must be supported by the linker.
359 no-whole-archive = -Wl,--no-whole-archive
360 whole-archive = -Wl,--whole-archive
362 # Installed name of the startup code.
363 # The ELF convention is that the startfile is called crt1.o
364 start-installed-name = crt1.o
365 # On systems that do not need a special startfile for statically linked
366 # binaries, simply set it to the normal name.
367 ifndef static-start-installed-name
368 static-start-installed-name = $(start-installed-name)
371 ifeq (yesyes,$(build-shared)$(have-z-combreloc))
372 combreloc-LDFLAGS = -Wl,-z,combreloc
373 LDFLAGS.so += $(combreloc-LDFLAGS)
374 LDFLAGS-rtld += $(combreloc-LDFLAGS)
377 relro-LDFLAGS = -Wl,-z,relro
378 LDFLAGS.so += $(relro-LDFLAGS)
379 LDFLAGS-rtld += $(relro-LDFLAGS)
381 ifeq (yes,$(have-hash-style))
382 # For the time being we unconditionally use 'both'. At some time we
383 # should declare statically linked code as 'out of luck' and compile
384 # with --hash-style=gnu only.
385 hashstyle-LDFLAGS = -Wl,--hash-style=both
386 LDFLAGS.so += $(hashstyle-LDFLAGS)
387 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
390 # Command for linking PIE programs with the C library.
392 +link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
393 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
394 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
395 $(addprefix $(csu-objpfx),S$(start-installed-name)) \
396 $(+preinit) $(+prectorS) \
397 $(filter-out $(addprefix $(csu-objpfx),start.o \
398 S$(start-installed-name))\
399 $(+preinit) $(link-extra-libs) \
400 $(common-objpfx)libc% $(+postinit),$^) \
402 +link-pie-after-libc = $(+postctorS) $(+postinit)
403 +link-pie = $(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) \
404 $(+link-pie-after-libc)
405 +link-pie-tests = $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) \
406 $(link-libc-tests) $(+link-pie-after-libc)
408 # Command for statically linking programs with the C library.
410 +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
411 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
412 $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
413 $(+preinit) $(+prectorT) \
414 $(filter-out $(addprefix $(csu-objpfx),start.o \
415 $(start-installed-name))\
416 $(+preinit) $(link-extra-libs-static) \
417 $(common-objpfx)libc% $(+postinit),$^) \
418 $(link-extra-libs-static)
419 +link-static-after-libc = $(+postctorT) $(+postinit)
420 +link-static = $(+link-static-before-libc) $(link-libc-static) \
421 $(+link-static-after-libc)
422 +link-static-tests = $(+link-static-before-libc) $(link-libc-static-tests) \
423 $(+link-static-after-libc)
425 # Commands for linking programs with the C library.
427 ifeq (yes,$(build-shared))
428 +link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
429 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
430 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
431 $(addprefix $(csu-objpfx),$(start-installed-name)) \
432 $(+preinit) $(+prector) \
433 $(filter-out $(addprefix $(csu-objpfx),start.o \
434 $(start-installed-name))\
435 $(+preinit) $(link-extra-libs) \
436 $(common-objpfx)libc% $(+postinit),$^) \
438 +link-after-libc = $(+postctor) $(+postinit)
439 +link = $(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) \
441 +link-tests = $(+link-before-libc) $(rtld-tests-LDFLAGS) \
442 $(link-libc-tests) $(+link-after-libc)
444 +link = $(+link-static)
445 +link-tests = $(+link-static-tests)
448 ifeq (yes,$(build-shared))
450 rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
452 ifndef rtld-tests-LDFLAGS
453 ifeq (yes,$(build-hardcoded-path-in-tests))
454 rtld-tests-LDFLAGS = -Wl,-dynamic-linker=$(common-objpfx)elf/ld.so
456 rtld-tests-LDFLAGS = $(rtld-LDFLAGS)
461 ifeq (yes,$(build-shared))
462 # We need the versioned name of libc.so in the deps of $(others) et al
463 # so that the symlink to libc.so is created before anything tries to
464 # run the linked programs.
465 link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link)
466 ifeq (yes,$(build-hardcoded-path-in-tests))
467 link-libc-tests-rpath-link = -Wl,-rpath=$(rpath-link)
469 link-libc-tests-rpath-link = $(link-libc-rpath-link)
471 link-libc-before-gnulib = $(common-objpfx)libc.so$(libc.so-version) \
472 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
473 $(as-needed) $(common-objpfx)elf/ld.so \
475 link-libc = $(link-libc-rpath-link) $(link-libc-before-gnulib) $(gnulib)
476 link-libc-tests = $(link-libc-tests-rpath-link) \
477 $(link-libc-before-gnulib) $(gnulib-tests)
478 # This is how to find at build-time things that will be installed there.
479 rpath-dirs = math elf dlfcn nss nis rt resolv crypt
481 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
483 link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
484 link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
488 elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
490 # Differences in the linkers on the various platforms.
491 LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
492 LDFLAGS-soname-fname = -Wl,-soname,$(@F)
493 LDFLAGS-rdynamic = -rdynamic
494 LDFLAGS-Bsymbolic = -Bsymbolic
496 # Choose the default search path for the dynamic linker based on
497 # where we will install libraries.
498 ifneq ($(libdir),$(slibdir))
499 default-rpath = $(slibdir):$(libdir)
501 default-rpath = $(libdir)
504 ifndef link-extra-libs
505 link-extra-libs = $(LDLIBS-$(@F))
506 link-extra-libs-static = $(link-extra-libs)
509 # The static libraries.
510 link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
511 link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
513 # How to link against libgcc. Some libgcc functions, such as those
514 # for "long long" arithmetic or software floating point, can always be
515 # built without use of C library headers and do not have any global
516 # state so can safely be linked statically into any executable or
517 # shared library requiring them; these functions are in libgcc.a.
518 # Other functions, relating to exception handling, may require C
519 # library headers to build and it may not be safe to have more than
520 # one copy of them in a process; these functions are only in
521 # libgcc_s.so and libgcc_eh.a.
523 # To avoid circular dependencies when bootstrapping, it is desirable
524 # to avoid use of libgcc_s and libgcc_eh in building glibc. Where any
525 # glibc functionality (in particular, thread cancellation) requires
526 # exception handling, this is implemented through dlopen of libgcc_s
527 # to avoid unnecessary dependencies on libgcc_s by programs not using
528 # that functionality; executables built with glibc do not use
529 # exception handling other than through thread cancellation.
531 # Undefined references to functions from libgcc_eh or libgcc_s may
532 # arise for code built with -fexceptions. In the case of statically
533 # linked programs installed by glibc, unwinding will never actually
534 # occur at runtime and the use of elf/static-stubs.c to resolve these
535 # references is safe. In the case of statically linked test programs
536 # and test programs built with -fexceptions, unwinding may occur in
537 # some cases and it is preferable to link with libgcc_eh or libgcc_s
538 # so that the testing is as similar as possible to how programs will
539 # be built with the installed glibc.
541 # Some architectures have architecture-specific systems for exception
542 # handling that may involve undefined references to
543 # architecture-specific functions. On those architectures,
544 # gnulib-arch and static-gnulib-arch may be defined in sysdeps
545 # makefiles to use additional libraries for linking executables and
546 # shared libraries built by glibc.
548 ifneq ($(have-cc-with-libunwind),yes)
553 libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
555 gnulib = -lgcc $(gnulib-arch)
556 gnulib-tests := -lgcc $(libgcc_eh)
558 # By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
559 # statically link programs. When --disable-shared is used, we use
560 # -lgcc_eh since elf/static-stubs.o isn't sufficient.
561 ifeq (yes,$(build-shared))
562 static-gnulib = -lgcc $(static-gnulib-arch)
564 static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch)
566 static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
567 libc.so-gnulib := -lgcc
569 +preinit = $(addprefix $(csu-objpfx),crti.o)
570 +postinit = $(addprefix $(csu-objpfx),crtn.o)
571 +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
572 +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
573 # Variants of the two previous definitions for linking PIE programs.
574 +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
575 +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
576 # Variants of the two previous definitions for statically linking programs.
577 +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
578 +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
579 +interp = $(addprefix $(elf-objpfx),interp.os)
580 csu-objpfx = $(common-objpfx)csu/
581 elf-objpfx = $(common-objpfx)elf/
583 # A command that, prepended to the name and arguments of a program,
584 # and run on the build system, causes that program with those
585 # arguments to be run on the host for which the library is built.
589 # Likewise, but the name of the program is preceded by
590 # <variable>=<value> assignments for environment variables.
591 ifndef test-wrapper-env
592 test-wrapper-env = $(test-wrapper) env
595 # Whether to run test programs built for the library's host system.
596 ifndef run-built-tests
597 ifeq (yes|,$(cross-compiling)|$(test-wrapper))
600 run-built-tests = yes
604 # Whether to stop immediately when a test fails. Nonempty means to
605 # stop, empty means not to stop.
606 ifndef stop-on-test-failure
607 stop-on-test-failure =
610 # How to run a program we just linked with our library.
611 # The program binary is assumed to be $(word 2,$^).
612 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
613 rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
615 $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
616 ifeq (yes,$(build-shared))
618 sysdep-library-path = \
619 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
620 $(filter -Wl$(comma)-rpath-link=%,\
621 $(sysdep-LDFLAGS)))))
622 # $(run-via-rtld-prefix) is a command that, when prepended to the name
623 # of a program built with the newly built library, produces a command
624 # that, executed on the host for which the library is built, runs that
625 # program. For tests listed in tests-static or xtests-static, it is
627 run-via-rtld-prefix = \
628 $(if $(strip $(filter $(notdir $(built-program-file)), \
629 $(tests-static) $(xtests-static))),, $(rtld-prefix))
631 run-via-rtld-prefix =
633 # $(run-program-prefix) is a command that, when prepended to the name
634 # of a program built with the newly built library, produces a command
635 # that, executed on the build system on which "make" is run, runs that
637 run-program-prefix = $(test-wrapper) $(run-via-rtld-prefix)
638 # $(built-program-cmd) is a command that, executed on the build system
639 # on which "make" is run, runs the newly built program that is the
640 # second dependency of the makefile target in which
641 # $(built-program-cmd) is used.
642 built-program-cmd = $(test-wrapper) \
643 $(run-via-rtld-prefix) $(built-program-file)
644 # $(host-built-program-cmd) is a command that, executed on the host
645 # for which the library is built, runs the newly built program that is
646 # the second dependency of the makefile target in which
647 # $(host-built-program-cmd) is used.
648 host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file)
654 # $(test-via-rtld-prefix) is a command that, when prepended to the name
655 # of a test program built with the newly built library, produces a command
656 # that, executed on the host for which the library is built, runs that
657 # program. For tests listed in tests-static or xtests-static as well
658 # as when test programs are hardcoded to the newly built libraries, it
661 # $(test-program-prefix) is a command that, when prepended to the name
662 # of a test program built with the newly built library, produces a command
663 # that, executed on the build system on which "make" is run, runs that
666 # $(test-program-cmd) is a command that, executed on the build system
667 # on which "make" is run, runs the newly built test program that is the
668 # second dependency of the makefile target in which
669 # $(test-program-cmd) is used.
671 # $(host-test-program-cmd) is a command that, executed on the host
672 # for which the library is built, runs the newly built test program that
673 # is the second dependency of the makefile target in which
674 # $(host-test-program-cmd) is used.
676 ifeq (yes,$(build-hardcoded-path-in-tests))
677 test-via-rtld-prefix =
678 test-program-prefix = $(test-wrapper)
679 test-program-cmd = $(test-wrapper) $(built-program-file)
680 host-test-program-cmd = $(built-program-file)
682 test-via-rtld-prefix = $(run-via-rtld-prefix)
683 test-program-prefix = $(run-program-prefix)
684 test-program-cmd = $(built-program-cmd)
685 host-test-program-cmd = $(host-built-program-cmd)
688 # Extra flags to pass to GCC.
689 ifeq ($(all-warnings),yes)
690 +gccwarn := -Wall -Wwrite-strings -Winline -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
692 +gccwarn := -Wall -Wwrite-strings -Winline
695 +gccwarn-c = -Wstrict-prototypes
697 # We do not depend on the address of constants in different files to be
698 # actually different, so allow the compiler to merge them all.
699 +merge-constants = -fmerge-all-constants
701 # We have to assume that glibc functions are called in any rounding
702 # mode and also change the rounding mode in a few functions. So,
703 # disable any optimization that assume default rounding mode.
704 +math-flags = -frounding-math
706 # This is the program that generates makefile dependencies from C source files.
707 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
708 # targets for headers so that removed headers don't break the build.
710 +mkdep = $(CC) -M -MP
713 # The program that makes Emacs-style TAGS files.
716 # The `xgettext' program for producing .pot files from sources.
721 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
722 # perhaps others) to preprocess assembly code in some cases.
725 # To force installation of files even if they are older than the
726 # installed files. This variable is included in the dependency list
727 # of all installation targets.
728 ifeq ($(force-install),yes)
729 +force = force-install
735 #### End of configuration variables.
738 # This tells some versions of GNU make before 3.63 not to export all variables.
741 # We want to echo the commands we're running without
742 # umpteen zillion filenames along with it (we use `...' instead)
743 # but we don't want this echoing done when the user has said
744 # he doesn't want to see commands echoed by using -s.
745 ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
746 +cmdecho := echo >/dev/null
751 # These are the flags given to the compiler to tell
752 # it what sort of optimization and/or debugging output to do.
754 # If `CFLAGS' was defined, use that.
756 +cflags := $(filter-out -I%,$(CFLAGS))
760 # If none of the above worked, default to "-g -O".
761 ifeq "$(strip $(+cflags))" ""
762 +cflags := $(default_cflags)
763 endif # $(+cflags) == ""
765 +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags)
768 # Don't duplicate options if we inherited variables from the parent.
769 +cflags := $(sort $(+cflags))
771 # Each sysdeps directory can contain header files that both will be
772 # used to compile and will be installed. Each can also contain an
773 # include/ subdirectory, whose header files will be used to compile
774 # but will not be installed, and will take precedence over the
775 # installed files. This mirrors the top-level include/ subdirectory.
776 +sysdep-includes := $(foreach dir,$(+sysdep_dirs),\
777 $(addprefix -I,$(wildcard $(dir)/include) $(dir)))
779 # These are flags given to the C compiler to tell it to look for
780 # include files (including ones given in angle brackets) in the parent
781 # library source directory, in the include directory, and in the
783 +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
784 $(+sysdep-includes) $(includes) \
785 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
787 # Since libio has several internal header files, we use a -I instead
788 # of many little headers in the include directory.
789 libio-include = -I$(..)libio
791 # These are the variables that the implicit compilation rules use.
792 # Note that we can't use -std=* in CPPFLAGS, because it overrides
793 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
794 # it causes cpp to stop predefining __ASSEMBLER__.
795 CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
796 $($(subdir)-CPPFLAGS) \
797 $(+includes) $(defines) \
798 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
799 $(CPPFLAGS-$(suffix $@)) \
800 $(foreach lib,$(libof-$(basename $(@F))) \
801 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
802 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
803 override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) $(config-extra-cflags) \
804 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
805 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
807 $(foreach lib,$(libof-$(basename $(@F))) \
808 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
809 override CXXFLAGS = $(c++-sysincludes) \
810 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
811 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
813 # If everything is compiled with -fPIC (implicitly) we must tell this by
814 # defining the PIC symbol.
815 ifeq (yes,$(build-pic-default))
819 # Enable object files for different versions of the library.
820 # Various things use $(object-suffixes) to know what all to make.
821 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
822 # to pass different flags for each flavor.
823 libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
824 all-object-suffixes := .o .os .op .og .oS
826 CPPFLAGS-.o = $(pic-default)
827 CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
829 object-suffixes += .o
830 ifeq (yes,$(build-shared))
831 # Under --enable-shared, we will build a shared library of PIC objects.
832 # The PIC object files are named foo.os.
833 object-suffixes += .os
834 CPPFLAGS-.os = -DPIC -DSHARED
835 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
836 libtype.os := lib%_pic.a
837 # This can be changed by a sysdep makefile
839 # This one should always stay like this unless there is a very good reason.
842 # This can be changed by a sysdep makefile
844 # This one should always stay like this unless there is a very good reason.
846 ifeq (yes,$(build-profile))
847 # Under --enable-profile, we will build a static library of profiled objects.
848 # The profiled object files are named foo.op.
849 object-suffixes += .op
850 CPPFLAGS-.op = -DPROF $(pic-default)
852 libtype.op = lib%_p.a
855 # Convenience variable for when we want to treat shared-library cases
856 # differently from the rest.
857 object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
859 object-suffixes-for-libc := $(object-suffixes)
861 ifeq (yes,$(build-shared))
862 # Build special library that contains the static-only routines for libc.
863 object-suffixes-for-libc += .oS
865 # Must build the routines as PIC, though, because they can end up in (users')
866 # shared objects. We don't want to use CFLAGS-os because users may, for
867 # example, make that processor-specific.
868 CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
869 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
870 libtype.oS = lib%_nonshared.a
873 # The assembler can generate debug information too.
875 ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
877 ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
883 move-if-change = $(SHELL) $(..)scripts/move-if-change
885 -include $(common-objpfx)sysd-sorted
886 subdirs = $(sorted-subdirs)
887 subdir-srcdirs = $(foreach dir,$(subdirs),\
888 $(firstword $($(dir)-srcdir) $(..)$(dir)))
890 # This is a pair of implicit rules to preprocess a file with # comments,
891 # %ifdef et al, based on config.h settings or other %include'd files.
892 # We use chained rules instead of a pipeline here so that we can properly
893 # check the exit status of cpp rather than using its bad output when there
894 # is a preprocessing error. Another rule should depend on the output file
895 # `FOO.v', and along with that `FOO.v.i' should be given dependencies
896 # listing both its input files, and any header files that it may reference
898 %.v.i: $(common-objpfx)config.h $(..)Makeconfig
899 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
900 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
901 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
905 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
908 ifeq (yes, $(build-shared))
910 # To generate a header to support more than one ABI for different
911 # architecture variants, the CPU/Makefile defines abi-variants to be a
912 # list of names for those variants (e.g. 32 64), and, for each variant,
913 # defines abi-$(variant)-condition to be the condition for those options
914 # to use in a C #if condition. abi-includes may be defined to a list of
915 # headers to include in the generated header, if the default does not
916 # suffice. default-abi is defined to be the ABI for the current glibc
920 abi-includes := bits/wordsize.h
923 # Process the shlib-versions file, which tells us what shared library
924 # version numbers to use when we install shared objects on this system.
925 # We need to wait until $(subdirs) is complete.
926 ifeq ($(sysd-sorted-done),t)
927 -include $(common-objpfx)soversions.mk
928 ifndef avoid-generated
929 # This lets add-ons give more-specific matches that override defaults
930 # in the top-level file.
931 $(common-objpfx)shlib-versions.v.i: \
932 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
933 $(subdir-srcdirs:=/shlib-versions)) \
936 soversions-default-setname = $(patsubst %, %,\
937 $(filter-out %_default,\
938 $(oldest-abi:%=GLIBC_%)))
939 $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
940 $(common-objpfx)shlib-versions.v
941 $(AWK) -v default_setname='$(soversions-default-setname)' \
942 -v cpu='$(config-machine)' \
943 -v vendor='$(config-vendor)' \
944 -v os='$(config-os)' \
947 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
948 (while read which lib number setname; do \
949 eval seen_$$which=1; \
950 test x"$$which" != xABI || echo abi-name = "$$lib"; \
951 test x"$$which" = xDEFAULT || continue; \
953 [0-9]*) echo "$$lib.so-version=.$$number"; \
954 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
955 *) echo "$$lib.so-version=\$$(if \$$(abi-$(default-abi)-$$lib-soname),\$$(abi-$(default-abi)-$$lib-soname),$$number)"; \
956 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
959 echo soversions.mk-done = t;) < $< > $@T; exit 0
964 postclean-generated += soversions.mk soversions.i \
965 shlib-versions.v shlib-versions.v.i
967 # Generate the header containing the names of all shared libraries.
968 # We use a stamp file to avoid unnecessary recompilations.
969 before-compile += $(common-objpfx)gnu/lib-names.h
970 ifeq ($(soversions.mk-done),t)
971 $(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
972 $(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
973 $(common-objpfx)soversions.i
974 $(make-target-directory)
976 echo '/* This file is automatically generated.';\
977 echo ' It defines macros to allow user program to find the shared'; \
978 echo ' library files which come as part of GNU libc. */'; \
979 echo '#ifndef __GNU_LIB_NAMES_H'; \
980 echo '#define __GNU_LIB_NAMES_H 1'; \
982 $(if $(abi-includes), \
983 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
985 $(if $(abi-variants), \
986 $(foreach v,$(abi-variants),\
987 $(if $(abi-$(v)-condition),\
988 echo '#if $(abi-$(v)-condition)'; \
989 ($(foreach s,$(all-sonames), \
990 $(if $(abi-$(v)-$(firstword $(subst =, ,$(s)))-soname),\
991 echo $(firstword $(subst =, ,$(s)))=$(abi-$(v)-$(firstword $(subst =, ,$(s)))-soname);, \
993 | LC_ALL=C $(AWK) -v multi=1 -f $(firstword $^) | LC_ALL=C sort;) \
994 $(if $(abi-$(v)-condition),echo '#endif';)), \
995 ($(foreach s,$(all-sonames), echo $(s);)) \
996 | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort;) \
998 echo '#endif /* gnu/lib-names.h */'; \
1000 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
1004 common-generated += gnu/lib-names.h gnu/lib-names.stmp
1006 # The name under which the run-time dynamic linker is installed.
1007 # We are currently going for the convention that `/lib/ld.so.1'
1008 # names the SVR4/ELF ABI-compliant dynamic linker.
1009 ifndef rtld-installed-name
1011 rtld-installed-name = $(ld.so-version)
1013 rtld-installed-name = ld.so.1
1017 ifndef rtld-version-installed-name
1018 rtld-version-installed-name = ld-$(version).so
1021 endif # build-shared
1024 ifeq ($(build-shared),yes)
1025 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
1027 libdl = $(common-objpfx)dlfcn/libdl.a
1030 ifeq ($(build-shared),yes)
1031 libm = $(common-objpfx)math/libm.so$(libm.so-version)
1033 libm = $(common-objpfx)math/libm.a
1036 # These are the subdirectories containing the library source. The order
1037 # is more or less arbitrary. The sorting step will take care of the
1039 all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
1040 stdlib stdio-common libio malloc string wcsmbs time dirent \
1041 grp pwd posix io termios resource misc socket sysvipc gmon \
1042 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
1043 crypt localedata timezone rt conform debug \
1044 $(add-on-subdirs) dlfcn elf
1046 ifndef avoid-generated
1047 # sysd-sorted itself will contain rules making the sysd-sorted target
1048 # depend on Depend files. But if you just added a Depend file to an
1049 # existing directory not in all-subdirs, then sysd-sorted needs to
1050 # be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files.
1051 all-Depend-files := $(wildcard $(sort \
1052 $(foreach dir,$(all-subdirs),\
1053 $(firstword $($(dir)-srcdir) \
1054 $(..)$(dir))/Depend) \
1055 $(sorted-subdirs:=/Depend)))
1056 $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
1057 $(common-objpfx)config.make $(..)Makeconfig \
1058 $(wildcard $(sysdirs:=/Subdirs)) \
1061 -v subdirs='$(all-subdirs)' \
1063 $(filter %/Subdirs %/Depend,$^) > $@-tmp
1065 $(all-Depend-files): ;
1068 # This gives partial TARGET:SOURCE pattern pairs to have rules
1069 # emitted into sysd-rules. A sysdeps Makeconfig fragment can
1070 # add its own special object file prefix to this list with e.g. foo-%:%
1071 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
1072 sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
1074 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
1075 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
1076 ifneq (,$(sysdep-makeconfigs))
1077 include $(sysdep-makeconfigs)
1080 # Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
1081 sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
1082 $(firstword $(subst :, ,$p))))
1084 # A sysdeps Makeconfig fragment may set libc-reentrant to yes.
1085 ifeq (yes,$(libc-reentrant))
1086 defines += -D_LIBC_REENTRANT
1088 libio-mtsafe = -D_IO_MTSAFE_IO
1091 # The name to give to a test in test results summaries.
1092 test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@)))
1094 # Likewise, in XFAIL variable names.
1095 test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@)))
1097 # Command to output a test status line (such as PASS: test-name). If
1098 # test-xfail-$(test-xfail-name) has a nonempty value, the status will be
1099 # XPASS or XFAIL rather than PASS or FAIL.
1100 evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \
1101 $(if $(test-xfail-$(test-xfail-name)),true,false) \
1102 $(if $(stop-on-test-failure),true,false) \
1103 > $(common-objpfx)$(test-name).test-result
1105 endif # Makeconfig not yet included