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