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