Blame Makeconfig

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