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