]> git.ipfire.org Git - thirdparty/glibc.git/blame - Makeconfig
Fix float range reduction problems (bug 14283).
[thirdparty/glibc.git] / Makeconfig
CommitLineData
bdeba135 1# Copyright (C) 1991-2003,2004,2005,2006,2007,2008,2009,2010,2011,2012
16cd816f 2# Free Software Foundation, Inc.
28f540f4
RM
3# This file is part of the GNU C Library.
4
5# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
28f540f4
RM
9
10# The GNU C Library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 13# Lesser General Public License for more details.
28f540f4 14
41bdb6e2 15# You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16# License along with the GNU C Library; if not, see
17# <http://www.gnu.org/licenses/>.
28f540f4
RM
18
19#
20# Makefile configuration options for the GNU C library.
21#
22ifneq (,)
23This makefile requires GNU Make.
24endif
25
3e5f5557
UD
26all: # Make this the default goal
27
28f540f4
RM
28ifneq "$(origin +included-Makeconfig)" "file"
29
30+included-Makeconfig := yes
31
32ifdef subdir
33.. := ../
34endif
35
36# If config.make exists, the source directory was configured,
37# so don't try to be clever and find another directory to build in.
38ifneq (,$(wildcard $(..)config.make))
39ARCH =
40machine =
41else # Not configured.
42ifndef ARCH
43ifdef machine
44ARCH = $(machine)
45endif # machine
46endif # ARCH
47endif # config.make
48
49# Directory for object files and libc.a. If this is not defined, the
50# object files live in the subdirectories where their sources live, and
51# libc.a lives in the parent directory (this probably doesn't work any
52# more).
53ifdef ARCH
54ifeq ($(filter /%,$(ARCH)),)
55objdir := $(..)$(ARCH)
56else
57objdir = $(ARCH)
58endif
59endif
60
094bacdb 61# $(common-objdir) is the place to put objects and
28f540f4
RM
62# such that are not specific to a single subdir.
63ifdef objdir
6e953631
UD
64objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
65common-objpfx = $(objdir)/
28f540f4
RM
66common-objdir = $(objdir)
67else
68objpfx :=
69ifdef ..
70common-objpfx = $(..)
71common-objdir = ..
72else
73# This is a kludge. make wizards might grok.
74common-objpfx = sysdeps/../
75common-objdir = .
76endif
77endif
78
f332db02
RM
79# Root of the sysdeps tree.
80sysdep_dir := $(..)sysdeps
81export sysdep_dir := $(sysdep_dir)
82
28f540f4
RM
83# Get the values defined by options to `configure'.
84include $(common-objpfx)config.make
85
e07bb02a
UD
86# What flags to give to sources which call user provided callbacks
87uses-callbacks = $(exceptions)
88
a4db3439
UD
89# What flags to give to tests which test stack alignment
90stack-align-test-flags =
91
0501d603
UD
92# We have a special subdir for each binary format.
93# For now, only ELF is fully supported.
0501d603 94binfmt-subdir = elf
0501d603 95
57ba7bb4 96# Complete path to sysdep dirs.
e0a3ed4f
RM
97# `configure' writes a definition of `config-sysdirs' in `config.make'.
98sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
99
100# Add-ons that contribute sysdeps trees get added to the include list
101# after sysdeps/generic. This makes #include <sysdeps/...> work right
102# to find specific add-on files without assuming the add-on directory name.
103# It also means that headers can go into an add-on's base directory
104# instead of the add-on needing a sysdeps/generic of its own.
04dca8d3
RM
105sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\
106 $(firstword $(filter /%,$(add-on)) \
107 $(..)$(add-on)))
108+sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs)
e0a3ed4f
RM
109ifdef objdir
110+sysdep_dirs := $(objdir) $(+sysdep_dirs)
111endif
57ba7bb4 112
273d56ce
RM
113# Run config.status to update config.make and config.h. We don't show the
114# dependence of config.h to Make, because it is only touched when it
115# changes and so config.status would be run every time; the dependence of
116# config.make should suffice to force regeneration and re-exec, and the new
117# image will notice if config.h changed.
19361cb7
UD
118$(common-objpfx)config.make: $(common-objpfx)config.status \
119 $(..)config.make.in $(..)config.h.in
273d56ce
RM
120 cd $(<D); $(SHELL) $(<F)
121
8f73811b
RM
122# Find all the add-on and sysdeps configure fragments, to make sure we
123# re-run configure when any of them changes.
5290baf0 124$(common-objpfx)config.status: $(..)version.h $(..)configure \
e0a3ed4f
RM
125 $(foreach dir,$(sysdirs),\
126 $(wildcard $(dir)/Implies) \
f332db02
RM
127 $(patsubst %.in,%,\
128 $(firstword $(wildcard \
8f73811b
RM
129 $(addprefix $(dir)/,configure configure.in))))) \
130 $(patsubst %.in,%,\
e0a3ed4f 131 $(foreach add-on,$(add-ons),\
8f73811b 132 $(firstword $(wildcard \
e0a3ed4f
RM
133 $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
134 configure configure.in)))))
273d56ce
RM
135 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
136 echo The GNU C library has not been configured. >&2; \
137 echo Run \`configure\' to configure it before building. >&2; \
138 echo Try \`configure --help\' for more details. >&2; \
139 exit 1; fi
28f540f4 140
74015205
UD
141# We don't want CPPFLAGS to be exported to the command running configure.
142unexport CPPFLAGS
143
28f540f4
RM
144# Get the user's configuration parameters.
145ifneq ($(wildcard $(..)configparms),)
146include $(..)configparms
147endif
148ifneq ($(objpfx),)
6e953631
UD
149ifneq ($(wildcard $(common-objpfx)configparms),)
150include $(common-objpfx)configparms
28f540f4
RM
151endif
152endif
28f540f4
RM
153\f
154####
155#### These are the configuration variables. You can define values for
156#### the variables below in the file `configparms'.
157#### Do NOT edit this file.
158####
159
160
161# Common prefix for machine-independent installation directories.
487253ea 162ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
28f540f4
RM
163prefix = /usr/local
164endif
165
0413b54c
UD
166# Decide whether we shall build the programs or not. We always do this
167# unless the user tells us (in configparms) or we are building for a
168# standalone target.
169ifndef build-programs
170ifneq ($(config-os),none)
171build-programs=yes
172else
173build-programs=no
174endif
175endif
176
28f540f4 177# Common prefix for machine-dependent installation directories.
487253ea 178ifeq ($(origin exec_prefix),undefined)
28f540f4
RM
179exec_prefix = $(prefix)
180endif
181
182# Where to install the library and object files.
183ifndef libdir
184libdir = $(exec_prefix)/lib
185endif
8d57beea 186inst_libdir = $(install_root)$(libdir)
28f540f4 187
094bacdb
RM
188# Where to install the shared library and dynamic linker.
189ifndef slibdir
190slibdir = $(exec_prefix)/lib
191endif
8d57beea 192inst_slibdir = $(install_root)$(slibdir)
094bacdb 193
28f540f4
RM
194# Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
195# the prefix is spliced between `lib' and the name, so the linker switch
196# `-l$(libprefix)NAME' finds the library; for other files the prefix is
197# just prepended to the whole file name.
487253ea 198ifeq ($(origin libprefix),undefined)
28f540f4
RM
199libprefix =
200endif
201
202# Where to install the header files.
203ifndef includedir
25c751d0 204includedir = $(prefix)/include
28f540f4 205endif
8d57beea 206inst_includedir = $(install_root)$(includedir)
28f540f4 207
28f540f4 208# Where to install machine-independent data files.
a2fe9c76 209# These are the timezone database, and the locale database.
28f540f4
RM
210ifndef datadir
211datadir = $(prefix)/share
212endif
8d57beea 213inst_datadir = $(install_root)$(datadir)
28f540f4
RM
214
215# Where to install the timezone data files (which are machine-independent).
216ifndef zonedir
217zonedir = $(datadir)/zoneinfo
218endif
8d57beea 219inst_zonedir = $(install_root)$(zonedir)
28f540f4 220
4a33c2f5 221# Where to install the locale files.
a2fe9c76 222ifndef localedir
4a33c2f5 223localedir = $(libdir)/locale
a2fe9c76 224endif
8d57beea 225inst_localedir = $(install_root)$(localedir)
a2fe9c76 226
4a33c2f5
UD
227# Where to install the message catalog data files (which are
228# machine-independent).
229ifndef msgcatdir
230msgcatdir = $(datadir)/locale
231endif
232inst_msgcatdir = $(install_root)$(msgcatdir)
233
3ec41e03 234# Where to install the locale charmap source files.
19bc17a9
RM
235ifndef i18ndir
236i18ndir = $(datadir)/i18n
a2fe9c76 237endif
8d57beea 238inst_i18ndir = $(install_root)$(i18ndir)
a2fe9c76 239
6973fc01
UD
240# Where to install the shared object for charset transformation.
241ifndef gconvdir
242gconvdir = $(libdir)/gconv
243endif
244inst_gconvdir = $(install_root)$(gconvdir)
245
28f540f4
RM
246# Where to install programs.
247ifndef bindir
248bindir = $(exec_prefix)/bin
249endif
8d57beea 250inst_bindir = $(install_root)$(bindir)
28f540f4 251
7f0ff1b0
UD
252# Where to install internal programs.
253ifndef libexecdir
254libexecdir = $(exec_prefix)/libexec
255endif
256inst_libexecdir = $(install_root)$(libexecdir)
257
28f540f4 258# Where to install administrative programs.
1ef32c3d
UD
259ifndef rootsbindir
260rootsbindir = $(exec_prefix)/sbin
261endif
8d57beea 262inst_rootsbindir = $(install_root)$(rootsbindir)
1ef32c3d 263
28f540f4
RM
264ifndef sbindir
265sbindir = $(exec_prefix)/sbin
266endif
8d57beea 267inst_sbindir = $(install_root)$(sbindir)
28f540f4
RM
268
269# Where to install the Info files.
270ifndef infodir
271infodir = $(prefix)/info
272endif
8d57beea 273inst_infodir = $(install_root)$(infodir)
28f540f4 274
a9171047
UD
275# Where to install audit libraries.
276ifndef auditdir
277auditdir = $(libdir)/audit
278endif
279inst_auditdir = $(install_root)$(auditdir)
280
28f540f4
RM
281# Where to install default configuration files. These include the local
282# timezone specification and network data base files.
283ifndef sysconfdir
284sysconfdir = $(prefix)/etc
285endif
8d57beea 286inst_sysconfdir = $(install_root)$(sysconfdir)
28f540f4 287
77fb9117
UD
288# Directory for the database files and Makefile for nss_db.
289ifndef vardbdir
4248b1b1 290vardbdir = $(localstatedir)/db
77fb9117
UD
291endif
292inst_vardbdir = $(install_root)$(vardbdir)
293
28f540f4
RM
294# Where to install the "localtime" timezone file; this is the file whose
295# contents $(localtime) specifies. If this is a relative pathname, it is
296# relative to $(zonedir). It is a good idea to put this somewhere
297# other than there, so the zoneinfo directory contains only universal data,
298# localizing the configuration data elsewhere.
299ifndef localtime-file
0d8733c4 300localtime-file = $(sysconfdir)/localtime
28f540f4
RM
301endif
302
59dd8641
RM
303# What to use for leap second specifications in compiling the default
304# timezone files. Set this to `/dev/null' for no leap second handling as
305# 1003.1 requires, or to `leapseconds' for proper leap second handling.
306# Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
307# This variable determines the default: if it's `/dev/null',
308# ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
309ifndef leapseconds
310leapseconds = /dev/null
311endif
312
28f540f4
RM
313# What timezone's DST rules should be used when a POSIX-style TZ
314# environment variable doesn't specify any rules. For 1003.1 compliance
315# this timezone must use rules that are as U.S. federal law defines DST.
316# Run `make -C time echo-zonenames' to see a list of available zone names.
317# This setting can be changed with `zic -p TIMEZONE' at any time.
318# If you want POSIX.1 compatibility, use `America/New_York'.
319ifndef posixrules
320posixrules = America/New_York
321endif
322
323# Where to install the "posixrules" timezone file; this is file
324# whose contents $(posixrules) specifies. If this is a relative
325# pathname, it is relative to $(zonedir).
326ifndef posixrules-file
327posixrules-file = posixrules
328endif
329
330
331# Directory where your system's native header files live.
332# This is used on Unix systems to generate some GNU libc header files.
333ifndef sysincludedir
334sysincludedir = /usr/include
335endif
336
337
338# Commands to install files.
339ifndef INSTALL_DATA
340INSTALL_DATA = $(INSTALL) -m 644
341endif
07627f49
UD
342ifndef INSTALL_SCRIPT
343INSTALL_SCRIPT = $(INSTALL)
344endif
28f540f4
RM
345ifndef INSTALL_PROGRAM
346INSTALL_PROGRAM = $(INSTALL)
347endif
348ifndef INSTALL
349INSTALL = install
350endif
351
352
353# The name of the C compiler.
354# If you've got GCC, and it works, use it.
355ifeq ($(origin CC),default)
356CC := gcc
357endif
358
359# The name of the C compiler to use for compilations of programs to run on
360# the host that is building the library. If you set CC to a
361# cross-compiler, you must set this to the normal compiler.
362ifndef BUILD_CC
363BUILD_CC = $(CC)
364endif
365
366# Default flags to pass the C compiler.
367ifndef default_cflags
1d5c2feb
UD
368ifeq ($(release),stable)
369default_cflags := -g -O2
370else
a8922de8 371default_cflags := -g -O
28f540f4 372endif
1d5c2feb 373endif
28f540f4
RM
374
375# Flags to pass the C compiler when assembling preprocessed assembly code
376# (`.S' files). On some systems the assembler doesn't understand the `#' line
377# directives the preprocessor produces. If you have troubling compiling
378# assembly code, try using -P here to suppress these directives.
379ifndef asm-CPPFLAGS
380asm-CPPFLAGS =
381endif
382
7e2b0c85
RM
383as-needed := -Wl,--as-needed
384no-as-needed := -Wl,--no-as-needed
7e2b0c85 385
3ce1f295
UD
386# Must be supported by the linker.
387no-whole-archive = -Wl,--no-whole-archive
388whole-archive = -Wl,--whole-archive
389
779ae82e 390# Installed name of the startup code.
26ecc33a 391# The ELF convention is that the startfile is called crt1.o
779ae82e 392start-installed-name = crt1.o
af09bfb5
RM
393# On systems that do not need a special startfile for statically linked
394# binaries, simply set it to the normal name.
395ifndef static-start-installed-name
396static-start-installed-name = $(start-installed-name)
397endif
779ae82e 398
0269750c 399ifeq (yesyes,$(build-shared)$(have-z-combreloc))
f13df7c7
UD
400combreloc-LDFLAGS = -Wl,-z,combreloc
401LDFLAGS.so += $(combreloc-LDFLAGS)
402LDFLAGS-rtld += $(combreloc-LDFLAGS)
403endif
404
1c563add
UD
405relro-LDFLAGS = -Wl,-z,relro
406LDFLAGS.so += $(relro-LDFLAGS)
407LDFLAGS-rtld += $(relro-LDFLAGS)
1c563add 408
871b9158
UD
409ifeq (yes,$(have-hash-style))
410# For the time being we unconditionally use 'both'. At some time we
411# should declare statically linked code as 'out of luck' and compile
412# with --hash-style=gnu only.
413hashstyle-LDFLAGS = -Wl,--hash-style=both
414LDFLAGS.so += $(hashstyle-LDFLAGS)
415LDFLAGS-rtld += $(hashstyle-LDFLAGS)
416endif
417
28f540f4
RM
418# Command for linking programs with the C library.
419ifndef +link
8e3cc80f 420+link = $(CC) -nostdlib -nostartfiles -o $@ \
482eec0d 421 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
871b9158 422 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
779ae82e
UD
423 $(addprefix $(csu-objpfx),$(start-installed-name)) \
424 $(+preinit) $(+prector) \
425 $(filter-out $(addprefix $(csu-objpfx),start.o \
426 $(start-installed-name))\
427 $(+preinit) $(link-extra-libs) \
428 $(common-objpfx)libc% $(+postinit),$^) \
5ae9d168 429 $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
28f540f4 430endif
435aa54b
L
431# Command for linking PIE programs with the C library.
432ifndef +link-pie
433+link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
434 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
435 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
436 $(addprefix $(csu-objpfx),S$(start-installed-name)) \
437 $(+preinit) $(+prectorS) \
438 $(filter-out $(addprefix $(csu-objpfx),start.o \
da62f81b
AS
439 S$(start-installed-name))\
440 $(+preinit) $(link-extra-libs) \
441 $(common-objpfx)libc% $(+postinit),$^) \
435aa54b
L
442 $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit)
443endif
e1586792
UD
444# Command for statically linking programs with the C library.
445ifndef +link-static
446+link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
9f0d7b6d 447 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
af09bfb5 448 $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
e1586792
UD
449 $(+preinit) $(+prector) \
450 $(filter-out $(addprefix $(csu-objpfx),start.o \
451 $(start-installed-name))\
452 $(+preinit) $(link-extra-libs-static) \
453 $(common-objpfx)libc% $(+postinit),$^) \
454 $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
455endif
ac556388
GM
456# Command for statically linking bounded-pointer programs with the C library.
457ifndef +link-bounded
458+link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
459 $(sysdep-LDFLAGS) $(LDFLAGS) \
460 $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
461 $(+preinit) $(+prector) \
4362aba5 462 $(filter-out $(addprefix $(csu-objpfx),start.ob \
ac556388
GM
463 $(start-installed-name))\
464 $(+preinit) $(link-extra-libs-bounded) \
465 $(common-objpfx)libc% $(+postinit),$^) \
466 $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
467endif
b122c703 468ifndef config-LDFLAGS
0269750c 469ifeq (yes,$(build-shared))
094bacdb 470config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
b122c703
RM
471endif
472endif
3fe9de0d
RM
473ifndef link-libc
474ifeq (yes,$(build-shared))
aa1075ea
RM
475# We need the versioned name of libc.so in the deps of $(others) et al
476# so that the symlink to libc.so is created before anything tries to
477# run the linked programs.
4d6acc61 478link-libc = -Wl,-rpath-link=$(rpath-link) \
aa1075ea 479 $(common-objpfx)libc.so$(libc.so-version) \
7e2b0c85
RM
480 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
481 $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) $(gnulib)
4d6acc61 482# This is how to find at build-time things that will be installed there.
b11f5954 483rpath-dirs = math elf dlfcn nss nis rt resolv crypt
e72bfd87
UD
484rpath-link = \
485$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
47707456 486elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
3fe9de0d 487else
ce85d65b
UD
488nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
489resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
4ac5087b 490link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
3fe9de0d
RM
491endif
492endif
900bec85 493
ad10cac8 494# Differences in the linkers on the various platforms.
ad10cac8
UD
495LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
496LDFLAGS-soname-fname = -Wl,-soname,$(@F)
497LDFLAGS-rdynamic = -rdynamic
498LDFLAGS-Bsymbolic = -Bsymbolic
ad10cac8 499
f01010de
UD
500# Choose the default search path for the dynamic linker based on
501# where we will install libraries.
502ifneq ($(libdir),$(slibdir))
503default-rpath = $(slibdir):$(libdir)
504else
505default-rpath = $(libdir)
506endif
507
57ba7bb4 508ifndef link-extra-libs
1d038b6b
RM
509link-extra-libs = $(LDLIBS-$(@F))
510link-extra-libs-static = $(link-extra-libs)
511link-extra-libs-bounded = $(link-extra-libs)
57ba7bb4 512endif
e1586792
UD
513
514# The static libraries.
b9af1301 515link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
ac556388 516link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
e1586792 517
28f540f4 518ifndef gnulib
cbdb12de
UD
519ifneq ($(have-cc-with-libunwind),yes)
520 libunwind =
feca5e0b 521else
cbdb12de 522 libunwind = -lunwind
feca5e0b 523endif
a3cc4f48 524libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
cbdb12de
UD
525gnulib := -lgcc $(libgcc_eh)
526static-gnulib := -lgcc -lgcc_eh $(libunwind)
527libc.so-gnulib := -lgcc
28f540f4 528endif
e75154a6
RM
529+preinit = $(addprefix $(csu-objpfx),crti.o)
530+postinit = $(addprefix $(csu-objpfx),crtn.o)
35e65999
RA
531+prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
532+postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
435aa54b 533# Variants of the two previous definitions for linking PIE programs.
35e65999
RA
534+prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
535+postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
66715f83 536+interp = $(addprefix $(elf-objpfx),interp.os)
6e953631
UD
537csu-objpfx = $(common-objpfx)csu/
538elf-objpfx = $(common-objpfx)elf/
28f540f4 539
03a75825
RM
540# How to run a program we just linked with our library.
541# The program binary is assumed to be $(word 2,$^).
542built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
0269750c 543ifeq (yes,$(build-shared))
196980f5 544comma = ,
11336c16
UD
545sysdep-library-path = \
546$(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
547 $(filter -Wl$(comma)-rpath-link=%,\
548 $(sysdep-LDFLAGS)))))
27abf7a3 549run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
ccd8de9a 550 $(tests-static) $(xtests-static)),, \
85857f93
UD
551 $(elf-objpfx)$(rtld-installed-name) \
552 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
8658ceda
UD
553else
554run-program-prefix =
555endif
ac556388
GM
556# Never use $(run-program-prefix) for the statically-linked %-bp test programs
557built-program-cmd = $(patsubst %,$(run-program-prefix),\
558 $(filter-out %-bp,$(built-program-file))) \
559 $(built-program-file)
03a75825 560
28f540f4
RM
561ifndef LD
562LD := ld -X
563endif
564
28f540f4 565# Extra flags to pass to GCC.
6cc7d725 566ifeq ($(all-warnings),yes)
7735afa2 567+gccwarn := -Wall -Wwrite-strings -Winline -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
6cc7d725 568else
7735afa2 569+gccwarn := -Wall -Wwrite-strings -Winline
6cc7d725 570endif
7735afa2 571+gccwarn-c = -Wstrict-prototypes
28f540f4 572
dec36b4f
UD
573# We do not depend on the address of constants in different files to be
574# actually different, so allow the compiler to merge them all.
575+merge-constants = -fmerge-all-constants
576
29ba805c
AJ
577# We have to assume that glibc functions are called in any rounding
578# mode and also change the rounding mode in a few functions. So,
579# disable any optimization that assume default rounding mode.
580+math-flags = -frounding-math
581
30077d51
RM
582# This is the program that generates makefile dependencies from C source files.
583# The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
584# targets for headers so that removed headers don't break the build.
28f540f4 585ifndef +mkdep
30077d51 586+mkdep = $(CC) -M -MP
28f540f4
RM
587endif
588
589# The program that makes Emacs-style TAGS files.
78759725 590ETAGS := etags
28f540f4 591
9de06f3c
RM
592# The `xgettext' program for producing .pot files from sources.
593ifndef XGETTEXT
594XGETTEXT = xgettext
595endif
596
28f540f4
RM
597# The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
598# perhaps others) to preprocess assembly code in some cases.
599M4 = m4
600
73237de3
UD
601# To force installation of files even if they are older than the
602# installed files. This variable is included in the dependency list
603# of all installation targets.
604ifeq ($(force-install),yes)
605+force = force-install
606else
607+force =
608endif
609
28f540f4
RM
610####
611#### End of configuration variables.
612####
613\f
614# This tells some versions of GNU make before 3.63 not to export all variables.
615.NOEXPORT:
616
617# We want to echo the commands we're running without
6d52618b 618# umpteen zillion filenames along with it (we use `...' instead)
28f540f4
RM
619# but we don't want this echoing done when the user has said
620# he doesn't want to see commands echoed by using -s.
621ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
622+cmdecho := echo >/dev/null
623else # not -s
624+cmdecho := echo
625endif # -s
626
627# These are the flags given to the compiler to tell
628# it what sort of optimization and/or debugging output to do.
629ifndef +cflags
630# If `CFLAGS' was defined, use that.
631ifdef CFLAGS
632+cflags := $(filter-out -I%,$(CFLAGS))
633endif # CFLAGS
634endif # +cflags
635
fd26970f 636# If none of the above worked, default to "-g -O".
28f540f4
RM
637ifeq "$(strip $(+cflags))" ""
638+cflags := $(default_cflags)
639endif # $(+cflags) == ""
640
29ba805c 641+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags)
28f540f4 642+gcc-nowarn := -w
28f540f4
RM
643
644# Don't duplicate options if we inherited variables from the parent.
645+cflags := $(sort $(+cflags))
646
b6ab06ce
UD
647# These are flags given to the C compiler to tell it to look for
648# include files (including ones given in angle brackets) in the parent
649# library source directory, in the include directory, and in the
650# current directory.
e0a3ed4f
RM
651+sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
652+includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
4ae73ca0
RM
653 $(+sysdep-includes) $(includes) \
654 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
28f540f4 655
96aa2d94 656# Since libio has several internal header files, we use a -I instead
762a2918 657# of many little headers in the include directory.
96aa2d94 658libio-include = -I$(..)libio
28f540f4
RM
659
660# These are the variables that the implicit compilation rules use.
ce460d04
RM
661# Note that we can't use -std=* in CPPFLAGS, because it overrides
662# the implicit -lang-asm and breaks cpp behavior for .S files--notably
663# it causes cpp to stop predefining __ASSEMBLER__.
61653dfb
RM
664CPPFLAGS = $(CPPUNDEFS) $(CPPFLAGS-config) $($(subdir)-CPPFLAGS) \
665 $(+includes) $(defines) \
ae8b36f7 666 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
0a951d0e 667 $(CPPFLAGS-$(suffix $@)) \
d29724f8 668 $(foreach lib,$(libof-$(basename $(@F))) \
bc96fbda 669 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
0a951d0e 670 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
30b99d79 671override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) $(config-extra-cflags) \
7735afa2
UD
672 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
673 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
44f0a71e
UD
674 $(CFLAGS-$(@F)) \
675 $(foreach lib,$(libof-$(basename $(@F))) \
676 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
ef226fec
RM
677override CXXFLAGS = $(c++-sysincludes) \
678 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
7735afa2 679 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
28f540f4 680
cc3fa755
UD
681# If everything is compiled with -fPIC (implicitly) we must tell this by
682# defining the PIC symbol.
683ifeq (yes,$(build-pic-default))
684pic-default = -DPIC
685endif
686
f0bf9cb9
RM
687# Enable object files for different versions of the library.
688# Various things use $(object-suffixes) to know what all to make.
689# The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
690# to pass different flags for each flavor.
91641c65 691libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
a35cb74d 692all-object-suffixes := .o .os .op .og .ob .oS
650425ce 693object-suffixes :=
cc3fa755 694CPPFLAGS-.o = $(pic-default)
14e9dd67 695CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
f0bf9cb9 696libtype.o := lib%.a
650425ce 697object-suffixes += .o
f0bf9cb9
RM
698ifeq (yes,$(build-shared))
699# Under --enable-shared, we will build a shared library of PIC objects.
40a55d20
UD
700# The PIC object files are named foo.os.
701object-suffixes += .os
b5567b2a 702CPPFLAGS-.os = -DPIC -DSHARED
14e9dd67 703CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
40a55d20 704libtype.os := lib%_pic.a
26b4d766
UD
705# This can be changed by a sysdep makefile
706pic-ccflag = -fPIC
231e88a4
UD
707# This one should always stay like this unless there is a very good reason.
708PIC-ccflag = -fPIC
f0bf9cb9 709endif
7b91359b
UD
710# This can be changed by a sysdep makefile
711pie-ccflag = -fpie
712# This one should always stay like this unless there is a very good reason.
713PIE-ccflag = -fPIE
f0bf9cb9
RM
714ifeq (yes,$(build-profile))
715# Under --enable-profile, we will build a static library of profiled objects.
40a55d20
UD
716# The profiled object files are named foo.op.
717object-suffixes += .op
cc3fa755 718CPPFLAGS-.op = -DPROF $(pic-default)
40a55d20
UD
719CFLAGS-.op = -pg
720libtype.op = lib%_p.a
f0bf9cb9 721endif
ab95290c 722
c1487492
RM
723# Convenience variable for when we want to treat shared-library cases
724# differently from the rest.
725object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
726
ab95290c 727bppfx = BP-
5a97622d
UD
728ifeq (yes,$(build-bounded))
729# Under --enable-bounded, we build the library with `-fbounded-pointers -g'
40a55d20 730# to runtime bounds checking. The bounded-pointer objects are named foo.ob.
58ff985d
GM
731# We disable sibling-call optimizations so that stack traces will be complete
732# and thus aid debugging, since after all, BPs are a debugging tool.
40a55d20 733object-suffixes += .ob
ab95290c 734CPPFLAGS-.ob = -fbounded-pointers $(pic-default)
e64911d1 735CFLAGS-.ob = -g -O2 -fno-optimize-sibling-calls -fno-strict-aliasing
40a55d20 736libtype.ob = lib%_b.a
5a97622d 737endif
f0bf9cb9 738
9afc8a59
UD
739object-suffixes-for-libc := $(object-suffixes)
740
741ifeq (yes,$(build-shared))
742# Build special library that contains the static-only routines for libc.
743object-suffixes-for-libc += .oS
744
745# Must build the routines as PIC, though, because they can end up in (users')
746# shared objects. We don't want to use CFLAGS-os because users may, for
747# example, make that processor-specific.
231e88a4 748CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
06b31ad3 749CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
9afc8a59
UD
750libtype.oS = lib%_nonshared.a
751endif
752
073e82bf
RM
753# The assembler can generate debug information too.
754ifndef ASFLAGS
755ifeq ($(have-cpp-asm-debuginfo),yes)
2e7c805d 756ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
35915ec8
UD
757else
758ASFLAGS :=
073e82bf
RM
759endif
760endif
eb29449a 761ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
9afc8a59 762
96bda0ea
RM
763ifndef BUILD_CC
764BUILD_CC = $(CC)
765endif
e72bfd87
UD
766
767move-if-change = $(SHELL) $(..)scripts/move-if-change
a641835a 768\f
281e6031
UD
769-include $(common-objpfx)sysd-sorted
770subdirs = $(sorted-subdirs)
e0a3ed4f
RM
771subdir-srcdirs = $(foreach dir,$(subdirs),\
772 $(firstword $($(dir)-srcdir) $(..)$(dir)))
9a0a462c 773
4de1d597
RM
774ifeq (yes, $(build-shared))
775
f3787738
RM
776# This is a pair of implicit rules to preprocess a file with # comments,
777# %ifdef et al, based on config.h settings or other %include'd files.
778# We use chained rules instead of a pipeline here so that we can properly
779# check the exit status of cpp rather than using its bad output when there
780# is a preprocessing error. Another rule should depend on the output file
781# `FOO.v', and along with that `FOO.v.i' should be given dependencies
782# listing both its input files, and any header files that it may reference
783# (but no commands).
8744841f
RM
784%.v.i: $(common-objpfx)config.h $(..)Makeconfig
785 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
786 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
02838201 787 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
f3787738
RM
788 > $@T
789 mv -f $@T $@
790%.v: %.v.i
791 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
792 mv -f $@T $@
480d827b 793
0ab0291b
L
794# To generate a header to support more than one ABI for different
795# architecture variants, the CPU/Makefile defines abi-variants to be a
796# list of names for those variants (e.g. 32 64), and, for each variant,
797# defines abi-$(variant)-condition to be the condition for those options
798# to use in a C #if condition. abi-includes may be defined to a list of
799# headers to include in the generated header, if the default does not
88a4576f
JM
800# suffice. default-abi is defined to be the ABI for the current glibc
801# build.
0ab0291b
L
802
803ifndef abi-includes
804abi-includes := bits/wordsize.h
805endif
806
4de1d597
RM
807# Process the shlib-versions file, which tells us what shared library
808# version numbers to use when we install shared objects on this system.
281e6031
UD
809# We need to wait until $(subdirs) is complete.
810ifeq ($(sysd-sorted-done),t)
4de1d597 811-include $(common-objpfx)soversions.mk
eca3eb3b 812ifndef avoid-generated
9632aaee
RM
813# This lets add-ons give more-specific matches that override defaults
814# in the top-level file.
f3787738 815$(common-objpfx)shlib-versions.v.i: \
e0a3ed4f
RM
816 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
817 $(subdir-srcdirs:=/shlib-versions)) \
9632aaee 818 $(..)shlib-versions
6d864d15
RM
819
820soversions-default-setname = $(patsubst %, %,\
821 $(filter-out %_default,\
822 $(oldest-abi:%=GLIBC_%)))
823$(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
824 $(common-objpfx)shlib-versions.v
825 $(AWK) -v default_setname='$(soversions-default-setname)' \
91adb529
RM
826 -v cpu='$(config-machine)' \
827 -v vendor='$(config-vendor)' \
828 -v os='$(config-os)' \
6d864d15 829 -f $^ > $@T
ba7e89ec 830 mv -f $@T $@
3e1e123d 831$(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
0ab0291b 832 (while read which lib number setname; do \
3e1e123d 833 eval seen_$$which=1; \
6fa16597 834 test x"$$which" != xABI || echo abi-name = "$$lib"; \
91adb529 835 test x"$$which" = xDEFAULT || continue; \
1bc777b8
UD
836 case $$number in \
837 [0-9]*) echo "$$lib.so-version=.$$number"; \
838 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
0ab0291b 839 *) echo "$$lib.so-version=\$$(if \$$(abi-$(default-abi)-$$lib-soname),\$$(abi-$(default-abi)-$$lib-soname),$$number)"; \
1bc777b8
UD
840 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
841 esac; \
842 done; \
843 echo soversions.mk-done = t;) < $< > $@T; exit 0
4de1d597 844 mv -f $@T $@
eca3eb3b 845endif
281e6031 846endif
eca3eb3b 847
f3787738
RM
848postclean-generated += soversions.mk soversions.i \
849 shlib-versions.v shlib-versions.v.i
4de1d597 850
c0e45674 851# Generate the header containing the names of all shared libraries.
5613ea18 852# We use a stamp file to avoid unnecessary recompilations.
c0e45674 853before-compile += $(common-objpfx)gnu/lib-names.h
1bc777b8 854ifeq ($(soversions.mk-done),t)
60c34a30 855$(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
91adb529
RM
856$(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
857 $(common-objpfx)soversions.i
c0e45674 858 $(make-target-directory)
0ab0291b
L
859 { \
860 echo '/* This file is automatically generated.';\
861 echo ' It defines macros to allow user program to find the shared'; \
862 echo ' library files which come as part of GNU libc. */'; \
863 echo '#ifndef __GNU_LIB_NAMES_H'; \
864 echo '#define __GNU_LIB_NAMES_H 1'; \
865 echo ''; \
866 $(if $(abi-includes), \
867 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
868 echo '';) \
869 $(if $(abi-variants), \
870 $(foreach v,$(abi-variants),\
871 $(if $(abi-$(v)-condition),\
872 echo '#if $(abi-$(v)-condition)'; \
873 ($(foreach s,$(all-sonames), \
874 $(if $(abi-$(v)-$(firstword $(subst =, ,$(s)))-soname),\
875 echo $(firstword $(subst =, ,$(s)))=$(abi-$(v)-$(firstword $(subst =, ,$(s)))-soname);, \
876 echo $(s);))) \
877 | LC_ALL=C $(AWK) -v multi=1 -f $(firstword $^) | LC_ALL=C sort;) \
878 $(if $(abi-$(v)-condition),echo '#endif';)), \
879 ($(foreach s,$(all-sonames), echo $(s);)) \
880 | LC_ALL=C $(AWK) -f $(firstword $^) | LC_ALL=C sort;) \
881 echo ''; \
882 echo '#endif /* gnu/lib-names.h */'; \
883 } > ${@:stmp=T}
7e7a548e 884 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
c0e45674 885 touch $@
1bc777b8 886endif
c0e45674
UD
887
888common-generated += gnu/lib-names.h gnu/lib-names.stmp
d41c6f61
UD
889
890# The name under which the run-time dynamic linker is installed.
891# We are currently going for the convention that `/lib/ld.so.1'
892# names the SVR4/ELF ABI-compliant dynamic linker.
893ifndef rtld-installed-name
894ifdef ld.so-version
895rtld-installed-name = $(ld.so-version)
896else
897rtld-installed-name = ld.so.1
898endif
899endif
900
1ef32c3d
UD
901ifndef rtld-version-installed-name
902rtld-version-installed-name = ld-$(version).so
903endif
904
f649c201
UD
905endif # build-shared
906
cbdee279 907
94e365c6
UD
908dlfcn = dlfcn
909ifeq ($(build-shared),yes)
910libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
911else
912libdl = $(common-objpfx)dlfcn/libdl.a
913endif
94e365c6 914
6ee65ed6
UD
915ifeq ($(build-shared),yes)
916libm = $(common-objpfx)math/libm.so$(libm.so-version)
917else
918libm = $(common-objpfx)math/libm.a
919endif
920
bb41a976
UD
921# These are the subdirectories containing the library source. The order
922# is more or less arbitrary. The sorting step will take care of the
e0a3ed4f 923# dependencies.
8d6f1731 924all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
e0a3ed4f 925 stdlib stdio-common libio malloc string wcsmbs time dirent \
b0b67c47 926 grp pwd posix io termios resource misc socket sysvipc gmon \
829fea46 927 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
e0a3ed4f
RM
928 crypt nss localedata timezone rt conform debug \
929 $(add-on-subdirs) $(dlfcn) $(binfmt-subdir)
b22fc5f5 930
b7e2d9a5 931ifndef avoid-generated
e0a3ed4f
RM
932all-Depend-files := $(wildcard $(foreach dir,$(all-subdirs),\
933 $(firstword $($(dir)-srcdir) \
934 $(..)$(dir))/Depend))
935$(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
936 $(common-objpfx)config.make $(..)Makeconfig \
937 $(wildcard $(sysdirs:=/Subdirs)) \
938 $(all-Depend-files)
939 $(AWK) -f $< \
940 -v subdirs='$(all-subdirs)' \
941 -v srcpfx='$(..)' \
942 $(filter %/Subdirs %/Depend,$^) > $@-tmp
bb41a976 943 mv -f $@-tmp $@
9de06f3c 944$(all-Depend-files): ;
b7e2d9a5 945endif
bb41a976 946
16cd816f
RM
947# This gives partial TARGET:SOURCE pattern pairs to have rules
948# emitted into sysd-rules. A sysdeps Makeconfig fragment can
949# add its own special object file prefix to this list with e.g. foo-%:%
950# to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
bc96fbda 951sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
16cd816f 952
083973f3 953# Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
e0a3ed4f 954sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
083973f3 955ifneq (,$(sysdep-makeconfigs))
e0a3ed4f 956include $(sysdep-makeconfigs)
083973f3
RM
957endif
958
363a641b 959# Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
bc96fbda
AS
960sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
961 $(firstword $(subst :, ,$p))))
083973f3 962
28f540f4 963endif # Makeconfig not yet included
c238ecf7
UD
964
965# Local Variables:
966# mode: makefile
967# End: