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