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