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