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