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