* elf/rtld-Rules (subdir-args): New variable.
[glibc.git] / Makeconfig
bloba0638f83432a4f2775f8cb7a353e4549222bdbce
1 # Copyright (C) 1991-2003,2004,2005,2006 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, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 # 02111-1307 USA.
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 ifeq ($(elf),yes)
95 binfmt-subdir = elf
96 else
97 # This is probably better than nothing.
98 binfmt-subdir = aout
99 endif
101 # Complete path to sysdep dirs.
102 # `configure' writes a definition of `config-sysdirs' in `config.make'.
103 sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
105 # Add-ons that contribute sysdeps trees get added to the include list
106 # after sysdeps/generic.  This makes #include <sysdeps/...> work right
107 # to find specific add-on files without assuming the add-on directory name.
108 # It also means that headers can go into an add-on's base directory
109 # instead of the add-on needing a sysdeps/generic of its own.
110 +sysdep_dirs := $(sysdirs) $(foreach add-on,$(sysdeps-add-ons),\
111                                      $(firstword $(filter /%,$(add-on)) \
112                                                  $(..)$(add-on)))
113 ifdef objdir
114 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
115 endif
117 # Run config.status to update config.make and config.h.  We don't show the
118 # dependence of config.h to Make, because it is only touched when it
119 # changes and so config.status would be run every time; the dependence of
120 # config.make should suffice to force regeneration and re-exec, and the new
121 # image will notice if config.h changed.
122 $(common-objpfx)config.make: $(common-objpfx)config.status \
123                              $(..)config.make.in $(..)config.h.in
124         cd $(<D); $(SHELL) $(<F)
126 # Find all the add-on and sysdeps configure fragments, to make sure we
127 # re-run configure when any of them changes.
128 $(common-objpfx)config.status: $(..)version.h $(..)configure \
129                                $(foreach dir,$(sysdirs),\
130                                          $(wildcard $(dir)/Implies) \
131                                          $(patsubst %.in,%,\
132                                                     $(firstword $(wildcard \
133  $(addprefix $(dir)/,configure configure.in))))) \
134                                $(patsubst %.in,%,\
135                                           $(foreach add-on,$(add-ons),\
136                                                     $(firstword $(wildcard \
137  $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
138              configure configure.in)))))
139         @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
140          echo The GNU C library has not been configured. >&2; \
141          echo Run \`configure\' to configure it before building. >&2; \
142          echo Try \`configure --help\' for more details. >&2; \
143          exit 1; fi
145 # We don't want CPPFLAGS to be exported to the command running configure.
146 unexport CPPFLAGS
148 # Get the user's configuration parameters.
149 ifneq ($(wildcard $(..)configparms),)
150 include $(..)configparms
151 endif
152 ifneq ($(objpfx),)
153 ifneq ($(wildcard $(common-objpfx)configparms),)
154 include $(common-objpfx)configparms
155 endif
156 endif
158 ####
159 ####    These are the configuration variables.  You can define values for
160 ####    the variables below in the file `configparms'.
161 ####    Do NOT edit this file.
162 ####
165 # Common prefix for machine-independent installation directories.
166 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
167 prefix = /usr/local
168 endif
170 # Decide whether we shall build the programs or not.  We always do this
171 # unless the user tells us (in configparms) or we are building for a
172 # standalone target.
173 ifndef build-programs
174 ifneq ($(config-os),none)
175 build-programs=yes
176 else
177 build-programs=no
178 endif
179 endif
181 # Common prefix for machine-dependent installation directories.
182 ifeq ($(origin exec_prefix),undefined)
183 exec_prefix = $(prefix)
184 endif
186 # Where to install the library and object files.
187 ifndef libdir
188 libdir = $(exec_prefix)/lib
189 endif
190 inst_libdir = $(install_root)$(libdir)
192 # Where to install the shared library and dynamic linker.
193 ifndef slibdir
194 slibdir = $(exec_prefix)/lib
195 endif
196 inst_slibdir = $(install_root)$(slibdir)
198 # Prefix to put on files installed in $(libdir).  For libraries `libNAME.a',
199 # the prefix is spliced between `lib' and the name, so the linker switch
200 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
201 # just prepended to the whole file name.
202 ifeq ($(origin libprefix),undefined)
203 libprefix =
204 endif
206 # Where to install the header files.
207 ifndef includedir
208 includedir = $(prefix)/include
209 endif
210 inst_includedir = $(install_root)$(includedir)
212 # Where to install machine-independent data files.
213 # These are the timezone database, and the locale database.
214 ifndef datadir
215 datadir = $(prefix)/share
216 endif
217 inst_datadir = $(install_root)$(datadir)
219 # Where to install the timezone data files (which are machine-independent).
220 ifndef zonedir
221 zonedir = $(datadir)/zoneinfo
222 endif
223 inst_zonedir = $(install_root)$(zonedir)
225 # Where to install the locale files.
226 ifndef localedir
227 localedir = $(libdir)/locale
228 endif
229 inst_localedir = $(install_root)$(localedir)
231 # Where to install the message catalog data files (which are
232 # machine-independent).
233 ifndef msgcatdir
234 msgcatdir = $(datadir)/locale
235 endif
236 inst_msgcatdir = $(install_root)$(msgcatdir)
238 # Where to install the locale charmap source files.
239 ifndef i18ndir
240 i18ndir = $(datadir)/i18n
241 endif
242 inst_i18ndir = $(install_root)$(i18ndir)
244 # Where to install the shared object for charset transformation.
245 ifndef gconvdir
246 gconvdir = $(libdir)/gconv
247 endif
248 inst_gconvdir = $(install_root)$(gconvdir)
250 # Where to install programs.
251 ifndef bindir
252 bindir = $(exec_prefix)/bin
253 endif
254 inst_bindir = $(install_root)$(bindir)
256 # Where to install internal programs.
257 ifndef libexecdir
258 libexecdir = $(exec_prefix)/libexec
259 endif
260 inst_libexecdir = $(install_root)$(libexecdir)
262 # Where to install administrative programs.
263 ifndef rootsbindir
264 rootsbindir = $(exec_prefix)/sbin
265 endif
266 inst_rootsbindir = $(install_root)$(rootsbindir)
268 ifndef sbindir
269 sbindir = $(exec_prefix)/sbin
270 endif
271 inst_sbindir = $(install_root)$(sbindir)
273 # Where to install the Info files.
274 ifndef infodir
275 infodir = $(prefix)/info
276 endif
277 inst_infodir = $(install_root)$(infodir)
279 # Where to install default configuration files.  These include the local
280 # timezone specification and network data base files.
281 ifndef sysconfdir
282 sysconfdir = $(prefix)/etc
283 endif
284 inst_sysconfdir = $(install_root)$(sysconfdir)
286 # What timezone should be the installed default (e.g., US/Eastern).
287 # Run `make -C time echo-zonenames' to see a list of available zone names.
288 # The local timezone can be changed with `zic -l TIMEZONE' at any time.
289 ifndef localtime
290 localtime = Factory
291 endif
293 # Where to install the "localtime" timezone file; this is the file whose
294 # contents $(localtime) specifies.  If this is a relative pathname, it is
295 # relative to $(zonedir).  It is a good idea to put this somewhere
296 # other than there, so the zoneinfo directory contains only universal data,
297 # localizing the configuration data elsewhere.
298 ifndef localtime-file
299 localtime-file = $(sysconfdir)/localtime
300 inst_localtime-file = $(install_root)$(localtime-file)
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 # ELF always supports init/fini sections
384 ifeq ($(elf),yes)
385 have-initfini = yes
386 endif
388 # Installed name of the startup code.
389 ifneq ($(have-initfini),yes)
390 # When not having init/fini, there is just one startfile, called crt0.o.
391 start-installed-name = crt0.o
392 else
393 # On systems having init/fini, crt0.o is called crt1.o, and there are
394 # some additional bizarre files.
395 start-installed-name = crt1.o
396 endif
397 # On systems that do not need a special startfile for statically linked
398 # binaries, simply set it to the normal name.
399 ifndef static-start-installed-name
400 static-start-installed-name = $(start-installed-name)
401 endif
403 ifeq (yesyesyes,$(build-shared)$(elf)$(have-z-combreloc))
404 combreloc-LDFLAGS = -Wl,-z,combreloc
405 LDFLAGS.so += $(combreloc-LDFLAGS)
406 LDFLAGS-rtld += $(combreloc-LDFLAGS)
407 endif
409 ifeq (yes,$(have-z-relro))
410 relro-LDFLAGS = -Wl,-z,relro
411 LDFLAGS.so += $(relro-LDFLAGS)
412 LDFLAGS-rtld += $(relro-LDFLAGS)
413 endif
415 # Command for linking programs with the C library.
416 ifndef +link
417 +link = $(CC) -nostdlib -nostartfiles -o $@ \
418               $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
419               $(combreloc-LDFLAGS) $(relro-LDFLAGS) \
420               $(addprefix $(csu-objpfx),$(start-installed-name)) \
421               $(+preinit) $(+prector) \
422               $(filter-out $(addprefix $(csu-objpfx),start.o \
423                                                      $(start-installed-name))\
424                            $(+preinit) $(link-extra-libs) \
425                            $(common-objpfx)libc% $(+postinit),$^) \
426               $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
427 endif
428 # Command for statically linking programs with the C library.
429 ifndef +link-static
430 +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
431               $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
432               $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
433               $(+preinit) $(+prector) \
434               $(filter-out $(addprefix $(csu-objpfx),start.o \
435                                                      $(start-installed-name))\
436                            $(+preinit) $(link-extra-libs-static) \
437                            $(common-objpfx)libc% $(+postinit),$^) \
438               $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
439 endif
440 # Command for statically linking bounded-pointer programs with the C library.
441 ifndef +link-bounded
442 +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
443               $(sysdep-LDFLAGS) $(LDFLAGS)  \
444               $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
445               $(+preinit) $(+prector) \
446               $(filter-out $(addprefix $(csu-objpfx),start.ob \
447                                                      $(start-installed-name))\
448                            $(+preinit) $(link-extra-libs-bounded) \
449                            $(common-objpfx)libc% $(+postinit),$^) \
450               $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
451 endif
452 ifndef config-LDFLAGS
453 ifeq (yesyes,$(build-shared)$(elf))
454 config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
455 endif
456 endif
457 ifndef link-libc
458 ifeq (yes,$(build-shared))
459 ifeq ($(elf),yes)
460 # We need the versioned name of libc.so in the deps of $(others) et al
461 # so that the symlink to libc.so is created before anything tries to
462 # run the linked programs.
463 link-libc = -Wl,-rpath-link=$(rpath-link) \
464             $(common-objpfx)libc.so$(libc.so-version) \
465             $(common-objpfx)$(patsubst %,$(libtype.oS),c) $(gnulib)
466 # This is how to find at build-time things that will be installed there.
467 rpath-dirs = math elf dlfcn nss nis rt resolv crypt
468 endif
469 rpath-link = \
470 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
471 elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
472 else
473 nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
474 resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
475 link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
476 endif
477 endif
479 # Differences in the linkers on the various platforms.
480 ifeq ($(elf),yes)
481 LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
482 LDFLAGS-soname-fname = -Wl,-soname,$(@F)
483 LDFLAGS-rdynamic = -rdynamic
484 LDFLAGS-Bsymbolic = -Bsymbolic
485 endif
487 # Choose the default search path for the dynamic linker based on
488 # where we will install libraries.
489 ifneq ($(libdir),$(slibdir))
490 default-rpath = $(slibdir):$(libdir)
491 else
492 default-rpath = $(libdir)
493 endif
495 ifndef link-extra-libs
496 link-extra-libs = $(LDLIBS-$(@F))
497 link-extra-libs-static = $(link-extra-libs)
498 link-extra-libs-bounded = $(link-extra-libs)
499 endif
501 # The static libraries.
502 ifeq (yes,$(build-static))
503 link-libc-static = $(common-objpfx)libc.a $(static-gnulib) $(common-objpfx)libc.a
504 else
505 ifeq (yes,$(build-shared))
506 # We can try to link the programs with lib*_pic.a...
507 link-libc-static = $(static-gnulib) $(common-objpfx)libc_pic.a
508 endif
509 endif
510 link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
512 ifndef gnulib
513 ifneq ($(have-cc-with-libunwind),yes)
514   libunwind =
515 else
516   libunwind = -lunwind
517 endif
518 ifneq ($(have-as-needed),yes)
519  libgcc_eh := -lgcc_eh $(libunwind)
520 else
521  libgcc_eh := -Wl,--as-needed -lgcc_s$(libgcc_s_suffix) $(libunwind) -Wl,--no-as-needed
522 endif
523 gnulib := -lgcc $(libgcc_eh)
524 static-gnulib := -lgcc -lgcc_eh $(libunwind)
525 libc.so-gnulib := -lgcc
526 endif
527 ifeq ($(elf),yes)
528 +preinit = $(addprefix $(csu-objpfx),crti.o)
529 +postinit = $(addprefix $(csu-objpfx),crtn.o)
530 +prector = `$(CC) --print-file-name=crtbegin.o`
531 +postctor = `$(CC) --print-file-name=crtend.o`
532 +interp = $(addprefix $(elf-objpfx),interp.os)
533 endif
534 csu-objpfx = $(common-objpfx)csu/
535 elf-objpfx = $(common-objpfx)elf/
537 # How to run a program we just linked with our library.
538 # The program binary is assumed to be $(word 2,$^).
539 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
540 ifeq (yesyes,$(build-shared)$(elf))
541 comma = ,
542 sysdep-library-path = \
543 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
544                                        $(filter -Wl$(comma)-rpath-link=%,\
545                                                 $(sysdep-LDFLAGS)))))
546 run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
547                                    $(tests-static) $(xtests-static)),, \
548                           $(elf-objpfx)$(rtld-installed-name) \
549                           --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
550 else
551 run-program-prefix =
552 endif
553 # Never use $(run-program-prefix) for the statically-linked %-bp test programs
554 built-program-cmd = $(patsubst %,$(run-program-prefix),\
555                         $(filter-out %-bp,$(built-program-file))) \
556                     $(built-program-file)
558 ifndef LD
559 LD := ld -X
560 endif
562 ifndef  RANLIB
563 RANLIB = ranlib
564 endif
566 # Extra flags to pass to GCC.
567 ifeq ($(all-warnings),yes)
568 +gccwarn := -Wall -Wwrite-strings -Winline -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
569 else
570 +gccwarn := -Wall -Wwrite-strings -Winline
571 endif
572 +gccwarn-c = -Wstrict-prototypes
574 # We do not depend on the address of constants in different files to be
575 # actually different, so allow the compiler to merge them all.
576 +merge-constants = -fmerge-all-constants
578 # This is the program that generates makefile dependencies from C source files.
579 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
580 # targets for headers so that removed headers don't break the build.
581 ifndef +mkdep
582 +mkdep = $(CC) -M -MP
583 endif
585 # The program that makes Emacs-style TAGS files.
586 ETAGS   := etags
588 # The `xgettext' program for producing .pot files from sources.
589 ifndef XGETTEXT
590 XGETTEXT = xgettext
591 endif
593 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
594 # perhaps others) to preprocess assembly code in some cases.
595 M4 = m4
597 # To force installation of files even if they are older than the
598 # installed files.  This variable is included in the dependency list
599 # of all installation targets.
600 ifeq ($(force-install),yes)
601 +force = force-install
602 else
603 +force =
604 endif
606 ####
607 #### End of configuration variables.
608 ####
610 # This tells some versions of GNU make before 3.63 not to export all variables.
611 .NOEXPORT:
613 # We want to echo the commands we're running without
614 # umpteen zillion filenames along with it (we use `...' instead)
615 # but we don't want this echoing done when the user has said
616 # he doesn't want to see commands echoed by using -s.
617 ifneq   "$(findstring s,$(MAKEFLAGS))" ""       # if -s
618 +cmdecho        := echo >/dev/null
619 else                                            # not -s
620 +cmdecho        := echo
621 endif                                           # -s
623 # These are the flags given to the compiler to tell
624 # it what sort of optimization and/or debugging output to do.
625 ifndef  +cflags
626 # If `CFLAGS' was defined, use that.
627 ifdef           CFLAGS
628 +cflags := $(filter-out -I%,$(CFLAGS))
629 endif           # CFLAGS
630 endif   # +cflags
632 # If none of the above worked, default to "-g -O".
633 ifeq    "$(strip $(+cflags))" ""
634 +cflags := $(default_cflags)
635 endif   # $(+cflags) == ""
637 +cflags += $(addprefix -mcpu=,$(with-cpu)) $(+gccwarn) $(+merge-constants)
638 +gcc-nowarn := -w
640 # Don't duplicate options if we inherited variables from the parent.
641 +cflags := $(sort $(+cflags))
644 # These are flags given to the C compiler to tell it to look for
645 # include files (including ones given in angle brackets) in the parent
646 # library source directory, in the include directory, and in the
647 # current directory.
648 +sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
649 +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
650             $(+sysdep-includes) \
651             $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
653 # Since libio has several internal header files, we use a -I instead
654 # of many little headers in the include directory.
655 libio-include = -I$(..)libio
657 # These are the variables that the implicit compilation rules use.
658 # Note that we can't use -std=* in CPPFLAGS, because it overrides
659 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
660 # it causes cpp to stop predefining __ASSEMBLER__.
661 CPPFLAGS = $($(subdir)-CPPFLAGS) $(+includes) $(defines) \
662            -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
663            $(CPPFLAGS-$(suffix $@)) \
664            $(foreach lib,$(libof-$(basename $(@F))) \
665                          $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
666            $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
667 override CFLAGS = -std=gnu99 \
668                   $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
669                   $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
670                   $(CFLAGS-$(@F))
671 override CXXFLAGS = $(c++-sysincludes) \
672                     $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
673                     $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
675 # If everything is compiled with -fPIC (implicitly) we must tell this by
676 # defining the PIC symbol.
677 ifeq (yes,$(build-pic-default))
678 pic-default = -DPIC
679 endif
681 # Enable object files for different versions of the library.
682 # Various things use $(object-suffixes) to know what all to make.
683 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
684 # to pass different flags for each flavor.
685 libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
686 all-object-suffixes := .o .os .op .og .ob .oS
687 object-suffixes :=
688 CPPFLAGS-.o = $(pic-default)
689 CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
690 ifeq (yes,$(build-static))
691 libtype.o := lib%.a
692 object-suffixes += .o
693 endif
694 ifeq (yes,$(build-shared))
695 # Under --enable-shared, we will build a shared library of PIC objects.
696 # The PIC object files are named foo.os.
697 object-suffixes += .os
698 CPPFLAGS-.os = -DPIC -DSHARED
699 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
700 libtype.os := lib%_pic.a
701 # This can be changed by a sysdep makefile
702 pic-ccflag = -fPIC
703 # This one should always stay like this unless there is a very good reason.
704 PIC-ccflag = -fPIC
705 endif
706 ifeq (yes,$(build-profile))
707 # Under --enable-profile, we will build a static library of profiled objects.
708 # The profiled object files are named foo.op.
709 object-suffixes += .op
710 CPPFLAGS-.op = -DPROF $(pic-default)
711 CFLAGS-.op = -pg
712 libtype.op = lib%_p.a
713 endif
714 ifeq (yes,$(build-omitfp))
715 # Under --enable-omitfp, we build the library optimized without
716 # debugging information using -fomit-frame-pointer, and build an extra
717 # library with debugging information.  The debuggable objects are named foo.og.
718 object-suffixes += .og
719 CPPFLAGS-.og = $(pic-default)
720 CFLAGS-.og = -g
721 CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES
722 CFLAGS-.os += -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES
723 libtype.og = lib%_g.a
724 endif
726 bppfx = BP-
727 ifeq (yes,$(build-bounded))
728 # Under --enable-bounded, we build the library with `-fbounded-pointers -g'
729 # to runtime bounds checking.  The bounded-pointer objects are named foo.ob.
730 # We disable sibling-call optimizations so that stack traces will be complete
731 # and thus aid debugging, since after all, BPs are a debugging tool.
732 object-suffixes += .ob
733 CPPFLAGS-.ob = -fbounded-pointers $(pic-default)
734 CFLAGS-.ob = -g -O2 -fno-optimize-sibling-calls -fno-strict-aliasing
735 libtype.ob = lib%_b.a
736 endif
738 object-suffixes-for-libc := $(object-suffixes)
740 ifeq (yes,$(build-shared))
741 # Build special library that contains the static-only routines for libc.
742 object-suffixes-for-libc += .oS
744 # Must build the routines as PIC, though, because they can end up in (users')
745 # shared objects.  We don't want to use CFLAGS-os because users may, for
746 # example, make that processor-specific.
747 CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
748 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
749 libtype.oS = lib%_nonshared.a
750 endif
752 # The assembler can generate debug information too.
753 ifndef ASFLAGS
754 ifeq ($(have-cpp-asm-debuginfo),yes)
755 ASFLAGS := $(filter -g%,$(CFLAGS))
756 else
757 ASFLAGS :=
758 endif
759 endif
760 ASFLAGS += $(ASFLAGS-config)
762 ifndef BUILD_CC
763 BUILD_CC = $(CC)
764 endif
766 move-if-change = $(SHELL) $(..)scripts/move-if-change
768 -include $(common-objpfx)sysd-sorted
769 subdirs = $(sorted-subdirs)
770 subdir-srcdirs = $(foreach dir,$(subdirs),\
771                            $(firstword $($(dir)-srcdir) $(..)$(dir)))
773 ifeq (yes, $(build-shared))
775 # This is a pair of implicit rules to preprocess a file with # comments,
776 # %ifdef et al, based on config.h settings or other %include'd files.
777 # We use chained rules instead of a pipeline here so that we can properly
778 # check the exit status of cpp rather than using its bad output when there
779 # is a preprocessing error.  Another rule should depend on the output file
780 # `FOO.v', and along with that `FOO.v.i' should be given dependencies
781 # listing both its input files, and any header files that it may reference
782 # (but no commands).
783 %.v.i: $(common-objpfx)config.h
784         sed '/^[        ]*#/d;s/^[      ]*%/#/' $(filter-out FORCE %.h,$^) \
785         | $(CC) -E -undef $(CPPFLAGS) \
786                    -DASSEMBLER -x assembler-with-cpp - \
787                    > $@T
788         mv -f $@T $@
789 %.v: %.v.i
790         sed '/^[        ]*#/d;/^[       ]*$$/d' $< > $@T
791         mv -f $@T $@
793 # Process the shlib-versions file, which tells us what shared library
794 # version numbers to use when we install shared objects on this system.
795 # We need to wait until $(subdirs) is complete.
796 ifeq ($(sysd-sorted-done),t)
797 -include $(common-objpfx)soversions.mk
798 ifndef avoid-generated
799 # This lets add-ons give more-specific matches that override defaults
800 # in the top-level file.
801 $(common-objpfx)shlib-versions.v.i: \
802         $(wildcard $(+sysdep_dirs:=/shlib-versions) \
803                    $(subdir-srcdirs:=/shlib-versions)) \
804         $(..)shlib-versions
806 soversions-default-setname = $(patsubst %, %,\
807                                         $(filter-out %_default,\
808                                                      $(oldest-abi:%=GLIBC_%)))
809 $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
810                               $(common-objpfx)shlib-versions.v
811         $(AWK) -v default_setname='$(soversions-default-setname)' \
812                -v cpu='$(config-machine)' \
813                -v vendor='$(config-vendor)' \
814                -v os='$(config-os)' \
815                -f $^ > $@T
816         mv -f $@T $@
817 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
818         (seen_DEFAULT=0; seen_WORDSIZE32=0; seen_WORDSIZE64=0; \
819          while read which lib number setname; do \
820            eval seen_$$which=1; \
821            test x"$$which" = xDEFAULT || continue; \
822            case $$number in \
823              [0-9]*) echo "$$lib.so-version=.$$number"; \
824                      echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
825              *)      echo "$$lib.so-version=$$number"; \
826                      echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
827            esac; \
828          done; \
829          case "$$seen_DEFAULT$$seen_WORDSIZE32$$seen_WORDSIZE64" in \
830            100) echo biarch = no;; \
831            101) echo biarch = 32;; \
832            ?1?) echo biarch = 64;; \
833            *) echo >&2 BUG; exit 2;; \
834          esac; \
835          echo soversions.mk-done = t;) < $< > $@T; exit 0
836         mv -f $@T $@
837 endif
838 endif
840 postclean-generated += soversions.mk soversions.i \
841                        shlib-versions.v shlib-versions.v.i
843 # Generate the header containing the names of all shared libraries.
844 # We use a stamp file to avoid unnecessary recompilations.
845 before-compile += $(common-objpfx)gnu/lib-names.h
846 ifeq ($(soversions.mk-done),t)
847 $(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
848 $(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
849                                     $(common-objpfx)soversions.i
850         $(make-target-directory)
851         @rm -f ${@:stmp=T} $@
852         $(AWK) -f $^ > ${@:stmp=T}
853         $(move-if-change) ${@:stmp=T} ${@:stmp=h}
854         touch $@
855 endif
857 common-generated += gnu/lib-names.h gnu/lib-names.stmp
859 # The name under which the run-time dynamic linker is installed.
860 # We are currently going for the convention that `/lib/ld.so.1'
861 # names the SVR4/ELF ABI-compliant dynamic linker.
862 ifndef rtld-installed-name
863 ifdef ld.so-version
864 rtld-installed-name = $(ld.so-version)
865 else
866 rtld-installed-name = ld.so.1
867 endif
868 endif
870 ifndef rtld-version-installed-name
871 rtld-version-installed-name = ld-$(version).so
872 endif
874 endif # build-shared
877 ifeq ($(elf),yes)
878 dlfcn = dlfcn
879 ifeq ($(build-shared),yes)
880 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
881 else
882 libdl = $(common-objpfx)dlfcn/libdl.a
883 endif
884 else
885 ifneq (,$(findstring aix,$(config-os)))
886 ifeq ($(build-shared),yes)
887 dlfcn = dlfcn
888 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
889 else
890 # No libdl without shared libs on AIX
891 dlfcn =
892 libdl =
893 endif
894 else
895 # No ELF, no AIX - no libdl, at least for now.
896 dlfcn =
897 libdl =
898 endif
899 endif
901 # These are the subdirectories containing the library source.  The order
902 # is more or less arbitrary.  The sorting step will take care of the
903 # dependencies.
904 all-subdirs = csu assert ctype locale intl catgets math setjmp signal       \
905               stdlib stdio-common libio malloc string wcsmbs time dirent    \
906               grp pwd posix io termios resource misc socket sysvipc gmon    \
907               gnulib iconv iconvdata wctype manual shadow po argp           \
908               crypt nss localedata timezone rt conform debug                \
909               $(add-on-subdirs) $(dlfcn) $(binfmt-subdir)
911 ifndef avoid-generated
912 all-Depend-files := $(wildcard $(foreach dir,$(all-subdirs),\
913                                          $(firstword $($(dir)-srcdir) \
914                                                      $(..)$(dir))/Depend))
915 $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
916                              $(common-objpfx)config.make $(..)Makeconfig \
917                              $(wildcard $(sysdirs:=/Subdirs)) \
918                              $(all-Depend-files)
919         $(AWK) -f $< \
920                -v subdirs='$(all-subdirs)' \
921                -v srcpfx='$(..)' \
922                $(filter %/Subdirs %/Depend,$^) > $@-tmp
923         mv -f $@-tmp $@
924 $(all-Depend-files): ;
925 endif
927 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
928 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
929 ifneq (,$(sysdep-makeconfigs))
930 include $(sysdep-makeconfigs)
931 endif
934 endif # Makeconfig not yet included
936 # Local Variables:
937 # mode: makefile
938 # End: