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