11 kx # Copyright (C) 1991-2023 Free Software Foundation, Inc.
11 kx # Copyright The GNU Toolchain Authors.
11 kx # This file is part of the GNU C Library.
11 kx
11 kx # The GNU C Library is free software; you can redistribute it and/or
11 kx # modify it under the terms of the GNU Lesser General Public
11 kx # License as published by the Free Software Foundation; either
11 kx # version 2.1 of the License, or (at your option) any later version.
11 kx
11 kx # The GNU C Library is distributed in the hope that it will be useful,
11 kx # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 kx # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 kx # Lesser General Public License for more details.
11 kx
11 kx # You should have received a copy of the GNU Lesser General Public
11 kx # License along with the GNU C Library; if not, see
11 kx # <https://www.gnu.org/licenses/>.
11 kx
11 kx #
11 kx # Makefile configuration options for the GNU C library.
11 kx #
11 kx ifneq (,)
11 kx This makefile requires GNU Make.
11 kx endif
11 kx
11 kx all: # Make this the default goal
11 kx
11 kx ifneq "$(origin +included-Makeconfig)" "file"
11 kx
11 kx +included-Makeconfig := yes
11 kx
11 kx ifdef subdir
11 kx .. := ../
11 kx endif
11 kx
11 kx # $(common-objdir) is the place to put objects and
11 kx # such that are not specific to a single subdir.
11 kx ifdef objdir
11 kx objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
11 kx common-objpfx = $(objdir)/
11 kx common-objdir = $(objdir)
11 kx else
11 kx $(error objdir must be defined by the build-directory Makefile)
11 kx endif
11 kx
11 kx # Did we request 'make -s' run? "yes" or "no".
11 kx # Starting from make-4.4 MAKEFLAGS now contains long
11 kx # options like '--shuffle'. To detect presence of 's'
11 kx # we pick first word with short options. Long options
11 kx # are guaranteed to come after whitespace. We use '-'
11 kx # prefix to always have a word before long options
11 kx # even if no short options were passed.
11 kx # Typical MAKEFLAGS values to watch for:
11 kx # "rs --shuffle=42" (silent)
11 kx # " --shuffle" (not silent)
11 kx ifeq ($(findstring s, $(firstword -$(MAKEFLAGS))),)
11 kx silent-make := no
11 kx else
11 kx silent-make := yes
11 kx endif
11 kx
11 kx # Root of the sysdeps tree.
11 kx sysdep_dir := $(..)sysdeps
11 kx export sysdep_dir := $(sysdep_dir)
11 kx
11 kx # Get the values defined by options to `configure'.
11 kx include $(common-objpfx)config.make
11 kx
11 kx # What flags to give to sources which call user provided callbacks
11 kx uses-callbacks = -fexceptions
11 kx
11 kx # What flags to give to tests which test stack alignment
11 kx stack-align-test-flags =
11 kx
11 kx # Complete path to sysdep dirs.
11 kx # `configure' writes a definition of `config-sysdirs' in `config.make'.
11 kx sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
11 kx
11 kx +sysdep_dirs = $(sysdirs)
11 kx ifdef objdir
11 kx +sysdep_dirs := $(objdir) $(+sysdep_dirs)
11 kx endif
11 kx
11 kx # Run config.status to update config.make and config.h. We don't show the
11 kx # dependence of config.h to Make, because it is only touched when it
11 kx # changes and so config.status would be run every time; the dependence of
11 kx # config.make should suffice to force regeneration and re-exec, and the new
11 kx # image will notice if config.h changed.
11 kx $(common-objpfx)config.make: $(common-objpfx)config.status \
11 kx $(..)config.make.in $(..)config.h.in
11 kx cd $(<D); $(SHELL) $(<F)
11 kx
11 kx # Find all the sysdeps configure fragments, to make sure we re-run
11 kx # configure when any of them changes.
11 kx $(common-objpfx)config.status: $(..)version.h $(..)configure \
11 kx $(foreach dir,$(sysdirs),\
11 kx $(wildcard $(dir)/Implies) \
11 kx $(patsubst %.ac,%,\
11 kx $(firstword $(wildcard \
11 kx $(addprefix $(dir)/,configure configure.ac))))) \
11 kx $(patsubst %.ac,%,\
11 kx $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac))
11 kx @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
11 kx echo The GNU C library has not been configured. >&2; \
11 kx echo Run \`configure\' to configure it before building. >&2; \
11 kx echo Try \`configure --help\' for more details. >&2; \
11 kx exit 1; fi
11 kx
11 kx # We don't want CPPFLAGS to be exported to the command running configure.
11 kx unexport CPPFLAGS
11 kx
11 kx # Get the user's configuration parameters.
11 kx ifneq ($(wildcard $(..)configparms),)
11 kx include $(..)configparms
11 kx endif
11 kx ifneq ($(objpfx),)
11 kx ifneq ($(wildcard $(common-objpfx)configparms),)
11 kx include $(common-objpfx)configparms
11 kx endif
11 kx endif
11 kx
11 kx ####
11 kx #### These are the configuration variables. You can define values for
11 kx #### the variables below in the file `configparms'.
11 kx #### Do NOT edit this file.
11 kx ####
11 kx
11 kx
11 kx # Common prefix for machine-independent installation directories.
11 kx ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
11 kx prefix = /usr/local
11 kx endif
11 kx
11 kx # Decide whether we shall build the programs or not. We always do this
11 kx # unless the user tells us (in configparms) or we are building for a
11 kx # standalone target.
11 kx ifndef build-programs
11 kx ifneq ($(config-os),none)
11 kx build-programs=yes
11 kx else
11 kx build-programs=no
11 kx endif
11 kx endif
11 kx
11 kx # Common prefix for machine-dependent installation directories.
11 kx ifeq ($(origin exec_prefix),undefined)
11 kx exec_prefix = $(prefix)
11 kx endif
11 kx
11 kx # Where to install the library and object files.
11 kx ifndef libdir
11 kx libdir = $(exec_prefix)/lib
11 kx endif
11 kx inst_libdir = $(install_root)$(libdir)
11 kx
11 kx # Where to install the shared library.
11 kx ifndef slibdir
11 kx slibdir = $(exec_prefix)/lib
11 kx endif
11 kx inst_slibdir = $(install_root)$(slibdir)
11 kx
11 kx # Where to install the dynamic linker.
11 kx ifndef rtlddir
11 kx rtlddir = $(slibdir)
11 kx endif
11 kx inst_rtlddir = $(install_root)$(rtlddir)
11 kx
11 kx # Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
11 kx # the prefix is spliced between `lib' and the name, so the linker switch
11 kx # `-l$(libprefix)NAME' finds the library; for other files the prefix is
11 kx # just prepended to the whole file name.
11 kx ifeq ($(origin libprefix),undefined)
11 kx libprefix =
11 kx endif
11 kx
11 kx # Where to install the header files.
11 kx ifndef includedir
11 kx includedir = $(prefix)/include
11 kx endif
11 kx inst_includedir = $(install_root)$(includedir)
11 kx
11 kx # Where to install machine-independent data files.
11 kx # These are the timezone database, and the locale database.
11 kx ifndef datadir
11 kx datadir = $(prefix)/share
11 kx endif
11 kx inst_datadir = $(install_root)$(datadir)
11 kx
11 kx # Where to install the timezone data files (which are machine-independent).
11 kx ifndef zonedir
11 kx zonedir = $(datadir)/zoneinfo
11 kx endif
11 kx inst_zonedir = $(install_root)$(zonedir)
11 kx
11 kx # Where to install the compiled binary locale archive and compiled
11 kx # binary locale files.
11 kx ifndef complocaledir
11 kx complocaledir = $(libdir)/locale
11 kx endif
11 kx inst_complocaledir = $(install_root)$(complocaledir)
11 kx
11 kx # Where to install the message catalog data files (which are
11 kx # machine-independent).
11 kx ifndef localedir
11 kx localedir = $(datadir)/locale
11 kx endif
11 kx inst_localedir = $(install_root)$(localedir)
11 kx
11 kx # Where to install the locale charmap source files.
11 kx ifndef i18ndir
11 kx i18ndir = $(datadir)/i18n
11 kx endif
11 kx inst_i18ndir = $(install_root)$(i18ndir)
11 kx
11 kx # Where to install the shared object for charset transformation.
11 kx ifndef gconvdir
11 kx gconvdir = $(libdir)/gconv
11 kx endif
11 kx inst_gconvdir = $(install_root)$(gconvdir)
11 kx
11 kx # Where to install programs.
11 kx ifndef bindir
11 kx bindir = $(exec_prefix)/bin
11 kx endif
11 kx inst_bindir = $(install_root)$(bindir)
11 kx
11 kx # Where to install internal programs.
11 kx ifndef libexecdir
11 kx libexecdir = $(exec_prefix)/libexec
11 kx endif
11 kx inst_libexecdir = $(install_root)$(libexecdir)
11 kx
11 kx # Where to install administrative programs.
11 kx ifndef rootsbindir
11 kx rootsbindir = $(exec_prefix)/sbin
11 kx endif
11 kx inst_rootsbindir = $(install_root)$(rootsbindir)
11 kx
11 kx ifndef sbindir
11 kx sbindir = $(exec_prefix)/sbin
11 kx endif
11 kx inst_sbindir = $(install_root)$(sbindir)
11 kx
11 kx # Where to install the Info files.
11 kx ifndef infodir
11 kx infodir = $(prefix)/info
11 kx endif
11 kx inst_infodir = $(install_root)$(infodir)
11 kx
11 kx # Where to install audit libraries.
11 kx ifndef auditdir
11 kx auditdir = $(libdir)/audit
11 kx endif
11 kx inst_auditdir = $(install_root)$(auditdir)
11 kx
11 kx # Where to install default configuration files. These include the local
11 kx # timezone specification and network data base files.
11 kx ifndef sysconfdir
11 kx sysconfdir = $(prefix)/etc
11 kx endif
11 kx inst_sysconfdir = $(install_root)$(sysconfdir)
11 kx
11 kx # Directory for the database files and Makefile for nss_db.
11 kx ifndef vardbdir
11 kx vardbdir = $(localstatedir)/db
11 kx endif
11 kx inst_vardbdir = $(install_root)$(vardbdir)
11 kx
11 kx # Where to install the "localtime" timezone file; this is the file whose
11 kx # contents $(localtime) specifies. If this is a relative pathname, it is
11 kx # relative to $(zonedir). It is a good idea to put this somewhere
11 kx # other than there, so the zoneinfo directory contains only universal data,
11 kx # localizing the configuration data elsewhere.
11 kx ifndef localtime-file
11 kx localtime-file = $(sysconfdir)/localtime
11 kx endif
11 kx
11 kx # What to use for leap second specifications in compiling the default
11 kx # timezone files. Set this to `/dev/null' for no leap second handling as
11 kx # 1003.1 requires, or to `leapseconds' for proper leap second handling.
11 kx # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
11 kx # This variable determines the default: if it's `/dev/null',
11 kx # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
11 kx ifndef leapseconds
11 kx leapseconds = /dev/null
11 kx endif
11 kx
11 kx # What timezone's DST rules should be used when a POSIX-style TZ
11 kx # environment variable doesn't specify any rules. For 1003.1 compliance
11 kx # this timezone must use rules that are as U.S. federal law defines DST.
11 kx # Run `make -C time echo-zonenames' to see a list of available zone names.
11 kx # This setting can be changed with `zic -p TIMEZONE' at any time.
11 kx # If you want POSIX.1 compatibility, use `America/New_York'.
11 kx ifndef posixrules
11 kx posixrules = America/New_York
11 kx endif
11 kx
11 kx # Where to install the "posixrules" timezone file; this is file
11 kx # whose contents $(posixrules) specifies. If this is a relative
11 kx # pathname, it is relative to $(zonedir).
11 kx ifndef posixrules-file
11 kx posixrules-file = posixrules
11 kx endif
11 kx
11 kx
11 kx # Directory where your system's native header files live.
11 kx # This is used on Unix systems to generate some GNU libc header files.
11 kx ifndef sysincludedir
11 kx sysincludedir = /usr/include
11 kx endif
11 kx
11 kx
11 kx # Commands to install files.
11 kx ifndef INSTALL_DATA
11 kx INSTALL_DATA = $(INSTALL) -m 644
11 kx endif
11 kx ifndef INSTALL_SCRIPT
11 kx INSTALL_SCRIPT = $(INSTALL)
11 kx endif
11 kx ifndef INSTALL_PROGRAM
11 kx INSTALL_PROGRAM = $(INSTALL)
11 kx endif
11 kx ifndef INSTALL
11 kx INSTALL = install
11 kx endif
11 kx
11 kx
11 kx # The name of the C compiler.
11 kx # If you've got GCC, and it works, use it.
11 kx ifeq ($(origin CC),default)
11 kx CC := gcc
11 kx endif
11 kx
11 kx # The name of the C compiler to use for compilations of programs to run on
11 kx # the host that is building the library. If you set CC to a
11 kx # cross-compiler, you must set this to the normal compiler.
11 kx ifndef BUILD_CC
11 kx BUILD_CC = $(CC)
11 kx endif
11 kx
11 kx # Default flags to pass the C compiler.
11 kx ifndef default_cflags
11 kx ifeq ($(release),stable)
11 kx default_cflags := -g -O2
11 kx else
11 kx default_cflags := -g -O
11 kx endif
11 kx endif
11 kx
11 kx # Flags to pass the C compiler when assembling preprocessed assembly code
11 kx # (`.S' files).
11 kx ifndef asm-CPPFLAGS
11 kx asm-CPPFLAGS =
11 kx endif
11 kx
11 kx # Must be supported by the linker.
11 kx no-whole-archive = -Wl,--no-whole-archive
11 kx whole-archive = -Wl,--whole-archive
11 kx
11 kx # Installed name of the startup code.
11 kx # The ELF convention is that the startfile is called crt1.o
11 kx start-installed-name = crt1.o
11 kx # On systems that do not need a special startfile for statically linked
11 kx # binaries, simply set it to the normal name.
11 kx ifndef static-start-installed-name
11 kx static-start-installed-name = $(start-installed-name)
11 kx endif
11 kx
11 kx ifeq (yes,$(enable-static-pie))
11 kx # Link with rcrt1.o, instead of crt1.o, to call _dl_relocate_static_pie
11 kx # to relocate static PIE.
11 kx real-static-start-installed-name = r$(static-start-installed-name)
11 kx else
11 kx real-static-start-installed-name = $(static-start-installed-name)
11 kx endif
11 kx
11 kx relro-LDFLAGS = -Wl,-z,relro
11 kx LDFLAGS.so += $(relro-LDFLAGS)
11 kx LDFLAGS-rtld += $(relro-LDFLAGS)
11 kx
11 kx # Linker options to enable and disable DT_RELR.
11 kx ifeq ($(have-dt-relr),yes)
11 kx dt-relr-ldflag = -Wl,-z,pack-relative-relocs
11 kx no-dt-relr-ldflag = -Wl,-z,nopack-relative-relocs
11 kx else
11 kx dt-relr-ldflag =
11 kx no-dt-relr-ldflag =
11 kx endif
11 kx
11 kx ifeq (yes,$(have-hash-style))
11 kx # For the time being we unconditionally use 'both'. At some time we
11 kx # should declare statically linked code as 'out of luck' and compile
11 kx # with --hash-style=gnu only.
11 kx hashstyle-LDFLAGS = -Wl,--hash-style=both
11 kx LDFLAGS.so += $(hashstyle-LDFLAGS)
11 kx LDFLAGS-rtld += $(hashstyle-LDFLAGS)
11 kx endif
11 kx
11 kx ifeq (no,$(build-pie-default))
11 kx pie-default = $(no-pie-ccflag)
11 kx else # build-pie-default
11 kx pic-default = -DPIC
11 kx # Compile libc.a and libc_p.a with -fPIE/-fpie for static PIE.
11 kx pie-default = $(pie-ccflag)
11 kx
11 kx ifeq (yes,$(enable-static-pie))
11 kx static-pie-dt-relr-ldflag = $(dt-relr-ldflag)
11 kx ifeq (yes,$(have-static-pie))
11 kx static-pie-ldflag = -static-pie
11 kx else
11 kx # Static PIE can't have dynamic relocations in read-only segments since
11 kx # static PIE is mapped into memory by kernel. --eh-frame-hdr is needed
11 kx # for PIE to support exception.
11 kx static-pie-ldflag = -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text
11 kx endif # have-static-pie
11 kx endif # enable-static-pie
11 kx endif # build-pie-default
11 kx
11 kx # If lazy relocations are disabled, add the -z now flag. Use
11 kx # LDFLAGS-lib.so instead of LDFLAGS.so, to avoid adding the flag to
11 kx # test modules.
11 kx ifeq ($(bind-now),yes)
11 kx LDFLAGS-lib.so += -Wl,-z,now
11 kx # Extra flags for dynamically linked non-test main programs.
11 kx link-extra-flags += -Wl,-z,now
11 kx endif
11 kx
11 kx # Command to run after every final link (executable or shared object).
11 kx # This is invoked with $(call after-link,...), so it should operate on
11 kx # the file $1. This can be set to do some sort of post-processing on
11 kx # binaries, or to perform some sort of static sanity check.
11 kx ifndef after-link
11 kx after-link =
11 kx endif
11 kx
11 kx # Additional libraries to link into every test.
11 kx link-extra-libs-tests = $(libsupport)
11 kx
11 kx # Command for linking PIE programs with the C library.
11 kx ifndef +link-pie
11 kx +link-pie-before-inputs = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
11 kx $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(dt-relr-ldflag)) \
11 kx -Wl,-O1 -nostdlib -nostartfiles \
11 kx $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
11 kx $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
11 kx $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \
11 kx $(+preinit) $(+prectorS)
11 kx +link-pie-before-libc = -o $@ $(+link-pie-before-inputs) \
11 kx $(filter-out $(addprefix $(csu-objpfx),start.o \
11 kx S$(start-installed-name))\
11 kx $(+preinit) $(link-extra-libs) \
11 kx $(common-objpfx)libc% $(+postinit),$^) \
11 kx $(link-extra-libs)
11 kx +link-pie-after-libc = $(+postctorS) $(+postinit)
11 kx define +link-pie
11 kx $(CC) $(link-libc-rpath-link) $(+link-pie-before-libc) $(rtld-LDFLAGS) \
11 kx $(link-extra-flags) $(link-libc) $(+link-pie-after-libc)
11 kx $(call after-link,$@)
11 kx endef
11 kx define +link-pie-tests
11 kx $(CC) $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
11 kx $(+link-pie-after-libc)
11 kx $(call after-link,$@)
11 kx endef
11 kx define +link-pie-printers-tests
11 kx $(CC) $(+link-pie-before-libc) $(built-rtld-LDFLAGS) \
11 kx $(link-libc-printers-tests) $(+link-pie-after-libc)
11 kx $(call after-link,$@)
11 kx endef
11 kx endif
11 kx # Command for statically linking programs with the C library.
11 kx ifndef +link-static
11 kx +link-static-before-inputs = -nostdlib -nostartfiles -static \
11 kx $(if $($(@F)-no-pie),$(no-pie-ldflag),$(static-pie-ldflag)) \
11 kx $(if $($(@F)-no-dt-relr),$(no-dt-relr-ldflag),$(static-pie-dt-relr-ldflag)) \
11 kx $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
11 kx $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
11 kx $(+preinit) $(+prectorT)
11 kx +link-static-before-libc = -o $@ $(+link-static-before-inputs) \
11 kx $(filter-out $(addprefix $(csu-objpfx),start.o \
11 kx $(start-installed-name))\
11 kx $(+preinit) $(link-extra-libs-static) \
11 kx $(common-objpfx)libc% $(+postinit),$^) \
11 kx $(link-extra-libs-static)
11 kx +link-static-after-libc = $(+postctorT) $(+postinit)
11 kx define +link-static
11 kx $(CC) $(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) \
11 kx $(+link-static-after-libc)
11 kx $(call after-link,$@)
11 kx endef
11 kx define +link-static-tests
11 kx $(CC) $(+link-static-before-libc) $(link-libc-static-tests) \
11 kx $(+link-static-after-libc)
11 kx $(call after-link,$@)
11 kx endef
11 kx endif
11 kx # Commands for linking programs with the C library.
11 kx ifndef +link
11 kx ifeq (yes,$(build-shared))
11 kx ifeq (yes,$(cc-pie-default))
11 kx no-pie-ldflag = -no-pie
11 kx endif
11 kx ifeq (yes,$(build-pie-default))
11 kx +link = $(+link-pie)
11 kx +link-tests = $(+link-pie-tests)
11 kx +link-tests-before-inputs = $(+link-pie-before-inputs) $(rtld-tests-LDFLAGS)
11 kx +link-tests-after-inputs = $(link-libc-tests) $(+link-pie-after-libc)
11 kx +link-printers-tests = $(+link-pie-printers-tests)
11 kx else # not build-pie-default
11 kx +link-before-inputs = -nostdlib -nostartfiles $(no-pie-ldflag) \
11 kx $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
11 kx $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
11 kx $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
11 kx $(+preinit) $(+prector)
11 kx +link-before-libc = -o $@ $(+link-before-inputs) \
11 kx $(filter-out $(addprefix $(csu-objpfx),start.o \
11 kx $(start-installed-name))\
11 kx $(+preinit) $(link-extra-libs) \
11 kx $(common-objpfx)libc% $(+postinit),$^) \
11 kx $(link-extra-libs)
11 kx +link-after-libc = $(+postctor) $(+postinit)
11 kx define +link
11 kx $(CC) $(link-libc-rpath-link) $(+link-before-libc) $(rtld-LDFLAGS) \
11 kx $(link-extra-flags) $(link-libc) $(+link-after-libc)
11 kx $(call after-link,$@)
11 kx endef
11 kx +link-tests-before-inputs = $(+link-before-inputs) $(rtld-tests-LDFLAGS)
11 kx +link-tests-after-inputs = $(link-libc-tests) $(+link-after-libc)
11 kx define +link-tests
11 kx $(CC) $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
11 kx $(+link-after-libc)
11 kx $(call after-link,$@)
11 kx endef
11 kx define +link-printers-tests
11 kx $(CC) $(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
11 kx $(+link-after-libc)
11 kx $(call after-link,$@)
11 kx endef
11 kx endif # build-pie-default
11 kx else # build-static
11 kx +link = $(+link-static)
11 kx +link-tests = $(+link-static-tests)
11 kx +link-tests-before-inputs = $(+link-static-before-inputs)
11 kx +link-tests-after-inputs = $(link-libc-static-tests) $(+link-static-after-libc)
11 kx +link-printers-tests = $(+link-static-tests)
11 kx endif # build-shared
11 kx endif # +link
11 kx
11 kx # The pretty printer test programs need to be compiled without optimizations
11 kx # so they won't confuse gdb. We could use either the 'GCC optimize' pragma
11 kx # or the 'optimize' function attribute to achieve this; however, at least on
11 kx # ARM, gcc always produces different debugging symbols when invoked with
11 kx # a -O greater than 0 than when invoked with -O0, regardless of anything else
11 kx # we're using to suppress optimizations. Therefore, we need to explicitly pass
11 kx # -O0 to it through CFLAGS.
11 kx # Additionally, the build system will try to -include $(common-objpfx)/config.h
11 kx # when compiling the tests, which will throw an error if some special macros
11 kx # (such as __OPTIMIZE__ and IS_IN_build) aren't defined. To avoid this, we
11 kx # tell gcc to define IS_IN_build.
11 kx CFLAGS-printers-tests := -O0 -ggdb3 -DIS_IN_build
11 kx
11 kx ifeq (yes,$(build-shared))
11 kx # These indicate whether to link using the built ld.so or the installed one.
11 kx installed-rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
11 kx built-rtld-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so
11 kx
11 kx ifndef rtld-LDFLAGS
11 kx rtld-LDFLAGS = $(installed-rtld-LDFLAGS)
11 kx endif
11 kx
11 kx ifndef rtld-tests-LDFLAGS
11 kx ifeq (yes,$(build-hardcoded-path-in-tests))
11 kx rtld-tests-LDFLAGS = $(built-rtld-LDFLAGS)
11 kx else
11 kx rtld-tests-LDFLAGS = $(installed-rtld-LDFLAGS)
11 kx endif # build-hardcoded-path-in-tests
11 kx endif # rtld-tests-LDFLAGS
11 kx
11 kx endif # build-shared
11 kx
11 kx ifndef link-libc
11 kx ifeq (yes,$(build-shared))
11 kx # We need the versioned name of libc.so in the deps of $(others) et al
11 kx # so that the symlink to libc.so is created before anything tries to
11 kx # run the linked programs.
11 kx link-libc-rpath = -Wl,-rpath=$(rpath-link)
11 kx link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link)
11 kx
11 kx # For programs which are not tests, $(link-libc-rpath-link) is added
11 kx # directly in $(+link), $(+link-pie) above, so that -Wl,-rpath-link
11 kx # comes before the expansion of LDLIBS-* and affects libraries added
11 kx # there. For shared objects, -Wl,-rpath-link is added via
11 kx # $(build-shlib-helper) and $(build-module-helper) in Makerules (also
11 kx # before the expansion of LDLIBS-* variables).
11 kx
11 kx # Tests use -Wl,-rpath instead of -Wl,-rpath-link for
11 kx # build-hardcoded-path-in-tests.
11 kx ifeq (yes,$(build-hardcoded-path-in-tests))
11 kx link-libc-tests-rpath-link = $(link-libc-rpath)
11 kx link-test-modules-rpath-link = $(link-libc-rpath)
11 kx else
11 kx link-libc-tests-rpath-link = $(link-libc-rpath-link)
11 kx link-test-modules-rpath-link =
11 kx endif # build-hardcoded-path-in-tests
11 kx
11 kx link-libc-between-gnulib = $(common-objpfx)libc.so$(libc.so-version) \
11 kx $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
11 kx -Wl,--as-needed $(elf-objpfx)ld.so \
11 kx -Wl,--no-as-needed
11 kx link-libc = $(link-libc-between-gnulib) $(gnulib)
11 kx
11 kx link-libc-tests-after-rpath-link = $(gnulib-tests) $(link-libc-between-gnulib) $(gnulib-tests)
11 kx link-libc-tests = $(link-libc-tests-rpath-link) \
11 kx $(link-libc-tests-after-rpath-link)
11 kx # Pretty printer test programs always require rpath instead of rpath-link.
11 kx link-libc-printers-tests = $(link-libc-rpath) \
11 kx $(link-libc-tests-after-rpath-link)
11 kx
11 kx # This is how to find at build-time things that will be installed there.
11 kx rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support
11 kx rpath-link = \
11 kx $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
11 kx else # build-static
11 kx link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
11 kx link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
11 kx endif # build-shared
11 kx endif # link-libc
11 kx
11 kx # Differences in the linkers on the various platforms.
11 kx LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
11 kx LDFLAGS-soname-fname = -Wl,-soname,$(@F)
11 kx LDFLAGS-rdynamic = -rdynamic
11 kx LDFLAGS-Bsymbolic = -Bsymbolic
11 kx
11 kx # Choose the default search path for the dynamic linker based on
11 kx # where we will install libraries.
11 kx ifneq ($(libdir),$(slibdir))
11 kx default-rpath = $(slibdir):$(libdir)
11 kx else
11 kx default-rpath = $(libdir)
11 kx endif
11 kx
11 kx ifndef link-extra-libs
11 kx link-extra-libs = $(LDLIBS-$(@F))
11 kx link-extra-libs-static = $(link-extra-libs)
11 kx endif
11 kx
11 kx # The static libraries.
11 kx link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
11 kx link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
11 kx
11 kx # How to link against libgcc. Some libgcc functions, such as those
11 kx # for "long long" arithmetic or software floating point, can always be
11 kx # built without use of C library headers and do not have any global
11 kx # state so can safely be linked statically into any executable or
11 kx # shared library requiring them; these functions are in libgcc.a.
11 kx # Other functions, relating to exception handling, may require C
11 kx # library headers to build and it may not be safe to have more than
11 kx # one copy of them in a process; these functions are only in
11 kx # libgcc_s.so and libgcc_eh.a.
11 kx #
11 kx # To avoid circular dependencies when bootstrapping, it is desirable
11 kx # to avoid use of libgcc_s and libgcc_eh in building glibc. Where any
11 kx # glibc functionality (in particular, thread cancellation) requires
11 kx # exception handling, this is implemented through dlopen of libgcc_s
11 kx # to avoid unnecessary dependencies on libgcc_s by programs not using
11 kx # that functionality; executables built with glibc do not use
11 kx # exception handling other than through thread cancellation.
11 kx #
11 kx # Undefined references to functions from libgcc_eh or libgcc_s may
11 kx # arise for code built with -fexceptions. In the case of statically
11 kx # linked programs installed by glibc, unwinding will never actually
11 kx # occur at runtime and the use of elf/static-stubs.c to resolve these
11 kx # references is safe. In the case of statically linked test programs
11 kx # and test programs built with -fexceptions, unwinding may occur in
11 kx # some cases and it is preferable to link with libgcc_eh or libgcc_s
11 kx # so that the testing is as similar as possible to how programs will
11 kx # be built with the installed glibc.
11 kx #
11 kx # Some architectures have architecture-specific systems for exception
11 kx # handling that may involve undefined references to
11 kx # architecture-specific functions. On those architectures,
11 kx # gnulib-arch and static-gnulib-arch may be defined in sysdeps
11 kx # makefiles to use additional libraries for linking executables and
11 kx # shared libraries built by glibc.
11 kx ifndef gnulib
11 kx ifneq ($(have-cc-with-libunwind),yes)
11 kx libunwind =
11 kx else
11 kx libunwind = -lunwind
11 kx endif
11 kx libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
11 kx gnulib-arch =
11 kx gnulib = -lgcc $(gnulib-arch)
11 kx gnulib-tests := -lgcc $(libgcc_eh)
11 kx static-gnulib-arch =
11 kx # By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
11 kx # statically link programs. When --disable-shared is used, we use
11 kx # -lgcc_eh since elf/static-stubs.o isn't sufficient.
11 kx ifeq (yes,$(build-shared))
11 kx static-gnulib = -lgcc $(static-gnulib-arch)
11 kx else
11 kx static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch)
11 kx endif
11 kx static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
11 kx libc.so-gnulib := -lgcc
11 kx endif
11 kx +preinit = $(addprefix $(csu-objpfx),crti.o)
11 kx +postinit = $(addprefix $(csu-objpfx),crtn.o)
11 kx +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
11 kx +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
11 kx # Variants of the two previous definitions for linking PIE programs.
11 kx +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
11 kx +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
11 kx # Variants of the two previous definitions for statically linking programs.
11 kx ifeq (yes,$(enable-static-pie))
11 kx # Static PIE must use PIE variants.
11 kx +prectorT = $(+prectorS)
11 kx +postctorT = $(+postctorS)
11 kx else
11 kx +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
11 kx +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
11 kx endif
11 kx csu-objpfx = $(common-objpfx)csu/
11 kx elf-objpfx = $(common-objpfx)elf/
11 kx
11 kx # A command that, prepended to the name and arguments of a program,
11 kx # and run on the build system, causes that program with those
11 kx # arguments to be run on the host for which the library is built.
11 kx ifndef test-wrapper
11 kx test-wrapper =
11 kx endif
11 kx # Likewise, but the name of the program is preceded by
11 kx # <variable>=<value> assignments for environment variables.
11 kx ifndef test-wrapper-env
11 kx test-wrapper-env = $(test-wrapper) env
11 kx endif
11 kx # Likewise, but the program's environment will be empty except for any
11 kx # explicit <variable>=<value> assignments preceding the program name.
11 kx ifndef test-wrapper-env-only
11 kx test-wrapper-env-only = $(test-wrapper) env -i
11 kx endif
11 kx
11 kx # Whether to run test programs built for the library's host system.
11 kx ifndef run-built-tests
11 kx ifeq (yes|,$(cross-compiling)|$(test-wrapper))
11 kx run-built-tests = no
11 kx else
11 kx run-built-tests = yes
11 kx endif
11 kx endif
11 kx
11 kx # Whether to stop immediately when a test fails. Nonempty means to
11 kx # stop, empty means not to stop.
11 kx ifndef stop-on-test-failure
11 kx stop-on-test-failure =
11 kx endif
11 kx
11 kx # How to run a program we just linked with our library.
11 kx # The program binary is assumed to be $(word 2,$^).
11 kx built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
11 kx rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
11 kx --library-path \
11 kx $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
11 kx ifeq (yes,$(build-shared))
11 kx comma = ,
11 kx sysdep-library-path = \
11 kx $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
11 kx $(filter -Wl$(comma)-rpath-link=%,\
11 kx $(sysdep-LDFLAGS)))))
11 kx # $(run-via-rtld-prefix) is a command that, when prepended to the name
11 kx # of a program built with the newly built library, produces a command
11 kx # that, executed on the host for which the library is built, runs that
11 kx # program. For tests listed in tests-static or xtests-static, it is
11 kx # empty.
11 kx run-via-rtld-prefix = \
11 kx $(if $(strip $(filter $(notdir $(built-program-file)), \
11 kx $(tests-static) $(xtests-static))),, $(rtld-prefix))
11 kx else
11 kx run-via-rtld-prefix =
11 kx endif
11 kx # $(run-program-env) is the default environment variable settings to
11 kx # use when running a program built with the newly built library.
11 kx run-program-env = GCONV_PATH=$(common-objpfx)iconvdata \
11 kx LOCPATH=$(common-objpfx)localedata LC_ALL=C
11 kx # $(run-program-prefix) is a command that, when prepended to the name
11 kx # of a program built with the newly built library, produces a command
11 kx # that, executed on the build system on which "make" is run, runs that
11 kx # program. $(run-program-prefix-before-env) and
11 kx # $(run-program-prefix-after-env) are similar, but separate parts
11 kx # before and after a list of environment variables.
11 kx run-program-prefix-before-env = $(test-wrapper-env)
11 kx run-program-prefix-after-env = $(run-via-rtld-prefix)
11 kx run-program-prefix = $(run-program-prefix-before-env) $(run-program-env) \
11 kx $(run-program-prefix-after-env)
11 kx # $(built-program-cmd) is a command that, executed on the build system
11 kx # on which "make" is run, runs the newly built program that is the
11 kx # second dependency of the makefile target in which
11 kx # $(built-program-cmd) is used. $(built-program-cmd-before-env) and
11 kx # $(built-program-cmd-after-env) are similar, before and after a list
11 kx # of environment variables.
11 kx built-program-cmd-before-env = $(test-wrapper-env)
11 kx built-program-cmd-after-env = $(run-via-rtld-prefix) $(built-program-file)
11 kx built-program-cmd = $(built-program-cmd-before-env) $(run-program-env) \
11 kx $(built-program-cmd-after-env)
11 kx # $(host-built-program-cmd) is a command that, executed on the host
11 kx # for which the library is built, runs the newly built program that is
11 kx # the second dependency of the makefile target in which
11 kx # $(host-built-program-cmd) is used.
11 kx host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file)
11 kx # $(ld-library-path) is the common content to be set in LD_LIBRARY_PATH
11 kx # for running static binaries that may load dynamic objects.
11 kx ld-library-path = $(objpfx):$(common-objpfx)$(addprefix :,$(sysdep-ld-library-path))
11 kx
11 kx ifndef LD
11 kx LD := ld -X
11 kx endif
11 kx
11 kx # $(test-via-rtld-prefix) is a command that, when prepended to the name
11 kx # of a test program built with the newly built library, produces a command
11 kx # that, executed on the host for which the library is built, runs that
11 kx # program. For tests listed in tests-static or xtests-static as well
11 kx # as when test programs are hardcoded to the newly built libraries, it
11 kx # is empty.
11 kx
11 kx # $(test-program-prefix) is a command that, when prepended to the name
11 kx # of a test program built with the newly built library, produces a command
11 kx # that, executed on the build system on which "make" is run, runs that
11 kx # test program. $(test-program-prefix-before-env) and
11 kx # $(test-program-prefix-after-env) are similar, before and after a
11 kx # list of environment variables.
11 kx
11 kx # $(test-program-cmd) is a command that, executed on the build system
11 kx # on which "make" is run, runs the newly built test program that is the
11 kx # second dependency of the makefile target in which
11 kx # $(test-program-cmd) is used. $(test-program-cmd-before-env) and
11 kx # $(test-program-cmd-after-env) are similar, before and after a list
11 kx # of environment variables.
11 kx
11 kx # $(host-test-program-cmd) is a command that, executed on the host
11 kx # for which the library is built, runs the newly built test program that
11 kx # is the second dependency of the makefile target in which
11 kx # $(host-test-program-cmd) is used.
11 kx
11 kx ifeq (yes,$(build-hardcoded-path-in-tests))
11 kx test-via-rtld-prefix =
11 kx test-program-prefix-before-env = $(test-wrapper-env)
11 kx test-program-prefix-after-env =
11 kx test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \
11 kx $(test-program-prefix-after-env)
11 kx test-program-cmd-before-env = $(test-wrapper-env)
11 kx test-program-cmd-after-env = $(built-program-file)
11 kx test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \
11 kx $(test-program-cmd-after-env)
11 kx host-test-program-cmd = $(built-program-file)
11 kx else
11 kx test-via-rtld-prefix = $(run-via-rtld-prefix)
11 kx test-program-prefix-before-env = $(run-program-prefix-before-env)
11 kx test-program-prefix-after-env = $(run-program-prefix-after-env)
11 kx test-program-prefix = $(run-program-prefix)
11 kx test-program-cmd-before-env = $(built-program-cmd-before-env)
11 kx test-program-cmd-after-env = $(built-program-cmd-after-env)
11 kx test-program-cmd = $(built-program-cmd)
11 kx host-test-program-cmd = $(host-built-program-cmd)
11 kx endif
11 kx
11 kx # Extra flags to pass to GCC.
11 kx ifeq ($(all-warnings),yes)
11 kx +gccwarn := -Wall -Wwrite-strings -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
11 kx else
11 kx +gccwarn := -Wall -Wwrite-strings
11 kx endif
11 kx +gccwarn += -Wundef
11 kx ifeq ($(enable-werror),yes)
11 kx +gccwarn += -Werror
11 kx endif
11 kx +gccwarn-c = -Wstrict-prototypes -Wold-style-definition
11 kx
11 kx # We do not depend on the address of constants in different files to be
11 kx # actually different, so allow the compiler to merge them all.
11 kx +merge-constants = -fmerge-all-constants
11 kx
11 kx # We have to assume that glibc functions are called in any rounding
11 kx # mode and also change the rounding mode in a few functions. So,
11 kx # disable any optimization that assume default rounding mode.
11 kx +math-flags = -frounding-math
11 kx
11 kx # Logically only "libnldbl", "nonlib" and "testsuite" should be using
11 kx # -fno-math-errno. However due to GCC bug #88576, only "libm" can use
11 kx # -fno-math-errno.
11 kx +extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)
11 kx
11 kx # Use 64 bit time_t support for installed programs
11 kx installed-modules = nonlib nscd ldconfig locale_programs \
11 kx iconvprogs libnss_files libnss_compat libnss_db libnss_hesiod \
11 kx libutil libpcprofile libnsl
11 kx +extra-time-flags = $(if $(filter $(installed-modules),\
11 kx $(in-module)),-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64)
11 kx
11 kx # We might want to compile with some stack-protection flag.
11 kx ifneq ($(stack-protector),)
11 kx +stack-protector=$(stack-protector)
11 kx endif
11 kx
11 kx # Some routines are unsafe to build with stack-protection since they're called
11 kx # before the stack check guard is set up. Provide a way to disable stack
11 kx # protector. The first argument is the extension (.o, .os, .oS) and the second
11 kx # is a list of routines that this path should be applied to.
11 kx define elide-stack-protector
11 kx $(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector))
11 kx endef
11 kx
11 kx # The program that makes Emacs-style TAGS files.
11 kx ETAGS := etags
11 kx
11 kx # The `xgettext' program for producing .pot files from sources.
11 kx ifndef XGETTEXT
11 kx XGETTEXT = xgettext
11 kx endif
11 kx
11 kx # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
11 kx # perhaps others) to preprocess assembly code in some cases.
11 kx M4 = m4
11 kx
11 kx # To force installation of files even if they are older than the
11 kx # installed files. This variable is included in the dependency list
11 kx # of all installation targets.
11 kx ifeq ($(force-install),yes)
11 kx +force = force-install
11 kx else
11 kx +force =
11 kx endif
11 kx
11 kx ####
11 kx #### End of configuration variables.
11 kx ####
11 kx
11 kx # This tells some versions of GNU make before 3.63 not to export all variables.
11 kx .NOEXPORT:
11 kx
11 kx # We want to echo the commands we're running without
11 kx # umpteen zillion filenames along with it (we use `...' instead)
11 kx # but we don't want this echoing done when the user has said
11 kx # he doesn't want to see commands echoed by using -s.
11 kx ifeq ($(silent-make),yes) # if -s
11 kx +cmdecho := echo >/dev/null
11 kx else # not -s
11 kx +cmdecho := echo
11 kx endif # -s
11 kx
11 kx # These are the flags given to the compiler to tell
11 kx # it what sort of optimization and/or debugging output to do.
11 kx ifndef +cflags
11 kx # If `CFLAGS' was defined, use that.
11 kx ifdef CFLAGS
11 kx +cflags := $(filter-out -I%,$(CFLAGS))
11 kx endif # CFLAGS
11 kx endif # +cflags
11 kx
11 kx # If none of the above worked, default to "-g -O".
11 kx ifeq "$(strip $(+cflags))" ""
11 kx +cflags := $(default_cflags)
11 kx endif # $(+cflags) == ""
11 kx
11 kx # Force building with -fno-common because hidden_def, compat_symbol
11 kx # and other constructs do not work for common symbols (and would
11 kx # otherwise require specifying __attribute__ ((nocommon)) on a
11 kx # case-by-case basis).
11 kx +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \
11 kx $(+stack-protector) -fno-common
11 kx +gcc-nowarn := -w
11 kx
11 kx # Each sysdeps directory can contain header files that both will be
11 kx # used to compile and will be installed. Each can also contain an
11 kx # include/ subdirectory, whose header files will be used to compile
11 kx # but will not be installed, and will take precedence over the
11 kx # installed files. This mirrors the top-level include/ subdirectory.
11 kx +sysdep-includes := $(foreach dir,$(+sysdep_dirs),\
11 kx $(addprefix -I,$(wildcard $(dir)/include) $(dir)))
11 kx
11 kx # These are flags given to the C compiler to tell it to look for
11 kx # include files (including ones given in angle brackets) in the parent
11 kx # library source directory, in the include directory, and in the
11 kx # current directory.
11 kx +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
11 kx $(+sysdep-includes) $(includes) \
11 kx $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
11 kx
11 kx # Since libio has several internal header files, we use a -I instead
11 kx # of many little headers in the include directory.
11 kx libio-include = -I$(..)libio
11 kx
11 kx # List of non-library modules that we build.
11 kx built-modules = iconvprogs iconvdata ldconfig libmemusage \
11 kx libpcprofile librpcsvc locale-programs \
11 kx memusagestat nonlib nscd extramodules libnldbl libsupport \
11 kx testsuite testsuite-internal
11 kx
11 kx in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
11 kx $(libof-$(<F)) \
11 kx $(libof-$(@F)) \
11 kx libc))
11 kx
11 kx # Build ld.so, libc.so and libpthread.so with -ftls-model=initial-exec
11 kx tls-model = $(if $(filter libpthread rtld \
11 kx libc,$(in-module)),-ftls-model=initial-exec,)
11 kx
11 kx module-cppflags-real = -include $(common-objpfx)libc-modules.h \
11 kx -DMODULE_NAME=$(in-module)
11 kx
11 kx # We don't need libc-modules.h and the MODULE_NAME definition for .v.i
11 kx # files. These targets don't (and will likely never need to) use the IS_IN
11 kx # facility. In fact, shlib-versions should not use it because that will
11 kx # create a circular dependency as libc-modules.h is generated from
11 kx # shlib-versions.
11 kx module-cppflags = $(if $(filter %.mk.i %.v.i,$(@F)),,$(module-cppflags-real))
11 kx
11 kx # These are the variables that the implicit compilation rules use.
11 kx # Note that we can't use -std=* in CPPFLAGS, because it overrides
11 kx # the implicit -lang-asm and breaks cpp behavior for .S files--notably
11 kx # it causes cpp to stop predefining __ASSEMBLER__.
11 kx CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
11 kx $($(subdir)-CPPFLAGS) \
11 kx $(+includes) $(defines) $(module-cppflags) \
11 kx -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
11 kx $(CPPFLAGS-$(suffix $@)) \
11 kx $(foreach lib,$(libof-$(basename $(@F))) \
11 kx $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
11 kx $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
11 kx
11 kx ifneq (no,$(have-tunables))
11 kx CPPFLAGS += -DTOP_NAMESPACE=glibc
11 kx endif
11 kx
11 kx override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
11 kx $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
11 kx $(+extra-math-flags) $(+extra-time-flags) \
11 kx $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
11 kx $(CFLAGS-$(@F)) $(tls-model) \
11 kx $(foreach lib,$(libof-$(basename $(@F))) \
11 kx $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
11 kx # Use our copies of cstdlib and cmath.
11 kx override CXXFLAGS = -I$(common-objpfx) $(c++-sysincludes) \
11 kx $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
11 kx $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
11 kx
11 kx # If everything is compiled with -fPIC (implicitly) we must tell this by
11 kx # defining the PIC symbol.
11 kx ifeq (yes,$(build-pic-default))
11 kx pic-default = -DPIC
11 kx endif
11 kx
11 kx # Enable object files for different versions of the library.
11 kx # Various things use $(object-suffixes) to know what all to make.
11 kx # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
11 kx # to pass different flags for each flavor.
11 kx libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
11 kx # .op may be added to all-object-suffixes below.
11 kx all-object-suffixes := .o .os .oS
11 kx object-suffixes :=
11 kx CPPFLAGS-.o = $(pic-default)
11 kx # libc.a must be compiled with -fPIE/-fpie for static PIE.
11 kx CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) $(pie-default)
11 kx libtype.o := lib%.a
11 kx object-suffixes += .o
11 kx ifeq (yes,$(build-shared))
11 kx # Under --enable-shared, we will build a shared library of PIC objects.
11 kx # The PIC object files are named foo.os.
11 kx object-suffixes += .os
11 kx pic-cppflags = -DPIC -DSHARED
11 kx CPPFLAGS-.os = $(pic-cppflags)
11 kx CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
11 kx libtype.os := lib%_pic.a
11 kx # This can be changed by a sysdep makefile
11 kx pic-ccflag = -fPIC
11 kx # This one should always stay like this unless there is a very good reason.
11 kx PIC-ccflag = -fPIC
11 kx endif
11 kx # This can be changed by a sysdep makefile
11 kx pie-ccflag = -fPIE
11 kx no-pie-ccflag = -fno-pie
11 kx # This one should always stay like this unless there is a very good reason.
11 kx PIE-ccflag = -fPIE
11 kx ifeq (yes,$(build-profile))
11 kx # Under --enable-profile, we will build a static library of profiled objects.
11 kx # The profiled object files are named foo.op.
11 kx all-object-suffixes += .op
11 kx object-suffixes += .op
11 kx CPPFLAGS-.op = -DPROF $(pic-default)
11 kx # libc_p.a must be compiled with -fPIE/-fpie for static PIE.
11 kx CFLAGS-.op = -pg $(pie-default)
11 kx libtype.op = lib%_p.a
11 kx endif
11 kx
11 kx # Convenience variable for when we want to treat shared-library cases
11 kx # differently from the rest.
11 kx object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
11 kx
11 kx object-suffixes-for-libc := $(object-suffixes)
11 kx
11 kx ifeq (yes,$(build-shared))
11 kx # Build special library that contains the static-only routines for libc.
11 kx object-suffixes-for-libc += .oS
11 kx
11 kx # Must build the routines as PIC, though, because they can end up in (users')
11 kx # shared objects. We don't want to use CFLAGS-os because users may, for
11 kx # example, make that processor-specific.
11 kx CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags)
11 kx CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
11 kx libtype.oS = lib%_nonshared.a
11 kx endif
11 kx
11 kx # The assembler can generate debug information too.
11 kx ifndef ASFLAGS
11 kx ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
11 kx endif
11 kx override ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
11 kx
11 kx ifndef BUILD_CC
11 kx BUILD_CC = $(CC)
11 kx endif
11 kx
11 kx move-if-change = $(SHELL) $(..)scripts/move-if-change
11 kx
11 kx -include $(common-objpfx)sysd-sorted
11 kx subdirs = $(sorted-subdirs)
11 kx subdir-srcdirs = $(foreach dir,$(subdirs),\
11 kx $(firstword $($(dir)-srcdir) $(..)$(dir)))
11 kx
11 kx # This is a pair of implicit rules to preprocess a file with # comments,
11 kx # %ifdef et al, based on config.h settings or other %include'd files.
11 kx # We use chained rules instead of a pipeline here so that we can properly
11 kx # check the exit status of cpp rather than using its bad output when there
11 kx # is a preprocessing error. Another rule should depend on the output file
11 kx # `FOO.v', and along with that `FOO.v.i' should be given dependencies
11 kx # listing both its input files, and any header files that it may reference
11 kx # (but no commands).
11 kx %.v.i: $(common-objpfx)config.h $(..)Makeconfig
11 kx sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
11 kx $(filter-out FORCE %.h $(..)Makeconfig,$^) \
11 kx | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
11 kx > $@T
11 kx mv -f $@T $@
11 kx %.v: %.v.i
11 kx sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
11 kx mv -f $@T $@
11 kx
11 kx ifeq (yes, $(build-shared))
11 kx
11 kx # To generate a header to support more than one ABI for different
11 kx # architecture variants, the CPU/Makefile defines abi-variants to be a
11 kx # list of names for those variants (e.g. 32 64), and, for each variant,
11 kx # defines abi-$(variant)-condition to be the condition for those options
11 kx # to use in a C #if condition. abi-includes may be defined to a list of
11 kx # headers to include in the generated header, if the default does not
11 kx # suffice. default-abi is defined to be the ABI for the current glibc
11 kx # build.
11 kx
11 kx ifndef abi-includes
11 kx abi-includes := bits/wordsize.h
11 kx endif
11 kx
11 kx # Process the shlib-versions file, which tells us what shared library
11 kx # version numbers to use when we install shared objects on this system.
11 kx # We need to wait until $(subdirs) is complete.
11 kx ifeq ($(sysd-sorted-done),t)
11 kx -include $(common-objpfx)soversions.mk
11 kx ifndef avoid-generated
11 kx $(common-objpfx)shlib-versions.v.i: \
11 kx $(wildcard $(+sysdep_dirs:=/shlib-versions) \
11 kx $(subdir-srcdirs:=/shlib-versions)) \
11 kx $(..)shlib-versions
11 kx
11 kx $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
11 kx $(common-objpfx)shlib-versions.v
11 kx $(AWK) -f $^ > $@T
11 kx mv -f $@T $@
11 kx $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
11 kx (while read which lib number setname; do \
11 kx eval seen_$$which=1; \
11 kx test x"$$which" = xDEFAULT || continue; \
11 kx case $$number in \
11 kx [0-9]*) echo "$$lib.so-version=.$$number"; \
11 kx echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
11 kx *) echo "$$lib.so-version=$$number"; \
11 kx echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
11 kx esac; \
11 kx done; \
11 kx echo soversions.mk-done = t;) < $< > $@T; exit 0
11 kx mv -f $@T $@
11 kx endif
11 kx endif
11 kx
11 kx postclean-generated += soversions.mk soversions.i \
11 kx shlib-versions.v shlib-versions.v.i
11 kx
11 kx before-compile += $(common-objpfx)libc-modules.h
11 kx common-generated += libc-modules.h libc-modules.stmp
11 kx ifeq ($(soversions.mk-done),t)
11 kx # Generate a header with macro definitions for use with the IS_IN macro.
11 kx # These are the possible values for the MODULE_NAME macro defined when building
11 kx # sources, to identify which module the translation unit is going to be built
11 kx # into.
11 kx $(common-objpfx)libc-modules.h: $(common-objpfx)libc-modules.stmp; @:
11 kx $(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \
11 kx $(common-objpfx)soversions.i
11 kx $(AWK) -v buildlist="$(subst -,_,$(built-modules))" -f $^ > ${@:stmp=T}
11 kx $(move-if-change) ${@:stmp=T} ${@:stmp=h}
11 kx touch $@
11 kx
11 kx endif
11 kx
11 kx # Build the tunables list header early since it could be used by any module in
11 kx # glibc.
11 kx ifneq (no,$(have-tunables))
11 kx before-compile += $(common-objpfx)dl-tunable-list.h
11 kx common-generated += dl-tunable-list.h dl-tunable-list.stmp
11 kx
11 kx $(common-objpfx)dl-tunable-list.h: $(common-objpfx)dl-tunable-list.stmp; @:
11 kx $(common-objpfx)dl-tunable-list.stmp: \
11 kx $(..)scripts/gen-tunables.awk \
11 kx $(..)elf/dl-tunables.list \
11 kx $(wildcard $(subdirs:%=$(..)%/dl-tunables.list)) \
11 kx $(wildcard $(sysdirs:%=%/dl-tunables.list))
11 kx $(AWK) -f $^ > ${@:stmp=T}
11 kx $(move-if-change) ${@:stmp=T} ${@:stmp=h}
11 kx touch $@
11 kx endif
11 kx
11 kx # Dump the GCC macros used by the default compiler flags to a header
11 kx # file, so that they can be inspected when using different compiler
11 kx # flags. Add the GCCMACRO prefix to make these macro names unique.
11 kx $(common-objpfx)gcc-macros.h.in: $(common-objpfx)config.status
11 kx $(CC) $(CFLAGS) $(CPPFLAGS) -E -dM -x c -o $@ /dev/null
11 kx $(common-objpfx)gcc-macros.h: $(common-objpfx)gcc-macros.h.in
11 kx sed 's/^#define /#define GCCMACRO/' < $< > $@
11 kx before-compile += $(common-objpfx)gcc-macros.h
11 kx
11 kx # Generate version maps, but wait until sysdep-subdirs is known
11 kx ifeq ($(sysd-sorted-done),t)
11 kx ifeq ($(build-shared),yes)
11 kx -include $(common-objpfx)sysd-versions
11 kx -include $(common-objpfx)Versions.mk
11 kx $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
11 kx common-generated += $(version-maps)
11 kx postclean-generated += sysd-versions Versions.all abi-versions.h \
11 kx Versions.def Versions.v.i Versions.v Versions.mk
11 kx
11 kx ifndef avoid-generated
11 kx ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
11 kx sysd-versions-force = FORCE
11 kx FORCE:
11 kx endif
11 kx
11 kx $(common-objpfx)Versions.def: $(..)scripts/versionlist.awk \
11 kx $(common-objpfx)Versions.v
11 kx LC_ALL=C $(AWK) -f $^ > $@T
11 kx mv -f $@T $@
11 kx
11 kx $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
11 kx $(common-objpfx)soversions.i \
11 kx $(common-objpfx)Versions.def
11 kx { while read which lib version setname; do \
11 kx test x"$$which" = xDEFAULT || continue; \
11 kx test -z "$$setname" || echo "$$lib : $$setname"; \
11 kx done < $(word 2,$^); \
11 kx cat $(word 3,$^); \
11 kx } | LC_ALL=C $(AWK) -f $< > $@T
11 kx mv -f $@T $@
11 kx $(common-objpfx)Versions.mk: $(..)scripts/haveversions.awk \
11 kx $(common-objpfx)Versions.all
11 kx $(AWK) -f $^ > $@T
11 kx mv -f $@T $@
11 kx # See %.v/%.v.i implicit rules in Makeconfig.
11 kx $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
11 kx $(wildcard $(sysdirs:%=%/Versions)) \
11 kx $(sysd-versions-force)
11 kx $(common-objpfx)sysd-versions: $(common-objpfx)versions.stmp
11 kx $(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \
11 kx $(common-objpfx)Versions.v \
11 kx $(..)scripts/versions.awk
11 kx ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
11 kx cat $(word 2,$^) \
11 kx | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
11 kx -v move_if_change='$(move-if-change)' \
11 kx -f $(word 3,$^); \
11 kx ) > $(common-objpfx)sysd-versionsT
11 kx mv -f $(common-objpfx)sysd-versionsT $(common-objpfx)sysd-versions
11 kx touch $@
11 kx endif # avoid-generated
11 kx endif # $(build-shared) = yes
11 kx
11 kx -include $(common-objpfx)time64-compat.mk
11 kx postclean-generated += time64-compat.mk
11 kx
11 kx $(common-objpfx)time64-compat.mk: $(common-objpfx)time64-compat.mk.i \
11 kx $(sysd-versions-force)
11 kx sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
11 kx mv -f $@T $@
11 kx $(common-objpfx)time64-compat.mk.i: $(..)Makeconfig
11 kx printf "#include <time64-compat.h>\n#ifdef TIME64_NON_DEFAULT\nhave-time64-compat = yes\n#endif" \
11 kx | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - > $@T
11 kx mv -f $@T $@
11 kx
11 kx
11 kx endif # sysd-sorted-done
11 kx
11 kx # The name under which the run-time dynamic linker is installed.
11 kx # We are currently going for the convention that `/lib/ld.so.1'
11 kx # names the SVR4/ELF ABI-compliant dynamic linker.
11 kx ifndef rtld-installed-name
11 kx ifdef ld.so-version
11 kx rtld-installed-name = $(ld.so-version)
11 kx else
11 kx rtld-installed-name = ld.so.1
11 kx endif
11 kx endif
11 kx
11 kx ifndef rtld-version-installed-name
11 kx rtld-version-installed-name = ld-$(version).so
11 kx endif
11 kx
11 kx endif # build-shared
11 kx
11 kx
11 kx ifeq ($(build-shared),yes)
11 kx libm = $(common-objpfx)math/libm.so$(libm.so-version)
11 kx libmvec = $(common-objpfx)mathvec/libmvec.so$(libmvec.so-version)
11 kx else
11 kx libm = $(common-objpfx)math/libm.a
11 kx libmvec = $(common-objpfx)mathvec/libmvec.a
11 kx endif
11 kx
11 kx ifeq ($(build-shared),yes)
11 kx libsupport = $(common-objpfx)support/libsupport_nonshared.a
11 kx else
11 kx libsupport = $(common-objpfx)support/libsupport.a
11 kx endif
11 kx
11 kx # This is a partial list of subdirectories containing the library source.
11 kx # The order is more or less arbitrary. The sorting step will take care of the
11 kx # dependencies and generate sorted-subdirs dynamically.
11 kx all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
11 kx stdlib stdio-common libio malloc string wcsmbs time dirent \
11 kx grp pwd posix io termios resource misc socket sysvipc gmon \
11 kx gnulib iconv iconvdata wctype manual shadow gshadow po argp \
11 kx localedata timezone rt conform debug mathvec support \
11 kx dlfcn elf
11 kx
11 kx ifeq ($(build-crypt),yes)
11 kx all-subdirs += crypt
11 kx rpath-dirs += crypt
11 kx endif
11 kx
11 kx ifndef avoid-generated
11 kx # sysd-sorted itself will contain rules making the sysd-sorted target
11 kx # depend on Depend files. But if you just added a Depend file to an
11 kx # existing directory not in all-subdirs, then sysd-sorted needs to
11 kx # be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files.
11 kx all-Depend-files := $(wildcard $(sort \
11 kx $(foreach dir,$(all-subdirs),\
11 kx $(firstword $($(dir)-srcdir) \
11 kx $(..)$(dir))/Depend) \
11 kx $(sorted-subdirs:=/Depend)))
11 kx $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
11 kx $(common-objpfx)config.make $(..)Makeconfig \
11 kx $(wildcard $(sysdirs:=/Subdirs)) \
11 kx $(all-Depend-files)
11 kx $(AWK) -f $< \
11 kx -v subdirs='$(all-subdirs)' \
11 kx -v srcpfx='$(..)' \
11 kx $(filter %/Subdirs %/Depend,$^) > $@-tmp
11 kx mv -f $@-tmp $@
11 kx $(all-Depend-files): ;
11 kx endif
11 kx
11 kx # This gives partial TARGET:SOURCE pattern pairs to have rules
11 kx # emitted into sysd-rules. A sysdeps Makeconfig fragment can
11 kx # add its own special object file prefix to this list with e.g. foo-%:%
11 kx # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
11 kx sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
11 kx
11 kx # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
11 kx sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
11 kx ifneq (,$(sysdep-makeconfigs))
11 kx include $(sysdep-makeconfigs)
11 kx endif
11 kx
11 kx # Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
11 kx sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
11 kx $(firstword $(subst :, ,$p))))
11 kx
11 kx # $(libpthread-routines-var) and $(librt-routines-var) are the make
11 kx # variable to which pthread routines need to be added to land in the
11 kx # right library.
11 kx ifeq ($(pthread-in-libc),yes)
11 kx libpthread-routines-var = routines
11 kx librt-routines-var = routines
11 kx libanl-routines-var = routines
11 kx else
11 kx libpthread-routines-var = libpthread-routines
11 kx librt-routines-var = librt-routines
11 kx libanl-routines-var = libanl-routines
11 kx endif
11 kx
11 kx # A sysdeps Makeconfig fragment may set libc-reentrant to yes.
11 kx ifeq (yes,$(libc-reentrant))
11 kx defines += -D_LIBC_REENTRANT
11 kx
11 kx libio-mtsafe = -D_IO_MTSAFE_IO
11 kx endif
11 kx
11 kx # The name to give to a test in test results summaries.
11 kx test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@)))
11 kx
11 kx # Likewise, in XFAIL variable names.
11 kx test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@)))
11 kx
11 kx # Command to output a test status line (such as PASS: test-name). If
11 kx # test-xfail-$(test-xfail-name) has a nonempty value, the status will be
11 kx # XPASS or XFAIL rather than PASS or FAIL.
11 kx evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \
11 kx $(if $(test-xfail-$(test-xfail-name)),true,false) \
11 kx $(if $(stop-on-test-failure),true,false) \
11 kx > $(common-objpfx)$(test-name).test-result
11 kx
11 kx endif # Makeconfig not yet included
11 kx
11 kx # Local Variables:
11 kx # mode: makefile
11 kx # End: