1 # Copyright (C) 1991-2003,2004,2005,2006,2007,2008,2009,2010,2011,2012
2 # Free Software Foundation, Inc.
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 # <http://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 # If config.make exists, the source directory was configured,
37 # so don't try to be clever and find another directory to build in.
38 ifneq (,$(wildcard $(..)config.make))
41 else # Not configured.
49 # Directory for object files and libc.a. If this is not defined, the
50 # object files live in the subdirectories where their sources live, and
51 # libc.a lives in the parent directory (this probably doesn't work any
54 ifeq ($(filter /%,$(ARCH)),)
55 objdir := $(..)$(ARCH)
61 # $(common-objdir) is the place to put objects and
62 # such that are not specific to a single subdir.
64 objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
65 common-objpfx = $(objdir)/
66 common-objdir = $(objdir)
73 # This is a kludge. make wizards might grok.
74 common-objpfx = sysdeps/../
79 # Root of the sysdeps tree.
80 sysdep_dir := $(..)sysdeps
81 export sysdep_dir := $(sysdep_dir)
83 # Get the values defined by options to `configure'.
84 include $(common-objpfx)config.make
86 # What flags to give to sources which call user provided callbacks
87 uses-callbacks = $(exceptions)
89 # What flags to give to tests which test stack alignment
90 stack-align-test-flags =
92 # Complete path to sysdep dirs.
93 # `configure' writes a definition of `config-sysdirs' in `config.make'.
94 sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
96 # Add-ons that contribute sysdeps trees get added to the include list
97 # after sysdeps/generic. This makes #include <sysdeps/...> work right
98 # to find specific add-on files without assuming the add-on directory name.
99 # It also means that headers can go into an add-on's base directory
100 # instead of the add-on needing a sysdeps/generic of its own.
101 sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\
102 $(firstword $(filter /%,$(add-on)) \
104 +sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs)
106 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
109 # Run config.status to update config.make and config.h. We don't show the
110 # dependence of config.h to Make, because it is only touched when it
111 # changes and so config.status would be run every time; the dependence of
112 # config.make should suffice to force regeneration and re-exec, and the new
113 # image will notice if config.h changed.
114 $(common-objpfx)config.make: $(common-objpfx)config.status \
115 $(..)config.make.in $(..)config.h.in
116 cd $(<D); $(SHELL) $(<F)
118 # Find all the add-on and sysdeps configure fragments, to make sure we
119 # re-run configure when any of them changes.
120 $(common-objpfx)config.status: $(..)version.h $(..)configure \
121 $(foreach dir,$(sysdirs),\
122 $(wildcard $(dir)/Implies) \
124 $(firstword $(wildcard \
125 $(addprefix $(dir)/,configure configure.in))))) \
127 $(foreach add-on,$(add-ons),\
128 $(firstword $(wildcard \
129 $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
130 configure configure.in)))))
131 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
132 echo The GNU C library has not been configured. >&2; \
133 echo Run \`configure\' to configure it before building. >&2; \
134 echo Try \`configure --help\' for more details. >&2; \
137 # We don't want CPPFLAGS to be exported to the command running configure.
140 # Get the user's configuration parameters.
141 ifneq ($(wildcard $(..)configparms),)
142 include $(..)configparms
145 ifneq ($(wildcard $(common-objpfx)configparms),)
146 include $(common-objpfx)configparms
151 #### These are the configuration variables. You can define values for
152 #### the variables below in the file `configparms'.
153 #### Do NOT edit this file.
157 # Common prefix for machine-independent installation directories.
158 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
162 # Decide whether we shall build the programs or not. We always do this
163 # unless the user tells us (in configparms) or we are building for a
165 ifndef build-programs
166 ifneq ($(config-os),none)
173 # Common prefix for machine-dependent installation directories.
174 ifeq ($(origin exec_prefix),undefined)
175 exec_prefix = $(prefix)
178 # Where to install the library and object files.
180 libdir = $(exec_prefix)/lib
182 inst_libdir = $(install_root)$(libdir)
184 # Where to install the shared library and dynamic linker.
186 slibdir = $(exec_prefix)/lib
188 inst_slibdir = $(install_root)$(slibdir)
190 # Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
191 # the prefix is spliced between `lib' and the name, so the linker switch
192 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
193 # just prepended to the whole file name.
194 ifeq ($(origin libprefix),undefined)
198 # Where to install the header files.
200 includedir = $(prefix)/include
202 inst_includedir = $(install_root)$(includedir)
204 # Where to install machine-independent data files.
205 # These are the timezone database, and the locale database.
207 datadir = $(prefix)/share
209 inst_datadir = $(install_root)$(datadir)
211 # Where to install the timezone data files (which are machine-independent).
213 zonedir = $(datadir)/zoneinfo
215 inst_zonedir = $(install_root)$(zonedir)
217 # Where to install the locale files.
219 localedir = $(libdir)/locale
221 inst_localedir = $(install_root)$(localedir)
223 # Where to install the message catalog data files (which are
224 # machine-independent).
226 msgcatdir = $(datadir)/locale
228 inst_msgcatdir = $(install_root)$(msgcatdir)
230 # Where to install the locale charmap source files.
232 i18ndir = $(datadir)/i18n
234 inst_i18ndir = $(install_root)$(i18ndir)
236 # Where to install the shared object for charset transformation.
238 gconvdir = $(libdir)/gconv
240 inst_gconvdir = $(install_root)$(gconvdir)
242 # Where to install programs.
244 bindir = $(exec_prefix)/bin
246 inst_bindir = $(install_root)$(bindir)
248 # Where to install internal programs.
250 libexecdir = $(exec_prefix)/libexec
252 inst_libexecdir = $(install_root)$(libexecdir)
254 # Where to install administrative programs.
256 rootsbindir = $(exec_prefix)/sbin
258 inst_rootsbindir = $(install_root)$(rootsbindir)
261 sbindir = $(exec_prefix)/sbin
263 inst_sbindir = $(install_root)$(sbindir)
265 # Where to install the Info files.
267 infodir = $(prefix)/info
269 inst_infodir = $(install_root)$(infodir)
271 # Where to install audit libraries.
273 auditdir = $(libdir)/audit
275 inst_auditdir = $(install_root)$(auditdir)
277 # Where to install default configuration files. These include the local
278 # timezone specification and network data base files.
280 sysconfdir = $(prefix)/etc
282 inst_sysconfdir = $(install_root)$(sysconfdir)
284 # Directory for the database files and Makefile for nss_db.
286 vardbdir = $(localstatedir)/db
288 inst_vardbdir = $(install_root)$(vardbdir)
290 # Where to install the "localtime" timezone file; this is the file whose
291 # contents $(localtime) specifies. If this is a relative pathname, it is
292 # relative to $(zonedir). It is a good idea to put this somewhere
293 # other than there, so the zoneinfo directory contains only universal data,
294 # localizing the configuration data elsewhere.
295 ifndef localtime-file
296 localtime-file = $(sysconfdir)/localtime
299 # What to use for leap second specifications in compiling the default
300 # timezone files. Set this to `/dev/null' for no leap second handling as
301 # 1003.1 requires, or to `leapseconds' for proper leap second handling.
302 # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
303 # This variable determines the default: if it's `/dev/null',
304 # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
306 leapseconds = /dev/null
309 # What timezone's DST rules should be used when a POSIX-style TZ
310 # environment variable doesn't specify any rules. For 1003.1 compliance
311 # this timezone must use rules that are as U.S. federal law defines DST.
312 # Run `make -C time echo-zonenames' to see a list of available zone names.
313 # This setting can be changed with `zic -p TIMEZONE' at any time.
314 # If you want POSIX.1 compatibility, use `America/New_York'.
316 posixrules = America/New_York
319 # Where to install the "posixrules" timezone file; this is file
320 # whose contents $(posixrules) specifies. If this is a relative
321 # pathname, it is relative to $(zonedir).
322 ifndef posixrules-file
323 posixrules-file = posixrules
327 # Directory where your system's native header files live.
328 # This is used on Unix systems to generate some GNU libc header files.
330 sysincludedir = /usr/include
334 # Commands to install files.
336 INSTALL_DATA = $(INSTALL) -m 644
338 ifndef INSTALL_SCRIPT
339 INSTALL_SCRIPT = $(INSTALL)
341 ifndef INSTALL_PROGRAM
342 INSTALL_PROGRAM = $(INSTALL)
349 # The name of the C compiler.
350 # If you've got GCC, and it works, use it.
351 ifeq ($(origin CC),default)
355 # The name of the C compiler to use for compilations of programs to run on
356 # the host that is building the library. If you set CC to a
357 # cross-compiler, you must set this to the normal compiler.
362 # Default flags to pass the C compiler.
363 ifndef default_cflags
364 ifeq ($(release),stable)
365 default_cflags := -g -O2
367 default_cflags := -g -O
371 # Flags to pass the C compiler when assembling preprocessed assembly code
372 # (`.S' files). On some systems the assembler doesn't understand the `#' line
373 # directives the preprocessor produces. If you have troubling compiling
374 # assembly code, try using -P here to suppress these directives.
379 as-needed := -Wl,--as-needed
380 no-as-needed := -Wl,--no-as-needed
382 # Must be supported by the linker.
383 no-whole-archive = -Wl,--no-whole-archive
384 whole-archive = -Wl,--whole-archive
386 # Installed name of the startup code.
387 # The ELF convention is that the startfile is called crt1.o
388 start-installed-name = crt1.o
389 # On systems that do not need a special startfile for statically linked
390 # binaries, simply set it to the normal name.
391 ifndef static-start-installed-name
392 static-start-installed-name = $(start-installed-name)
395 ifeq (yesyes,$(build-shared)$(have-z-combreloc))
396 combreloc-LDFLAGS = -Wl,-z,combreloc
397 LDFLAGS.so += $(combreloc-LDFLAGS)
398 LDFLAGS-rtld += $(combreloc-LDFLAGS)
401 relro-LDFLAGS = -Wl,-z,relro
402 LDFLAGS.so += $(relro-LDFLAGS)
403 LDFLAGS-rtld += $(relro-LDFLAGS)
405 ifeq (yes,$(have-hash-style))
406 # For the time being we unconditionally use 'both'. At some time we
407 # should declare statically linked code as 'out of luck' and compile
408 # with --hash-style=gnu only.
409 hashstyle-LDFLAGS = -Wl,--hash-style=both
410 LDFLAGS.so += $(hashstyle-LDFLAGS)
411 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
414 # Commands for linking programs with the C library.
416 +link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
417 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
418 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
419 $(addprefix $(csu-objpfx),$(start-installed-name)) \
420 $(+preinit) $(+prector) \
421 $(filter-out $(addprefix $(csu-objpfx),start.o \
422 $(start-installed-name))\
423 $(+preinit) $(link-extra-libs) \
424 $(common-objpfx)libc% $(+postinit),$^) \
426 +link-after-libc = $(+postctor) $(+postinit)
427 +link = $(+link-before-libc) $(link-libc) $(+link-after-libc)
428 +link-tests = $(+link-before-libc) $(link-libc-tests) $(+link-after-libc)
430 # Command for linking PIE programs with the C library.
432 +link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
433 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
434 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
435 $(addprefix $(csu-objpfx),S$(start-installed-name)) \
436 $(+preinit) $(+prectorS) \
437 $(filter-out $(addprefix $(csu-objpfx),start.o \
438 S$(start-installed-name))\
439 $(+preinit) $(link-extra-libs) \
440 $(common-objpfx)libc% $(+postinit),$^) \
441 $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit)
443 # Command for statically linking programs with the C library.
445 +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
446 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
447 $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
448 $(+preinit) $(+prector) \
449 $(filter-out $(addprefix $(csu-objpfx),start.o \
450 $(start-installed-name))\
451 $(+preinit) $(link-extra-libs-static) \
452 $(common-objpfx)libc% $(+postinit),$^) \
453 $(link-extra-libs-static) $(link-libc-static)
454 +link-static-after-libc = $(+postctor) $(+postinit)
455 +link-static = $(+link-static-before-libc) $(link-libc-static) \
456 $(+link-static-after-libc)
457 +link-static-tests = $(+link-static-before-libc) $(link-libc-static-tests) \
458 $(+link-static-after-libc)
460 # Command for statically linking bounded-pointer programs with the C library.
462 +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
463 $(sysdep-LDFLAGS) $(LDFLAGS) \
464 $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
465 $(+preinit) $(+prector) \
466 $(filter-out $(addprefix $(csu-objpfx),start.ob \
467 $(start-installed-name))\
468 $(+preinit) $(link-extra-libs-bounded) \
469 $(common-objpfx)libc% $(+postinit),$^) \
470 $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
472 ifndef config-LDFLAGS
473 ifeq (yes,$(build-shared))
474 config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
478 ifeq (yes,$(build-shared))
479 # We need the versioned name of libc.so in the deps of $(others) et al
480 # so that the symlink to libc.so is created before anything tries to
481 # run the linked programs.
482 link-libc-before-gnulib = -Wl,-rpath-link=$(rpath-link) \
483 $(common-objpfx)libc.so$(libc.so-version) \
484 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
485 $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed)
486 link-libc = $(link-libc-before-gnulib) $(gnulib)
487 link-libc-tests = $(link-libc-before-gnulib) $(gnulib-tests)
488 # This is how to find at build-time things that will be installed there.
489 rpath-dirs = math elf dlfcn nss nis rt resolv crypt
491 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
492 elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
494 nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
495 resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
496 link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
497 link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
501 # Differences in the linkers on the various platforms.
502 LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
503 LDFLAGS-soname-fname = -Wl,-soname,$(@F)
504 LDFLAGS-rdynamic = -rdynamic
505 LDFLAGS-Bsymbolic = -Bsymbolic
507 # Choose the default search path for the dynamic linker based on
508 # where we will install libraries.
509 ifneq ($(libdir),$(slibdir))
510 default-rpath = $(slibdir):$(libdir)
512 default-rpath = $(libdir)
515 ifndef link-extra-libs
516 link-extra-libs = $(LDLIBS-$(@F))
517 link-extra-libs-static = $(link-extra-libs)
518 link-extra-libs-bounded = $(link-extra-libs)
521 # The static libraries.
522 link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
523 link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
524 link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
526 # How to link against libgcc. Some libgcc functions, such as those
527 # for "long long" arithmetic or software floating point, can always be
528 # built without use of C library headers and do not have any global
529 # state so can safely be linked statically into any executable or
530 # shared library requiring them; these functions are in libgcc.a.
531 # Other functions, relating to exception handling, may require C
532 # library headers to build and it may not be safe to have more than
533 # one copy of them in a process; these functions are only in
534 # libgcc_s.so and libgcc_eh.a.
536 # To avoid circular dependencies when bootstrapping, it is desirable
537 # to avoid use of libgcc_s and libgcc_eh in building glibc. Where any
538 # glibc functionality (in particular, thread cancellation) requires
539 # exception handling, this is implemented through dlopen of libgcc_s
540 # to avoid unnecessary dependencies on libgcc_s by programs not using
541 # that functionality; executables built with glibc do not use
542 # exception handling other than through thread cancellation.
544 # Undefined references to functions from libgcc_eh or libgcc_s may
545 # arise for code built with -fexceptions. In the case of statically
546 # linked programs installed by glibc, unwinding will never actually
547 # occur at runtime and the use of elf/static-stubs.c to resolve these
548 # references is safe. In the case of statically linked test programs
549 # and test programs built with -fexceptions, unwinding may occur in
550 # some cases and it is preferable to link with libgcc_eh or libgcc_s
551 # so that the testing is as similar as possible to how programs will
552 # be built with the installed glibc.
554 # Some architectures have architecture-specific systems for exception
555 # handling that may involve undefined references to
556 # architecture-specific functions. On those architectures,
557 # gnulib-arch and static-gnulib-arch may be defined in sysdeps
558 # makefiles to use additional libraries for linking executables and
559 # shared libraries built by glibc.
561 ifneq ($(have-cc-with-libunwind),yes)
566 libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
568 gnulib = -lgcc $(gnulib-arch)
569 gnulib-tests := -lgcc $(libgcc_eh)
571 static-gnulib = -lgcc $(static-gnulib-arch)
572 static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
573 libc.so-gnulib := -lgcc
575 +preinit = $(addprefix $(csu-objpfx),crti.o)
576 +postinit = $(addprefix $(csu-objpfx),crtn.o)
577 +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
578 +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
579 # Variants of the two previous definitions for linking PIE programs.
580 +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
581 +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
582 +interp = $(addprefix $(elf-objpfx),interp.os)
583 csu-objpfx = $(common-objpfx)csu/
584 elf-objpfx = $(common-objpfx)elf/
586 # How to run a program we just linked with our library.
587 # The program binary is assumed to be $(word 2,$^).
588 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
589 ifeq (yes,$(build-shared))
591 sysdep-library-path = \
592 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
593 $(filter -Wl$(comma)-rpath-link=%,\
594 $(sysdep-LDFLAGS)))))
595 run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
596 $(tests-static) $(xtests-static)),, \
597 $(elf-objpfx)$(rtld-installed-name) \
598 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
602 # Never use $(run-program-prefix) for the statically-linked %-bp test programs
603 built-program-cmd = $(patsubst %,$(run-program-prefix),\
604 $(filter-out %-bp,$(built-program-file))) \
605 $(built-program-file)
611 # Extra flags to pass to GCC.
612 ifeq ($(all-warnings),yes)
613 +gccwarn := -Wall -Wwrite-strings -Winline -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
615 +gccwarn := -Wall -Wwrite-strings -Winline
617 +gccwarn-c = -Wstrict-prototypes
619 # We do not depend on the address of constants in different files to be
620 # actually different, so allow the compiler to merge them all.
621 +merge-constants = -fmerge-all-constants
623 # We have to assume that glibc functions are called in any rounding
624 # mode and also change the rounding mode in a few functions. So,
625 # disable any optimization that assume default rounding mode.
626 +math-flags = -frounding-math
628 # This is the program that generates makefile dependencies from C source files.
629 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
630 # targets for headers so that removed headers don't break the build.
632 +mkdep = $(CC) -M -MP
635 # The program that makes Emacs-style TAGS files.
638 # The `xgettext' program for producing .pot files from sources.
643 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
644 # perhaps others) to preprocess assembly code in some cases.
647 # To force installation of files even if they are older than the
648 # installed files. This variable is included in the dependency list
649 # of all installation targets.
650 ifeq ($(force-install),yes)
651 +force = force-install
657 #### End of configuration variables.
660 # This tells some versions of GNU make before 3.63 not to export all variables.
663 # We want to echo the commands we're running without
664 # umpteen zillion filenames along with it (we use `...' instead)
665 # but we don't want this echoing done when the user has said
666 # he doesn't want to see commands echoed by using -s.
667 ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
668 +cmdecho := echo >/dev/null
673 # These are the flags given to the compiler to tell
674 # it what sort of optimization and/or debugging output to do.
676 # If `CFLAGS' was defined, use that.
678 +cflags := $(filter-out -I%,$(CFLAGS))
682 # If none of the above worked, default to "-g -O".
683 ifeq "$(strip $(+cflags))" ""
684 +cflags := $(default_cflags)
685 endif # $(+cflags) == ""
687 +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags)
690 # Don't duplicate options if we inherited variables from the parent.
691 +cflags := $(sort $(+cflags))
693 # These are flags given to the C compiler to tell it to look for
694 # include files (including ones given in angle brackets) in the parent
695 # library source directory, in the include directory, and in the
697 +sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
698 +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
699 $(+sysdep-includes) $(includes) \
700 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
702 # Since libio has several internal header files, we use a -I instead
703 # of many little headers in the include directory.
704 libio-include = -I$(..)libio
706 # These are the variables that the implicit compilation rules use.
707 # Note that we can't use -std=* in CPPFLAGS, because it overrides
708 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
709 # it causes cpp to stop predefining __ASSEMBLER__.
710 CPPFLAGS = $(CPPUNDEFS) $(CPPFLAGS-config) $($(subdir)-CPPFLAGS) \
711 $(+includes) $(defines) \
712 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
713 $(CPPFLAGS-$(suffix $@)) \
714 $(foreach lib,$(libof-$(basename $(@F))) \
715 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
716 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
717 override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) $(config-extra-cflags) \
718 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
719 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
721 $(foreach lib,$(libof-$(basename $(@F))) \
722 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
723 override CXXFLAGS = $(c++-sysincludes) \
724 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
725 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
727 # If everything is compiled with -fPIC (implicitly) we must tell this by
728 # defining the PIC symbol.
729 ifeq (yes,$(build-pic-default))
733 # Enable object files for different versions of the library.
734 # Various things use $(object-suffixes) to know what all to make.
735 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
736 # to pass different flags for each flavor.
737 libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
738 all-object-suffixes := .o .os .op .og .ob .oS
740 CPPFLAGS-.o = $(pic-default)
741 CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
743 object-suffixes += .o
744 ifeq (yes,$(build-shared))
745 # Under --enable-shared, we will build a shared library of PIC objects.
746 # The PIC object files are named foo.os.
747 object-suffixes += .os
748 CPPFLAGS-.os = -DPIC -DSHARED
749 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
750 libtype.os := lib%_pic.a
751 # This can be changed by a sysdep makefile
753 # This one should always stay like this unless there is a very good reason.
756 # This can be changed by a sysdep makefile
758 # This one should always stay like this unless there is a very good reason.
760 ifeq (yes,$(build-profile))
761 # Under --enable-profile, we will build a static library of profiled objects.
762 # The profiled object files are named foo.op.
763 object-suffixes += .op
764 CPPFLAGS-.op = -DPROF $(pic-default)
766 libtype.op = lib%_p.a
769 # Convenience variable for when we want to treat shared-library cases
770 # differently from the rest.
771 object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
774 ifeq (yes,$(build-bounded))
775 # Under --enable-bounded, we build the library with `-fbounded-pointers -g'
776 # to runtime bounds checking. The bounded-pointer objects are named foo.ob.
777 # We disable sibling-call optimizations so that stack traces will be complete
778 # and thus aid debugging, since after all, BPs are a debugging tool.
779 object-suffixes += .ob
780 CPPFLAGS-.ob = -fbounded-pointers $(pic-default)
781 CFLAGS-.ob = -g -O2 -fno-optimize-sibling-calls -fno-strict-aliasing
782 libtype.ob = lib%_b.a
785 object-suffixes-for-libc := $(object-suffixes)
787 ifeq (yes,$(build-shared))
788 # Build special library that contains the static-only routines for libc.
789 object-suffixes-for-libc += .oS
791 # Must build the routines as PIC, though, because they can end up in (users')
792 # shared objects. We don't want to use CFLAGS-os because users may, for
793 # example, make that processor-specific.
794 CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
795 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
796 libtype.oS = lib%_nonshared.a
799 # The assembler can generate debug information too.
801 ifeq ($(have-cpp-asm-debuginfo),yes)
802 ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
807 ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
813 move-if-change = $(SHELL) $(..)scripts/move-if-change
815 -include $(common-objpfx)sysd-sorted
816 subdirs = $(sorted-subdirs)
817 subdir-srcdirs = $(foreach dir,$(subdirs),\
818 $(firstword $($(dir)-srcdir) $(..)$(dir)))
820 ifeq (yes, $(build-shared))
822 # This is a pair of implicit rules to preprocess a file with # comments,
823 # %ifdef et al, based on config.h settings or other %include'd files.
824 # We use chained rules instead of a pipeline here so that we can properly
825 # check the exit status of cpp rather than using its bad output when there
826 # is a preprocessing error. Another rule should depend on the output file
827 # `FOO.v', and along with that `FOO.v.i' should be given dependencies
828 # listing both its input files, and any header files that it may reference
830 %.v.i: $(common-objpfx)config.h $(..)Makeconfig
831 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
832 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
833 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
837 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
840 # To generate a header to support more than one ABI for different
841 # architecture variants, the CPU/Makefile defines abi-variants to be a
842 # list of names for those variants (e.g. 32 64), and, for each variant,
843 # defines abi-$(variant)-condition to be the condition for those options
844 # to use in a C #if condition. abi-includes may be defined to a list of
845 # headers to include in the generated header, if the default does not
846 # suffice. default-abi is defined to be the ABI for the current glibc
850 abi-includes := bits/wordsize.h
853 # Process the shlib-versions file, which tells us what shared library
854 # version numbers to use when we install shared objects on this system.
855 # We need to wait until $(subdirs) is complete.
856 ifeq ($(sysd-sorted-done),t)
857 -include $(common-objpfx)soversions.mk
858 ifndef avoid-generated
859 # This lets add-ons give more-specific matches that override defaults
860 # in the top-level file.
861 $(common-objpfx)shlib-versions.v.i: \
862 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
863 $(subdir-srcdirs:=/shlib-versions)) \
866 soversions-default-setname = $(patsubst %, %,\
867 $(filter-out %_default,\
868 $(oldest-abi:%=GLIBC_%)))
869 $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
870 $(common-objpfx)shlib-versions.v
871 $(AWK) -v default_setname='$(soversions-default-setname)' \
872 -v cpu='$(config-machine)' \
873 -v vendor='$(config-vendor)' \
874 -v os='$(config-os)' \
877 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
878 (while read which lib number setname; do \
879 eval seen_$$which=1; \
880 test x"$$which" != xABI || echo abi-name = "$$lib"; \
881 test x"$$which" = xDEFAULT || continue; \
883 [0-9]*) echo "$$lib.so-version=.$$number"; \
884 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
885 *) echo "$$lib.so-version=\$$(if \$$(abi-$(default-abi)-$$lib-soname),\$$(abi-$(default-abi)-$$lib-soname),$$number)"; \
886 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
889 echo soversions.mk-done = t;) < $< > $@T; exit 0
894 postclean-generated += soversions.mk soversions.i \
895 shlib-versions.v shlib-versions.v.i
897 # Generate the header containing the names of all shared libraries.
898 # We use a stamp file to avoid unnecessary recompilations.
899 before-compile += $(common-objpfx)gnu/lib-names.h
900 ifeq ($(soversions.mk-done),t)
901 $(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
902 $(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
903 $(common-objpfx)soversions.i
904 $(make-target-directory)
906 echo '/* This file is automatically generated.';\
907 echo ' It defines macros to allow user program to find the shared'; \
908 echo ' library files which come as part of GNU libc. */'; \
909 echo '#ifndef __GNU_LIB_NAMES_H'; \
910 echo '#define __GNU_LIB_NAMES_H 1'; \
912 $(if $(abi-includes), \
913 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
915 $(if $(abi-variants), \
916 $(foreach v,$(abi-variants),\
917 $(if $(abi-$(v)-condition),\
918 echo '#if $(abi-$(v)-condition)'; \
919 ($(foreach s,$(all-sonames), \
920 $(if $(abi-$(v)-$(firstword $(subst =, ,$(s)))-soname),\
921 echo $(firstword $(subst =, ,$(s)))=$(abi-$(v)-$(firstword $(subst =, ,$(s)))-soname);, \
923 | LC_ALL=C $(AWK) -v multi=1 -f $(firstword $^) | LC_ALL=C sort;) \
924 $(if $(abi-$(v)-condition),echo '#endif';)), \
925 ($(foreach s,$(all-sonames), echo $(s);)) \
926 | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort;) \
928 echo '#endif /* gnu/lib-names.h */'; \
930 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
934 common-generated += gnu/lib-names.h gnu/lib-names.stmp
936 # The name under which the run-time dynamic linker is installed.
937 # We are currently going for the convention that `/lib/ld.so.1'
938 # names the SVR4/ELF ABI-compliant dynamic linker.
939 ifndef rtld-installed-name
941 rtld-installed-name = $(ld.so-version)
943 rtld-installed-name = ld.so.1
947 ifndef rtld-version-installed-name
948 rtld-version-installed-name = ld-$(version).so
954 ifeq ($(build-shared),yes)
955 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
957 libdl = $(common-objpfx)dlfcn/libdl.a
960 ifeq ($(build-shared),yes)
961 libm = $(common-objpfx)math/libm.so$(libm.so-version)
963 libm = $(common-objpfx)math/libm.a
966 # These are the subdirectories containing the library source. The order
967 # is more or less arbitrary. The sorting step will take care of the
969 all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
970 stdlib stdio-common libio malloc string wcsmbs time dirent \
971 grp pwd posix io termios resource misc socket sysvipc gmon \
972 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
973 crypt nss localedata timezone rt conform debug \
974 $(add-on-subdirs) dlfcn elf
976 ifndef avoid-generated
977 all-Depend-files := $(wildcard $(foreach dir,$(all-subdirs),\
978 $(firstword $($(dir)-srcdir) \
979 $(..)$(dir))/Depend))
980 $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
981 $(common-objpfx)config.make $(..)Makeconfig \
982 $(wildcard $(sysdirs:=/Subdirs)) \
985 -v subdirs='$(all-subdirs)' \
987 $(filter %/Subdirs %/Depend,$^) > $@-tmp
989 $(all-Depend-files): ;
992 # This gives partial TARGET:SOURCE pattern pairs to have rules
993 # emitted into sysd-rules. A sysdeps Makeconfig fragment can
994 # add its own special object file prefix to this list with e.g. foo-%:%
995 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
996 sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
998 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
999 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
1000 ifneq (,$(sysdep-makeconfigs))
1001 include $(sysdep-makeconfigs)
1004 # Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
1005 sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
1006 $(firstword $(subst :, ,$p))))
1008 # A sysdeps Makeconfig fragment may set libc-reentrant to yes.
1009 ifeq (yes,$(libc-reentrant))
1010 defines += -D_LIBC_REENTRANT
1012 libio-mtsafe = -D_IO_MTSAFE_IO
1015 endif # Makeconfig not yet included