]> git.ipfire.org Git - thirdparty/glibc.git/blame_incremental - Makeconfig
Fix -Wundef warning in SHLIB_COMPAT
[thirdparty/glibc.git] / Makeconfig
... / ...
CommitLineData
1# Copyright (C) 1991-2014 Free Software Foundation, Inc.
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
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.
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
12# Lesser General Public License for more details.
13
14# You should have received a copy of the GNU Lesser General Public
15# License along with the GNU C Library; if not, see
16# <http://www.gnu.org/licenses/>.
17
18#
19# Makefile configuration options for the GNU C library.
20#
21ifneq (,)
22This makefile requires GNU Make.
23endif
24
25all: # Make this the default goal
26
27ifneq "$(origin +included-Makeconfig)" "file"
28
29+included-Makeconfig := yes
30
31ifdef subdir
32.. := ../
33endif
34
35# $(common-objdir) is the place to put objects and
36# such that are not specific to a single subdir.
37ifdef objdir
38objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
39common-objpfx = $(objdir)/
40common-objdir = $(objdir)
41else
42objdir must be defined by the build-directory Makefile.
43endif
44
45# Root of the sysdeps tree.
46sysdep_dir := $(..)sysdeps
47export sysdep_dir := $(sysdep_dir)
48
49# Get the values defined by options to `configure'.
50include $(common-objpfx)config.make
51
52# What flags to give to sources which call user provided callbacks
53uses-callbacks = $(exceptions)
54
55# What flags to give to tests which test stack alignment
56stack-align-test-flags =
57
58# Complete path to sysdep dirs.
59# `configure' writes a definition of `config-sysdirs' in `config.make'.
60sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
61
62# Add-ons that contribute sysdeps trees get added to the include list
63# after sysdeps/generic. This makes #include <sysdeps/...> work right
64# to find specific add-on files without assuming the add-on directory name.
65# It also means that headers can go into an add-on's base directory
66# instead of the add-on needing a sysdeps/generic of its own.
67sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\
68 $(firstword $(filter /%,$(add-on)) \
69 $(..)$(add-on)))
70+sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs)
71ifdef objdir
72+sysdep_dirs := $(objdir) $(+sysdep_dirs)
73endif
74
75# Run config.status to update config.make and config.h. We don't show the
76# dependence of config.h to Make, because it is only touched when it
77# changes and so config.status would be run every time; the dependence of
78# config.make should suffice to force regeneration and re-exec, and the new
79# image will notice if config.h changed.
80$(common-objpfx)config.make: $(common-objpfx)config.status \
81 $(..)config.make.in $(..)config.h.in
82 cd $(<D); $(SHELL) $(<F)
83
84# Find all the add-on and sysdeps configure fragments, to make sure we
85# re-run configure when any of them changes.
86$(common-objpfx)config.status: $(..)version.h $(..)configure \
87 $(foreach dir,$(sysdirs),\
88 $(wildcard $(dir)/Implies) \
89 $(patsubst %.ac,%,\
90 $(firstword $(wildcard \
91 $(addprefix $(dir)/,configure configure.ac))))) \
92 $(patsubst %.ac,%,\
93 $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac)) \
94 $(patsubst %.ac,%,\
95 $(foreach add-on,$(add-ons),\
96 $(firstword $(wildcard \
97 $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
98 configure configure.ac))) \
99 $(wildcard $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
100 sysdeps/*/preconfigure sysdeps/*/preconfigure.ac))))
101 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
102 echo The GNU C library has not been configured. >&2; \
103 echo Run \`configure\' to configure it before building. >&2; \
104 echo Try \`configure --help\' for more details. >&2; \
105 exit 1; fi
106
107# We don't want CPPFLAGS to be exported to the command running configure.
108unexport CPPFLAGS
109
110# Get the user's configuration parameters.
111ifneq ($(wildcard $(..)configparms),)
112include $(..)configparms
113endif
114ifneq ($(objpfx),)
115ifneq ($(wildcard $(common-objpfx)configparms),)
116include $(common-objpfx)configparms
117endif
118endif
119\f
120####
121#### These are the configuration variables. You can define values for
122#### the variables below in the file `configparms'.
123#### Do NOT edit this file.
124####
125
126
127# Common prefix for machine-independent installation directories.
128ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
129prefix = /usr/local
130endif
131
132# Decide whether we shall build the programs or not. We always do this
133# unless the user tells us (in configparms) or we are building for a
134# standalone target.
135ifndef build-programs
136ifneq ($(config-os),none)
137build-programs=yes
138else
139build-programs=no
140endif
141endif
142
143# Common prefix for machine-dependent installation directories.
144ifeq ($(origin exec_prefix),undefined)
145exec_prefix = $(prefix)
146endif
147
148# Where to install the library and object files.
149ifndef libdir
150libdir = $(exec_prefix)/lib
151endif
152inst_libdir = $(install_root)$(libdir)
153
154# Where to install the shared library.
155ifndef slibdir
156slibdir = $(exec_prefix)/lib
157endif
158inst_slibdir = $(install_root)$(slibdir)
159
160# Where to install the dynamic linker.
161ifndef rtlddir
162rtlddir = $(slibdir)
163endif
164inst_rtlddir = $(install_root)$(rtlddir)
165
166# Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
167# the prefix is spliced between `lib' and the name, so the linker switch
168# `-l$(libprefix)NAME' finds the library; for other files the prefix is
169# just prepended to the whole file name.
170ifeq ($(origin libprefix),undefined)
171libprefix =
172endif
173
174# Where to install the header files.
175ifndef includedir
176includedir = $(prefix)/include
177endif
178inst_includedir = $(install_root)$(includedir)
179
180# Where to install machine-independent data files.
181# These are the timezone database, and the locale database.
182ifndef datadir
183datadir = $(prefix)/share
184endif
185inst_datadir = $(install_root)$(datadir)
186
187# Where to install the timezone data files (which are machine-independent).
188ifndef zonedir
189zonedir = $(datadir)/zoneinfo
190endif
191inst_zonedir = $(install_root)$(zonedir)
192
193# Where to install the locale files.
194ifndef localedir
195localedir = $(libdir)/locale
196endif
197inst_localedir = $(install_root)$(localedir)
198
199# Where to install the message catalog data files (which are
200# machine-independent).
201ifndef msgcatdir
202msgcatdir = $(datadir)/locale
203endif
204inst_msgcatdir = $(install_root)$(msgcatdir)
205
206# Where to install the locale charmap source files.
207ifndef i18ndir
208i18ndir = $(datadir)/i18n
209endif
210inst_i18ndir = $(install_root)$(i18ndir)
211
212# Where to install the shared object for charset transformation.
213ifndef gconvdir
214gconvdir = $(libdir)/gconv
215endif
216inst_gconvdir = $(install_root)$(gconvdir)
217
218# Where to install programs.
219ifndef bindir
220bindir = $(exec_prefix)/bin
221endif
222inst_bindir = $(install_root)$(bindir)
223
224# Where to install internal programs.
225ifndef libexecdir
226libexecdir = $(exec_prefix)/libexec
227endif
228inst_libexecdir = $(install_root)$(libexecdir)
229
230# Where to install administrative programs.
231ifndef rootsbindir
232rootsbindir = $(exec_prefix)/sbin
233endif
234inst_rootsbindir = $(install_root)$(rootsbindir)
235
236ifndef sbindir
237sbindir = $(exec_prefix)/sbin
238endif
239inst_sbindir = $(install_root)$(sbindir)
240
241# Where to install the Info files.
242ifndef infodir
243infodir = $(prefix)/info
244endif
245inst_infodir = $(install_root)$(infodir)
246
247# Where to install audit libraries.
248ifndef auditdir
249auditdir = $(libdir)/audit
250endif
251inst_auditdir = $(install_root)$(auditdir)
252
253# Where to install default configuration files. These include the local
254# timezone specification and network data base files.
255ifndef sysconfdir
256sysconfdir = $(prefix)/etc
257endif
258inst_sysconfdir = $(install_root)$(sysconfdir)
259
260# Directory for the database files and Makefile for nss_db.
261ifndef vardbdir
262vardbdir = $(localstatedir)/db
263endif
264inst_vardbdir = $(install_root)$(vardbdir)
265
266# Where to install the "localtime" timezone file; this is the file whose
267# contents $(localtime) specifies. If this is a relative pathname, it is
268# relative to $(zonedir). It is a good idea to put this somewhere
269# other than there, so the zoneinfo directory contains only universal data,
270# localizing the configuration data elsewhere.
271ifndef localtime-file
272localtime-file = $(sysconfdir)/localtime
273endif
274
275# What to use for leap second specifications in compiling the default
276# timezone files. Set this to `/dev/null' for no leap second handling as
277# 1003.1 requires, or to `leapseconds' for proper leap second handling.
278# Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
279# This variable determines the default: if it's `/dev/null',
280# ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
281ifndef leapseconds
282leapseconds = /dev/null
283endif
284
285# What timezone's DST rules should be used when a POSIX-style TZ
286# environment variable doesn't specify any rules. For 1003.1 compliance
287# this timezone must use rules that are as U.S. federal law defines DST.
288# Run `make -C time echo-zonenames' to see a list of available zone names.
289# This setting can be changed with `zic -p TIMEZONE' at any time.
290# If you want POSIX.1 compatibility, use `America/New_York'.
291ifndef posixrules
292posixrules = America/New_York
293endif
294
295# Where to install the "posixrules" timezone file; this is file
296# whose contents $(posixrules) specifies. If this is a relative
297# pathname, it is relative to $(zonedir).
298ifndef posixrules-file
299posixrules-file = posixrules
300endif
301
302
303# Directory where your system's native header files live.
304# This is used on Unix systems to generate some GNU libc header files.
305ifndef sysincludedir
306sysincludedir = /usr/include
307endif
308
309
310# Commands to install files.
311ifndef INSTALL_DATA
312INSTALL_DATA = $(INSTALL) -m 644
313endif
314ifndef INSTALL_SCRIPT
315INSTALL_SCRIPT = $(INSTALL)
316endif
317ifndef INSTALL_PROGRAM
318INSTALL_PROGRAM = $(INSTALL)
319endif
320ifndef INSTALL
321INSTALL = install
322endif
323
324
325# The name of the C compiler.
326# If you've got GCC, and it works, use it.
327ifeq ($(origin CC),default)
328CC := gcc
329endif
330
331# The name of the C compiler to use for compilations of programs to run on
332# the host that is building the library. If you set CC to a
333# cross-compiler, you must set this to the normal compiler.
334ifndef BUILD_CC
335BUILD_CC = $(CC)
336endif
337
338# Default flags to pass the C compiler.
339ifndef default_cflags
340ifeq ($(release),stable)
341default_cflags := -g -O2
342else
343default_cflags := -g -O
344endif
345endif
346
347# Flags to pass the C compiler when assembling preprocessed assembly code
348# (`.S' files). On some systems the assembler doesn't understand the `#' line
349# directives the preprocessor produces. If you have troubling compiling
350# assembly code, try using -P here to suppress these directives.
351ifndef asm-CPPFLAGS
352asm-CPPFLAGS =
353endif
354
355as-needed := -Wl,--as-needed
356no-as-needed := -Wl,--no-as-needed
357
358# Must be supported by the linker.
359no-whole-archive = -Wl,--no-whole-archive
360whole-archive = -Wl,--whole-archive
361
362# Installed name of the startup code.
363# The ELF convention is that the startfile is called crt1.o
364start-installed-name = crt1.o
365# On systems that do not need a special startfile for statically linked
366# binaries, simply set it to the normal name.
367ifndef static-start-installed-name
368static-start-installed-name = $(start-installed-name)
369endif
370
371ifeq (yesyes,$(build-shared)$(have-z-combreloc))
372combreloc-LDFLAGS = -Wl,-z,combreloc
373LDFLAGS.so += $(combreloc-LDFLAGS)
374LDFLAGS-rtld += $(combreloc-LDFLAGS)
375endif
376
377relro-LDFLAGS = -Wl,-z,relro
378LDFLAGS.so += $(relro-LDFLAGS)
379LDFLAGS-rtld += $(relro-LDFLAGS)
380
381ifeq (yes,$(have-hash-style))
382# For the time being we unconditionally use 'both'. At some time we
383# should declare statically linked code as 'out of luck' and compile
384# with --hash-style=gnu only.
385hashstyle-LDFLAGS = -Wl,--hash-style=both
386LDFLAGS.so += $(hashstyle-LDFLAGS)
387LDFLAGS-rtld += $(hashstyle-LDFLAGS)
388endif
389
390# Command for linking PIE programs with the C library.
391ifndef +link-pie
392+link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
393 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
394 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
395 $(addprefix $(csu-objpfx),S$(start-installed-name)) \
396 $(+preinit) $(+prectorS) \
397 $(filter-out $(addprefix $(csu-objpfx),start.o \
398 S$(start-installed-name))\
399 $(+preinit) $(link-extra-libs) \
400 $(common-objpfx)libc% $(+postinit),$^) \
401 $(link-extra-libs)
402+link-pie-after-libc = $(+postctorS) $(+postinit)
403+link-pie = $(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-libc) \
404 $(+link-pie-after-libc)
405+link-pie-tests = $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) \
406 $(link-libc-tests) $(+link-pie-after-libc)
407endif
408# Command for statically linking programs with the C library.
409ifndef +link-static
410+link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
411 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
412 $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
413 $(+preinit) $(+prectorT) \
414 $(filter-out $(addprefix $(csu-objpfx),start.o \
415 $(start-installed-name))\
416 $(+preinit) $(link-extra-libs-static) \
417 $(common-objpfx)libc% $(+postinit),$^) \
418 $(link-extra-libs-static)
419+link-static-after-libc = $(+postctorT) $(+postinit)
420+link-static = $(+link-static-before-libc) $(link-libc-static) \
421 $(+link-static-after-libc)
422+link-static-tests = $(+link-static-before-libc) $(link-libc-static-tests) \
423 $(+link-static-after-libc)
424endif
425# Commands for linking programs with the C library.
426ifndef +link
427ifeq (yes,$(build-shared))
428+link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
429 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
430 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
431 $(addprefix $(csu-objpfx),$(start-installed-name)) \
432 $(+preinit) $(+prector) \
433 $(filter-out $(addprefix $(csu-objpfx),start.o \
434 $(start-installed-name))\
435 $(+preinit) $(link-extra-libs) \
436 $(common-objpfx)libc% $(+postinit),$^) \
437 $(link-extra-libs)
438+link-after-libc = $(+postctor) $(+postinit)
439+link = $(+link-before-libc) $(rtld-LDFLAGS) $(link-libc) \
440 $(+link-after-libc)
441+link-tests = $(+link-before-libc) $(rtld-tests-LDFLAGS) \
442 $(link-libc-tests) $(+link-after-libc)
443else
444+link = $(+link-static)
445+link-tests = $(+link-static-tests)
446endif
447endif
448ifeq (yes,$(build-shared))
449ifndef rtld-LDFLAGS
450rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
451endif
452ifndef rtld-tests-LDFLAGS
453ifeq (yes,$(build-hardcoded-path-in-tests))
454rtld-tests-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so
455else
456rtld-tests-LDFLAGS = $(rtld-LDFLAGS)
457endif
458endif
459endif
460ifndef link-libc
461ifeq (yes,$(build-shared))
462# We need the versioned name of libc.so in the deps of $(others) et al
463# so that the symlink to libc.so is created before anything tries to
464# run the linked programs.
465link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link)
466ifeq (yes,$(build-hardcoded-path-in-tests))
467link-libc-tests-rpath-link = -Wl,-rpath=$(rpath-link)
468else
469link-libc-tests-rpath-link = $(link-libc-rpath-link)
470endif
471link-libc-before-gnulib = $(common-objpfx)libc.so$(libc.so-version) \
472 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
473 $(as-needed) $(elf-objpfx)ld.so \
474 $(no-as-needed)
475link-libc = $(link-libc-rpath-link) $(link-libc-before-gnulib) $(gnulib)
476link-libc-tests = $(link-libc-tests-rpath-link) \
477 $(link-libc-before-gnulib) $(gnulib-tests)
478# This is how to find at build-time things that will be installed there.
479rpath-dirs = math elf dlfcn nss nis rt resolv crypt
480rpath-link = \
481$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
482else
483link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
484link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
485endif
486endif
487
488# Differences in the linkers on the various platforms.
489LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
490LDFLAGS-soname-fname = -Wl,-soname,$(@F)
491LDFLAGS-rdynamic = -rdynamic
492LDFLAGS-Bsymbolic = -Bsymbolic
493
494# Choose the default search path for the dynamic linker based on
495# where we will install libraries.
496ifneq ($(libdir),$(slibdir))
497default-rpath = $(slibdir):$(libdir)
498else
499default-rpath = $(libdir)
500endif
501
502ifndef link-extra-libs
503link-extra-libs = $(LDLIBS-$(@F))
504link-extra-libs-static = $(link-extra-libs)
505endif
506
507# The static libraries.
508link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
509link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
510
511# How to link against libgcc. Some libgcc functions, such as those
512# for "long long" arithmetic or software floating point, can always be
513# built without use of C library headers and do not have any global
514# state so can safely be linked statically into any executable or
515# shared library requiring them; these functions are in libgcc.a.
516# Other functions, relating to exception handling, may require C
517# library headers to build and it may not be safe to have more than
518# one copy of them in a process; these functions are only in
519# libgcc_s.so and libgcc_eh.a.
520#
521# To avoid circular dependencies when bootstrapping, it is desirable
522# to avoid use of libgcc_s and libgcc_eh in building glibc. Where any
523# glibc functionality (in particular, thread cancellation) requires
524# exception handling, this is implemented through dlopen of libgcc_s
525# to avoid unnecessary dependencies on libgcc_s by programs not using
526# that functionality; executables built with glibc do not use
527# exception handling other than through thread cancellation.
528#
529# Undefined references to functions from libgcc_eh or libgcc_s may
530# arise for code built with -fexceptions. In the case of statically
531# linked programs installed by glibc, unwinding will never actually
532# occur at runtime and the use of elf/static-stubs.c to resolve these
533# references is safe. In the case of statically linked test programs
534# and test programs built with -fexceptions, unwinding may occur in
535# some cases and it is preferable to link with libgcc_eh or libgcc_s
536# so that the testing is as similar as possible to how programs will
537# be built with the installed glibc.
538#
539# Some architectures have architecture-specific systems for exception
540# handling that may involve undefined references to
541# architecture-specific functions. On those architectures,
542# gnulib-arch and static-gnulib-arch may be defined in sysdeps
543# makefiles to use additional libraries for linking executables and
544# shared libraries built by glibc.
545ifndef gnulib
546ifneq ($(have-cc-with-libunwind),yes)
547 libunwind =
548else
549 libunwind = -lunwind
550endif
551libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
552gnulib-arch =
553gnulib = -lgcc $(gnulib-arch)
554gnulib-tests := -lgcc $(libgcc_eh)
555static-gnulib-arch =
556# By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
557# statically link programs. When --disable-shared is used, we use
558# -lgcc_eh since elf/static-stubs.o isn't sufficient.
559ifeq (yes,$(build-shared))
560static-gnulib = -lgcc $(static-gnulib-arch)
561else
562static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch)
563endif
564static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
565libc.so-gnulib := -lgcc
566endif
567+preinit = $(addprefix $(csu-objpfx),crti.o)
568+postinit = $(addprefix $(csu-objpfx),crtn.o)
569+prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
570+postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
571# Variants of the two previous definitions for linking PIE programs.
572+prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
573+postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
574# Variants of the two previous definitions for statically linking programs.
575+prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
576+postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
577+interp = $(addprefix $(elf-objpfx),interp.os)
578csu-objpfx = $(common-objpfx)csu/
579elf-objpfx = $(common-objpfx)elf/
580
581# A command that, prepended to the name and arguments of a program,
582# and run on the build system, causes that program with those
583# arguments to be run on the host for which the library is built.
584ifndef test-wrapper
585test-wrapper =
586endif
587# Likewise, but the name of the program is preceded by
588# <variable>=<value> assignments for environment variables.
589ifndef test-wrapper-env
590test-wrapper-env = $(test-wrapper) env
591endif
592
593# Whether to run test programs built for the library's host system.
594ifndef run-built-tests
595ifeq (yes|,$(cross-compiling)|$(test-wrapper))
596run-built-tests = no
597else
598run-built-tests = yes
599endif
600endif
601
602# Whether to stop immediately when a test fails. Nonempty means to
603# stop, empty means not to stop.
604ifndef stop-on-test-failure
605stop-on-test-failure =
606endif
607
608# How to run a program we just linked with our library.
609# The program binary is assumed to be $(word 2,$^).
610built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
611rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
612 --library-path \
613 $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
614ifeq (yes,$(build-shared))
615comma = ,
616sysdep-library-path = \
617$(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
618 $(filter -Wl$(comma)-rpath-link=%,\
619 $(sysdep-LDFLAGS)))))
620# $(run-via-rtld-prefix) is a command that, when prepended to the name
621# of a program built with the newly built library, produces a command
622# that, executed on the host for which the library is built, runs that
623# program. For tests listed in tests-static or xtests-static, it is
624# empty.
625run-via-rtld-prefix = \
626 $(if $(strip $(filter $(notdir $(built-program-file)), \
627 $(tests-static) $(xtests-static))),, $(rtld-prefix))
628else
629run-via-rtld-prefix =
630endif
631# $(run-program-env) is the default environment variable settings to
632# use when running a program built with the newly built library.
633run-program-env = GCONV_PATH=$(common-objpfx)iconvdata \
634 LOCPATH=$(common-objpfx)localedata LC_ALL=C
635# $(run-program-prefix) is a command that, when prepended to the name
636# of a program built with the newly built library, produces a command
637# that, executed on the build system on which "make" is run, runs that
638# program. $(run-program-prefix-before-env) and
639# $(run-program-prefix-after-env) are similar, but separate parts
640# before and after a list of environment variables.
641run-program-prefix-before-env = $(test-wrapper-env)
642run-program-prefix-after-env = $(run-via-rtld-prefix)
643run-program-prefix = $(run-program-prefix-before-env) $(run-program-env) \
644 $(run-program-prefix-after-env)
645# $(built-program-cmd) is a command that, executed on the build system
646# on which "make" is run, runs the newly built program that is the
647# second dependency of the makefile target in which
648# $(built-program-cmd) is used. $(built-program-cmd-before-env) and
649# $(built-program-cmd-after-env) are similar, before and after a list
650# of environment variables.
651built-program-cmd-before-env = $(test-wrapper-env)
652built-program-cmd-after-env = $(run-via-rtld-prefix) $(built-program-file)
653built-program-cmd = $(built-program-cmd-before-env) $(run-program-env) \
654 $(built-program-cmd-after-env)
655# $(host-built-program-cmd) is a command that, executed on the host
656# for which the library is built, runs the newly built program that is
657# the second dependency of the makefile target in which
658# $(host-built-program-cmd) is used.
659host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file)
660
661ifndef LD
662LD := ld -X
663endif
664
665# $(test-via-rtld-prefix) is a command that, when prepended to the name
666# of a test program built with the newly built library, produces a command
667# that, executed on the host for which the library is built, runs that
668# program. For tests listed in tests-static or xtests-static as well
669# as when test programs are hardcoded to the newly built libraries, it
670# is empty.
671
672# $(test-program-prefix) is a command that, when prepended to the name
673# of a test program built with the newly built library, produces a command
674# that, executed on the build system on which "make" is run, runs that
675# test program. $(test-program-prefix-before-env) and
676# $(test-program-prefix-after-env) are similar, before and after a
677# list of environment variables.
678
679# $(test-program-cmd) is a command that, executed on the build system
680# on which "make" is run, runs the newly built test program that is the
681# second dependency of the makefile target in which
682# $(test-program-cmd) is used. $(test-program-cmd-before-env) and
683# $(test-program-cmd-after-env) are similar, before and after a list
684# of environment variables.
685
686# $(host-test-program-cmd) is a command that, executed on the host
687# for which the library is built, runs the newly built test program that
688# is the second dependency of the makefile target in which
689# $(host-test-program-cmd) is used.
690
691ifeq (yes,$(build-hardcoded-path-in-tests))
692test-via-rtld-prefix =
693test-program-prefix-before-env = $(test-wrapper-env)
694test-program-prefix-after-env =
695test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \
696 $(test-program-prefix-after-env)
697test-program-cmd-before-env = $(test-wrapper-env)
698test-program-cmd-after-env = $(built-program-file)
699test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \
700 $(test-program-cmd-after-env)
701host-test-program-cmd = $(built-program-file)
702else
703test-via-rtld-prefix = $(run-via-rtld-prefix)
704test-program-prefix-before-env = $(run-program-prefix-before-env)
705test-program-prefix-after-env = $(run-program-prefix-after-env)
706test-program-prefix = $(run-program-prefix)
707test-program-cmd-before-env = $(built-program-cmd-before-env)
708test-program-cmd-after-env = $(built-program-cmd-after-env)
709test-program-cmd = $(built-program-cmd)
710host-test-program-cmd = $(host-built-program-cmd)
711endif
712
713# Extra flags to pass to GCC.
714ifeq ($(all-warnings),yes)
715+gccwarn := -Wall -Wwrite-strings -Winline -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
716else
717+gccwarn := -Wall -Wwrite-strings -Winline
718endif
719+gccwarn += -Wundef
720+gccwarn-c = -Wstrict-prototypes -Werror=implicit-function-declaration
721
722# We do not depend on the address of constants in different files to be
723# actually different, so allow the compiler to merge them all.
724+merge-constants = -fmerge-all-constants
725
726# We have to assume that glibc functions are called in any rounding
727# mode and also change the rounding mode in a few functions. So,
728# disable any optimization that assume default rounding mode.
729+math-flags = -frounding-math
730
731# This is the program that generates makefile dependencies from C source files.
732# The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
733# targets for headers so that removed headers don't break the build.
734ifndef +mkdep
735+mkdep = $(CC) -M -MP
736endif
737
738# The program that makes Emacs-style TAGS files.
739ETAGS := etags
740
741# The `xgettext' program for producing .pot files from sources.
742ifndef XGETTEXT
743XGETTEXT = xgettext
744endif
745
746# The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
747# perhaps others) to preprocess assembly code in some cases.
748M4 = m4
749
750# To force installation of files even if they are older than the
751# installed files. This variable is included in the dependency list
752# of all installation targets.
753ifeq ($(force-install),yes)
754+force = force-install
755else
756+force =
757endif
758
759####
760#### End of configuration variables.
761####
762\f
763# This tells some versions of GNU make before 3.63 not to export all variables.
764.NOEXPORT:
765
766# We want to echo the commands we're running without
767# umpteen zillion filenames along with it (we use `...' instead)
768# but we don't want this echoing done when the user has said
769# he doesn't want to see commands echoed by using -s.
770ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
771+cmdecho := echo >/dev/null
772else # not -s
773+cmdecho := echo
774endif # -s
775
776# These are the flags given to the compiler to tell
777# it what sort of optimization and/or debugging output to do.
778ifndef +cflags
779# If `CFLAGS' was defined, use that.
780ifdef CFLAGS
781+cflags := $(filter-out -I%,$(CFLAGS))
782endif # CFLAGS
783endif # +cflags
784
785# If none of the above worked, default to "-g -O".
786ifeq "$(strip $(+cflags))" ""
787+cflags := $(default_cflags)
788endif # $(+cflags) == ""
789
790+cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags)
791+gcc-nowarn := -w
792
793# Don't duplicate options if we inherited variables from the parent.
794+cflags := $(sort $(+cflags))
795
796# Each sysdeps directory can contain header files that both will be
797# used to compile and will be installed. Each can also contain an
798# include/ subdirectory, whose header files will be used to compile
799# but will not be installed, and will take precedence over the
800# installed files. This mirrors the top-level include/ subdirectory.
801+sysdep-includes := $(foreach dir,$(+sysdep_dirs),\
802 $(addprefix -I,$(wildcard $(dir)/include) $(dir)))
803
804# These are flags given to the C compiler to tell it to look for
805# include files (including ones given in angle brackets) in the parent
806# library source directory, in the include directory, and in the
807# current directory.
808+includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
809 $(+sysdep-includes) $(includes) \
810 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
811
812# Since libio has several internal header files, we use a -I instead
813# of many little headers in the include directory.
814libio-include = -I$(..)libio
815
816in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
817 $(libof-$(<F)) \
818 $(libof-$(@F)) \
819 libc))
820
821# These are the variables that the implicit compilation rules use.
822# Note that we can't use -std=* in CPPFLAGS, because it overrides
823# the implicit -lang-asm and breaks cpp behavior for .S files--notably
824# it causes cpp to stop predefining __ASSEMBLER__.
825CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
826 $($(subdir)-CPPFLAGS) \
827 $(+includes) $(defines) \
828 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
829 $(CPPFLAGS-$(suffix $@)) -DIN_MODULE=MODULE_$(in-module) \
830 $(foreach lib,$(libof-$(basename $(@F))) \
831 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
832 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
833override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) $(config-extra-cflags) \
834 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
835 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
836 $(CFLAGS-$(@F)) \
837 $(foreach lib,$(libof-$(basename $(@F))) \
838 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
839override CXXFLAGS = $(c++-sysincludes) \
840 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
841 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
842
843# If everything is compiled with -fPIC (implicitly) we must tell this by
844# defining the PIC symbol.
845ifeq (yes,$(build-pic-default))
846pic-default = -DPIC
847endif
848
849# Enable object files for different versions of the library.
850# Various things use $(object-suffixes) to know what all to make.
851# The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
852# to pass different flags for each flavor.
853libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
854all-object-suffixes := .o .os .op .og .oS
855object-suffixes :=
856CPPFLAGS-.o = $(pic-default)
857CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
858libtype.o := lib%.a
859object-suffixes += .o
860ifeq (yes,$(build-shared))
861# Under --enable-shared, we will build a shared library of PIC objects.
862# The PIC object files are named foo.os.
863object-suffixes += .os
864CPPFLAGS-.os = -DPIC -DSHARED
865CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
866libtype.os := lib%_pic.a
867# This can be changed by a sysdep makefile
868pic-ccflag = -fPIC
869# This one should always stay like this unless there is a very good reason.
870PIC-ccflag = -fPIC
871endif
872# This can be changed by a sysdep makefile
873pie-ccflag = -fpie
874# This one should always stay like this unless there is a very good reason.
875PIE-ccflag = -fPIE
876ifeq (yes,$(build-profile))
877# Under --enable-profile, we will build a static library of profiled objects.
878# The profiled object files are named foo.op.
879object-suffixes += .op
880CPPFLAGS-.op = -DPROF $(pic-default)
881CFLAGS-.op = -pg
882libtype.op = lib%_p.a
883endif
884
885# Convenience variable for when we want to treat shared-library cases
886# differently from the rest.
887object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
888
889object-suffixes-for-libc := $(object-suffixes)
890
891ifeq (yes,$(build-shared))
892# Build special library that contains the static-only routines for libc.
893object-suffixes-for-libc += .oS
894
895# Must build the routines as PIC, though, because they can end up in (users')
896# shared objects. We don't want to use CFLAGS-os because users may, for
897# example, make that processor-specific.
898CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
899CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
900libtype.oS = lib%_nonshared.a
901endif
902
903# The assembler can generate debug information too.
904ifndef ASFLAGS
905ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
906endif
907ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
908
909ifndef BUILD_CC
910BUILD_CC = $(CC)
911endif
912
913move-if-change = $(SHELL) $(..)scripts/move-if-change
914\f
915-include $(common-objpfx)sysd-sorted
916subdirs = $(sorted-subdirs)
917subdir-srcdirs = $(foreach dir,$(subdirs),\
918 $(firstword $($(dir)-srcdir) $(..)$(dir)))
919
920# This is a pair of implicit rules to preprocess a file with # comments,
921# %ifdef et al, based on config.h settings or other %include'd files.
922# We use chained rules instead of a pipeline here so that we can properly
923# check the exit status of cpp rather than using its bad output when there
924# is a preprocessing error. Another rule should depend on the output file
925# `FOO.v', and along with that `FOO.v.i' should be given dependencies
926# listing both its input files, and any header files that it may reference
927# (but no commands).
928%.v.i: $(common-objpfx)config.h $(..)Makeconfig
929 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
930 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
931 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
932 > $@T
933 mv -f $@T $@
934%.v: %.v.i
935 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
936 mv -f $@T $@
937
938ifeq (yes, $(build-shared))
939
940# To generate a header to support more than one ABI for different
941# architecture variants, the CPU/Makefile defines abi-variants to be a
942# list of names for those variants (e.g. 32 64), and, for each variant,
943# defines abi-$(variant)-condition to be the condition for those options
944# to use in a C #if condition. abi-includes may be defined to a list of
945# headers to include in the generated header, if the default does not
946# suffice. default-abi is defined to be the ABI for the current glibc
947# build.
948
949ifndef abi-includes
950abi-includes := bits/wordsize.h
951endif
952
953# Process the shlib-versions file, which tells us what shared library
954# version numbers to use when we install shared objects on this system.
955# We need to wait until $(subdirs) is complete.
956ifeq ($(sysd-sorted-done),t)
957-include $(common-objpfx)soversions.mk
958ifndef avoid-generated
959# This lets add-ons give more-specific matches that override defaults
960# in the top-level file.
961$(common-objpfx)shlib-versions.v.i: \
962 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
963 $(subdir-srcdirs:=/shlib-versions)) \
964 $(..)shlib-versions
965
966$(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
967 $(common-objpfx)shlib-versions.v
968 $(AWK) -f $^ > $@T
969 mv -f $@T $@
970$(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
971 (while read which lib number setname; do \
972 eval seen_$$which=1; \
973 test x"$$which" = xDEFAULT || continue; \
974 case $$number in \
975 [0-9]*) echo "$$lib.so-version=.$$number"; \
976 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
977 *) echo "$$lib.so-version=$$number"; \
978 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
979 esac; \
980 done; \
981 echo soversions.mk-done = t;) < $< > $@T; exit 0
982 mv -f $@T $@
983endif
984endif
985
986postclean-generated += soversions.mk soversions.i \
987 shlib-versions.v shlib-versions.v.i
988
989# The name under which the run-time dynamic linker is installed.
990# We are currently going for the convention that `/lib/ld.so.1'
991# names the SVR4/ELF ABI-compliant dynamic linker.
992ifndef rtld-installed-name
993ifdef ld.so-version
994rtld-installed-name = $(ld.so-version)
995else
996rtld-installed-name = ld.so.1
997endif
998endif
999
1000ifndef rtld-version-installed-name
1001rtld-version-installed-name = ld-$(version).so
1002endif
1003
1004endif # build-shared
1005
1006
1007ifeq ($(build-shared),yes)
1008libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
1009else
1010libdl = $(common-objpfx)dlfcn/libdl.a
1011endif
1012
1013ifeq ($(build-shared),yes)
1014libm = $(common-objpfx)math/libm.so$(libm.so-version)
1015else
1016libm = $(common-objpfx)math/libm.a
1017endif
1018
1019# These are the subdirectories containing the library source. The order
1020# is more or less arbitrary. The sorting step will take care of the
1021# dependencies.
1022all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
1023 stdlib stdio-common libio malloc string wcsmbs time dirent \
1024 grp pwd posix io termios resource misc socket sysvipc gmon \
1025 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
1026 crypt localedata timezone rt conform debug \
1027 $(add-on-subdirs) dlfcn elf
1028
1029ifndef avoid-generated
1030# sysd-sorted itself will contain rules making the sysd-sorted target
1031# depend on Depend files. But if you just added a Depend file to an
1032# existing directory not in all-subdirs, then sysd-sorted needs to
1033# be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files.
1034all-Depend-files := $(wildcard $(sort \
1035 $(foreach dir,$(all-subdirs),\
1036 $(firstword $($(dir)-srcdir) \
1037 $(..)$(dir))/Depend) \
1038 $(sorted-subdirs:=/Depend)))
1039$(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
1040 $(common-objpfx)config.make $(..)Makeconfig \
1041 $(wildcard $(sysdirs:=/Subdirs)) \
1042 $(all-Depend-files)
1043 $(AWK) -f $< \
1044 -v subdirs='$(all-subdirs)' \
1045 -v srcpfx='$(..)' \
1046 $(filter %/Subdirs %/Depend,$^) > $@-tmp
1047 mv -f $@-tmp $@
1048$(all-Depend-files): ;
1049endif
1050
1051# This gives partial TARGET:SOURCE pattern pairs to have rules
1052# emitted into sysd-rules. A sysdeps Makeconfig fragment can
1053# add its own special object file prefix to this list with e.g. foo-%:%
1054# to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
1055sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
1056
1057# Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
1058sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
1059ifneq (,$(sysdep-makeconfigs))
1060include $(sysdep-makeconfigs)
1061endif
1062
1063# Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
1064sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
1065 $(firstword $(subst :, ,$p))))
1066
1067# A sysdeps Makeconfig fragment may set libc-reentrant to yes.
1068ifeq (yes,$(libc-reentrant))
1069defines += -D_LIBC_REENTRANT
1070
1071libio-mtsafe = -D_IO_MTSAFE_IO
1072endif
1073
1074# The name to give to a test in test results summaries.
1075test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@)))
1076
1077# Likewise, in XFAIL variable names.
1078test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@)))
1079
1080# Command to output a test status line (such as PASS: test-name). If
1081# test-xfail-$(test-xfail-name) has a nonempty value, the status will be
1082# XPASS or XFAIL rather than PASS or FAIL.
1083evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \
1084 $(if $(test-xfail-$(test-xfail-name)),true,false) \
1085 $(if $(stop-on-test-failure),true,false) \
1086 > $(common-objpfx)$(test-name).test-result
1087
1088endif # Makeconfig not yet included
1089
1090# Local Variables:
1091# mode: makefile
1092# End: