1 # Copyright (C) 1991-2003,2004,2005,2006,2007,2008,2009,2010,2011
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, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 # Makefile configuration options for the GNU C library.
24 This makefile requires GNU Make.
27 all: # Make this the default goal
29 ifneq "$(origin +included-Makeconfig)" "file"
31 +included-Makeconfig := yes
37 # If config.make exists, the source directory was configured,
38 # so don't try to be clever and find another directory to build in.
39 ifneq (,$(wildcard $(..)config.make))
42 else # Not configured.
50 # Directory for object files and libc.a. If this is not defined, the
51 # object files live in the subdirectories where their sources live, and
52 # libc.a lives in the parent directory (this probably doesn't work any
55 ifeq ($(filter /%,$(ARCH)),)
56 objdir := $(..)$(ARCH)
62 # $(common-objdir) is the place to put objects and
63 # such that are not specific to a single subdir.
65 objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
66 common-objpfx = $(objdir)/
67 common-objdir = $(objdir)
74 # This is a kludge. make wizards might grok.
75 common-objpfx = sysdeps/../
80 # Root of the sysdeps tree.
81 sysdep_dir := $(..)sysdeps
82 export sysdep_dir := $(sysdep_dir)
84 # Get the values defined by options to `configure'.
85 include $(common-objpfx)config.make
87 # What flags to give to sources which call user provided callbacks
88 uses-callbacks = $(exceptions)
90 # What flags to give to tests which test stack alignment
91 stack-align-test-flags =
93 # We have a special subdir for each binary format.
94 # For now, only ELF is fully supported.
98 # This is probably better than nothing.
102 # Complete path to sysdep dirs.
103 # `configure' writes a definition of `config-sysdirs' in `config.make'.
104 sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
106 # Add-ons that contribute sysdeps trees get added to the include list
107 # after sysdeps/generic. This makes #include <sysdeps/...> work right
108 # to find specific add-on files without assuming the add-on directory name.
109 # It also means that headers can go into an add-on's base directory
110 # instead of the add-on needing a sysdeps/generic of its own.
111 sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\
112 $(firstword $(filter /%,$(add-on)) \
114 +sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs)
116 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
119 # Run config.status to update config.make and config.h. We don't show the
120 # dependence of config.h to Make, because it is only touched when it
121 # changes and so config.status would be run every time; the dependence of
122 # config.make should suffice to force regeneration and re-exec, and the new
123 # image will notice if config.h changed.
124 $(common-objpfx)config.make: $(common-objpfx)config.status \
125 $(..)config.make.in $(..)config.h.in
126 cd $(<D); $(SHELL) $(<F)
128 # Find all the add-on and sysdeps configure fragments, to make sure we
129 # re-run configure when any of them changes.
130 $(common-objpfx)config.status: $(..)version.h $(..)configure \
131 $(foreach dir,$(sysdirs),\
132 $(wildcard $(dir)/Implies) \
134 $(firstword $(wildcard \
135 $(addprefix $(dir)/,configure configure.in))))) \
137 $(foreach add-on,$(add-ons),\
138 $(firstword $(wildcard \
139 $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
140 configure configure.in)))))
141 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
142 echo The GNU C library has not been configured. >&2; \
143 echo Run \`configure\' to configure it before building. >&2; \
144 echo Try \`configure --help\' for more details. >&2; \
147 # We don't want CPPFLAGS to be exported to the command running configure.
150 # Get the user's configuration parameters.
151 ifneq ($(wildcard $(..)configparms),)
152 include $(..)configparms
155 ifneq ($(wildcard $(common-objpfx)configparms),)
156 include $(common-objpfx)configparms
161 #### These are the configuration variables. You can define values for
162 #### the variables below in the file `configparms'.
163 #### Do NOT edit this file.
167 # Common prefix for machine-independent installation directories.
168 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
172 # Decide whether we shall build the programs or not. We always do this
173 # unless the user tells us (in configparms) or we are building for a
175 ifndef build-programs
176 ifneq ($(config-os),none)
183 # Common prefix for machine-dependent installation directories.
184 ifeq ($(origin exec_prefix),undefined)
185 exec_prefix = $(prefix)
188 # Where to install the library and object files.
190 libdir = $(exec_prefix)/lib
192 inst_libdir = $(install_root)$(libdir)
194 # Where to install the shared library and dynamic linker.
196 slibdir = $(exec_prefix)/lib
198 inst_slibdir = $(install_root)$(slibdir)
200 # Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
201 # the prefix is spliced between `lib' and the name, so the linker switch
202 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
203 # just prepended to the whole file name.
204 ifeq ($(origin libprefix),undefined)
208 # Where to install the header files.
210 includedir = $(prefix)/include
212 inst_includedir = $(install_root)$(includedir)
214 # Where to install machine-independent data files.
215 # These are the timezone database, and the locale database.
217 datadir = $(prefix)/share
219 inst_datadir = $(install_root)$(datadir)
221 # Where to install the timezone data files (which are machine-independent).
223 zonedir = $(datadir)/zoneinfo
225 inst_zonedir = $(install_root)$(zonedir)
227 # Where to install the locale files.
229 localedir = $(libdir)/locale
231 inst_localedir = $(install_root)$(localedir)
233 # Where to install the message catalog data files (which are
234 # machine-independent).
236 msgcatdir = $(datadir)/locale
238 inst_msgcatdir = $(install_root)$(msgcatdir)
240 # Where to install the locale charmap source files.
242 i18ndir = $(datadir)/i18n
244 inst_i18ndir = $(install_root)$(i18ndir)
246 # Where to install the shared object for charset transformation.
248 gconvdir = $(libdir)/gconv
250 inst_gconvdir = $(install_root)$(gconvdir)
252 # Where to install programs.
254 bindir = $(exec_prefix)/bin
256 inst_bindir = $(install_root)$(bindir)
258 # Where to install internal programs.
260 libexecdir = $(exec_prefix)/libexec
262 inst_libexecdir = $(install_root)$(libexecdir)
264 # Where to install administrative programs.
266 rootsbindir = $(exec_prefix)/sbin
268 inst_rootsbindir = $(install_root)$(rootsbindir)
271 sbindir = $(exec_prefix)/sbin
273 inst_sbindir = $(install_root)$(sbindir)
275 # Where to install the Info files.
277 infodir = $(prefix)/info
279 inst_infodir = $(install_root)$(infodir)
281 # Where to install audit libraries.
283 auditdir = $(libdir)/audit
285 inst_auditdir = $(install_root)$(auditdir)
287 # Where to install default configuration files. These include the local
288 # timezone specification and network data base files.
290 sysconfdir = $(prefix)/etc
292 inst_sysconfdir = $(install_root)$(sysconfdir)
294 # What timezone should be the installed default (e.g., US/Eastern).
295 # Run `make -C time echo-zonenames' to see a list of available zone names.
296 # The local timezone can be changed with `zic -l TIMEZONE' at any time.
301 # Where to install the "localtime" timezone file; this is the file whose
302 # contents $(localtime) specifies. If this is a relative pathname, it is
303 # relative to $(zonedir). It is a good idea to put this somewhere
304 # other than there, so the zoneinfo directory contains only universal data,
305 # localizing the configuration data elsewhere.
306 ifndef localtime-file
307 localtime-file = $(sysconfdir)/localtime
308 inst_localtime-file = $(install_root)$(localtime-file)
311 # What to use for leap second specifications in compiling the default
312 # timezone files. Set this to `/dev/null' for no leap second handling as
313 # 1003.1 requires, or to `leapseconds' for proper leap second handling.
314 # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
315 # This variable determines the default: if it's `/dev/null',
316 # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
318 leapseconds = /dev/null
321 # What timezone's DST rules should be used when a POSIX-style TZ
322 # environment variable doesn't specify any rules. For 1003.1 compliance
323 # this timezone must use rules that are as U.S. federal law defines DST.
324 # Run `make -C time echo-zonenames' to see a list of available zone names.
325 # This setting can be changed with `zic -p TIMEZONE' at any time.
326 # If you want POSIX.1 compatibility, use `America/New_York'.
328 posixrules = America/New_York
331 # Where to install the "posixrules" timezone file; this is file
332 # whose contents $(posixrules) specifies. If this is a relative
333 # pathname, it is relative to $(zonedir).
334 ifndef posixrules-file
335 posixrules-file = posixrules
339 # Directory where your system's native header files live.
340 # This is used on Unix systems to generate some GNU libc header files.
342 sysincludedir = /usr/include
346 # Commands to install files.
348 INSTALL_DATA = $(INSTALL) -m 644
350 ifndef INSTALL_SCRIPT
351 INSTALL_SCRIPT = $(INSTALL)
353 ifndef INSTALL_PROGRAM
354 INSTALL_PROGRAM = $(INSTALL)
361 # The name of the C compiler.
362 # If you've got GCC, and it works, use it.
363 ifeq ($(origin CC),default)
367 # The name of the C compiler to use for compilations of programs to run on
368 # the host that is building the library. If you set CC to a
369 # cross-compiler, you must set this to the normal compiler.
374 # Default flags to pass the C compiler.
375 ifndef default_cflags
376 ifeq ($(release),stable)
377 default_cflags := -g -O2
379 default_cflags := -g -O
383 # Flags to pass the C compiler when assembling preprocessed assembly code
384 # (`.S' files). On some systems the assembler doesn't understand the `#' line
385 # directives the preprocessor produces. If you have troubling compiling
386 # assembly code, try using -P here to suppress these directives.
391 # ELF always supports init/fini sections
396 ifeq ($(have-as-needed),yes)
397 as-needed := -Wl,--as-needed
398 no-as-needed := -Wl,--no-as-needed
404 # Installed name of the startup code.
405 ifneq ($(have-initfini),yes)
406 # When not having init/fini, there is just one startfile, called crt0.o.
407 start-installed-name = crt0.o
409 # On systems having init/fini, crt0.o is called crt1.o, and there are
410 # some additional bizarre files.
411 start-installed-name = crt1.o
413 # On systems that do not need a special startfile for statically linked
414 # binaries, simply set it to the normal name.
415 ifndef static-start-installed-name
416 static-start-installed-name = $(start-installed-name)
419 ifeq (yesyesyes,$(build-shared)$(elf)$(have-z-combreloc))
420 combreloc-LDFLAGS = -Wl,-z,combreloc
421 LDFLAGS.so += $(combreloc-LDFLAGS)
422 LDFLAGS-rtld += $(combreloc-LDFLAGS)
425 relro-LDFLAGS = -Wl,-z,relro
426 LDFLAGS.so += $(relro-LDFLAGS)
427 LDFLAGS-rtld += $(relro-LDFLAGS)
429 ifeq (yes,$(have-hash-style))
430 # For the time being we unconditionally use 'both'. At some time we
431 # should declare statically linked code as 'out of luck' and compile
432 # with --hash-style=gnu only.
433 hashstyle-LDFLAGS = -Wl,--hash-style=both
434 LDFLAGS.so += $(hashstyle-LDFLAGS)
435 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
438 # Command for linking programs with the C library.
440 +link = $(CC) -nostdlib -nostartfiles -o $@ \
441 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
442 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
443 $(addprefix $(csu-objpfx),$(start-installed-name)) \
444 $(+preinit) $(+prector) \
445 $(filter-out $(addprefix $(csu-objpfx),start.o \
446 $(start-installed-name))\
447 $(+preinit) $(link-extra-libs) \
448 $(common-objpfx)libc% $(+postinit),$^) \
449 $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
451 # Command for linking PIE programs with the C library.
453 +link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
454 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
455 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
456 $(addprefix $(csu-objpfx),S$(start-installed-name)) \
457 $(+preinit) $(+prectorS) \
458 $(filter-out $(addprefix $(csu-objpfx),start.o \
459 S$(start-installed-name))\
460 $(+preinit) $(link-extra-libs) \
461 $(common-objpfx)libc% $(+postinit),$^) \
462 $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit)
464 # Command for statically linking programs with the C library.
466 +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
467 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
468 $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
469 $(+preinit) $(+prector) \
470 $(filter-out $(addprefix $(csu-objpfx),start.o \
471 $(start-installed-name))\
472 $(+preinit) $(link-extra-libs-static) \
473 $(common-objpfx)libc% $(+postinit),$^) \
474 $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
476 # Command for statically linking bounded-pointer programs with the C library.
478 +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
479 $(sysdep-LDFLAGS) $(LDFLAGS) \
480 $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
481 $(+preinit) $(+prector) \
482 $(filter-out $(addprefix $(csu-objpfx),start.ob \
483 $(start-installed-name))\
484 $(+preinit) $(link-extra-libs-bounded) \
485 $(common-objpfx)libc% $(+postinit),$^) \
486 $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
488 ifndef config-LDFLAGS
489 ifeq (yesyes,$(build-shared)$(elf))
490 config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
494 ifeq (yes,$(build-shared))
496 # We need the versioned name of libc.so in the deps of $(others) et al
497 # so that the symlink to libc.so is created before anything tries to
498 # run the linked programs.
499 link-libc = -Wl,-rpath-link=$(rpath-link) \
500 $(common-objpfx)libc.so$(libc.so-version) \
501 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
502 $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) $(gnulib)
503 # This is how to find at build-time things that will be installed there.
504 rpath-dirs = math elf dlfcn nss nis rt resolv crypt
507 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
508 elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
510 nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
511 resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
512 link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
516 # Differences in the linkers on the various platforms.
518 LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
519 LDFLAGS-soname-fname = -Wl,-soname,$(@F)
520 LDFLAGS-rdynamic = -rdynamic
521 LDFLAGS-Bsymbolic = -Bsymbolic
524 # Choose the default search path for the dynamic linker based on
525 # where we will install libraries.
526 ifneq ($(libdir),$(slibdir))
527 default-rpath = $(slibdir):$(libdir)
529 default-rpath = $(libdir)
532 ifndef link-extra-libs
533 link-extra-libs = $(LDLIBS-$(@F))
534 link-extra-libs-static = $(link-extra-libs)
535 link-extra-libs-bounded = $(link-extra-libs)
538 # The static libraries.
539 ifeq (yes,$(build-static))
540 link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
542 ifeq (yes,$(build-shared))
543 # We can try to link the programs with lib*_pic.a...
544 link-libc-static = $(static-gnulib) $(common-objpfx)libc_pic.a
547 link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
550 ifneq ($(have-cc-with-libunwind),yes)
555 ifneq ($(have-as-needed),yes)
556 libgcc_eh := -lgcc_eh $(libunwind)
558 libgcc_eh := -Wl,--as-needed -lgcc_s$(libgcc_s_suffix) $(libunwind) -Wl,--no-as-needed
560 gnulib := -lgcc $(libgcc_eh)
561 static-gnulib := -lgcc -lgcc_eh $(libunwind)
562 libc.so-gnulib := -lgcc
565 +preinit = $(addprefix $(csu-objpfx),crti.o)
566 +postinit = $(addprefix $(csu-objpfx),crtn.o)
567 +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
568 +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
569 # Variants of the two previous definitions for linking PIE programs.
570 +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
571 +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
572 +interp = $(addprefix $(elf-objpfx),interp.os)
574 csu-objpfx = $(common-objpfx)csu/
575 elf-objpfx = $(common-objpfx)elf/
577 # How to run a program we just linked with our library.
578 # The program binary is assumed to be $(word 2,$^).
579 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
580 ifeq (yesyes,$(build-shared)$(elf))
582 sysdep-library-path = \
583 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
584 $(filter -Wl$(comma)-rpath-link=%,\
585 $(sysdep-LDFLAGS)))))
586 run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
587 $(tests-static) $(xtests-static)),, \
588 $(elf-objpfx)$(rtld-installed-name) \
589 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
593 # Never use $(run-program-prefix) for the statically-linked %-bp test programs
594 built-program-cmd = $(patsubst %,$(run-program-prefix),\
595 $(filter-out %-bp,$(built-program-file))) \
596 $(built-program-file)
602 # Extra flags to pass to GCC.
603 ifeq ($(all-warnings),yes)
604 +gccwarn := -Wall -Wwrite-strings -Winline -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
606 +gccwarn := -Wall -Wwrite-strings -Winline
608 +gccwarn-c = -Wstrict-prototypes
610 # We do not depend on the address of constants in different files to be
611 # actually different, so allow the compiler to merge them all.
612 +merge-constants = -fmerge-all-constants
614 # This is the program that generates makefile dependencies from C source files.
615 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
616 # targets for headers so that removed headers don't break the build.
618 +mkdep = $(CC) -M -MP
621 # The program that makes Emacs-style TAGS files.
624 # The `xgettext' program for producing .pot files from sources.
629 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
630 # perhaps others) to preprocess assembly code in some cases.
633 # To force installation of files even if they are older than the
634 # installed files. This variable is included in the dependency list
635 # of all installation targets.
636 ifeq ($(force-install),yes)
637 +force = force-install
643 #### End of configuration variables.
646 # This tells some versions of GNU make before 3.63 not to export all variables.
649 # We want to echo the commands we're running without
650 # umpteen zillion filenames along with it (we use `...' instead)
651 # but we don't want this echoing done when the user has said
652 # he doesn't want to see commands echoed by using -s.
653 ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
654 +cmdecho := echo >/dev/null
659 # These are the flags given to the compiler to tell
660 # it what sort of optimization and/or debugging output to do.
662 # If `CFLAGS' was defined, use that.
664 +cflags := $(filter-out -I%,$(CFLAGS))
668 # If none of the above worked, default to "-g -O".
669 ifeq "$(strip $(+cflags))" ""
670 +cflags := $(default_cflags)
671 endif # $(+cflags) == ""
673 +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants)
676 # Don't duplicate options if we inherited variables from the parent.
677 +cflags := $(sort $(+cflags))
679 # These are flags given to the C compiler to tell it to look for
680 # include files (including ones given in angle brackets) in the parent
681 # library source directory, in the include directory, and in the
683 +sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
684 +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
685 $(+sysdep-includes) $(includes) \
686 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
688 # Since libio has several internal header files, we use a -I instead
689 # of many little headers in the include directory.
690 libio-include = -I$(..)libio
692 # These are the variables that the implicit compilation rules use.
693 # Note that we can't use -std=* in CPPFLAGS, because it overrides
694 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
695 # it causes cpp to stop predefining __ASSEMBLER__.
696 CPPFLAGS = $($(subdir)-CPPFLAGS) $(+includes) $(defines) \
697 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
698 $(CPPFLAGS-$(suffix $@)) \
699 $(foreach lib,$(libof-$(basename $(@F))) \
700 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
701 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
702 override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) \
703 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
704 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
706 override CXXFLAGS = $(c++-sysincludes) \
707 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
708 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
710 # If everything is compiled with -fPIC (implicitly) we must tell this by
711 # defining the PIC symbol.
712 ifeq (yes,$(build-pic-default))
716 # Enable object files for different versions of the library.
717 # Various things use $(object-suffixes) to know what all to make.
718 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
719 # to pass different flags for each flavor.
720 libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
721 all-object-suffixes := .o .os .op .og .ob .oS
723 CPPFLAGS-.o = $(pic-default)
724 CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
725 ifeq (yes,$(build-static))
727 object-suffixes += .o
729 ifeq (yes,$(build-shared))
730 # Under --enable-shared, we will build a shared library of PIC objects.
731 # The PIC object files are named foo.os.
732 object-suffixes += .os
733 CPPFLAGS-.os = -DPIC -DSHARED
734 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
735 libtype.os := lib%_pic.a
736 # This can be changed by a sysdep makefile
738 # This one should always stay like this unless there is a very good reason.
741 # This can be changed by a sysdep makefile
743 # This one should always stay like this unless there is a very good reason.
745 ifeq (yes,$(build-profile))
746 # Under --enable-profile, we will build a static library of profiled objects.
747 # The profiled object files are named foo.op.
748 object-suffixes += .op
749 CPPFLAGS-.op = -DPROF $(pic-default)
751 libtype.op = lib%_p.a
753 ifeq (yes,$(build-omitfp))
754 # Under --enable-omitfp, we build the library optimized without
755 # debugging information using -fomit-frame-pointer, and build an extra
756 # library with debugging information. The debuggable objects are named foo.og.
757 object-suffixes += .og
758 CPPFLAGS-.og = $(pic-default)
760 CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES
761 CFLAGS-.os += -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES
762 libtype.og = lib%_g.a
766 ifeq (yes,$(build-bounded))
767 # Under --enable-bounded, we build the library with `-fbounded-pointers -g'
768 # to runtime bounds checking. The bounded-pointer objects are named foo.ob.
769 # We disable sibling-call optimizations so that stack traces will be complete
770 # and thus aid debugging, since after all, BPs are a debugging tool.
771 object-suffixes += .ob
772 CPPFLAGS-.ob = -fbounded-pointers $(pic-default)
773 CFLAGS-.ob = -g -O2 -fno-optimize-sibling-calls -fno-strict-aliasing
774 libtype.ob = lib%_b.a
777 object-suffixes-for-libc := $(object-suffixes)
779 ifeq (yes,$(build-shared))
780 # Build special library that contains the static-only routines for libc.
781 object-suffixes-for-libc += .oS
783 # Must build the routines as PIC, though, because they can end up in (users')
784 # shared objects. We don't want to use CFLAGS-os because users may, for
785 # example, make that processor-specific.
786 CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
787 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
788 libtype.oS = lib%_nonshared.a
791 # The assembler can generate debug information too.
793 ifeq ($(have-cpp-asm-debuginfo),yes)
794 ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
799 ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
805 move-if-change = $(SHELL) $(..)scripts/move-if-change
807 -include $(common-objpfx)sysd-sorted
808 subdirs = $(sorted-subdirs)
809 subdir-srcdirs = $(foreach dir,$(subdirs),\
810 $(firstword $($(dir)-srcdir) $(..)$(dir)))
812 ifeq (yes, $(build-shared))
814 # This is a pair of implicit rules to preprocess a file with # comments,
815 # %ifdef et al, based on config.h settings or other %include'd files.
816 # We use chained rules instead of a pipeline here so that we can properly
817 # check the exit status of cpp rather than using its bad output when there
818 # is a preprocessing error. Another rule should depend on the output file
819 # `FOO.v', and along with that `FOO.v.i' should be given dependencies
820 # listing both its input files, and any header files that it may reference
822 %.v.i: $(common-objpfx)config.h $(..)Makeconfig
823 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
824 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
825 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
829 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
832 # Process the shlib-versions file, which tells us what shared library
833 # version numbers to use when we install shared objects on this system.
834 # We need to wait until $(subdirs) is complete.
835 ifeq ($(sysd-sorted-done),t)
836 -include $(common-objpfx)soversions.mk
837 ifndef avoid-generated
838 # This lets add-ons give more-specific matches that override defaults
839 # in the top-level file.
840 $(common-objpfx)shlib-versions.v.i: \
841 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
842 $(subdir-srcdirs:=/shlib-versions)) \
845 soversions-default-setname = $(patsubst %, %,\
846 $(filter-out %_default,\
847 $(oldest-abi:%=GLIBC_%)))
848 $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
849 $(common-objpfx)shlib-versions.v
850 $(AWK) -v default_setname='$(soversions-default-setname)' \
851 -v cpu='$(config-machine)' \
852 -v vendor='$(config-vendor)' \
853 -v os='$(config-os)' \
856 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
857 (seen_DEFAULT=0; seen_WORDSIZE32=0; seen_WORDSIZE64=0; \
858 while read which lib number setname; do \
859 eval seen_$$which=1; \
860 test x"$$which" != xABI || echo abi-name = "$$lib"; \
861 test x"$$which" = xDEFAULT || continue; \
863 [0-9]*) echo "$$lib.so-version=.$$number"; \
864 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
865 *) echo "$$lib.so-version=$$number"; \
866 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
869 case "$$seen_DEFAULT$$seen_WORDSIZE32$$seen_WORDSIZE64" in \
870 100) echo biarch = no;; \
871 101) echo biarch = 32;; \
872 ?1?) echo biarch = 64;; \
873 *) echo >&2 BUG; exit 2;; \
875 echo soversions.mk-done = t;) < $< > $@T; exit 0
880 postclean-generated += soversions.mk soversions.i \
881 shlib-versions.v shlib-versions.v.i
883 # Generate the header containing the names of all shared libraries.
884 # We use a stamp file to avoid unnecessary recompilations.
885 before-compile += $(common-objpfx)gnu/lib-names.h
886 ifeq ($(soversions.mk-done),t)
887 $(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
888 $(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
889 $(common-objpfx)soversions.i
890 $(make-target-directory)
891 @rm -f ${@:stmp=T} $@
892 LC_ALL=C $(AWK) -f $^ > ${@:stmp=T}
893 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
897 common-generated += gnu/lib-names.h gnu/lib-names.stmp
899 # The name under which the run-time dynamic linker is installed.
900 # We are currently going for the convention that `/lib/ld.so.1'
901 # names the SVR4/ELF ABI-compliant dynamic linker.
902 ifndef rtld-installed-name
904 rtld-installed-name = $(ld.so-version)
906 rtld-installed-name = ld.so.1
910 ifndef rtld-version-installed-name
911 rtld-version-installed-name = ld-$(version).so
919 ifeq ($(build-shared),yes)
920 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
922 libdl = $(common-objpfx)dlfcn/libdl.a
925 ifneq (,$(findstring aix,$(config-os)))
926 ifeq ($(build-shared),yes)
928 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
930 # No libdl without shared libs on AIX
935 # No ELF, no AIX - no libdl, at least for now.
941 # These are the subdirectories containing the library source. The order
942 # is more or less arbitrary. The sorting step will take care of the
944 all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
945 stdlib stdio-common libio malloc string wcsmbs time dirent \
946 grp pwd posix io termios resource misc socket sysvipc gmon \
947 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
948 crypt nss localedata timezone rt conform debug \
949 $(add-on-subdirs) $(dlfcn) $(binfmt-subdir)
951 ifndef avoid-generated
952 all-Depend-files := $(wildcard $(foreach dir,$(all-subdirs),\
953 $(firstword $($(dir)-srcdir) \
954 $(..)$(dir))/Depend))
955 $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
956 $(common-objpfx)config.make $(..)Makeconfig \
957 $(wildcard $(sysdirs:=/Subdirs)) \
960 -v subdirs='$(all-subdirs)' \
962 $(filter %/Subdirs %/Depend,$^) > $@-tmp
964 $(all-Depend-files): ;
967 # This gives partial TARGET:SOURCE pattern pairs to have rules
968 # emitted into sysd-rules. A sysdeps Makeconfig fragment can
969 # add its own special object file prefix to this list with e.g. foo-%:%
970 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
971 sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
973 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
974 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
975 ifneq (,$(sysdep-makeconfigs))
976 include $(sysdep-makeconfigs)
979 # Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
980 sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
981 $(firstword $(subst :, ,$p))))
983 endif # Makeconfig not yet included