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