]> git.ipfire.org Git - thirdparty/glibc.git/blame - Makeconfig
Remove add-ons mechanism.
[thirdparty/glibc.git] / Makeconfig
CommitLineData
bfff8b1b 1# Copyright (C) 1991-2017 Free Software Foundation, Inc.
28f540f4
RM
2# This file is part of the GNU C Library.
3
4# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
28f540f4
RM
8
9# The GNU C Library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12# Lesser General Public License for more details.
28f540f4 13
41bdb6e2 14# You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15# License along with the GNU C Library; if not, see
16# <http://www.gnu.org/licenses/>.
28f540f4
RM
17
18#
19# Makefile configuration options for the GNU C library.
20#
21ifneq (,)
22This makefile requires GNU Make.
23endif
24
3e5f5557
UD
25all: # Make this the default goal
26
28f540f4
RM
27ifneq "$(origin +included-Makeconfig)" "file"
28
29+included-Makeconfig := yes
30
31ifdef subdir
32.. := ../
33endif
34
094bacdb 35# $(common-objdir) is the place to put objects and
28f540f4
RM
36# such that are not specific to a single subdir.
37ifdef objdir
6e953631
UD
38objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
39common-objpfx = $(objdir)/
28f540f4
RM
40common-objdir = $(objdir)
41else
728e272a 42objdir must be defined by the build-directory Makefile.
28f540f4
RM
43endif
44
f332db02
RM
45# Root of the sysdeps tree.
46sysdep_dir := $(..)sysdeps
47export sysdep_dir := $(sysdep_dir)
48
28f540f4
RM
49# Get the values defined by options to `configure'.
50include $(common-objpfx)config.make
51
e07bb02a 52# What flags to give to sources which call user provided callbacks
56ab3869 53uses-callbacks = -fexceptions
e07bb02a 54
a4db3439
UD
55# What flags to give to tests which test stack alignment
56stack-align-test-flags =
57
57ba7bb4 58# Complete path to sysdep dirs.
e0a3ed4f
RM
59# `configure' writes a definition of `config-sysdirs' in `config.make'.
60sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
61
644d3857 62+sysdep_dirs = $(sysdirs)
e0a3ed4f
RM
63ifdef objdir
64+sysdep_dirs := $(objdir) $(+sysdep_dirs)
65endif
57ba7bb4 66
273d56ce
RM
67# Run config.status to update config.make and config.h. We don't show the
68# dependence of config.h to Make, because it is only touched when it
69# changes and so config.status would be run every time; the dependence of
70# config.make should suffice to force regeneration and re-exec, and the new
71# image will notice if config.h changed.
19361cb7
UD
72$(common-objpfx)config.make: $(common-objpfx)config.status \
73 $(..)config.make.in $(..)config.h.in
273d56ce
RM
74 cd $(<D); $(SHELL) $(<F)
75
644d3857
JM
76# Find all the sysdeps configure fragments, to make sure we re-run
77# configure when any of them changes.
5290baf0 78$(common-objpfx)config.status: $(..)version.h $(..)configure \
e0a3ed4f
RM
79 $(foreach dir,$(sysdirs),\
80 $(wildcard $(dir)/Implies) \
95afbbe5 81 $(patsubst %.ac,%,\
f332db02 82 $(firstword $(wildcard \
cb8a6dbd 83 $(addprefix $(dir)/,configure configure.ac))))) \
95afbbe5 84 $(patsubst %.ac,%,\
644d3857 85 $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac))
273d56ce
RM
86 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
87 echo The GNU C library has not been configured. >&2; \
88 echo Run \`configure\' to configure it before building. >&2; \
89 echo Try \`configure --help\' for more details. >&2; \
90 exit 1; fi
28f540f4 91
74015205
UD
92# We don't want CPPFLAGS to be exported to the command running configure.
93unexport CPPFLAGS
94
28f540f4
RM
95# Get the user's configuration parameters.
96ifneq ($(wildcard $(..)configparms),)
97include $(..)configparms
98endif
99ifneq ($(objpfx),)
6e953631
UD
100ifneq ($(wildcard $(common-objpfx)configparms),)
101include $(common-objpfx)configparms
28f540f4
RM
102endif
103endif
28f540f4
RM
104\f
105####
106#### These are the configuration variables. You can define values for
107#### the variables below in the file `configparms'.
108#### Do NOT edit this file.
109####
110
111
112# Common prefix for machine-independent installation directories.
487253ea 113ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
28f540f4
RM
114prefix = /usr/local
115endif
116
0413b54c
UD
117# Decide whether we shall build the programs or not. We always do this
118# unless the user tells us (in configparms) or we are building for a
119# standalone target.
120ifndef build-programs
121ifneq ($(config-os),none)
122build-programs=yes
123else
124build-programs=no
125endif
126endif
127
28f540f4 128# Common prefix for machine-dependent installation directories.
487253ea 129ifeq ($(origin exec_prefix),undefined)
28f540f4
RM
130exec_prefix = $(prefix)
131endif
132
133# Where to install the library and object files.
134ifndef libdir
135libdir = $(exec_prefix)/lib
136endif
8d57beea 137inst_libdir = $(install_root)$(libdir)
28f540f4 138
aaa8cb4b 139# Where to install the shared library.
094bacdb
RM
140ifndef slibdir
141slibdir = $(exec_prefix)/lib
142endif
8d57beea 143inst_slibdir = $(install_root)$(slibdir)
094bacdb 144
aaa8cb4b
AS
145# Where to install the dynamic linker.
146ifndef rtlddir
147rtlddir = $(slibdir)
148endif
149inst_rtlddir = $(install_root)$(rtlddir)
150
28f540f4
RM
151# Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
152# the prefix is spliced between `lib' and the name, so the linker switch
153# `-l$(libprefix)NAME' finds the library; for other files the prefix is
154# just prepended to the whole file name.
487253ea 155ifeq ($(origin libprefix),undefined)
28f540f4
RM
156libprefix =
157endif
158
159# Where to install the header files.
160ifndef includedir
25c751d0 161includedir = $(prefix)/include
28f540f4 162endif
8d57beea 163inst_includedir = $(install_root)$(includedir)
28f540f4 164
28f540f4 165# Where to install machine-independent data files.
a2fe9c76 166# These are the timezone database, and the locale database.
28f540f4
RM
167ifndef datadir
168datadir = $(prefix)/share
169endif
8d57beea 170inst_datadir = $(install_root)$(datadir)
28f540f4
RM
171
172# Where to install the timezone data files (which are machine-independent).
173ifndef zonedir
174zonedir = $(datadir)/zoneinfo
175endif
8d57beea 176inst_zonedir = $(install_root)$(zonedir)
28f540f4 177
90fe682d
CD
178# Where to install the compiled binary locale archive and compiled
179# binary locale files.
180ifndef complocaledir
181complocaledir = $(libdir)/locale
a2fe9c76 182endif
90fe682d 183inst_complocaledir = $(install_root)$(complocaledir)
a2fe9c76 184
4a33c2f5
UD
185# Where to install the message catalog data files (which are
186# machine-independent).
314f6dee
CD
187ifndef localedir
188localedir = $(datadir)/locale
4a33c2f5 189endif
314f6dee 190inst_localedir = $(install_root)$(localedir)
4a33c2f5 191
3ec41e03 192# Where to install the locale charmap source files.
19bc17a9
RM
193ifndef i18ndir
194i18ndir = $(datadir)/i18n
a2fe9c76 195endif
8d57beea 196inst_i18ndir = $(install_root)$(i18ndir)
a2fe9c76 197
6973fc01
UD
198# Where to install the shared object for charset transformation.
199ifndef gconvdir
200gconvdir = $(libdir)/gconv
201endif
202inst_gconvdir = $(install_root)$(gconvdir)
203
28f540f4
RM
204# Where to install programs.
205ifndef bindir
206bindir = $(exec_prefix)/bin
207endif
8d57beea 208inst_bindir = $(install_root)$(bindir)
28f540f4 209
7f0ff1b0
UD
210# Where to install internal programs.
211ifndef libexecdir
212libexecdir = $(exec_prefix)/libexec
213endif
214inst_libexecdir = $(install_root)$(libexecdir)
215
28f540f4 216# Where to install administrative programs.
1ef32c3d
UD
217ifndef rootsbindir
218rootsbindir = $(exec_prefix)/sbin
219endif
8d57beea 220inst_rootsbindir = $(install_root)$(rootsbindir)
1ef32c3d 221
28f540f4
RM
222ifndef sbindir
223sbindir = $(exec_prefix)/sbin
224endif
8d57beea 225inst_sbindir = $(install_root)$(sbindir)
28f540f4
RM
226
227# Where to install the Info files.
228ifndef infodir
229infodir = $(prefix)/info
230endif
8d57beea 231inst_infodir = $(install_root)$(infodir)
28f540f4 232
a9171047
UD
233# Where to install audit libraries.
234ifndef auditdir
235auditdir = $(libdir)/audit
236endif
237inst_auditdir = $(install_root)$(auditdir)
238
28f540f4
RM
239# Where to install default configuration files. These include the local
240# timezone specification and network data base files.
241ifndef sysconfdir
242sysconfdir = $(prefix)/etc
243endif
8d57beea 244inst_sysconfdir = $(install_root)$(sysconfdir)
28f540f4 245
77fb9117
UD
246# Directory for the database files and Makefile for nss_db.
247ifndef vardbdir
4248b1b1 248vardbdir = $(localstatedir)/db
77fb9117
UD
249endif
250inst_vardbdir = $(install_root)$(vardbdir)
251
28f540f4
RM
252# Where to install the "localtime" timezone file; this is the file whose
253# contents $(localtime) specifies. If this is a relative pathname, it is
254# relative to $(zonedir). It is a good idea to put this somewhere
255# other than there, so the zoneinfo directory contains only universal data,
256# localizing the configuration data elsewhere.
257ifndef localtime-file
0d8733c4 258localtime-file = $(sysconfdir)/localtime
28f540f4
RM
259endif
260
59dd8641
RM
261# What to use for leap second specifications in compiling the default
262# timezone files. Set this to `/dev/null' for no leap second handling as
263# 1003.1 requires, or to `leapseconds' for proper leap second handling.
264# Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
265# This variable determines the default: if it's `/dev/null',
266# ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
267ifndef leapseconds
268leapseconds = /dev/null
269endif
270
28f540f4
RM
271# What timezone's DST rules should be used when a POSIX-style TZ
272# environment variable doesn't specify any rules. For 1003.1 compliance
273# this timezone must use rules that are as U.S. federal law defines DST.
274# Run `make -C time echo-zonenames' to see a list of available zone names.
275# This setting can be changed with `zic -p TIMEZONE' at any time.
276# If you want POSIX.1 compatibility, use `America/New_York'.
277ifndef posixrules
278posixrules = America/New_York
279endif
280
281# Where to install the "posixrules" timezone file; this is file
282# whose contents $(posixrules) specifies. If this is a relative
283# pathname, it is relative to $(zonedir).
284ifndef posixrules-file
285posixrules-file = posixrules
286endif
287
288
289# Directory where your system's native header files live.
290# This is used on Unix systems to generate some GNU libc header files.
291ifndef sysincludedir
292sysincludedir = /usr/include
293endif
294
295
296# Commands to install files.
297ifndef INSTALL_DATA
298INSTALL_DATA = $(INSTALL) -m 644
299endif
07627f49
UD
300ifndef INSTALL_SCRIPT
301INSTALL_SCRIPT = $(INSTALL)
302endif
28f540f4
RM
303ifndef INSTALL_PROGRAM
304INSTALL_PROGRAM = $(INSTALL)
305endif
306ifndef INSTALL
307INSTALL = install
308endif
309
310
311# The name of the C compiler.
312# If you've got GCC, and it works, use it.
313ifeq ($(origin CC),default)
314CC := gcc
315endif
316
317# The name of the C compiler to use for compilations of programs to run on
318# the host that is building the library. If you set CC to a
319# cross-compiler, you must set this to the normal compiler.
320ifndef BUILD_CC
321BUILD_CC = $(CC)
322endif
323
324# Default flags to pass the C compiler.
325ifndef default_cflags
1d5c2feb
UD
326ifeq ($(release),stable)
327default_cflags := -g -O2
328else
a8922de8 329default_cflags := -g -O
28f540f4 330endif
1d5c2feb 331endif
28f540f4
RM
332
333# Flags to pass the C compiler when assembling preprocessed assembly code
e4f5eae8 334# (`.S' files).
28f540f4
RM
335ifndef asm-CPPFLAGS
336asm-CPPFLAGS =
337endif
338
7e2b0c85
RM
339as-needed := -Wl,--as-needed
340no-as-needed := -Wl,--no-as-needed
7e2b0c85 341
3ce1f295
UD
342# Must be supported by the linker.
343no-whole-archive = -Wl,--no-whole-archive
344whole-archive = -Wl,--whole-archive
345
779ae82e 346# Installed name of the startup code.
26ecc33a 347# The ELF convention is that the startfile is called crt1.o
779ae82e 348start-installed-name = crt1.o
af09bfb5
RM
349# On systems that do not need a special startfile for statically linked
350# binaries, simply set it to the normal name.
351ifndef static-start-installed-name
352static-start-installed-name = $(start-installed-name)
353endif
779ae82e 354
0269750c 355ifeq (yesyes,$(build-shared)$(have-z-combreloc))
f13df7c7
UD
356combreloc-LDFLAGS = -Wl,-z,combreloc
357LDFLAGS.so += $(combreloc-LDFLAGS)
358LDFLAGS-rtld += $(combreloc-LDFLAGS)
359endif
360
1c563add
UD
361relro-LDFLAGS = -Wl,-z,relro
362LDFLAGS.so += $(relro-LDFLAGS)
363LDFLAGS-rtld += $(relro-LDFLAGS)
1c563add 364
871b9158
UD
365ifeq (yes,$(have-hash-style))
366# For the time being we unconditionally use 'both'. At some time we
367# should declare statically linked code as 'out of luck' and compile
368# with --hash-style=gnu only.
369hashstyle-LDFLAGS = -Wl,--hash-style=both
370LDFLAGS.so += $(hashstyle-LDFLAGS)
371LDFLAGS-rtld += $(hashstyle-LDFLAGS)
372endif
373
2d6ab5df
FW
374# If lazy relocations are disabled, add the -z now flag. Use
375# LDFLAGS-lib.so instead of LDFLAGS.so, to avoid adding the flag to
376# test modules.
377ifeq ($(bind-now),yes)
378LDFLAGS-lib.so += -Wl,-z,now
379endif
380
04f5a636
RM
381# Command to run after every final link (executable or shared object).
382# This is invoked with $(call after-link,...), so it should operate on
383# the file $1. This can be set to do some sort of post-processing on
384# binaries, or to perform some sort of static sanity check.
385ifndef after-link
386after-link =
387endif
388
c23de0aa
FW
389# Additional libraries to link into every test.
390link-extra-libs-tests = $(libsupport)
391
435aa54b
L
392# Command for linking PIE programs with the C library.
393ifndef +link-pie
740b3dbe
L
394+link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
395 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
435aa54b 396 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
34d6a3cb 397 $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \
435aa54b
L
398 $(+preinit) $(+prectorS) \
399 $(filter-out $(addprefix $(csu-objpfx),start.o \
da62f81b
AS
400 S$(start-installed-name))\
401 $(+preinit) $(link-extra-libs) \
402 $(common-objpfx)libc% $(+postinit),$^) \
740b3dbe
L
403 $(link-extra-libs)
404+link-pie-after-libc = $(+postctorS) $(+postinit)
04f5a636
RM
405define +link-pie
406$(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-pie-after-libc)
407$(call after-link,$@)
408endef
409define +link-pie-tests
76dcbf42
FW
410$(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
411 $(+link-pie-after-libc)
04f5a636
RM
412$(call after-link,$@)
413endef
23b5cae1
MG
414define +link-pie-printers-tests
415$(+link-pie-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
416 $(+link-pie-after-libc)
417$(call after-link,$@)
418endef
435aa54b 419endif
e1586792
UD
420# Command for statically linking programs with the C library.
421ifndef +link-static
95f5a9a8 422+link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
a67029ff 423 $(DEFAULT-LDFLAGS-$(@F)) \
9f0d7b6d 424 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
af09bfb5 425 $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
a5055ad1 426 $(+preinit) $(+prectorT) \
e1586792
UD
427 $(filter-out $(addprefix $(csu-objpfx),start.o \
428 $(start-installed-name))\
429 $(+preinit) $(link-extra-libs-static) \
430 $(common-objpfx)libc% $(+postinit),$^) \
d173d12e 431 $(link-extra-libs-static)
a5055ad1 432+link-static-after-libc = $(+postctorT) $(+postinit)
04f5a636
RM
433define +link-static
434$(+link-static-before-libc) $(link-libc-static) $(+link-static-after-libc)
435$(call after-link,$@)
436endef
437define +link-static-tests
76dcbf42 438$(+link-static-before-libc) $(link-libc-static-tests) $(+link-static-after-libc)
04f5a636
RM
439$(call after-link,$@)
440endef
e1586792 441endif
94b32c39
L
442# Commands for linking programs with the C library.
443ifndef +link
444ifeq (yes,$(build-shared))
cc08749b
L
445ifeq (yes,$(build-pie-default))
446no-pie-ldflag = -no-pie
447+link = $(+link-pie)
448+link-tests = $(+link-pie-tests)
23b5cae1
MG
449+link-printers-tests = $(+link-pie-printers-tests)
450else # not build-pie-default
94b32c39 451+link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
740b3dbe 452 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
94b32c39 453 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
6014c65d 454 $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
94b32c39
L
455 $(+preinit) $(+prector) \
456 $(filter-out $(addprefix $(csu-objpfx),start.o \
457 $(start-installed-name))\
458 $(+preinit) $(link-extra-libs) \
459 $(common-objpfx)libc% $(+postinit),$^) \
460 $(link-extra-libs)
461+link-after-libc = $(+postctor) $(+postinit)
04f5a636
RM
462define +link
463$(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) $(+link-after-libc)
464$(call after-link,$@)
465endef
466define +link-tests
76dcbf42
FW
467$(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
468 $(+link-after-libc)
04f5a636
RM
469$(call after-link,$@)
470endef
23b5cae1
MG
471define +link-printers-tests
472$(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
473 $(+link-after-libc)
474$(call after-link,$@)
475endef
476endif # build-pie-default
477else # build-static
94b32c39
L
478+link = $(+link-static)
479+link-tests = $(+link-static-tests)
23b5cae1
MG
480+link-printers-tests = $(+link-static-tests)
481endif # build-shared
482endif # +link
483
484# The pretty printer test programs need to be compiled without optimizations
485# so they won't confuse gdb. We could use either the 'GCC optimize' pragma
486# or the 'optimize' function attribute to achieve this; however, at least on
487# ARM, gcc always produces different debugging symbols when invoked with
488# a -O greater than 0 than when invoked with -O0, regardless of anything else
489# we're using to suppress optimizations. Therefore, we need to explicitly pass
490# -O0 to it through CFLAGS.
491# Additionally, the build system will try to -include $(common-objpfx)/config.h
492# when compiling the tests, which will throw an error if some special macros
493# (such as __OPTIMIZE__ and IS_IN_build) aren't defined. To avoid this, we
494# tell gcc to define IS_IN_build.
495CFLAGS-printers-tests := -O0 -ggdb3 -DIS_IN_build
496
0269750c 497ifeq (yes,$(build-shared))
23b5cae1
MG
498# These indicate whether to link using the built ld.so or the installed one.
499installed-rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
500built-rtld-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so
501
740b3dbe 502ifndef rtld-LDFLAGS
23b5cae1 503rtld-LDFLAGS = $(installed-rtld-LDFLAGS)
740b3dbe 504endif
23b5cae1 505
740b3dbe
L
506ifndef rtld-tests-LDFLAGS
507ifeq (yes,$(build-hardcoded-path-in-tests))
23b5cae1 508rtld-tests-LDFLAGS = $(built-rtld-LDFLAGS)
740b3dbe 509else
23b5cae1
MG
510rtld-tests-LDFLAGS = $(installed-rtld-LDFLAGS)
511endif # build-hardcoded-path-in-tests
512endif # rtld-tests-LDFLAGS
513
514endif # build-shared
515
3fe9de0d
RM
516ifndef link-libc
517ifeq (yes,$(build-shared))
aa1075ea
RM
518# We need the versioned name of libc.so in the deps of $(others) et al
519# so that the symlink to libc.so is created before anything tries to
520# run the linked programs.
23b5cae1 521link-libc-rpath = -Wl,-rpath=$(rpath-link)
740b3dbe 522link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link)
23b5cae1 523
740b3dbe 524ifeq (yes,$(build-hardcoded-path-in-tests))
23b5cae1 525link-libc-tests-rpath-link = $(link-libc-rpath)
740b3dbe
L
526else
527link-libc-tests-rpath-link = $(link-libc-rpath-link)
23b5cae1
MG
528endif # build-hardcoded-path-in-tests
529
740b3dbe
L
530link-libc-before-gnulib = $(common-objpfx)libc.so$(libc.so-version) \
531 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
4134b50d 532 $(as-needed) $(elf-objpfx)ld.so \
740b3dbe
L
533 $(no-as-needed)
534link-libc = $(link-libc-rpath-link) $(link-libc-before-gnulib) $(gnulib)
23b5cae1
MG
535
536link-libc-tests-after-rpath-link = $(link-libc-before-gnulib) $(gnulib-tests)
740b3dbe 537link-libc-tests = $(link-libc-tests-rpath-link) \
23b5cae1
MG
538 $(link-libc-tests-after-rpath-link)
539# Pretty printer test programs always require rpath instead of rpath-link.
540link-libc-printers-tests = $(link-libc-rpath) \
541 $(link-libc-tests-after-rpath-link)
542
4d6acc61 543# This is how to find at build-time things that will be installed there.
c23de0aa 544rpath-dirs = math elf dlfcn nss nis rt resolv crypt mathvec support
e72bfd87
UD
545rpath-link = \
546$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
23b5cae1 547else # build-static
4ac5087b 548link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
95f5a9a8 549link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
23b5cae1
MG
550endif # build-shared
551endif # link-libc
900bec85 552
ad10cac8 553# Differences in the linkers on the various platforms.
ad10cac8
UD
554LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
555LDFLAGS-soname-fname = -Wl,-soname,$(@F)
556LDFLAGS-rdynamic = -rdynamic
557LDFLAGS-Bsymbolic = -Bsymbolic
ad10cac8 558
f01010de
UD
559# Choose the default search path for the dynamic linker based on
560# where we will install libraries.
561ifneq ($(libdir),$(slibdir))
562default-rpath = $(slibdir):$(libdir)
563else
564default-rpath = $(libdir)
565endif
566
57ba7bb4 567ifndef link-extra-libs
1d038b6b
RM
568link-extra-libs = $(LDLIBS-$(@F))
569link-extra-libs-static = $(link-extra-libs)
57ba7bb4 570endif
e1586792
UD
571
572# The static libraries.
b9af1301 573link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
95f5a9a8 574link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
e1586792 575
95f5a9a8
JM
576# How to link against libgcc. Some libgcc functions, such as those
577# for "long long" arithmetic or software floating point, can always be
578# built without use of C library headers and do not have any global
579# state so can safely be linked statically into any executable or
580# shared library requiring them; these functions are in libgcc.a.
581# Other functions, relating to exception handling, may require C
582# library headers to build and it may not be safe to have more than
583# one copy of them in a process; these functions are only in
584# libgcc_s.so and libgcc_eh.a.
585#
586# To avoid circular dependencies when bootstrapping, it is desirable
587# to avoid use of libgcc_s and libgcc_eh in building glibc. Where any
588# glibc functionality (in particular, thread cancellation) requires
589# exception handling, this is implemented through dlopen of libgcc_s
590# to avoid unnecessary dependencies on libgcc_s by programs not using
591# that functionality; executables built with glibc do not use
592# exception handling other than through thread cancellation.
593#
594# Undefined references to functions from libgcc_eh or libgcc_s may
595# arise for code built with -fexceptions. In the case of statically
596# linked programs installed by glibc, unwinding will never actually
597# occur at runtime and the use of elf/static-stubs.c to resolve these
598# references is safe. In the case of statically linked test programs
599# and test programs built with -fexceptions, unwinding may occur in
600# some cases and it is preferable to link with libgcc_eh or libgcc_s
601# so that the testing is as similar as possible to how programs will
602# be built with the installed glibc.
603#
604# Some architectures have architecture-specific systems for exception
605# handling that may involve undefined references to
606# architecture-specific functions. On those architectures,
607# gnulib-arch and static-gnulib-arch may be defined in sysdeps
608# makefiles to use additional libraries for linking executables and
609# shared libraries built by glibc.
28f540f4 610ifndef gnulib
cbdb12de
UD
611ifneq ($(have-cc-with-libunwind),yes)
612 libunwind =
feca5e0b 613else
cbdb12de 614 libunwind = -lunwind
feca5e0b 615endif
a3cc4f48 616libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
95f5a9a8
JM
617gnulib-arch =
618gnulib = -lgcc $(gnulib-arch)
619gnulib-tests := -lgcc $(libgcc_eh)
620static-gnulib-arch =
94b32c39
L
621# By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
622# statically link programs. When --disable-shared is used, we use
623# -lgcc_eh since elf/static-stubs.o isn't sufficient.
624ifeq (yes,$(build-shared))
95f5a9a8 625static-gnulib = -lgcc $(static-gnulib-arch)
94b32c39
L
626else
627static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch)
628endif
95f5a9a8 629static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
cbdb12de 630libc.so-gnulib := -lgcc
28f540f4 631endif
e75154a6
RM
632+preinit = $(addprefix $(csu-objpfx),crti.o)
633+postinit = $(addprefix $(csu-objpfx),crtn.o)
35e65999
RA
634+prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
635+postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
435aa54b 636# Variants of the two previous definitions for linking PIE programs.
35e65999
RA
637+prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
638+postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
a5055ad1
L
639# Variants of the two previous definitions for statically linking programs.
640+prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
189e935b 641+postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
6e953631
UD
642csu-objpfx = $(common-objpfx)csu/
643elf-objpfx = $(common-objpfx)elf/
28f540f4 644
cc1290d0
JM
645# A command that, prepended to the name and arguments of a program,
646# and run on the build system, causes that program with those
647# arguments to be run on the host for which the library is built.
648ifndef test-wrapper
649test-wrapper =
650endif
651# Likewise, but the name of the program is preceded by
652# <variable>=<value> assignments for environment variables.
653ifndef test-wrapper-env
654test-wrapper-env = $(test-wrapper) env
655endif
9162c01d
RM
656# Likewise, but the program's environment will be empty except for any
657# explicit <variable>=<value> assignments preceding the program name.
658ifndef test-wrapper-env-only
659test-wrapper-env-only = $(test-wrapper) env -i
660endif
cc1290d0 661
03ac099f
JM
662# Whether to run test programs built for the library's host system.
663ifndef run-built-tests
cc1290d0 664ifeq (yes|,$(cross-compiling)|$(test-wrapper))
03ac099f
JM
665run-built-tests = no
666else
667run-built-tests = yes
668endif
669endif
670
d6fe5e58
JM
671# Whether to stop immediately when a test fails. Nonempty means to
672# stop, empty means not to stop.
673ifndef stop-on-test-failure
674stop-on-test-failure =
675endif
676
03a75825
RM
677# How to run a program we just linked with our library.
678# The program binary is assumed to be $(word 2,$^).
679built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
01dc6df9
SP
680rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
681 --library-path \
682 $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
0269750c 683ifeq (yes,$(build-shared))
196980f5 684comma = ,
11336c16
UD
685sysdep-library-path = \
686$(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
687 $(filter -Wl$(comma)-rpath-link=%,\
688 $(sysdep-LDFLAGS)))))
88866099
JM
689# $(run-via-rtld-prefix) is a command that, when prepended to the name
690# of a program built with the newly built library, produces a command
691# that, executed on the host for which the library is built, runs that
daaa7713
JM
692# program. For tests listed in tests-static or xtests-static, it is
693# empty.
88866099
JM
694run-via-rtld-prefix = \
695 $(if $(strip $(filter $(notdir $(built-program-file)), \
01dc6df9 696 $(tests-static) $(xtests-static))),, $(rtld-prefix))
8658ceda 697else
88866099
JM
698run-via-rtld-prefix =
699endif
8540f6d2
JM
700# $(run-program-env) is the default environment variable settings to
701# use when running a program built with the newly built library.
702run-program-env = GCONV_PATH=$(common-objpfx)iconvdata \
703 LOCPATH=$(common-objpfx)localedata LC_ALL=C
25fe8932 704# $(run-program-prefix) is a command that, when prepended to the name
88866099
JM
705# of a program built with the newly built library, produces a command
706# that, executed on the build system on which "make" is run, runs that
8540f6d2
JM
707# program. $(run-program-prefix-before-env) and
708# $(run-program-prefix-after-env) are similar, but separate parts
709# before and after a list of environment variables.
710run-program-prefix-before-env = $(test-wrapper-env)
711run-program-prefix-after-env = $(run-via-rtld-prefix)
712run-program-prefix = $(run-program-prefix-before-env) $(run-program-env) \
713 $(run-program-prefix-after-env)
88866099
JM
714# $(built-program-cmd) is a command that, executed on the build system
715# on which "make" is run, runs the newly built program that is the
716# second dependency of the makefile target in which
8540f6d2
JM
717# $(built-program-cmd) is used. $(built-program-cmd-before-env) and
718# $(built-program-cmd-after-env) are similar, before and after a list
719# of environment variables.
720built-program-cmd-before-env = $(test-wrapper-env)
721built-program-cmd-after-env = $(run-via-rtld-prefix) $(built-program-file)
722built-program-cmd = $(built-program-cmd-before-env) $(run-program-env) \
723 $(built-program-cmd-after-env)
166bca24
JB
724# $(host-built-program-cmd) is a command that, executed on the host
725# for which the library is built, runs the newly built program that is
726# the second dependency of the makefile target in which
727# $(host-built-program-cmd) is used.
728host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file)
03a75825 729
28f540f4
RM
730ifndef LD
731LD := ld -X
732endif
733
740b3dbe
L
734# $(test-via-rtld-prefix) is a command that, when prepended to the name
735# of a test program built with the newly built library, produces a command
736# that, executed on the host for which the library is built, runs that
daaa7713
JM
737# program. For tests listed in tests-static or xtests-static as well
738# as when test programs are hardcoded to the newly built libraries, it
739# is empty.
740b3dbe
L
740
741# $(test-program-prefix) is a command that, when prepended to the name
742# of a test program built with the newly built library, produces a command
743# that, executed on the build system on which "make" is run, runs that
8540f6d2
JM
744# test program. $(test-program-prefix-before-env) and
745# $(test-program-prefix-after-env) are similar, before and after a
746# list of environment variables.
740b3dbe
L
747
748# $(test-program-cmd) is a command that, executed on the build system
749# on which "make" is run, runs the newly built test program that is the
750# second dependency of the makefile target in which
8540f6d2
JM
751# $(test-program-cmd) is used. $(test-program-cmd-before-env) and
752# $(test-program-cmd-after-env) are similar, before and after a list
753# of environment variables.
740b3dbe
L
754
755# $(host-test-program-cmd) is a command that, executed on the host
756# for which the library is built, runs the newly built test program that
757# is the second dependency of the makefile target in which
758# $(host-test-program-cmd) is used.
759
760ifeq (yes,$(build-hardcoded-path-in-tests))
761test-via-rtld-prefix =
8540f6d2
JM
762test-program-prefix-before-env = $(test-wrapper-env)
763test-program-prefix-after-env =
764test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \
765 $(test-program-prefix-after-env)
766test-program-cmd-before-env = $(test-wrapper-env)
767test-program-cmd-after-env = $(built-program-file)
768test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \
769 $(test-program-cmd-after-env)
740b3dbe
L
770host-test-program-cmd = $(built-program-file)
771else
772test-via-rtld-prefix = $(run-via-rtld-prefix)
8540f6d2
JM
773test-program-prefix-before-env = $(run-program-prefix-before-env)
774test-program-prefix-after-env = $(run-program-prefix-after-env)
740b3dbe 775test-program-prefix = $(run-program-prefix)
8540f6d2
JM
776test-program-cmd-before-env = $(built-program-cmd-before-env)
777test-program-cmd-after-env = $(built-program-cmd-after-env)
740b3dbe
L
778test-program-cmd = $(built-program-cmd)
779host-test-program-cmd = $(host-built-program-cmd)
780endif
781
28f540f4 782# Extra flags to pass to GCC.
6cc7d725 783ifeq ($(all-warnings),yes)
ed159672 784+gccwarn := -Wall -Wwrite-strings -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
6cc7d725 785else
ed159672 786+gccwarn := -Wall -Wwrite-strings
6cc7d725 787endif
498a2233 788+gccwarn += -Wundef
a4ecc9eb 789ifeq ($(enable-werror),yes)
48bb14bd 790+gccwarn += -Werror
a4ecc9eb 791endif
8e2f7c68 792+gccwarn-c = -Wstrict-prototypes -Wold-style-definition
28f540f4 793
dec36b4f
UD
794# We do not depend on the address of constants in different files to be
795# actually different, so allow the compiler to merge them all.
796+merge-constants = -fmerge-all-constants
797
29ba805c
AJ
798# We have to assume that glibc functions are called in any rounding
799# mode and also change the rounding mode in a few functions. So,
800# disable any optimization that assume default rounding mode.
801+math-flags = -frounding-math
802
cecbc796
NA
803# We might want to compile with some stack-protection flag.
804ifneq ($(stack-protector),)
805+stack-protector=$(stack-protector)
806endif
807
30077d51
RM
808# This is the program that generates makefile dependencies from C source files.
809# The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
810# targets for headers so that removed headers don't break the build.
28f540f4 811ifndef +mkdep
30077d51 812+mkdep = $(CC) -M -MP
28f540f4
RM
813endif
814
815# The program that makes Emacs-style TAGS files.
78759725 816ETAGS := etags
28f540f4 817
9de06f3c
RM
818# The `xgettext' program for producing .pot files from sources.
819ifndef XGETTEXT
820XGETTEXT = xgettext
821endif
822
28f540f4
RM
823# The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
824# perhaps others) to preprocess assembly code in some cases.
825M4 = m4
826
73237de3
UD
827# To force installation of files even if they are older than the
828# installed files. This variable is included in the dependency list
829# of all installation targets.
830ifeq ($(force-install),yes)
831+force = force-install
832else
833+force =
834endif
835
28f540f4
RM
836####
837#### End of configuration variables.
838####
839\f
840# This tells some versions of GNU make before 3.63 not to export all variables.
841.NOEXPORT:
842
843# We want to echo the commands we're running without
6d52618b 844# umpteen zillion filenames along with it (we use `...' instead)
28f540f4
RM
845# but we don't want this echoing done when the user has said
846# he doesn't want to see commands echoed by using -s.
847ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
848+cmdecho := echo >/dev/null
849else # not -s
850+cmdecho := echo
851endif # -s
852
853# These are the flags given to the compiler to tell
854# it what sort of optimization and/or debugging output to do.
855ifndef +cflags
856# If `CFLAGS' was defined, use that.
857ifdef CFLAGS
858+cflags := $(filter-out -I%,$(CFLAGS))
859endif # CFLAGS
860endif # +cflags
861
fd26970f 862# If none of the above worked, default to "-g -O".
28f540f4
RM
863ifeq "$(strip $(+cflags))" ""
864+cflags := $(default_cflags)
865endif # $(+cflags) == ""
866
cecbc796
NA
867+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \
868 $(+stack-protector)
28f540f4 869+gcc-nowarn := -w
28f540f4
RM
870
871# Don't duplicate options if we inherited variables from the parent.
872+cflags := $(sort $(+cflags))
873
b84660a8
RM
874# Each sysdeps directory can contain header files that both will be
875# used to compile and will be installed. Each can also contain an
876# include/ subdirectory, whose header files will be used to compile
877# but will not be installed, and will take precedence over the
878# installed files. This mirrors the top-level include/ subdirectory.
879+sysdep-includes := $(foreach dir,$(+sysdep_dirs),\
880 $(addprefix -I,$(wildcard $(dir)/include) $(dir)))
881
b6ab06ce
UD
882# These are flags given to the C compiler to tell it to look for
883# include files (including ones given in angle brackets) in the parent
884# library source directory, in the include directory, and in the
885# current directory.
e0a3ed4f 886+includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
4ae73ca0
RM
887 $(+sysdep-includes) $(includes) \
888 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
28f540f4 889
96aa2d94 890# Since libio has several internal header files, we use a -I instead
762a2918 891# of many little headers in the include directory.
96aa2d94 892libio-include = -I$(..)libio
28f540f4 893
130ac68c
SP
894# List of non-library modules that we build.
895built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
896 libSegFault libpcprofile librpcsvc locale-programs \
7c3018f9
ZW
897 memusagestat nonlib nscd extramodules libnldbl libsupport \
898 testsuite
130ac68c 899
9cd47470
SP
900in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
901 $(libof-$(<F)) \
902 $(libof-$(@F)) \
903 libc))
904
e400f3cc
SP
905# Build ld.so, libc.so and libpthread.so with -ftls-model=initial-exec
906tls-model = $(if $(filter libpthread rtld \
907 libc,$(in-module)),-ftls-model=initial-exec,)
908
130ac68c 909module-cppflags-real = -include $(common-objpfx)libc-modules.h \
279bc5b3 910 -DMODULE_NAME=$(in-module)
130ac68c 911
8a257e2c
RM
912# We don't need libc-modules.h and the MODULE_NAME definition for .v.i
913# files. These targets don't (and will likely never need to) use the IS_IN
914# facility. In fact, shlib-versions should not use it because that will
915# create a circular dependency as libc-modules.h is generated from
916# shlib-versions.
917module-cppflags = $(if $(filter %.v.i,$(@F)),,$(module-cppflags-real))
130ac68c 918
28f540f4 919# These are the variables that the implicit compilation rules use.
ce460d04
RM
920# Note that we can't use -std=* in CPPFLAGS, because it overrides
921# the implicit -lang-asm and breaks cpp behavior for .S files--notably
922# it causes cpp to stop predefining __ASSEMBLER__.
7ffa9423
AZ
923CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
924 $($(subdir)-CPPFLAGS) \
130ac68c 925 $(+includes) $(defines) $(module-cppflags) \
ae8b36f7 926 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
130ac68c 927 $(CPPFLAGS-$(suffix $@)) \
d29724f8 928 $(foreach lib,$(libof-$(basename $(@F))) \
bc96fbda 929 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
0a951d0e 930 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
67e58f39 931
6765d5d3 932ifneq (no,$(have-tunables))
67e58f39
SP
933CPPFLAGS += -DTOP_NAMESPACE=glibc
934endif
935
783dd2d3 936override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
7735afa2
UD
937 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
938 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
e400f3cc 939 $(CFLAGS-$(@F)) $(tls-model) \
44f0a71e
UD
940 $(foreach lib,$(libof-$(basename $(@F))) \
941 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
83212868
L
942# Use our copies of cstdlib and cmath.
943override CXXFLAGS = -I$(common-objpfx) $(c++-sysincludes) \
ef226fec 944 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
7735afa2 945 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
28f540f4 946
cc3fa755
UD
947# If everything is compiled with -fPIC (implicitly) we must tell this by
948# defining the PIC symbol.
949ifeq (yes,$(build-pic-default))
950pic-default = -DPIC
951endif
952
f0bf9cb9
RM
953# Enable object files for different versions of the library.
954# Various things use $(object-suffixes) to know what all to make.
955# The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
956# to pass different flags for each flavor.
91641c65 957libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
612148c6
FW
958# .op may be added to all-object-suffixes below.
959all-object-suffixes := .o .os .oS
650425ce 960object-suffixes :=
cc3fa755 961CPPFLAGS-.o = $(pic-default)
14e9dd67 962CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
f0bf9cb9 963libtype.o := lib%.a
650425ce 964object-suffixes += .o
f0bf9cb9
RM
965ifeq (yes,$(build-shared))
966# Under --enable-shared, we will build a shared library of PIC objects.
40a55d20
UD
967# The PIC object files are named foo.os.
968object-suffixes += .os
b5567b2a 969CPPFLAGS-.os = -DPIC -DSHARED
14e9dd67 970CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
40a55d20 971libtype.os := lib%_pic.a
26b4d766
UD
972# This can be changed by a sysdep makefile
973pic-ccflag = -fPIC
231e88a4
UD
974# This one should always stay like this unless there is a very good reason.
975PIC-ccflag = -fPIC
f0bf9cb9 976endif
7b91359b
UD
977# This can be changed by a sysdep makefile
978pie-ccflag = -fpie
979# This one should always stay like this unless there is a very good reason.
980PIE-ccflag = -fPIE
f0bf9cb9
RM
981ifeq (yes,$(build-profile))
982# Under --enable-profile, we will build a static library of profiled objects.
40a55d20 983# The profiled object files are named foo.op.
612148c6 984all-object-suffixes += .op
40a55d20 985object-suffixes += .op
cc3fa755 986CPPFLAGS-.op = -DPROF $(pic-default)
40a55d20
UD
987CFLAGS-.op = -pg
988libtype.op = lib%_p.a
f0bf9cb9 989endif
ab95290c 990
c1487492
RM
991# Convenience variable for when we want to treat shared-library cases
992# differently from the rest.
993object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
994
9afc8a59
UD
995object-suffixes-for-libc := $(object-suffixes)
996
997ifeq (yes,$(build-shared))
998# Build special library that contains the static-only routines for libc.
999object-suffixes-for-libc += .oS
1000
1001# Must build the routines as PIC, though, because they can end up in (users')
1002# shared objects. We don't want to use CFLAGS-os because users may, for
1003# example, make that processor-specific.
231e88a4 1004CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
06b31ad3 1005CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
9afc8a59
UD
1006libtype.oS = lib%_nonshared.a
1007endif
1008
073e82bf
RM
1009# The assembler can generate debug information too.
1010ifndef ASFLAGS
2e7c805d 1011ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
073e82bf 1012endif
96a15749 1013ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
9afc8a59 1014
96bda0ea
RM
1015ifndef BUILD_CC
1016BUILD_CC = $(CC)
1017endif
e72bfd87
UD
1018
1019move-if-change = $(SHELL) $(..)scripts/move-if-change
a641835a 1020\f
281e6031
UD
1021-include $(common-objpfx)sysd-sorted
1022subdirs = $(sorted-subdirs)
e0a3ed4f
RM
1023subdir-srcdirs = $(foreach dir,$(subdirs),\
1024 $(firstword $($(dir)-srcdir) $(..)$(dir)))
9a0a462c 1025
f3787738
RM
1026# This is a pair of implicit rules to preprocess a file with # comments,
1027# %ifdef et al, based on config.h settings or other %include'd files.
1028# We use chained rules instead of a pipeline here so that we can properly
1029# check the exit status of cpp rather than using its bad output when there
1030# is a preprocessing error. Another rule should depend on the output file
1031# `FOO.v', and along with that `FOO.v.i' should be given dependencies
1032# listing both its input files, and any header files that it may reference
1033# (but no commands).
8744841f
RM
1034%.v.i: $(common-objpfx)config.h $(..)Makeconfig
1035 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
90f42071 1036 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
02838201 1037 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
f3787738
RM
1038 > $@T
1039 mv -f $@T $@
1040%.v: %.v.i
1041 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
1042 mv -f $@T $@
480d827b 1043
7e80ddb8
RM
1044ifeq (yes, $(build-shared))
1045
0ab0291b
L
1046# To generate a header to support more than one ABI for different
1047# architecture variants, the CPU/Makefile defines abi-variants to be a
1048# list of names for those variants (e.g. 32 64), and, for each variant,
1049# defines abi-$(variant)-condition to be the condition for those options
1050# to use in a C #if condition. abi-includes may be defined to a list of
1051# headers to include in the generated header, if the default does not
88a4576f
JM
1052# suffice. default-abi is defined to be the ABI for the current glibc
1053# build.
0ab0291b
L
1054
1055ifndef abi-includes
1056abi-includes := bits/wordsize.h
1057endif
1058
4de1d597
RM
1059# Process the shlib-versions file, which tells us what shared library
1060# version numbers to use when we install shared objects on this system.
281e6031
UD
1061# We need to wait until $(subdirs) is complete.
1062ifeq ($(sysd-sorted-done),t)
4de1d597 1063-include $(common-objpfx)soversions.mk
eca3eb3b 1064ifndef avoid-generated
f3787738 1065$(common-objpfx)shlib-versions.v.i: \
e0a3ed4f
RM
1066 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
1067 $(subdir-srcdirs:=/shlib-versions)) \
9632aaee 1068 $(..)shlib-versions
6d864d15 1069
6d864d15
RM
1070$(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
1071 $(common-objpfx)shlib-versions.v
af296fcd 1072 $(AWK) -f $^ > $@T
ba7e89ec 1073 mv -f $@T $@
3e1e123d 1074$(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
0ab0291b 1075 (while read which lib number setname; do \
3e1e123d 1076 eval seen_$$which=1; \
91adb529 1077 test x"$$which" = xDEFAULT || continue; \
1bc777b8
UD
1078 case $$number in \
1079 [0-9]*) echo "$$lib.so-version=.$$number"; \
1080 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
93ae1eba 1081 *) echo "$$lib.so-version=$$number"; \
1bc777b8
UD
1082 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
1083 esac; \
1084 done; \
1085 echo soversions.mk-done = t;) < $< > $@T; exit 0
4de1d597 1086 mv -f $@T $@
eca3eb3b 1087endif
281e6031 1088endif
eca3eb3b 1089
f3787738
RM
1090postclean-generated += soversions.mk soversions.i \
1091 shlib-versions.v shlib-versions.v.i
4de1d597 1092
130ac68c 1093before-compile += $(common-objpfx)libc-modules.h
65b6d8b7 1094common-generated += libc-modules.h libc-modules.stmp
130ac68c
SP
1095ifeq ($(soversions.mk-done),t)
1096# Generate a header with macro definitions for use with the IS_IN macro.
279bc5b3 1097# These are the possible values for the MODULE_NAME macro defined when building
130ac68c
SP
1098# sources, to identify which module the translation unit is going to be built
1099# into.
1100$(common-objpfx)libc-modules.h: $(common-objpfx)libc-modules.stmp; @:
1101$(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \
1102 $(common-objpfx)soversions.i
1103 $(AWK) -v buildlist="$(subst -,_,$(built-modules))" -f $^ > ${@:stmp=T}
1104 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
1105 touch $@
1106
1107endif
1108
67e58f39
SP
1109# Build the tunables list header early since it could be used by any module in
1110# glibc.
6765d5d3 1111ifneq (no,$(have-tunables))
67e58f39 1112before-compile += $(common-objpfx)dl-tunable-list.h
65b6d8b7
ZW
1113common-generated += dl-tunable-list.h dl-tunable-list.stmp
1114
1115$(common-objpfx)dl-tunable-list.h: $(common-objpfx)dl-tunable-list.stmp; @:
1116$(common-objpfx)dl-tunable-list.stmp: \
1117 $(..)scripts/gen-tunables.awk \
1118 $(..)elf/dl-tunables.list \
1119 $(wildcard $(subdirs:%=$(..)%/dl-tunables.list)) \
1120 $(wildcard $(sysdirs:%=%/dl-tunables.list))
1121 $(AWK) -f $^ > ${@:stmp=T}
1122 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
1123 touch $@
67e58f39
SP
1124endif
1125
d41c6f61
UD
1126# The name under which the run-time dynamic linker is installed.
1127# We are currently going for the convention that `/lib/ld.so.1'
1128# names the SVR4/ELF ABI-compliant dynamic linker.
1129ifndef rtld-installed-name
1130ifdef ld.so-version
1131rtld-installed-name = $(ld.so-version)
1132else
1133rtld-installed-name = ld.so.1
1134endif
1135endif
1136
1ef32c3d
UD
1137ifndef rtld-version-installed-name
1138rtld-version-installed-name = ld-$(version).so
1139endif
1140
f649c201
UD
1141endif # build-shared
1142
cbdee279 1143
94e365c6
UD
1144ifeq ($(build-shared),yes)
1145libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
1146else
1147libdl = $(common-objpfx)dlfcn/libdl.a
1148endif
94e365c6 1149
6ee65ed6
UD
1150ifeq ($(build-shared),yes)
1151libm = $(common-objpfx)math/libm.so$(libm.so-version)
5695d46f 1152libmvec = $(common-objpfx)mathvec/libmvec.so$(libmvec.so-version)
6ee65ed6
UD
1153else
1154libm = $(common-objpfx)math/libm.a
5695d46f 1155libmvec = $(common-objpfx)mathvec/libmvec.a
6ee65ed6
UD
1156endif
1157
c23de0aa
FW
1158ifeq ($(build-shared),yes)
1159libsupport = $(common-objpfx)support/libsupport_nonshared.a
1160else
1161libsupport = $(common-objpfx)support/libsupport.a
1162endif
1163
bb41a976
UD
1164# These are the subdirectories containing the library source. The order
1165# is more or less arbitrary. The sorting step will take care of the
e0a3ed4f 1166# dependencies.
8d6f1731 1167all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
e0a3ed4f 1168 stdlib stdio-common libio malloc string wcsmbs time dirent \
b0b67c47 1169 grp pwd posix io termios resource misc socket sysvipc gmon \
829fea46 1170 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
c23de0aa 1171 crypt localedata timezone rt conform debug mathvec support \
644d3857 1172 dlfcn elf
b22fc5f5 1173
b7e2d9a5 1174ifndef avoid-generated
7bd642f5
RM
1175# sysd-sorted itself will contain rules making the sysd-sorted target
1176# depend on Depend files. But if you just added a Depend file to an
1177# existing directory not in all-subdirs, then sysd-sorted needs to
1178# be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files.
1179all-Depend-files := $(wildcard $(sort \
95afbbe5 1180 $(foreach dir,$(all-subdirs),\
7bd642f5
RM
1181 $(firstword $($(dir)-srcdir) \
1182 $(..)$(dir))/Depend) \
1183 $(sorted-subdirs:=/Depend)))
e0a3ed4f
RM
1184$(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
1185 $(common-objpfx)config.make $(..)Makeconfig \
1186 $(wildcard $(sysdirs:=/Subdirs)) \
1187 $(all-Depend-files)
1188 $(AWK) -f $< \
1189 -v subdirs='$(all-subdirs)' \
1190 -v srcpfx='$(..)' \
1191 $(filter %/Subdirs %/Depend,$^) > $@-tmp
bb41a976 1192 mv -f $@-tmp $@
9de06f3c 1193$(all-Depend-files): ;
b7e2d9a5 1194endif
bb41a976 1195
16cd816f
RM
1196# This gives partial TARGET:SOURCE pattern pairs to have rules
1197# emitted into sysd-rules. A sysdeps Makeconfig fragment can
1198# add its own special object file prefix to this list with e.g. foo-%:%
1199# to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
bc96fbda 1200sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
16cd816f 1201
083973f3 1202# Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
e0a3ed4f 1203sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
083973f3 1204ifneq (,$(sysdep-makeconfigs))
e0a3ed4f 1205include $(sysdep-makeconfigs)
083973f3
RM
1206endif
1207
363a641b 1208# Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
bc96fbda
AS
1209sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
1210 $(firstword $(subst :, ,$p))))
083973f3 1211
c75ccd4c
RM
1212# A sysdeps Makeconfig fragment may set libc-reentrant to yes.
1213ifeq (yes,$(libc-reentrant))
1214defines += -D_LIBC_REENTRANT
1215
1216libio-mtsafe = -D_IO_MTSAFE_IO
1217endif
1218
591aeaf7
TD
1219# The name to give to a test in test results summaries.
1220test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@)))
1221
54ee292d
JM
1222# Likewise, in XFAIL variable names.
1223test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@)))
1224
f8c17e79 1225# Command to output a test status line (such as PASS: test-name). If
54ee292d 1226# test-xfail-$(test-xfail-name) has a nonempty value, the status will be
f8c17e79 1227# XPASS or XFAIL rather than PASS or FAIL.
591aeaf7 1228evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \
54ee292d 1229 $(if $(test-xfail-$(test-xfail-name)),true,false) \
d6fe5e58 1230 $(if $(stop-on-test-failure),true,false) \
591aeaf7
TD
1231 > $(common-objpfx)$(test-name).test-result
1232
28f540f4 1233endif # Makeconfig not yet included
c238ecf7
UD
1234
1235# Local Variables:
1236# mode: makefile
1237# End: