]> git.ipfire.org Git - thirdparty/glibc.git/blame - Makeconfig
Parse hexadecimal and octal strings correctly
[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
290vardbdir = /var/db
291endif
292inst_vardbdir = $(install_root)$(vardbdir)
293
28f540f4
RM
294# What timezone should be the installed default (e.g., US/Eastern).
295# Run `make -C time echo-zonenames' to see a list of available zone names.
296# The local timezone can be changed with `zic -l TIMEZONE' at any time.
297ifndef localtime
298localtime = Factory
299endif
300
301# Where to install the "localtime" timezone file; this is the file whose
302# contents $(localtime) specifies. If this is a relative pathname, it is
303# relative to $(zonedir). It is a good idea to put this somewhere
304# other than there, so the zoneinfo directory contains only universal data,
305# localizing the configuration data elsewhere.
306ifndef localtime-file
0d8733c4
UD
307localtime-file = $(sysconfdir)/localtime
308inst_localtime-file = $(install_root)$(localtime-file)
28f540f4
RM
309endif
310
59dd8641
RM
311# What to use for leap second specifications in compiling the default
312# timezone files. Set this to `/dev/null' for no leap second handling as
313# 1003.1 requires, or to `leapseconds' for proper leap second handling.
314# Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
315# This variable determines the default: if it's `/dev/null',
316# ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
317ifndef leapseconds
318leapseconds = /dev/null
319endif
320
28f540f4
RM
321# What timezone's DST rules should be used when a POSIX-style TZ
322# environment variable doesn't specify any rules. For 1003.1 compliance
323# this timezone must use rules that are as U.S. federal law defines DST.
324# Run `make -C time echo-zonenames' to see a list of available zone names.
325# This setting can be changed with `zic -p TIMEZONE' at any time.
326# If you want POSIX.1 compatibility, use `America/New_York'.
327ifndef posixrules
328posixrules = America/New_York
329endif
330
331# Where to install the "posixrules" timezone file; this is file
332# whose contents $(posixrules) specifies. If this is a relative
333# pathname, it is relative to $(zonedir).
334ifndef posixrules-file
335posixrules-file = posixrules
336endif
337
338
339# Directory where your system's native header files live.
340# This is used on Unix systems to generate some GNU libc header files.
341ifndef sysincludedir
342sysincludedir = /usr/include
343endif
344
345
346# Commands to install files.
347ifndef INSTALL_DATA
348INSTALL_DATA = $(INSTALL) -m 644
349endif
07627f49
UD
350ifndef INSTALL_SCRIPT
351INSTALL_SCRIPT = $(INSTALL)
352endif
28f540f4
RM
353ifndef INSTALL_PROGRAM
354INSTALL_PROGRAM = $(INSTALL)
355endif
356ifndef INSTALL
357INSTALL = install
358endif
359
360
361# The name of the C compiler.
362# If you've got GCC, and it works, use it.
363ifeq ($(origin CC),default)
364CC := gcc
365endif
366
367# The name of the C compiler to use for compilations of programs to run on
368# the host that is building the library. If you set CC to a
369# cross-compiler, you must set this to the normal compiler.
370ifndef BUILD_CC
371BUILD_CC = $(CC)
372endif
373
374# Default flags to pass the C compiler.
375ifndef default_cflags
1d5c2feb
UD
376ifeq ($(release),stable)
377default_cflags := -g -O2
378else
a8922de8 379default_cflags := -g -O
28f540f4 380endif
1d5c2feb 381endif
28f540f4
RM
382
383# Flags to pass the C compiler when assembling preprocessed assembly code
384# (`.S' files). On some systems the assembler doesn't understand the `#' line
385# directives the preprocessor produces. If you have troubling compiling
386# assembly code, try using -P here to suppress these directives.
387ifndef asm-CPPFLAGS
388asm-CPPFLAGS =
389endif
390
7e2b0c85
RM
391ifeq ($(have-as-needed),yes)
392as-needed := -Wl,--as-needed
393no-as-needed := -Wl,--no-as-needed
394else
395as-needed :=
396no-as-needed :=
397endif
398
3ce1f295
UD
399# Must be supported by the linker.
400no-whole-archive = -Wl,--no-whole-archive
401whole-archive = -Wl,--whole-archive
402
779ae82e 403# Installed name of the startup code.
26ecc33a 404# The ELF convention is that the startfile is called crt1.o
779ae82e 405start-installed-name = crt1.o
af09bfb5
RM
406# On systems that do not need a special startfile for statically linked
407# binaries, simply set it to the normal name.
408ifndef static-start-installed-name
409static-start-installed-name = $(start-installed-name)
410endif
779ae82e 411
0269750c 412ifeq (yesyes,$(build-shared)$(have-z-combreloc))
f13df7c7
UD
413combreloc-LDFLAGS = -Wl,-z,combreloc
414LDFLAGS.so += $(combreloc-LDFLAGS)
415LDFLAGS-rtld += $(combreloc-LDFLAGS)
416endif
417
1c563add
UD
418relro-LDFLAGS = -Wl,-z,relro
419LDFLAGS.so += $(relro-LDFLAGS)
420LDFLAGS-rtld += $(relro-LDFLAGS)
1c563add 421
871b9158
UD
422ifeq (yes,$(have-hash-style))
423# For the time being we unconditionally use 'both'. At some time we
424# should declare statically linked code as 'out of luck' and compile
425# with --hash-style=gnu only.
426hashstyle-LDFLAGS = -Wl,--hash-style=both
427LDFLAGS.so += $(hashstyle-LDFLAGS)
428LDFLAGS-rtld += $(hashstyle-LDFLAGS)
429endif
430
28f540f4
RM
431# Command for linking programs with the C library.
432ifndef +link
8e3cc80f 433+link = $(CC) -nostdlib -nostartfiles -o $@ \
482eec0d 434 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
871b9158 435 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
779ae82e
UD
436 $(addprefix $(csu-objpfx),$(start-installed-name)) \
437 $(+preinit) $(+prector) \
438 $(filter-out $(addprefix $(csu-objpfx),start.o \
439 $(start-installed-name))\
440 $(+preinit) $(link-extra-libs) \
441 $(common-objpfx)libc% $(+postinit),$^) \
5ae9d168 442 $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
28f540f4 443endif
435aa54b
L
444# Command for linking PIE programs with the C library.
445ifndef +link-pie
446+link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
447 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
448 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
449 $(addprefix $(csu-objpfx),S$(start-installed-name)) \
450 $(+preinit) $(+prectorS) \
451 $(filter-out $(addprefix $(csu-objpfx),start.o \
da62f81b
AS
452 S$(start-installed-name))\
453 $(+preinit) $(link-extra-libs) \
454 $(common-objpfx)libc% $(+postinit),$^) \
435aa54b
L
455 $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit)
456endif
e1586792
UD
457# Command for statically linking programs with the C library.
458ifndef +link-static
459+link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
9f0d7b6d 460 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
af09bfb5 461 $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
e1586792
UD
462 $(+preinit) $(+prector) \
463 $(filter-out $(addprefix $(csu-objpfx),start.o \
464 $(start-installed-name))\
465 $(+preinit) $(link-extra-libs-static) \
466 $(common-objpfx)libc% $(+postinit),$^) \
467 $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
468endif
ac556388
GM
469# Command for statically linking bounded-pointer programs with the C library.
470ifndef +link-bounded
471+link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
472 $(sysdep-LDFLAGS) $(LDFLAGS) \
473 $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
474 $(+preinit) $(+prector) \
4362aba5 475 $(filter-out $(addprefix $(csu-objpfx),start.ob \
ac556388
GM
476 $(start-installed-name))\
477 $(+preinit) $(link-extra-libs-bounded) \
478 $(common-objpfx)libc% $(+postinit),$^) \
479 $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
480endif
b122c703 481ifndef config-LDFLAGS
0269750c 482ifeq (yes,$(build-shared))
094bacdb 483config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
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.
4d6acc61 491link-libc = -Wl,-rpath-link=$(rpath-link) \
aa1075ea 492 $(common-objpfx)libc.so$(libc.so-version) \
7e2b0c85
RM
493 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
494 $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) $(gnulib)
4d6acc61 495# This is how to find at build-time things that will be installed there.
b11f5954 496rpath-dirs = math elf dlfcn nss nis rt resolv crypt
e72bfd87
UD
497rpath-link = \
498$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
47707456 499elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
3fe9de0d 500else
ce85d65b
UD
501nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
502resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
4ac5087b 503link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
3fe9de0d
RM
504endif
505endif
900bec85 506
ad10cac8 507# Differences in the linkers on the various platforms.
ad10cac8
UD
508LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
509LDFLAGS-soname-fname = -Wl,-soname,$(@F)
510LDFLAGS-rdynamic = -rdynamic
511LDFLAGS-Bsymbolic = -Bsymbolic
ad10cac8 512
f01010de
UD
513# Choose the default search path for the dynamic linker based on
514# where we will install libraries.
515ifneq ($(libdir),$(slibdir))
516default-rpath = $(slibdir):$(libdir)
517else
518default-rpath = $(libdir)
519endif
520
57ba7bb4 521ifndef link-extra-libs
1d038b6b
RM
522link-extra-libs = $(LDLIBS-$(@F))
523link-extra-libs-static = $(link-extra-libs)
524link-extra-libs-bounded = $(link-extra-libs)
57ba7bb4 525endif
e1586792
UD
526
527# The static libraries.
b9af1301 528link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
ac556388 529link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
e1586792 530
28f540f4 531ifndef gnulib
cbdb12de
UD
532ifneq ($(have-cc-with-libunwind),yes)
533 libunwind =
feca5e0b 534else
cbdb12de 535 libunwind = -lunwind
feca5e0b 536endif
cbdb12de
UD
537ifneq ($(have-as-needed),yes)
538 libgcc_eh := -lgcc_eh $(libunwind)
26b30508 539else
3a533ca3 540 libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
26b30508 541endif
cbdb12de
UD
542gnulib := -lgcc $(libgcc_eh)
543static-gnulib := -lgcc -lgcc_eh $(libunwind)
544libc.so-gnulib := -lgcc
28f540f4 545endif
e75154a6
RM
546+preinit = $(addprefix $(csu-objpfx),crti.o)
547+postinit = $(addprefix $(csu-objpfx),crtn.o)
35e65999
RA
548+prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
549+postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
435aa54b 550# Variants of the two previous definitions for linking PIE programs.
35e65999
RA
551+prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
552+postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
66715f83 553+interp = $(addprefix $(elf-objpfx),interp.os)
6e953631
UD
554csu-objpfx = $(common-objpfx)csu/
555elf-objpfx = $(common-objpfx)elf/
28f540f4 556
03a75825
RM
557# How to run a program we just linked with our library.
558# The program binary is assumed to be $(word 2,$^).
559built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
0269750c 560ifeq (yes,$(build-shared))
196980f5 561comma = ,
11336c16
UD
562sysdep-library-path = \
563$(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
564 $(filter -Wl$(comma)-rpath-link=%,\
565 $(sysdep-LDFLAGS)))))
27abf7a3 566run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
ccd8de9a 567 $(tests-static) $(xtests-static)),, \
85857f93
UD
568 $(elf-objpfx)$(rtld-installed-name) \
569 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
8658ceda
UD
570else
571run-program-prefix =
572endif
ac556388
GM
573# Never use $(run-program-prefix) for the statically-linked %-bp test programs
574built-program-cmd = $(patsubst %,$(run-program-prefix),\
575 $(filter-out %-bp,$(built-program-file))) \
576 $(built-program-file)
03a75825 577
28f540f4
RM
578ifndef LD
579LD := ld -X
580endif
581
28f540f4 582# Extra flags to pass to GCC.
6cc7d725 583ifeq ($(all-warnings),yes)
7735afa2 584+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 585else
7735afa2 586+gccwarn := -Wall -Wwrite-strings -Winline
6cc7d725 587endif
7735afa2 588+gccwarn-c = -Wstrict-prototypes
28f540f4 589
dec36b4f
UD
590# We do not depend on the address of constants in different files to be
591# actually different, so allow the compiler to merge them all.
592+merge-constants = -fmerge-all-constants
593
30077d51
RM
594# This is the program that generates makefile dependencies from C source files.
595# The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
596# targets for headers so that removed headers don't break the build.
28f540f4 597ifndef +mkdep
30077d51 598+mkdep = $(CC) -M -MP
28f540f4
RM
599endif
600
601# The program that makes Emacs-style TAGS files.
78759725 602ETAGS := etags
28f540f4 603
9de06f3c
RM
604# The `xgettext' program for producing .pot files from sources.
605ifndef XGETTEXT
606XGETTEXT = xgettext
607endif
608
28f540f4
RM
609# The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
610# perhaps others) to preprocess assembly code in some cases.
611M4 = m4
612
73237de3
UD
613# To force installation of files even if they are older than the
614# installed files. This variable is included in the dependency list
615# of all installation targets.
616ifeq ($(force-install),yes)
617+force = force-install
618else
619+force =
620endif
621
28f540f4
RM
622####
623#### End of configuration variables.
624####
625\f
626# This tells some versions of GNU make before 3.63 not to export all variables.
627.NOEXPORT:
628
629# We want to echo the commands we're running without
6d52618b 630# umpteen zillion filenames along with it (we use `...' instead)
28f540f4
RM
631# but we don't want this echoing done when the user has said
632# he doesn't want to see commands echoed by using -s.
633ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
634+cmdecho := echo >/dev/null
635else # not -s
636+cmdecho := echo
637endif # -s
638
639# These are the flags given to the compiler to tell
640# it what sort of optimization and/or debugging output to do.
641ifndef +cflags
642# If `CFLAGS' was defined, use that.
643ifdef CFLAGS
644+cflags := $(filter-out -I%,$(CFLAGS))
645endif # CFLAGS
646endif # +cflags
647
fd26970f 648# If none of the above worked, default to "-g -O".
28f540f4
RM
649ifeq "$(strip $(+cflags))" ""
650+cflags := $(default_cflags)
651endif # $(+cflags) == ""
652
2cf9ad57 653+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants)
28f540f4 654+gcc-nowarn := -w
28f540f4
RM
655
656# Don't duplicate options if we inherited variables from the parent.
657+cflags := $(sort $(+cflags))
658
b6ab06ce
UD
659# These are flags given to the C compiler to tell it to look for
660# include files (including ones given in angle brackets) in the parent
661# library source directory, in the include directory, and in the
662# current directory.
e0a3ed4f
RM
663+sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
664+includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
4ae73ca0
RM
665 $(+sysdep-includes) $(includes) \
666 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
28f540f4 667
96aa2d94 668# Since libio has several internal header files, we use a -I instead
762a2918 669# of many little headers in the include directory.
96aa2d94 670libio-include = -I$(..)libio
28f540f4
RM
671
672# These are the variables that the implicit compilation rules use.
ce460d04
RM
673# Note that we can't use -std=* in CPPFLAGS, because it overrides
674# the implicit -lang-asm and breaks cpp behavior for .S files--notably
675# it causes cpp to stop predefining __ASSEMBLER__.
1c3b002b 676CPPFLAGS = $(CPPFLAGS-config) $($(subdir)-CPPFLAGS) $(+includes) $(defines) \
ae8b36f7 677 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
0a951d0e 678 $(CPPFLAGS-$(suffix $@)) \
d29724f8 679 $(foreach lib,$(libof-$(basename $(@F))) \
bc96fbda 680 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
0a951d0e 681 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
b037a293 682override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) \
7735afa2
UD
683 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
684 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
44f0a71e
UD
685 $(CFLAGS-$(@F)) \
686 $(foreach lib,$(libof-$(basename $(@F))) \
687 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
ef226fec
RM
688override CXXFLAGS = $(c++-sysincludes) \
689 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
7735afa2 690 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
28f540f4 691
cc3fa755
UD
692# If everything is compiled with -fPIC (implicitly) we must tell this by
693# defining the PIC symbol.
694ifeq (yes,$(build-pic-default))
695pic-default = -DPIC
696endif
697
f0bf9cb9
RM
698# Enable object files for different versions of the library.
699# Various things use $(object-suffixes) to know what all to make.
700# The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
701# to pass different flags for each flavor.
91641c65 702libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
a35cb74d 703all-object-suffixes := .o .os .op .og .ob .oS
650425ce 704object-suffixes :=
cc3fa755 705CPPFLAGS-.o = $(pic-default)
14e9dd67 706CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
f0bf9cb9 707libtype.o := lib%.a
650425ce 708object-suffixes += .o
f0bf9cb9
RM
709ifeq (yes,$(build-shared))
710# Under --enable-shared, we will build a shared library of PIC objects.
40a55d20
UD
711# The PIC object files are named foo.os.
712object-suffixes += .os
b5567b2a 713CPPFLAGS-.os = -DPIC -DSHARED
14e9dd67 714CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
40a55d20 715libtype.os := lib%_pic.a
26b4d766
UD
716# This can be changed by a sysdep makefile
717pic-ccflag = -fPIC
231e88a4
UD
718# This one should always stay like this unless there is a very good reason.
719PIC-ccflag = -fPIC
f0bf9cb9 720endif
7b91359b
UD
721# This can be changed by a sysdep makefile
722pie-ccflag = -fpie
723# This one should always stay like this unless there is a very good reason.
724PIE-ccflag = -fPIE
f0bf9cb9
RM
725ifeq (yes,$(build-profile))
726# Under --enable-profile, we will build a static library of profiled objects.
40a55d20
UD
727# The profiled object files are named foo.op.
728object-suffixes += .op
cc3fa755 729CPPFLAGS-.op = -DPROF $(pic-default)
40a55d20
UD
730CFLAGS-.op = -pg
731libtype.op = lib%_p.a
f0bf9cb9 732endif
ab95290c
UD
733
734bppfx = BP-
5a97622d
UD
735ifeq (yes,$(build-bounded))
736# Under --enable-bounded, we build the library with `-fbounded-pointers -g'
40a55d20 737# to runtime bounds checking. The bounded-pointer objects are named foo.ob.
58ff985d
GM
738# We disable sibling-call optimizations so that stack traces will be complete
739# and thus aid debugging, since after all, BPs are a debugging tool.
40a55d20 740object-suffixes += .ob
ab95290c 741CPPFLAGS-.ob = -fbounded-pointers $(pic-default)
e64911d1 742CFLAGS-.ob = -g -O2 -fno-optimize-sibling-calls -fno-strict-aliasing
40a55d20 743libtype.ob = lib%_b.a
5a97622d 744endif
f0bf9cb9 745
9afc8a59
UD
746object-suffixes-for-libc := $(object-suffixes)
747
748ifeq (yes,$(build-shared))
749# Build special library that contains the static-only routines for libc.
750object-suffixes-for-libc += .oS
751
752# Must build the routines as PIC, though, because they can end up in (users')
753# shared objects. We don't want to use CFLAGS-os because users may, for
754# example, make that processor-specific.
231e88a4 755CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
06b31ad3 756CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
9afc8a59
UD
757libtype.oS = lib%_nonshared.a
758endif
759
073e82bf
RM
760# The assembler can generate debug information too.
761ifndef ASFLAGS
762ifeq ($(have-cpp-asm-debuginfo),yes)
2e7c805d 763ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
35915ec8
UD
764else
765ASFLAGS :=
073e82bf
RM
766endif
767endif
eb29449a 768ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
9afc8a59 769
96bda0ea
RM
770ifndef BUILD_CC
771BUILD_CC = $(CC)
772endif
e72bfd87
UD
773
774move-if-change = $(SHELL) $(..)scripts/move-if-change
a641835a 775\f
281e6031
UD
776-include $(common-objpfx)sysd-sorted
777subdirs = $(sorted-subdirs)
e0a3ed4f
RM
778subdir-srcdirs = $(foreach dir,$(subdirs),\
779 $(firstword $($(dir)-srcdir) $(..)$(dir)))
9a0a462c 780
4de1d597
RM
781ifeq (yes, $(build-shared))
782
f3787738
RM
783# This is a pair of implicit rules to preprocess a file with # comments,
784# %ifdef et al, based on config.h settings or other %include'd files.
785# We use chained rules instead of a pipeline here so that we can properly
786# check the exit status of cpp rather than using its bad output when there
787# is a preprocessing error. Another rule should depend on the output file
788# `FOO.v', and along with that `FOO.v.i' should be given dependencies
789# listing both its input files, and any header files that it may reference
790# (but no commands).
8744841f
RM
791%.v.i: $(common-objpfx)config.h $(..)Makeconfig
792 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
793 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
02838201 794 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
f3787738
RM
795 > $@T
796 mv -f $@T $@
797%.v: %.v.i
798 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
799 mv -f $@T $@
480d827b 800
4de1d597
RM
801# Process the shlib-versions file, which tells us what shared library
802# version numbers to use when we install shared objects on this system.
281e6031
UD
803# We need to wait until $(subdirs) is complete.
804ifeq ($(sysd-sorted-done),t)
4de1d597 805-include $(common-objpfx)soversions.mk
eca3eb3b 806ifndef avoid-generated
9632aaee
RM
807# This lets add-ons give more-specific matches that override defaults
808# in the top-level file.
f3787738 809$(common-objpfx)shlib-versions.v.i: \
e0a3ed4f
RM
810 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
811 $(subdir-srcdirs:=/shlib-versions)) \
9632aaee 812 $(..)shlib-versions
6d864d15
RM
813
814soversions-default-setname = $(patsubst %, %,\
815 $(filter-out %_default,\
816 $(oldest-abi:%=GLIBC_%)))
817$(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
818 $(common-objpfx)shlib-versions.v
819 $(AWK) -v default_setname='$(soversions-default-setname)' \
91adb529
RM
820 -v cpu='$(config-machine)' \
821 -v vendor='$(config-vendor)' \
822 -v os='$(config-os)' \
6d864d15 823 -f $^ > $@T
ba7e89ec 824 mv -f $@T $@
3e1e123d
RM
825$(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
826 (seen_DEFAULT=0; seen_WORDSIZE32=0; seen_WORDSIZE64=0; \
827 while read which lib number setname; do \
828 eval seen_$$which=1; \
6fa16597 829 test x"$$which" != xABI || echo abi-name = "$$lib"; \
91adb529 830 test x"$$which" = xDEFAULT || continue; \
1bc777b8
UD
831 case $$number in \
832 [0-9]*) echo "$$lib.so-version=.$$number"; \
833 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
834 *) echo "$$lib.so-version=$$number"; \
835 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
836 esac; \
837 done; \
3e1e123d
RM
838 case "$$seen_DEFAULT$$seen_WORDSIZE32$$seen_WORDSIZE64" in \
839 100) echo biarch = no;; \
840 101) echo biarch = 32;; \
841 ?1?) echo biarch = 64;; \
842 *) echo >&2 BUG; exit 2;; \
843 esac; \
1bc777b8 844 echo soversions.mk-done = t;) < $< > $@T; exit 0
4de1d597 845 mv -f $@T $@
eca3eb3b 846endif
281e6031 847endif
eca3eb3b 848
f3787738
RM
849postclean-generated += soversions.mk soversions.i \
850 shlib-versions.v shlib-versions.v.i
4de1d597 851
c0e45674 852# Generate the header containing the names of all shared libraries.
5613ea18 853# We use a stamp file to avoid unnecessary recompilations.
c0e45674 854before-compile += $(common-objpfx)gnu/lib-names.h
1bc777b8 855ifeq ($(soversions.mk-done),t)
60c34a30 856$(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
91adb529
RM
857$(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
858 $(common-objpfx)soversions.i
c0e45674
UD
859 $(make-target-directory)
860 @rm -f ${@:stmp=T} $@
4facf4af 861 LC_ALL=C $(AWK) -f $^ > ${@:stmp=T}
7e7a548e 862 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
c0e45674 863 touch $@
1bc777b8 864endif
c0e45674
UD
865
866common-generated += gnu/lib-names.h gnu/lib-names.stmp
d41c6f61
UD
867
868# The name under which the run-time dynamic linker is installed.
869# We are currently going for the convention that `/lib/ld.so.1'
870# names the SVR4/ELF ABI-compliant dynamic linker.
871ifndef rtld-installed-name
872ifdef ld.so-version
873rtld-installed-name = $(ld.so-version)
874else
875rtld-installed-name = ld.so.1
876endif
877endif
878
1ef32c3d
UD
879ifndef rtld-version-installed-name
880rtld-version-installed-name = ld-$(version).so
881endif
882
f649c201
UD
883endif # build-shared
884
cbdee279 885
94e365c6
UD
886dlfcn = dlfcn
887ifeq ($(build-shared),yes)
888libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
889else
890libdl = $(common-objpfx)dlfcn/libdl.a
891endif
94e365c6 892
6ee65ed6
UD
893ifeq ($(build-shared),yes)
894libm = $(common-objpfx)math/libm.so$(libm.so-version)
895else
896libm = $(common-objpfx)math/libm.a
897endif
898
bb41a976
UD
899# These are the subdirectories containing the library source. The order
900# is more or less arbitrary. The sorting step will take care of the
e0a3ed4f 901# dependencies.
8d6f1731 902all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
e0a3ed4f 903 stdlib stdio-common libio malloc string wcsmbs time dirent \
b0b67c47 904 grp pwd posix io termios resource misc socket sysvipc gmon \
829fea46 905 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
e0a3ed4f
RM
906 crypt nss localedata timezone rt conform debug \
907 $(add-on-subdirs) $(dlfcn) $(binfmt-subdir)
b22fc5f5 908
b7e2d9a5 909ifndef avoid-generated
e0a3ed4f
RM
910all-Depend-files := $(wildcard $(foreach dir,$(all-subdirs),\
911 $(firstword $($(dir)-srcdir) \
912 $(..)$(dir))/Depend))
913$(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
914 $(common-objpfx)config.make $(..)Makeconfig \
915 $(wildcard $(sysdirs:=/Subdirs)) \
916 $(all-Depend-files)
917 $(AWK) -f $< \
918 -v subdirs='$(all-subdirs)' \
919 -v srcpfx='$(..)' \
920 $(filter %/Subdirs %/Depend,$^) > $@-tmp
bb41a976 921 mv -f $@-tmp $@
9de06f3c 922$(all-Depend-files): ;
b7e2d9a5 923endif
bb41a976 924
16cd816f
RM
925# This gives partial TARGET:SOURCE pattern pairs to have rules
926# emitted into sysd-rules. A sysdeps Makeconfig fragment can
927# add its own special object file prefix to this list with e.g. foo-%:%
928# to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
bc96fbda 929sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
16cd816f 930
083973f3 931# Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
e0a3ed4f 932sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
083973f3 933ifneq (,$(sysdep-makeconfigs))
e0a3ed4f 934include $(sysdep-makeconfigs)
083973f3
RM
935endif
936
363a641b 937# Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
bc96fbda
AS
938sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
939 $(firstword $(subst :, ,$p))))
083973f3 940
28f540f4 941endif # Makeconfig not yet included
c238ecf7
UD
942
943# Local Variables:
944# mode: makefile
945# End: