2005-12-21 Roland McGrath <roland@redhat.com>
[glibc.git] / Makeconfig
blobf8de97d3a0ab7ac3022aaa69fa3afb93548fd773
1 # Copyright (C) 1991-2003, 2004, 2005 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 export full_config_sysdirs := $(addprefix $(..),$(config-sysdirs))
104 # Run config.status to update config.make and config.h.  We don't show the
105 # dependence of config.h to Make, because it is only touched when it
106 # changes and so config.status would be run every time; the dependence of
107 # config.make should suffice to force regeneration and re-exec, and the new
108 # image will notice if config.h changed.
109 $(common-objpfx)config.make: $(common-objpfx)config.status \
110                              $(..)config.make.in $(..)config.h.in
111         cd $(<D); $(SHELL) $(<F)
113 # Find all the add-on and sysdeps configure fragments, to make sure we
114 # re-run configure when any of them changes.
115 $(common-objpfx)config.status: $(..)version.h $(..)configure \
116                                $(foreach dir,$(full_config_sysdirs),\
117                                          $(wildcard \
118                                            $(dir)/Implies) \
119                                          $(patsubst %.in,%,\
120                                                     $(firstword $(wildcard \
121  $(addprefix $(dir)/,configure configure.in))))) \
122                                $(patsubst %.in,%,\
123                                           $(foreach dir,$(add-ons),\
124                                                     $(firstword $(wildcard \
125  $(addprefix $(..)$(dir)/,configure configure.in)))))
126         @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
127          echo The GNU C library has not been configured. >&2; \
128          echo Run \`configure\' to configure it before building. >&2; \
129          echo Try \`configure --help\' for more details. >&2; \
130          exit 1; fi
132 # We don't want CPPFLAGS to be exported to the command running configure.
133 unexport CPPFLAGS
135 # Get the user's configuration parameters.
136 ifneq ($(wildcard $(..)configparms),)
137 include $(..)configparms
138 endif
139 ifneq ($(objpfx),)
140 ifneq ($(wildcard $(common-objpfx)configparms),)
141 include $(common-objpfx)configparms
142 endif
143 endif
145 ####
146 ####    These are the configuration variables.  You can define values for
147 ####    the variables below in the file `configparms'.
148 ####    Do NOT edit this file.
149 ####
152 # Common prefix for machine-independent installation directories.
153 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
154 prefix = /usr/local
155 endif
157 # Decide whether we shall build the programs or not.  We always do this
158 # unless the user tells us (in configparms) or we are building for a
159 # standalone target.
160 ifndef build-programs
161 ifneq ($(config-os),none)
162 build-programs=yes
163 else
164 build-programs=no
165 endif
166 endif
168 # Common prefix for machine-dependent installation directories.
169 ifeq ($(origin exec_prefix),undefined)
170 exec_prefix = $(prefix)
171 endif
173 # Where to install the library and object files.
174 ifndef libdir
175 libdir = $(exec_prefix)/lib
176 endif
177 inst_libdir = $(install_root)$(libdir)
179 # Where to install the shared library and dynamic linker.
180 ifndef slibdir
181 slibdir = $(exec_prefix)/lib
182 endif
183 inst_slibdir = $(install_root)$(slibdir)
185 # Prefix to put on files installed in $(libdir).  For libraries `libNAME.a',
186 # the prefix is spliced between `lib' and the name, so the linker switch
187 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
188 # just prepended to the whole file name.
189 ifeq ($(origin libprefix),undefined)
190 libprefix =
191 endif
193 # Where to install the header files.
194 ifndef includedir
195 includedir = $(prefix)/include
196 endif
197 inst_includedir = $(install_root)$(includedir)
199 # Where to install machine-independent data files.
200 # These are the timezone database, and the locale database.
201 ifndef datadir
202 datadir = $(prefix)/share
203 endif
204 inst_datadir = $(install_root)$(datadir)
206 # Where to install the timezone data files (which are machine-independent).
207 ifndef zonedir
208 zonedir = $(datadir)/zoneinfo
209 endif
210 inst_zonedir = $(install_root)$(zonedir)
212 # Where to install the locale files.
213 ifndef localedir
214 localedir = $(libdir)/locale
215 endif
216 inst_localedir = $(install_root)$(localedir)
218 # Where to install the message catalog data files (which are
219 # machine-independent).
220 ifndef msgcatdir
221 msgcatdir = $(datadir)/locale
222 endif
223 inst_msgcatdir = $(install_root)$(msgcatdir)
225 # Where to install the locale charmap source files.
226 ifndef i18ndir
227 i18ndir = $(datadir)/i18n
228 endif
229 inst_i18ndir = $(install_root)$(i18ndir)
231 # Where to install the shared object for charset transformation.
232 ifndef gconvdir
233 gconvdir = $(libdir)/gconv
234 endif
235 inst_gconvdir = $(install_root)$(gconvdir)
237 # Where to install programs.
238 ifndef bindir
239 bindir = $(exec_prefix)/bin
240 endif
241 inst_bindir = $(install_root)$(bindir)
243 # Where to install internal programs.
244 ifndef libexecdir
245 libexecdir = $(exec_prefix)/libexec
246 endif
247 inst_libexecdir = $(install_root)$(libexecdir)
249 # Where to install administrative programs.
250 ifndef rootsbindir
251 rootsbindir = $(exec_prefix)/sbin
252 endif
253 inst_rootsbindir = $(install_root)$(rootsbindir)
255 ifndef sbindir
256 sbindir = $(exec_prefix)/sbin
257 endif
258 inst_sbindir = $(install_root)$(sbindir)
260 # Where to install the Info files.
261 ifndef infodir
262 infodir = $(prefix)/info
263 endif
264 inst_infodir = $(install_root)$(infodir)
266 # Where to install default configuration files.  These include the local
267 # timezone specification and network data base files.
268 ifndef sysconfdir
269 sysconfdir = $(prefix)/etc
270 endif
271 inst_sysconfdir = $(install_root)$(sysconfdir)
273 # What timezone should be the installed default (e.g., US/Eastern).
274 # Run `make -C time echo-zonenames' to see a list of available zone names.
275 # The local timezone can be changed with `zic -l TIMEZONE' at any time.
276 ifndef localtime
277 localtime = Factory
278 endif
280 # Where to install the "localtime" timezone file; this is the file whose
281 # contents $(localtime) specifies.  If this is a relative pathname, it is
282 # relative to $(zonedir).  It is a good idea to put this somewhere
283 # other than there, so the zoneinfo directory contains only universal data,
284 # localizing the configuration data elsewhere.
285 ifndef localtime-file
286 localtime-file = $(sysconfdir)/localtime
287 inst_localtime-file = $(install_root)$(localtime-file)
288 endif
290 # What to use for leap second specifications in compiling the default
291 # timezone files.  Set this to `/dev/null' for no leap second handling as
292 # 1003.1 requires, or to `leapseconds' for proper leap second handling.
293 # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
294 # This variable determines the default: if it's `/dev/null',
295 # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
296 ifndef leapseconds
297 leapseconds = /dev/null
298 endif
300 # What timezone's DST rules should be used when a POSIX-style TZ
301 # environment variable doesn't specify any rules.  For 1003.1 compliance
302 # this timezone must use rules that are as U.S. federal law defines DST.
303 # Run `make -C time echo-zonenames' to see a list of available zone names.
304 # This setting can be changed with `zic -p TIMEZONE' at any time.
305 # If you want POSIX.1 compatibility, use `America/New_York'.
306 ifndef posixrules
307 posixrules = America/New_York
308 endif
310 # Where to install the "posixrules" timezone file; this is file
311 # whose contents $(posixrules) specifies.  If this is a relative
312 # pathname, it is relative to $(zonedir).
313 ifndef posixrules-file
314 posixrules-file = posixrules
315 endif
318 # Directory where your system's native header files live.
319 # This is used on Unix systems to generate some GNU libc header files.
320 ifndef sysincludedir
321 sysincludedir = /usr/include
322 endif
325 # Commands to install files.
326 ifndef INSTALL_DATA
327 INSTALL_DATA = $(INSTALL) -m 644
328 endif
329 ifndef INSTALL_SCRIPT
330 INSTALL_SCRIPT = $(INSTALL)
331 endif
332 ifndef INSTALL_PROGRAM
333 INSTALL_PROGRAM = $(INSTALL)
334 endif
335 ifndef INSTALL
336 INSTALL = install
337 endif
340 # The name of the C compiler.
341 # If you've got GCC, and it works, use it.
342 ifeq ($(origin CC),default)
343 CC := gcc
344 endif
346 # The name of the C compiler to use for compilations of programs to run on
347 # the host that is building the library.  If you set CC to a
348 # cross-compiler, you must set this to the normal compiler.
349 ifndef BUILD_CC
350 BUILD_CC = $(CC)
351 endif
353 # Default flags to pass the C compiler.
354 ifndef default_cflags
355 ifeq ($(release),stable)
356 default_cflags := -g -O2
357 else
358 default_cflags := -g -O
359 endif
360 endif
362 # Flags to pass the C compiler when assembling preprocessed assembly code
363 # (`.S' files).  On some systems the assembler doesn't understand the `#' line
364 # directives the preprocessor produces.  If you have troubling compiling
365 # assembly code, try using -P here to suppress these directives.
366 ifndef asm-CPPFLAGS
367 asm-CPPFLAGS =
368 endif
370 # ELF always supports init/fini sections
371 ifeq ($(elf),yes)
372 have-initfini = yes
373 endif
375 # Installed name of the startup code.
376 ifneq ($(have-initfini),yes)
377 # When not having init/fini, there is just one startfile, called crt0.o.
378 start-installed-name = crt0.o
379 else
380 # On systems having init/fini, crt0.o is called crt1.o, and there are
381 # some additional bizarre files.
382 start-installed-name = crt1.o
383 endif
384 # On systems that do not need a special startfile for statically linked
385 # binaries, simply set it to the normal name.
386 ifndef static-start-installed-name
387 static-start-installed-name = $(start-installed-name)
388 endif
390 ifeq (yesyesyes,$(build-shared)$(elf)$(have-z-combreloc))
391 combreloc-LDFLAGS = -Wl,-z,combreloc
392 LDFLAGS.so += $(combreloc-LDFLAGS)
393 LDFLAGS-rtld += $(combreloc-LDFLAGS)
394 endif
396 ifeq (yes,$(have-z-relro))
397 relro-LDFLAGS = -Wl,-z,relro
398 LDFLAGS.so += $(relro-LDFLAGS)
399 LDFLAGS-rtld += $(relro-LDFLAGS)
400 endif
402 # Command for linking programs with the C library.
403 ifndef +link
404 +link = $(CC) -nostdlib -nostartfiles -o $@ \
405               $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
406               $(combreloc-LDFLAGS) $(relro-LDFLAGS) \
407               $(addprefix $(csu-objpfx),$(start-installed-name)) \
408               $(+preinit) $(+prector) \
409               $(filter-out $(addprefix $(csu-objpfx),start.o \
410                                                      $(start-installed-name))\
411                            $(+preinit) $(link-extra-libs) \
412                            $(common-objpfx)libc% $(+postinit),$^) \
413               $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
414 endif
415 # Command for statically linking programs with the C library.
416 ifndef +link-static
417 +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
418               $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
419               $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
420               $(+preinit) $(+prector) \
421               $(filter-out $(addprefix $(csu-objpfx),start.o \
422                                                      $(start-installed-name))\
423                            $(+preinit) $(link-extra-libs-static) \
424                            $(common-objpfx)libc% $(+postinit),$^) \
425               $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
426 endif
427 # Command for statically linking bounded-pointer programs with the C library.
428 ifndef +link-bounded
429 +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
430               $(sysdep-LDFLAGS) $(LDFLAGS)  \
431               $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
432               $(+preinit) $(+prector) \
433               $(filter-out $(addprefix $(csu-objpfx),start.ob \
434                                                      $(start-installed-name))\
435                            $(+preinit) $(link-extra-libs-bounded) \
436                            $(common-objpfx)libc% $(+postinit),$^) \
437               $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
438 endif
439 ifndef config-LDFLAGS
440 ifeq (yesyes,$(build-shared)$(elf))
441 config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
442 endif
443 endif
444 ifndef link-libc
445 ifeq (yes,$(build-shared))
446 ifeq ($(elf),yes)
447 # We need the versioned name of libc.so in the deps of $(others) et al
448 # so that the symlink to libc.so is created before anything tries to
449 # run the linked programs.
450 link-libc = -Wl,-rpath-link=$(rpath-link) \
451             $(common-objpfx)libc.so$(libc.so-version) \
452             $(common-objpfx)$(patsubst %,$(libtype.oS),c) $(gnulib)
453 # This is how to find at build-time things that will be installed there.
454 rpath-dirs = math elf dlfcn nss nis rt resolv crypt
455 endif
456 rpath-link = \
457 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
458 elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
459 else
460 nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
461 resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
462 link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
463 endif
464 endif
466 # Differences in the linkers on the various platforms.
467 ifeq ($(elf),yes)
468 LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
469 LDFLAGS-soname-fname = -Wl,-soname,$(@F)
470 LDFLAGS-rdynamic = -rdynamic
471 LDFLAGS-Bsymbolic = -Bsymbolic
472 endif
474 # Choose the default search path for the dynamic linker based on
475 # where we will install libraries.
476 ifneq ($(libdir),$(slibdir))
477 default-rpath = $(slibdir):$(libdir)
478 else
479 default-rpath = $(libdir)
480 endif
482 ifndef link-extra-libs
483 link-extra-libs = $(LDLIBS-$(@F))
484 link-extra-libs-static = $(link-extra-libs)
485 link-extra-libs-bounded = $(link-extra-libs)
486 endif
488 # The static libraries.
489 ifeq (yes,$(build-static))
490 link-libc-static = $(common-objpfx)libc.a $(static-gnulib) $(common-objpfx)libc.a
491 else
492 ifeq (yes,$(build-shared))
493 # We can try to link the programs with lib*_pic.a...
494 link-libc-static = $(static-gnulib) $(common-objpfx)libc_pic.a
495 endif
496 endif
497 link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
499 ifndef gnulib
500 ifneq ($(have-cc-with-libunwind),yes)
501   libunwind =
502 else
503   libunwind = -lunwind
504 endif
505 ifneq ($(have-as-needed),yes)
506  libgcc_eh := -lgcc_eh $(libunwind)
507 else
508  libgcc_eh := -Wl,--as-needed -lgcc_s$(libgcc_s_suffix) $(libunwind) -Wl,--no-as-needed
509 endif
510 gnulib := -lgcc $(libgcc_eh)
511 static-gnulib := -lgcc -lgcc_eh $(libunwind)
512 libc.so-gnulib := -lgcc
513 endif
514 ifeq ($(elf),yes)
515 +preinit = $(addprefix $(csu-objpfx),crti.o)
516 +postinit = $(addprefix $(csu-objpfx),crtn.o)
517 +prector = `$(CC) --print-file-name=crtbegin.o`
518 +postctor = `$(CC) --print-file-name=crtend.o`
519 +interp = $(addprefix $(elf-objpfx),interp.os)
520 endif
521 csu-objpfx = $(common-objpfx)csu/
522 elf-objpfx = $(common-objpfx)elf/
524 # How to run a program we just linked with our library.
525 # The program binary is assumed to be $(word 2,$^).
526 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
527 ifeq (yesyes,$(build-shared)$(elf))
528 comma = ,
529 sysdep-library-path = \
530 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
531                                        $(filter -Wl$(comma)-rpath-link=%,\
532                                                 $(sysdep-LDFLAGS)))))
533 run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
534                                    $(tests-static) $(xtests-static)),, \
535                           $(elf-objpfx)$(rtld-installed-name) \
536                           --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
537 else
538 run-program-prefix =
539 endif
540 # Never use $(run-program-prefix) for the statically-linked %-bp test programs
541 built-program-cmd = $(patsubst %,$(run-program-prefix),\
542                         $(filter-out %-bp,$(built-program-file))) \
543                     $(built-program-file)
545 ifndef LD
546 LD := ld -X
547 endif
549 ifndef  RANLIB
550 RANLIB = ranlib
551 endif
553 # Extra flags to pass to GCC.
554 ifeq ($(all-warnings),yes)
555 +gccwarn := -Wall -Wwrite-strings -Winline -Wstrict-prototypes -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
556 else
557 +gccwarn := -Wall -Wwrite-strings -Winline -Wstrict-prototypes
558 endif
560 # We do not depend on the address of constants in different files to be
561 # actually different, so allow the compiler to merge them all.
562 +merge-constants = -fmerge-all-constants
564 # This is the program that generates makefile dependencies from C source files.
565 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
566 # targets for headers so that removed headers don't break the build.
567 ifndef +mkdep
568 +mkdep = $(CC) -M -MP
569 endif
571 # The program that makes Emacs-style TAGS files.
572 ETAGS   := etags
574 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
575 # perhaps others) to preprocess assembly code in some cases.
576 M4 = m4
578 # To force installation of files even if they are older than the
579 # installed files.  This variable is included in the dependency list
580 # of all installation targets.
581 ifeq ($(force-install),yes)
582 +force = force-install
583 else
584 +force =
585 endif
587 ####
588 #### End of configuration variables.
589 ####
591 # This tells some versions of GNU make before 3.63 not to export all variables.
592 .NOEXPORT:
594 # We want to echo the commands we're running without
595 # umpteen zillion filenames along with it (we use `...' instead)
596 # but we don't want this echoing done when the user has said
597 # he doesn't want to see commands echoed by using -s.
598 ifneq   "$(findstring s,$(MAKEFLAGS))" ""       # if -s
599 +cmdecho        := echo >/dev/null
600 else                                            # not -s
601 +cmdecho        := echo
602 endif                                           # -s
604 # These are the flags given to the compiler to tell
605 # it what sort of optimization and/or debugging output to do.
606 ifndef  +cflags
607 # If `CFLAGS' was defined, use that.
608 ifdef           CFLAGS
609 +cflags := $(filter-out -I%,$(CFLAGS))
610 endif           # CFLAGS
611 endif   # +cflags
613 # If none of the above worked, default to "-g -O".
614 ifeq    "$(strip $(+cflags))" ""
615 +cflags := $(default_cflags)
616 endif   # $(+cflags) == ""
618 +cflags += $(addprefix -mcpu=,$(with-cpu)) $(+gccwarn) $(+merge-constants)
619 +gcc-nowarn := -w
621 # Don't duplicate options if we inherited variables from the parent.
622 +cflags := $(sort $(+cflags))
625 # These are flags given to the C compiler to tell it to look for
626 # include files (including ones given in angle brackets) in the parent
627 # library source directory, in the include directory, and in the
628 # current directory.
629 # `+sysdep-includes' will be defined by Makerules.
630 +includes = -I$(..)include \
631             $(patsubst %/,-I%,$(objpfx)) $(+sysdep-includes) \
632             $(patsubst %/,-I%,$(..)) $(libio-include) $(includes) -I. \
633             $(sysincludes)
635 # Since libio has several internal header files, we use a -I instead
636 # of many little headers in the include directory.
637 libio-include = -I$(..)libio
639 # These are the variables that the implicit compilation rules use.
640 # Note that we can't use -std=* in CPPFLAGS, because it overrides
641 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
642 # it causes cpp to stop predefining __ASSEMBLER__.
643 CPPFLAGS = $($(subdir)-CPPFLAGS) $(+includes) $(defines) \
644            -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
645            $(CPPFLAGS-$(suffix $@)) \
646            $(foreach lib,$(libof-$(basename $(@F))) \
647                          $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
648            $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
649 override CFLAGS = -std=gnu99 \
650                   $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
651                   $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
653 # If everything is compiled with -fPIC (implicitly) we must tell this by
654 # defining the PIC symbol.
655 ifeq (yes,$(build-pic-default))
656 pic-default = -DPIC
657 endif
659 # Enable object files for different versions of the library.
660 # Various things use $(object-suffixes) to know what all to make.
661 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
662 # to pass different flags for each flavor.
663 libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
664 all-object-suffixes := .o .os .op .og .ob .oS
665 object-suffixes :=
666 CPPFLAGS-.o = $(pic-default)
667 CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
668 ifeq (yes,$(build-static))
669 libtype.o := lib%.a
670 object-suffixes += .o
671 endif
672 ifeq (yes,$(build-shared))
673 # Under --enable-shared, we will build a shared library of PIC objects.
674 # The PIC object files are named foo.os.
675 object-suffixes += .os
676 CPPFLAGS-.os = -DPIC -DSHARED
677 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
678 libtype.os := lib%_pic.a
679 # This can be changed by a sysdep makefile
680 pic-ccflag = -fPIC
681 # This one should always stay like this unless there is a very good reason.
682 PIC-ccflag = -fPIC
683 endif
684 ifeq (yes,$(build-profile))
685 # Under --enable-profile, we will build a static library of profiled objects.
686 # The profiled object files are named foo.op.
687 object-suffixes += .op
688 CPPFLAGS-.op = -DPROF $(pic-default)
689 CFLAGS-.op = -pg
690 libtype.op = lib%_p.a
691 endif
692 ifeq (yes,$(build-omitfp))
693 # Under --enable-omitfp, we build the library optimized without
694 # debugging information using -fomit-frame-pointer, and build an extra
695 # library with debugging information.  The debuggable objects are named foo.og.
696 object-suffixes += .og
697 CPPFLAGS-.og = $(pic-default)
698 CFLAGS-.og = -g
699 CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES
700 CFLAGS-.os += -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES
701 libtype.og = lib%_g.a
702 endif
704 bppfx = BP-
705 ifeq (yes,$(build-bounded))
706 # Under --enable-bounded, we build the library with `-fbounded-pointers -g'
707 # to runtime bounds checking.  The bounded-pointer objects are named foo.ob.
708 # We disable sibling-call optimizations so that stack traces will be complete
709 # and thus aid debugging, since after all, BPs are a debugging tool.
710 object-suffixes += .ob
711 CPPFLAGS-.ob = -fbounded-pointers $(pic-default)
712 CFLAGS-.ob = -g -O2 -fno-optimize-sibling-calls -fno-strict-aliasing
713 libtype.ob = lib%_b.a
714 endif
716 object-suffixes-for-libc := $(object-suffixes)
718 ifeq (yes,$(build-shared))
719 # Build special library that contains the static-only routines for libc.
720 object-suffixes-for-libc += .oS
722 # Must build the routines as PIC, though, because they can end up in (users')
723 # shared objects.  We don't want to use CFLAGS-os because users may, for
724 # example, make that processor-specific.
725 CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
726 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
727 libtype.oS = lib%_nonshared.a
728 endif
730 # The assembler can generate debug information too.
731 ifndef ASFLAGS
732 ifeq ($(have-cpp-asm-debuginfo),yes)
733 ASFLAGS := $(filter -g%,$(CFLAGS))
734 else
735 ASFLAGS :=
736 endif
737 endif
738 ASFLAGS += $(ASFLAGS-config)
740 +gnu-stabs = $(shell echo>&2 '*** BARF ON ME')
742 ifndef BUILD_CC
743 BUILD_CC = $(CC)
744 endif
746 move-if-change = $(SHELL) $(..)scripts/move-if-change
748 -include $(common-objpfx)sysd-dirs
750 ifeq ($(sysd-dirs-done),t)
751 -include $(common-objpfx)sysd-sorted
752 subdirs = $(sorted-subdirs)
753 endif
755 ifeq (yes, $(build-shared))
757 # This is a pair of implicit rules to preprocess a file with # comments,
758 # %ifdef et al, based on config.h settings or other %include'd files.
759 # We use chained rules instead of a pipeline here so that we can properly
760 # check the exit status of cpp rather than using its bad output when there
761 # is a preprocessing error.  Another rule should depend on the output file
762 # `FOO.v', and along with that `FOO.v.i' should be given dependencies
763 # listing both its input files, and any header files that it may reference
764 # (but no commands).
765 %.v.i: $(common-objpfx)config.h
766         sed '/^[        ]*#/d;s/^[      ]*%/#/' $(filter-out FORCE %.h,$^) \
767         | $(CC) -E -undef $(CPPFLAGS) \
768                    -DASSEMBLER -x assembler-with-cpp - \
769                    > $@T
770         mv -f $@T $@
771 %.v: %.v.i
772         sed '/^[        ]*#/d;/^[       ]*$$/d' $< > $@T
773         mv -f $@T $@
775 # Process the shlib-versions file, which tells us what shared library
776 # version numbers to use when we install shared objects on this system.
777 # We need to wait until $(subdirs) is complete.
778 ifeq ($(sysd-sorted-done),t)
779 -include $(common-objpfx)soversions.mk
780 ifndef avoid-generated
781 # This lets add-ons give more-specific matches that override defaults
782 # in the top-level file.
783 $(common-objpfx)shlib-versions.v.i: \
784         $(wildcard $(patsubst %, $(..)%/shlib-versions,$(add-ons) \
785                                                        $(config-sysdirs) \
786                                                        $(subdirs))) \
787         $(..)shlib-versions
789 soversions-default-setname = $(patsubst %, %,\
790                                         $(filter-out %_default,\
791                                                      $(oldest-abi:%=GLIBC_%)))
792 $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
793                               $(common-objpfx)shlib-versions.v
794         $(AWK) -v default_setname='$(soversions-default-setname)' \
795                -v cpu='$(config-machine)' \
796                -v vendor='$(config-vendor)' \
797                -v os='$(config-os)' \
798                -f $^ > $@T
799         mv -f $@T $@
800 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
801         (seen_DEFAULT=0; seen_WORDSIZE32=0; seen_WORDSIZE64=0; \
802          while read which lib number setname; do \
803            eval seen_$$which=1; \
804            test x"$$which" = xDEFAULT || continue; \
805            case $$number in \
806              [0-9]*) echo "$$lib.so-version=.$$number"; \
807                      echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
808              *)      echo "$$lib.so-version=$$number"; \
809                      echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
810            esac; \
811          done; \
812          case "$$seen_DEFAULT$$seen_WORDSIZE32$$seen_WORDSIZE64" in \
813            100) echo biarch = no;; \
814            101) echo biarch = 32;; \
815            ?1?) echo biarch = 64;; \
816            *) echo >&2 BUG; exit 2;; \
817          esac; \
818          echo soversions.mk-done = t;) < $< > $@T; exit 0
819         mv -f $@T $@
820 endif
821 endif
823 postclean-generated += soversions.mk soversions.i \
824                        shlib-versions.v shlib-versions.v.i
826 # Generate the header containing the names of all shared libraries.
827 # We use a stamp file to avoid unnecessary recompilations.
828 before-compile += $(common-objpfx)gnu/lib-names.h
829 ifeq ($(soversions.mk-done),t)
830 $(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
831 $(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
832                                     $(common-objpfx)soversions.i
833         $(make-target-directory)
834         @rm -f ${@:stmp=T} $@
835         $(AWK) -f $^ > ${@:stmp=T}
836         $(move-if-change) ${@:stmp=T} ${@:stmp=h}
837         touch $@
838 endif
840 common-generated += gnu/lib-names.h gnu/lib-names.stmp
842 # The name under which the run-time dynamic linker is installed.
843 # We are currently going for the convention that `/lib/ld.so.1'
844 # names the SVR4/ELF ABI-compliant dynamic linker.
845 ifndef rtld-installed-name
846 ifdef ld.so-version
847 rtld-installed-name = $(ld.so-version)
848 else
849 rtld-installed-name = ld.so.1
850 endif
851 endif
853 ifndef rtld-version-installed-name
854 rtld-version-installed-name = ld-$(version).so
855 endif
857 endif # build-shared
860 ifeq ($(elf),yes)
861 dlfcn = dlfcn
862 ifeq ($(build-shared),yes)
863 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
864 else
865 libdl = $(common-objpfx)dlfcn/libdl.a
866 endif
867 else
868 ifneq (,$(findstring aix,$(config-os)))
869 ifeq ($(build-shared),yes)
870 dlfcn = dlfcn
871 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
872 else
873 # No libdl without shared libs on AIX
874 dlfcn =
875 libdl =
876 endif
877 else
878 # No ELF, no AIX - no libdl, at least for now.
879 dlfcn =
880 libdl =
881 endif
882 endif
884 # These are the subdirectories containing the library source.  The order
885 # is more or less arbitrary.  The sorting step will take care of the
886 # dependencies.  Only the $(binfmt-subdir) should always be kept at the
887 # end of the list.
888 all-subdirs = csu assert ctype locale intl catgets math setjmp signal       \
889               stdlib stdio-common libio malloc string wcsmbs time dirent \
890               grp pwd posix io termios resource misc socket sysvipc gmon    \
891               gnulib iconv iconvdata wctype manual shadow po argp           \
892               crypt $(add-ons) nss localedata timezone rt conform debug     \
893               $(sysdep-subdirs) $(dlfcn) $(binfmt-subdir)
894 all-subdirs := $(filter-out $(sysdep-inhibit-subdirs),$(all-subdirs))
896 # The mach and hurd subdirectories have many generated header files which
897 # much of the rest of the library depends on, so it is best to build them
898 # first (and mach before hurd, at that).  The before-compile additions in
899 # sysdeps/{mach,hurd}/Makefile should make it reliably work for these files
900 # not to exist when making in other directories, but it will be slower that
901 # way with more somewhat expensive `make' invocations.
902 subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
903            $(filter-out mach hurd,$(subdirs))
905 ifndef avoid-generated
906 all-Subdirs-files = $(wildcard $(config-sysdirs:%=$(..)%/Subdirs))
907 $(common-objpfx)sysd-dirs: $(common-objpfx)config.make $(all-Subdirs-files)
908         $(AWK) 'BEGIN { subdirs = ""; inhibit = "" };                   \
909                 /^#/ { next };                                          \
910                 /^[^-]/ { subdirs = subdirs " " $$0 };                  \
911                 /^-/ { inhibit = inhibit " " substr($$0, 2) };          \
912                 END { printf "sysdep-subdirs =%s\n", subdirs;           \
913                       printf "sysdep-inhibit-subdirs =%s\n", inhibit;   \
914                       print "sysd-dirs-done = t" }'                     \
915                $(patsubst $<,/dev/null,$^) > $@-tmp
916         mv -f $@-tmp $@
918 all-Depend-files = $(wildcard $(..)*/Depend)
919 $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk $(all-Depend-files) \
920                              $(common-objpfx)sysd-dirs $(..)Makeconfig
921         { { dirs='$(patsubst $(..)%/Depend,%,$(filter %/Depend,$^))';     \
922             for d in $$dirs; do                                           \
923               while read on; do                                           \
924                 echo "depend $$d $$on";                                   \
925               done < $(..)$$d/Depend;                                     \
926             done;                                                         \
927             for f in $(all-subdirs); do                                   \
928               echo $$f;                                                   \
929             done;                                                         \
930           } | $(AWK) -f $< &&                                             \
931           echo sysd-sorted-done = t;                                      \
932         } > $@-tmp
933         mv -f $@-tmp $@
934 endif
936 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
937 sysdep-makeconfigs := $(wildcard $(patsubst %,$(..)%/Makeconfig,\
938                                             $(config-sysdirs) $(add-ons)))
940 ifneq (,$(sysdep-makeconfigs))
941 Makeconfig-doing-sysdep := $(sysdep-makeconfigs)
942 # Before each one, include ourselves again to do the bit below that
943 # will set `Makeconfig-add-on' in an add-on's Makeconfig fragment.
944 include $(foreach M,$(sysdep-makeconfigs),$(..)Makeconfig $M)
945 endif
948 endif # Makeconfig not yet included
950 # The whole body above didn't run when we are included as a subroutine
951 # of ourselves in the sysdep-makeconfigs include line.  This bit runs.
952 ifneq (,$(Makeconfig-doing-sysdep))
953 sysdep-Makeconfig := $(firstword $(Makeconfig-doing-sysdep))
954 Makeconfig-doing-sysdep := $(filter-out $(sysdep-Makeconfig),\
955                                         $(Makeconfig-doing-sysdep))
956 Makeconfig-add-on := $(filter $(add-ons),$(patsubst $(..)%/Makeconfig,%,\
957                                                     $(sysdep-Makeconfig)))
958 endif
960 # Local Variables:
961 # mode: makefile
962 # End: