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