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