Hurd: Update posix_opt.h
[glibc.git] / Makeconfig
blobf68a752766a44f1c90c646c26dcac2fe453ab649
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 # If config.make exists, the source directory was configured,
37 # so don't try to be clever and find another directory to build in.
38 ifneq (,$(wildcard $(..)config.make))
39 ARCH =
40 machine =
41 else    # Not configured.
42 ifndef ARCH
43 ifdef machine
44 ARCH = $(machine)
45 endif # machine
46 endif # ARCH
47 endif # config.make
49 # Directory for object files and libc.a.  If this is not defined, the
50 # object files live in the subdirectories where their sources live, and
51 # libc.a lives in the parent directory (this probably doesn't work any
52 # more).
53 ifdef ARCH
54 ifeq ($(filter /%,$(ARCH)),)
55 objdir := $(..)$(ARCH)
56 else
57 objdir = $(ARCH)
58 endif
59 endif
61 # $(common-objdir) is the place to put objects and
62 # such that are not specific to a single subdir.
63 ifdef objdir
64 objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
65 common-objpfx = $(objdir)/
66 common-objdir = $(objdir)
67 else
68 objpfx :=
69 ifdef ..
70 common-objpfx = $(..)
71 common-objdir = ..
72 else
73 # This is a kludge.  make wizards might grok.
74 common-objpfx = sysdeps/../
75 common-objdir = .
76 endif
77 endif
79 # Root of the sysdeps tree.
80 sysdep_dir := $(..)sysdeps
81 export sysdep_dir := $(sysdep_dir)
83 # Get the values defined by options to `configure'.
84 include $(common-objpfx)config.make
86 # What flags to give to sources which call user provided callbacks
87 uses-callbacks = $(exceptions)
89 # What flags to give to tests which test stack alignment
90 stack-align-test-flags =
92 # We have a special subdir for each binary format.
93 # For now, only ELF is fully supported.
94 binfmt-subdir = elf
96 # Complete path to sysdep dirs.
97 # `configure' writes a definition of `config-sysdirs' in `config.make'.
98 sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
100 # Add-ons that contribute sysdeps trees get added to the include list
101 # after sysdeps/generic.  This makes #include <sysdeps/...> work right
102 # to find specific add-on files without assuming the add-on directory name.
103 # It also means that headers can go into an add-on's base directory
104 # instead of the add-on needing a sysdeps/generic of its own.
105 sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\
106                              $(firstword $(filter /%,$(add-on)) \
107                                          $(..)$(add-on)))
108 +sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs)
109 ifdef objdir
110 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
111 endif
113 # Run config.status to update config.make and config.h.  We don't show the
114 # dependence of config.h to Make, because it is only touched when it
115 # changes and so config.status would be run every time; the dependence of
116 # config.make should suffice to force regeneration and re-exec, and the new
117 # image will notice if config.h changed.
118 $(common-objpfx)config.make: $(common-objpfx)config.status \
119                              $(..)config.make.in $(..)config.h.in
120         cd $(<D); $(SHELL) $(<F)
122 # Find all the add-on and sysdeps configure fragments, to make sure we
123 # re-run configure when any of them changes.
124 $(common-objpfx)config.status: $(..)version.h $(..)configure \
125                                $(foreach dir,$(sysdirs),\
126                                          $(wildcard $(dir)/Implies) \
127                                          $(patsubst %.in,%,\
128                                                     $(firstword $(wildcard \
129  $(addprefix $(dir)/,configure configure.in))))) \
130                                $(patsubst %.in,%,\
131                                           $(foreach add-on,$(add-ons),\
132                                                     $(firstword $(wildcard \
133  $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
134              configure configure.in)))))
135         @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
136          echo The GNU C library has not been configured. >&2; \
137          echo Run \`configure\' to configure it before building. >&2; \
138          echo Try \`configure --help\' for more details. >&2; \
139          exit 1; fi
141 # We don't want CPPFLAGS to be exported to the command running configure.
142 unexport CPPFLAGS
144 # Get the user's configuration parameters.
145 ifneq ($(wildcard $(..)configparms),)
146 include $(..)configparms
147 endif
148 ifneq ($(objpfx),)
149 ifneq ($(wildcard $(common-objpfx)configparms),)
150 include $(common-objpfx)configparms
151 endif
152 endif
154 ####
155 ####    These are the configuration variables.  You can define values for
156 ####    the variables below in the file `configparms'.
157 ####    Do NOT edit this file.
158 ####
161 # Common prefix for machine-independent installation directories.
162 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
163 prefix = /usr/local
164 endif
166 # Decide whether we shall build the programs or not.  We always do this
167 # unless the user tells us (in configparms) or we are building for a
168 # standalone target.
169 ifndef build-programs
170 ifneq ($(config-os),none)
171 build-programs=yes
172 else
173 build-programs=no
174 endif
175 endif
177 # Common prefix for machine-dependent installation directories.
178 ifeq ($(origin exec_prefix),undefined)
179 exec_prefix = $(prefix)
180 endif
182 # Where to install the library and object files.
183 ifndef libdir
184 libdir = $(exec_prefix)/lib
185 endif
186 inst_libdir = $(install_root)$(libdir)
188 # Where to install the shared library and dynamic linker.
189 ifndef slibdir
190 slibdir = $(exec_prefix)/lib
191 endif
192 inst_slibdir = $(install_root)$(slibdir)
194 # Prefix to put on files installed in $(libdir).  For libraries `libNAME.a',
195 # the prefix is spliced between `lib' and the name, so the linker switch
196 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
197 # just prepended to the whole file name.
198 ifeq ($(origin libprefix),undefined)
199 libprefix =
200 endif
202 # Where to install the header files.
203 ifndef includedir
204 includedir = $(prefix)/include
205 endif
206 inst_includedir = $(install_root)$(includedir)
208 # Where to install machine-independent data files.
209 # These are the timezone database, and the locale database.
210 ifndef datadir
211 datadir = $(prefix)/share
212 endif
213 inst_datadir = $(install_root)$(datadir)
215 # Where to install the timezone data files (which are machine-independent).
216 ifndef zonedir
217 zonedir = $(datadir)/zoneinfo
218 endif
219 inst_zonedir = $(install_root)$(zonedir)
221 # Where to install the locale files.
222 ifndef localedir
223 localedir = $(libdir)/locale
224 endif
225 inst_localedir = $(install_root)$(localedir)
227 # Where to install the message catalog data files (which are
228 # machine-independent).
229 ifndef msgcatdir
230 msgcatdir = $(datadir)/locale
231 endif
232 inst_msgcatdir = $(install_root)$(msgcatdir)
234 # Where to install the locale charmap source files.
235 ifndef i18ndir
236 i18ndir = $(datadir)/i18n
237 endif
238 inst_i18ndir = $(install_root)$(i18ndir)
240 # Where to install the shared object for charset transformation.
241 ifndef gconvdir
242 gconvdir = $(libdir)/gconv
243 endif
244 inst_gconvdir = $(install_root)$(gconvdir)
246 # Where to install programs.
247 ifndef bindir
248 bindir = $(exec_prefix)/bin
249 endif
250 inst_bindir = $(install_root)$(bindir)
252 # Where to install internal programs.
253 ifndef libexecdir
254 libexecdir = $(exec_prefix)/libexec
255 endif
256 inst_libexecdir = $(install_root)$(libexecdir)
258 # Where to install administrative programs.
259 ifndef rootsbindir
260 rootsbindir = $(exec_prefix)/sbin
261 endif
262 inst_rootsbindir = $(install_root)$(rootsbindir)
264 ifndef sbindir
265 sbindir = $(exec_prefix)/sbin
266 endif
267 inst_sbindir = $(install_root)$(sbindir)
269 # Where to install the Info files.
270 ifndef infodir
271 infodir = $(prefix)/info
272 endif
273 inst_infodir = $(install_root)$(infodir)
275 # Where to install audit libraries.
276 ifndef auditdir
277 auditdir = $(libdir)/audit
278 endif
279 inst_auditdir = $(install_root)$(auditdir)
281 # Where to install default configuration files.  These include the local
282 # timezone specification and network data base files.
283 ifndef sysconfdir
284 sysconfdir = $(prefix)/etc
285 endif
286 inst_sysconfdir = $(install_root)$(sysconfdir)
288 # Directory for the database files and Makefile for nss_db.
289 ifndef vardbdir
290 vardbdir = /var/db
291 endif
292 inst_vardbdir = $(install_root)$(vardbdir)
294 # Where to install the "localtime" timezone file; this is the file whose
295 # contents $(localtime) specifies.  If this is a relative pathname, it is
296 # relative to $(zonedir).  It is a good idea to put this somewhere
297 # other than there, so the zoneinfo directory contains only universal data,
298 # localizing the configuration data elsewhere.
299 ifndef localtime-file
300 localtime-file = $(sysconfdir)/localtime
301 endif
303 # What to use for leap second specifications in compiling the default
304 # timezone files.  Set this to `/dev/null' for no leap second handling as
305 # 1003.1 requires, or to `leapseconds' for proper leap second handling.
306 # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
307 # This variable determines the default: if it's `/dev/null',
308 # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
309 ifndef leapseconds
310 leapseconds = /dev/null
311 endif
313 # What timezone's DST rules should be used when a POSIX-style TZ
314 # environment variable doesn't specify any rules.  For 1003.1 compliance
315 # this timezone must use rules that are as U.S. federal law defines DST.
316 # Run `make -C time echo-zonenames' to see a list of available zone names.
317 # This setting can be changed with `zic -p TIMEZONE' at any time.
318 # If you want POSIX.1 compatibility, use `America/New_York'.
319 ifndef posixrules
320 posixrules = America/New_York
321 endif
323 # Where to install the "posixrules" timezone file; this is file
324 # whose contents $(posixrules) specifies.  If this is a relative
325 # pathname, it is relative to $(zonedir).
326 ifndef posixrules-file
327 posixrules-file = posixrules
328 endif
331 # Directory where your system's native header files live.
332 # This is used on Unix systems to generate some GNU libc header files.
333 ifndef sysincludedir
334 sysincludedir = /usr/include
335 endif
338 # Commands to install files.
339 ifndef INSTALL_DATA
340 INSTALL_DATA = $(INSTALL) -m 644
341 endif
342 ifndef INSTALL_SCRIPT
343 INSTALL_SCRIPT = $(INSTALL)
344 endif
345 ifndef INSTALL_PROGRAM
346 INSTALL_PROGRAM = $(INSTALL)
347 endif
348 ifndef INSTALL
349 INSTALL = install
350 endif
353 # The name of the C compiler.
354 # If you've got GCC, and it works, use it.
355 ifeq ($(origin CC),default)
356 CC := gcc
357 endif
359 # The name of the C compiler to use for compilations of programs to run on
360 # the host that is building the library.  If you set CC to a
361 # cross-compiler, you must set this to the normal compiler.
362 ifndef BUILD_CC
363 BUILD_CC = $(CC)
364 endif
366 # Default flags to pass the C compiler.
367 ifndef default_cflags
368 ifeq ($(release),stable)
369 default_cflags := -g -O2
370 else
371 default_cflags := -g -O
372 endif
373 endif
375 # Flags to pass the C compiler when assembling preprocessed assembly code
376 # (`.S' files).  On some systems the assembler doesn't understand the `#' line
377 # directives the preprocessor produces.  If you have troubling compiling
378 # assembly code, try using -P here to suppress these directives.
379 ifndef asm-CPPFLAGS
380 asm-CPPFLAGS =
381 endif
383 as-needed := -Wl,--as-needed
384 no-as-needed := -Wl,--no-as-needed
386 # Must be supported by the linker.
387 no-whole-archive = -Wl,--no-whole-archive
388 whole-archive = -Wl,--whole-archive
390 # Installed name of the startup code.
391 # The ELF convention is that the startfile is called crt1.o
392 start-installed-name = crt1.o
393 # On systems that do not need a special startfile for statically linked
394 # binaries, simply set it to the normal name.
395 ifndef static-start-installed-name
396 static-start-installed-name = $(start-installed-name)
397 endif
399 ifeq (yesyes,$(build-shared)$(have-z-combreloc))
400 combreloc-LDFLAGS = -Wl,-z,combreloc
401 LDFLAGS.so += $(combreloc-LDFLAGS)
402 LDFLAGS-rtld += $(combreloc-LDFLAGS)
403 endif
405 relro-LDFLAGS = -Wl,-z,relro
406 LDFLAGS.so += $(relro-LDFLAGS)
407 LDFLAGS-rtld += $(relro-LDFLAGS)
409 ifeq (yes,$(have-hash-style))
410 # For the time being we unconditionally use 'both'.  At some time we
411 # should declare statically linked code as 'out of luck' and compile
412 # with --hash-style=gnu only.
413 hashstyle-LDFLAGS = -Wl,--hash-style=both
414 LDFLAGS.so += $(hashstyle-LDFLAGS)
415 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
416 endif
418 # Command for linking programs with the C library.
419 ifndef +link
420 +link = $(CC) -nostdlib -nostartfiles -o $@ \
421               $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
422               $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
423               $(addprefix $(csu-objpfx),$(start-installed-name)) \
424               $(+preinit) $(+prector) \
425               $(filter-out $(addprefix $(csu-objpfx),start.o \
426                                                      $(start-installed-name))\
427                            $(+preinit) $(link-extra-libs) \
428                            $(common-objpfx)libc% $(+postinit),$^) \
429               $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
430 endif
431 # Command for linking PIE programs with the C library.
432 ifndef +link-pie
433 +link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
434              $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
435              $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
436              $(addprefix $(csu-objpfx),S$(start-installed-name)) \
437              $(+preinit) $(+prectorS) \
438              $(filter-out $(addprefix $(csu-objpfx),start.o \
439                                                     S$(start-installed-name))\
440                           $(+preinit) $(link-extra-libs) \
441                           $(common-objpfx)libc% $(+postinit),$^) \
442              $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit)
443 endif
444 # Command for statically linking programs with the C library.
445 ifndef +link-static
446 +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
447               $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
448               $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
449               $(+preinit) $(+prector) \
450               $(filter-out $(addprefix $(csu-objpfx),start.o \
451                                                      $(start-installed-name))\
452                            $(+preinit) $(link-extra-libs-static) \
453                            $(common-objpfx)libc% $(+postinit),$^) \
454               $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
455 endif
456 # Command for statically linking bounded-pointer programs with the C library.
457 ifndef +link-bounded
458 +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
459               $(sysdep-LDFLAGS) $(LDFLAGS)  \
460               $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
461               $(+preinit) $(+prector) \
462               $(filter-out $(addprefix $(csu-objpfx),start.ob \
463                                                      $(start-installed-name))\
464                            $(+preinit) $(link-extra-libs-bounded) \
465                            $(common-objpfx)libc% $(+postinit),$^) \
466               $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
467 endif
468 ifndef config-LDFLAGS
469 ifeq (yes,$(build-shared))
470 config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
471 endif
472 endif
473 ifndef link-libc
474 ifeq (yes,$(build-shared))
475 # We need the versioned name of libc.so in the deps of $(others) et al
476 # so that the symlink to libc.so is created before anything tries to
477 # run the linked programs.
478 link-libc = -Wl,-rpath-link=$(rpath-link) \
479             $(common-objpfx)libc.so$(libc.so-version) \
480             $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
481             $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) $(gnulib)
482 # This is how to find at build-time things that will be installed there.
483 rpath-dirs = math elf dlfcn nss nis rt resolv crypt
484 rpath-link = \
485 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
486 elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
487 else
488 nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
489 resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
490 link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
491 endif
492 endif
494 # Differences in the linkers on the various platforms.
495 LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
496 LDFLAGS-soname-fname = -Wl,-soname,$(@F)
497 LDFLAGS-rdynamic = -rdynamic
498 LDFLAGS-Bsymbolic = -Bsymbolic
500 # Choose the default search path for the dynamic linker based on
501 # where we will install libraries.
502 ifneq ($(libdir),$(slibdir))
503 default-rpath = $(slibdir):$(libdir)
504 else
505 default-rpath = $(libdir)
506 endif
508 ifndef link-extra-libs
509 link-extra-libs = $(LDLIBS-$(@F))
510 link-extra-libs-static = $(link-extra-libs)
511 link-extra-libs-bounded = $(link-extra-libs)
512 endif
514 # The static libraries.
515 link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
516 link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
518 ifndef gnulib
519 ifneq ($(have-cc-with-libunwind),yes)
520   libunwind =
521 else
522   libunwind = -lunwind
523 endif
524 libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
525 gnulib := -lgcc $(libgcc_eh)
526 static-gnulib := -lgcc -lgcc_eh $(libunwind)
527 libc.so-gnulib := -lgcc
528 endif
529 +preinit = $(addprefix $(csu-objpfx),crti.o)
530 +postinit = $(addprefix $(csu-objpfx),crtn.o)
531 +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
532 +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
533 # Variants of the two previous definitions for linking PIE programs.
534 +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
535 +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
536 +interp = $(addprefix $(elf-objpfx),interp.os)
537 csu-objpfx = $(common-objpfx)csu/
538 elf-objpfx = $(common-objpfx)elf/
540 # How to run a program we just linked with our library.
541 # The program binary is assumed to be $(word 2,$^).
542 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
543 ifeq (yes,$(build-shared))
544 comma = ,
545 sysdep-library-path = \
546 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
547                                        $(filter -Wl$(comma)-rpath-link=%,\
548                                                 $(sysdep-LDFLAGS)))))
549 run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
550                                    $(tests-static) $(xtests-static)),, \
551                           $(elf-objpfx)$(rtld-installed-name) \
552                           --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
553 else
554 run-program-prefix =
555 endif
556 # Never use $(run-program-prefix) for the statically-linked %-bp test programs
557 built-program-cmd = $(patsubst %,$(run-program-prefix),\
558                         $(filter-out %-bp,$(built-program-file))) \
559                     $(built-program-file)
561 ifndef LD
562 LD := ld -X
563 endif
565 # Extra flags to pass to GCC.
566 ifeq ($(all-warnings),yes)
567 +gccwarn := -Wall -Wwrite-strings -Winline -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
568 else
569 +gccwarn := -Wall -Wwrite-strings -Winline
570 endif
571 +gccwarn-c = -Wstrict-prototypes
573 # We do not depend on the address of constants in different files to be
574 # actually different, so allow the compiler to merge them all.
575 +merge-constants = -fmerge-all-constants
577 # We have to assume that glibc functions are called in any rounding
578 # mode and also change the rounding mode in a few functions. So,
579 # disable any optimization that assume default rounding mode.
580 +math-flags = -frounding-math
582 # This is the program that generates makefile dependencies from C source files.
583 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
584 # targets for headers so that removed headers don't break the build.
585 ifndef +mkdep
586 +mkdep = $(CC) -M -MP
587 endif
589 # The program that makes Emacs-style TAGS files.
590 ETAGS   := etags
592 # The `xgettext' program for producing .pot files from sources.
593 ifndef XGETTEXT
594 XGETTEXT = xgettext
595 endif
597 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
598 # perhaps others) to preprocess assembly code in some cases.
599 M4 = m4
601 # To force installation of files even if they are older than the
602 # installed files.  This variable is included in the dependency list
603 # of all installation targets.
604 ifeq ($(force-install),yes)
605 +force = force-install
606 else
607 +force =
608 endif
610 ####
611 #### End of configuration variables.
612 ####
614 # This tells some versions of GNU make before 3.63 not to export all variables.
615 .NOEXPORT:
617 # We want to echo the commands we're running without
618 # umpteen zillion filenames along with it (we use `...' instead)
619 # but we don't want this echoing done when the user has said
620 # he doesn't want to see commands echoed by using -s.
621 ifneq   "$(findstring s,$(MAKEFLAGS))" ""       # if -s
622 +cmdecho        := echo >/dev/null
623 else                                            # not -s
624 +cmdecho        := echo
625 endif                                           # -s
627 # These are the flags given to the compiler to tell
628 # it what sort of optimization and/or debugging output to do.
629 ifndef  +cflags
630 # If `CFLAGS' was defined, use that.
631 ifdef           CFLAGS
632 +cflags := $(filter-out -I%,$(CFLAGS))
633 endif           # CFLAGS
634 endif   # +cflags
636 # If none of the above worked, default to "-g -O".
637 ifeq    "$(strip $(+cflags))" ""
638 +cflags := $(default_cflags)
639 endif   # $(+cflags) == ""
641 +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags)
642 +gcc-nowarn := -w
644 # Don't duplicate options if we inherited variables from the parent.
645 +cflags := $(sort $(+cflags))
647 # These are flags given to the C compiler to tell it to look for
648 # include files (including ones given in angle brackets) in the parent
649 # library source directory, in the include directory, and in the
650 # current directory.
651 +sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
652 +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
653             $(+sysdep-includes) $(includes) \
654             $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
656 # Since libio has several internal header files, we use a -I instead
657 # of many little headers in the include directory.
658 libio-include = -I$(..)libio
660 # These are the variables that the implicit compilation rules use.
661 # Note that we can't use -std=* in CPPFLAGS, because it overrides
662 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
663 # it causes cpp to stop predefining __ASSEMBLER__.
664 CPPFLAGS = $(CPPFLAGS-config) $($(subdir)-CPPFLAGS) $(+includes) $(defines) \
665            -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
666            $(CPPFLAGS-$(suffix $@)) \
667            $(foreach lib,$(libof-$(basename $(@F))) \
668                          $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
669            $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
670 override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) \
671                   $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
672                   $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
673                   $(CFLAGS-$(@F)) \
674                   $(foreach lib,$(libof-$(basename $(@F))) \
675                                 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
676 override CXXFLAGS = $(c++-sysincludes) \
677                     $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
678                     $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
680 # If everything is compiled with -fPIC (implicitly) we must tell this by
681 # defining the PIC symbol.
682 ifeq (yes,$(build-pic-default))
683 pic-default = -DPIC
684 endif
686 # Enable object files for different versions of the library.
687 # Various things use $(object-suffixes) to know what all to make.
688 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
689 # to pass different flags for each flavor.
690 libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
691 all-object-suffixes := .o .os .op .og .ob .oS
692 object-suffixes :=
693 CPPFLAGS-.o = $(pic-default)
694 CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
695 libtype.o := lib%.a
696 object-suffixes += .o
697 ifeq (yes,$(build-shared))
698 # Under --enable-shared, we will build a shared library of PIC objects.
699 # The PIC object files are named foo.os.
700 object-suffixes += .os
701 CPPFLAGS-.os = -DPIC -DSHARED
702 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
703 libtype.os := lib%_pic.a
704 # This can be changed by a sysdep makefile
705 pic-ccflag = -fPIC
706 # This one should always stay like this unless there is a very good reason.
707 PIC-ccflag = -fPIC
708 endif
709 # This can be changed by a sysdep makefile
710 pie-ccflag = -fpie
711 # This one should always stay like this unless there is a very good reason.
712 PIE-ccflag = -fPIE
713 ifeq (yes,$(build-profile))
714 # Under --enable-profile, we will build a static library of profiled objects.
715 # The profiled object files are named foo.op.
716 object-suffixes += .op
717 CPPFLAGS-.op = -DPROF $(pic-default)
718 CFLAGS-.op = -pg
719 libtype.op = lib%_p.a
720 endif
722 bppfx = BP-
723 ifeq (yes,$(build-bounded))
724 # Under --enable-bounded, we build the library with `-fbounded-pointers -g'
725 # to runtime bounds checking.  The bounded-pointer objects are named foo.ob.
726 # We disable sibling-call optimizations so that stack traces will be complete
727 # and thus aid debugging, since after all, BPs are a debugging tool.
728 object-suffixes += .ob
729 CPPFLAGS-.ob = -fbounded-pointers $(pic-default)
730 CFLAGS-.ob = -g -O2 -fno-optimize-sibling-calls -fno-strict-aliasing
731 libtype.ob = lib%_b.a
732 endif
734 object-suffixes-for-libc := $(object-suffixes)
736 ifeq (yes,$(build-shared))
737 # Build special library that contains the static-only routines for libc.
738 object-suffixes-for-libc += .oS
740 # Must build the routines as PIC, though, because they can end up in (users')
741 # shared objects.  We don't want to use CFLAGS-os because users may, for
742 # example, make that processor-specific.
743 CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
744 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
745 libtype.oS = lib%_nonshared.a
746 endif
748 # The assembler can generate debug information too.
749 ifndef ASFLAGS
750 ifeq ($(have-cpp-asm-debuginfo),yes)
751 ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
752 else
753 ASFLAGS :=
754 endif
755 endif
756 ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
758 ifndef BUILD_CC
759 BUILD_CC = $(CC)
760 endif
762 move-if-change = $(SHELL) $(..)scripts/move-if-change
764 -include $(common-objpfx)sysd-sorted
765 subdirs = $(sorted-subdirs)
766 subdir-srcdirs = $(foreach dir,$(subdirs),\
767                            $(firstword $($(dir)-srcdir) $(..)$(dir)))
769 ifeq (yes, $(build-shared))
771 # This is a pair of implicit rules to preprocess a file with # comments,
772 # %ifdef et al, based on config.h settings or other %include'd files.
773 # We use chained rules instead of a pipeline here so that we can properly
774 # check the exit status of cpp rather than using its bad output when there
775 # is a preprocessing error.  Another rule should depend on the output file
776 # `FOO.v', and along with that `FOO.v.i' should be given dependencies
777 # listing both its input files, and any header files that it may reference
778 # (but no commands).
779 %.v.i: $(common-objpfx)config.h $(..)Makeconfig
780         sed '/^[        ]*%/!s/#.*$$//;/^[      ]*$$/d;s/^[     ]*%/#/' \
781             $(filter-out FORCE %.h $(..)Makeconfig,$^) \
782         | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
783                    > $@T
784         mv -f $@T $@
785 %.v: %.v.i
786         sed '/^[        ]*#/d;/^[       ]*$$/d' $< > $@T
787         mv -f $@T $@
789 # Process the shlib-versions file, which tells us what shared library
790 # version numbers to use when we install shared objects on this system.
791 # We need to wait until $(subdirs) is complete.
792 ifeq ($(sysd-sorted-done),t)
793 -include $(common-objpfx)soversions.mk
794 ifndef avoid-generated
795 # This lets add-ons give more-specific matches that override defaults
796 # in the top-level file.
797 $(common-objpfx)shlib-versions.v.i: \
798         $(wildcard $(+sysdep_dirs:=/shlib-versions) \
799                    $(subdir-srcdirs:=/shlib-versions)) \
800         $(..)shlib-versions
802 soversions-default-setname = $(patsubst %, %,\
803                                         $(filter-out %_default,\
804                                                      $(oldest-abi:%=GLIBC_%)))
805 $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
806                               $(common-objpfx)shlib-versions.v
807         $(AWK) -v default_setname='$(soversions-default-setname)' \
808                -v cpu='$(config-machine)' \
809                -v vendor='$(config-vendor)' \
810                -v os='$(config-os)' \
811                -f $^ > $@T
812         mv -f $@T $@
813 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
814         (seen_DEFAULT=0; seen_WORDSIZE32=0; seen_WORDSIZE64=0; \
815          while read which lib number setname; do \
816            eval seen_$$which=1; \
817            test x"$$which" != xABI || echo abi-name = "$$lib"; \
818            test x"$$which" = xDEFAULT || continue; \
819            case $$number in \
820              [0-9]*) echo "$$lib.so-version=.$$number"; \
821                      echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
822              *)      echo "$$lib.so-version=$$number"; \
823                      echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
824            esac; \
825          done; \
826          case "$$seen_DEFAULT$$seen_WORDSIZE32$$seen_WORDSIZE64" in \
827            100) echo biarch = no;; \
828            101) echo biarch = 32;; \
829            ?1?) echo biarch = 64;; \
830            *) echo >&2 BUG; exit 2;; \
831          esac; \
832          echo soversions.mk-done = t;) < $< > $@T; exit 0
833         mv -f $@T $@
834 endif
835 endif
837 postclean-generated += soversions.mk soversions.i \
838                        shlib-versions.v shlib-versions.v.i
840 # Generate the header containing the names of all shared libraries.
841 # We use a stamp file to avoid unnecessary recompilations.
842 before-compile += $(common-objpfx)gnu/lib-names.h
843 ifeq ($(soversions.mk-done),t)
844 $(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
845 $(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
846                                     $(common-objpfx)soversions.i
847         $(make-target-directory)
848         @rm -f ${@:stmp=T} $@
849         LC_ALL=C $(AWK) -f $^ > ${@:stmp=T}
850         $(move-if-change) ${@:stmp=T} ${@:stmp=h}
851         touch $@
852 endif
854 common-generated += gnu/lib-names.h gnu/lib-names.stmp
856 # The name under which the run-time dynamic linker is installed.
857 # We are currently going for the convention that `/lib/ld.so.1'
858 # names the SVR4/ELF ABI-compliant dynamic linker.
859 ifndef rtld-installed-name
860 ifdef ld.so-version
861 rtld-installed-name = $(ld.so-version)
862 else
863 rtld-installed-name = ld.so.1
864 endif
865 endif
867 ifndef rtld-version-installed-name
868 rtld-version-installed-name = ld-$(version).so
869 endif
871 endif # build-shared
874 dlfcn = dlfcn
875 ifeq ($(build-shared),yes)
876 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
877 else
878 libdl = $(common-objpfx)dlfcn/libdl.a
879 endif
881 ifeq ($(build-shared),yes)
882 libm = $(common-objpfx)math/libm.so$(libm.so-version)
883 else
884 libm = $(common-objpfx)math/libm.a
885 endif
887 # These are the subdirectories containing the library source.  The order
888 # is more or less arbitrary.  The sorting step will take care of the
889 # dependencies.
890 all-subdirs = csu assert ctype locale intl catgets math setjmp signal       \
891               stdlib stdio-common libio malloc string wcsmbs time dirent    \
892               grp pwd posix io termios resource misc socket sysvipc gmon    \
893               gnulib iconv iconvdata wctype manual shadow gshadow po argp   \
894               crypt nss localedata timezone rt conform debug                \
895               $(add-on-subdirs) $(dlfcn) $(binfmt-subdir)
897 ifndef avoid-generated
898 all-Depend-files := $(wildcard $(foreach dir,$(all-subdirs),\
899                                          $(firstword $($(dir)-srcdir) \
900                                                      $(..)$(dir))/Depend))
901 $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
902                              $(common-objpfx)config.make $(..)Makeconfig \
903                              $(wildcard $(sysdirs:=/Subdirs)) \
904                              $(all-Depend-files)
905         $(AWK) -f $< \
906                -v subdirs='$(all-subdirs)' \
907                -v srcpfx='$(..)' \
908                $(filter %/Subdirs %/Depend,$^) > $@-tmp
909         mv -f $@-tmp $@
910 $(all-Depend-files): ;
911 endif
913 # This gives partial TARGET:SOURCE pattern pairs to have rules
914 # emitted into sysd-rules.  A sysdeps Makeconfig fragment can
915 # add its own special object file prefix to this list with e.g. foo-%:%
916 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
917 sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
919 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
920 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
921 ifneq (,$(sysdep-makeconfigs))
922 include $(sysdep-makeconfigs)
923 endif
925 # Compute just the target patterns.  Makeconfig has set sysd-rules-patterns.
926 sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
927                                          $(firstword $(subst :, ,$p))))
929 endif # Makeconfig not yet included
931 # Local Variables:
932 # mode: makefile
933 # End: