]> git.ipfire.org Git - thirdparty/glibc.git/blob - Makeconfig
Build libc-start with stack protector for SHARED
[thirdparty/glibc.git] / Makeconfig
1 # Copyright (C) 1991-2021 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 # <https://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 $(error 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 = -fexceptions
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 +sysdep_dirs = $(sysdirs)
63 ifdef objdir
64 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
65 endif
66
67 # Run config.status to update config.make and config.h. We don't show the
68 # dependence of config.h to Make, because it is only touched when it
69 # changes and so config.status would be run every time; the dependence of
70 # config.make should suffice to force regeneration and re-exec, and the new
71 # image will notice if config.h changed.
72 $(common-objpfx)config.make: $(common-objpfx)config.status \
73 $(..)config.make.in $(..)config.h.in
74 cd $(<D); $(SHELL) $(<F)
75
76 # Find all the sysdeps configure fragments, to make sure we re-run
77 # configure when any of them changes.
78 $(common-objpfx)config.status: $(..)version.h $(..)configure \
79 $(foreach dir,$(sysdirs),\
80 $(wildcard $(dir)/Implies) \
81 $(patsubst %.ac,%,\
82 $(firstword $(wildcard \
83 $(addprefix $(dir)/,configure configure.ac))))) \
84 $(patsubst %.ac,%,\
85 $(wildcard $(..)sysdeps/*/preconfigure $(..)sysdeps/*/preconfigure.ac))
86 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
87 echo The GNU C library has not been configured. >&2; \
88 echo Run \`configure\' to configure it before building. >&2; \
89 echo Try \`configure --help\' for more details. >&2; \
90 exit 1; fi
91
92 # We don't want CPPFLAGS to be exported to the command running configure.
93 unexport CPPFLAGS
94
95 # Get the user's configuration parameters.
96 ifneq ($(wildcard $(..)configparms),)
97 include $(..)configparms
98 endif
99 ifneq ($(objpfx),)
100 ifneq ($(wildcard $(common-objpfx)configparms),)
101 include $(common-objpfx)configparms
102 endif
103 endif
104 \f
105 ####
106 #### These are the configuration variables. You can define values for
107 #### the variables below in the file `configparms'.
108 #### Do NOT edit this file.
109 ####
110
111
112 # Common prefix for machine-independent installation directories.
113 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
114 prefix = /usr/local
115 endif
116
117 # Decide whether we shall build the programs or not. We always do this
118 # unless the user tells us (in configparms) or we are building for a
119 # standalone target.
120 ifndef build-programs
121 ifneq ($(config-os),none)
122 build-programs=yes
123 else
124 build-programs=no
125 endif
126 endif
127
128 # Common prefix for machine-dependent installation directories.
129 ifeq ($(origin exec_prefix),undefined)
130 exec_prefix = $(prefix)
131 endif
132
133 # Where to install the library and object files.
134 ifndef libdir
135 libdir = $(exec_prefix)/lib
136 endif
137 inst_libdir = $(install_root)$(libdir)
138
139 # Where to install the shared library.
140 ifndef slibdir
141 slibdir = $(exec_prefix)/lib
142 endif
143 inst_slibdir = $(install_root)$(slibdir)
144
145 # Where to install the dynamic linker.
146 ifndef rtlddir
147 rtlddir = $(slibdir)
148 endif
149 inst_rtlddir = $(install_root)$(rtlddir)
150
151 # Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
152 # the prefix is spliced between `lib' and the name, so the linker switch
153 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
154 # just prepended to the whole file name.
155 ifeq ($(origin libprefix),undefined)
156 libprefix =
157 endif
158
159 # Where to install the header files.
160 ifndef includedir
161 includedir = $(prefix)/include
162 endif
163 inst_includedir = $(install_root)$(includedir)
164
165 # Where to install machine-independent data files.
166 # These are the timezone database, and the locale database.
167 ifndef datadir
168 datadir = $(prefix)/share
169 endif
170 inst_datadir = $(install_root)$(datadir)
171
172 # Where to install the timezone data files (which are machine-independent).
173 ifndef zonedir
174 zonedir = $(datadir)/zoneinfo
175 endif
176 inst_zonedir = $(install_root)$(zonedir)
177
178 # Where to install the compiled binary locale archive and compiled
179 # binary locale files.
180 ifndef complocaledir
181 complocaledir = $(libdir)/locale
182 endif
183 inst_complocaledir = $(install_root)$(complocaledir)
184
185 # Where to install the message catalog data files (which are
186 # machine-independent).
187 ifndef localedir
188 localedir = $(datadir)/locale
189 endif
190 inst_localedir = $(install_root)$(localedir)
191
192 # Where to install the locale charmap source files.
193 ifndef i18ndir
194 i18ndir = $(datadir)/i18n
195 endif
196 inst_i18ndir = $(install_root)$(i18ndir)
197
198 # Where to install the shared object for charset transformation.
199 ifndef gconvdir
200 gconvdir = $(libdir)/gconv
201 endif
202 inst_gconvdir = $(install_root)$(gconvdir)
203
204 # Where to install programs.
205 ifndef bindir
206 bindir = $(exec_prefix)/bin
207 endif
208 inst_bindir = $(install_root)$(bindir)
209
210 # Where to install internal programs.
211 ifndef libexecdir
212 libexecdir = $(exec_prefix)/libexec
213 endif
214 inst_libexecdir = $(install_root)$(libexecdir)
215
216 # Where to install administrative programs.
217 ifndef rootsbindir
218 rootsbindir = $(exec_prefix)/sbin
219 endif
220 inst_rootsbindir = $(install_root)$(rootsbindir)
221
222 ifndef sbindir
223 sbindir = $(exec_prefix)/sbin
224 endif
225 inst_sbindir = $(install_root)$(sbindir)
226
227 # Where to install the Info files.
228 ifndef infodir
229 infodir = $(prefix)/info
230 endif
231 inst_infodir = $(install_root)$(infodir)
232
233 # Where to install audit libraries.
234 ifndef auditdir
235 auditdir = $(libdir)/audit
236 endif
237 inst_auditdir = $(install_root)$(auditdir)
238
239 # Where to install default configuration files. These include the local
240 # timezone specification and network data base files.
241 ifndef sysconfdir
242 sysconfdir = $(prefix)/etc
243 endif
244 inst_sysconfdir = $(install_root)$(sysconfdir)
245
246 # Directory for the database files and Makefile for nss_db.
247 ifndef vardbdir
248 vardbdir = $(localstatedir)/db
249 endif
250 inst_vardbdir = $(install_root)$(vardbdir)
251
252 # Where to install the "localtime" timezone file; this is the file whose
253 # contents $(localtime) specifies. If this is a relative pathname, it is
254 # relative to $(zonedir). It is a good idea to put this somewhere
255 # other than there, so the zoneinfo directory contains only universal data,
256 # localizing the configuration data elsewhere.
257 ifndef localtime-file
258 localtime-file = $(sysconfdir)/localtime
259 endif
260
261 # What to use for leap second specifications in compiling the default
262 # timezone files. Set this to `/dev/null' for no leap second handling as
263 # 1003.1 requires, or to `leapseconds' for proper leap second handling.
264 # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
265 # This variable determines the default: if it's `/dev/null',
266 # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
267 ifndef leapseconds
268 leapseconds = /dev/null
269 endif
270
271 # What timezone's DST rules should be used when a POSIX-style TZ
272 # environment variable doesn't specify any rules. For 1003.1 compliance
273 # this timezone must use rules that are as U.S. federal law defines DST.
274 # Run `make -C time echo-zonenames' to see a list of available zone names.
275 # This setting can be changed with `zic -p TIMEZONE' at any time.
276 # If you want POSIX.1 compatibility, use `America/New_York'.
277 ifndef posixrules
278 posixrules = America/New_York
279 endif
280
281 # Where to install the "posixrules" timezone file; this is file
282 # whose contents $(posixrules) specifies. If this is a relative
283 # pathname, it is relative to $(zonedir).
284 ifndef posixrules-file
285 posixrules-file = posixrules
286 endif
287
288
289 # Directory where your system's native header files live.
290 # This is used on Unix systems to generate some GNU libc header files.
291 ifndef sysincludedir
292 sysincludedir = /usr/include
293 endif
294
295
296 # Commands to install files.
297 ifndef INSTALL_DATA
298 INSTALL_DATA = $(INSTALL) -m 644
299 endif
300 ifndef INSTALL_SCRIPT
301 INSTALL_SCRIPT = $(INSTALL)
302 endif
303 ifndef INSTALL_PROGRAM
304 INSTALL_PROGRAM = $(INSTALL)
305 endif
306 ifndef INSTALL
307 INSTALL = install
308 endif
309
310
311 # The name of the C compiler.
312 # If you've got GCC, and it works, use it.
313 ifeq ($(origin CC),default)
314 CC := gcc
315 endif
316
317 # The name of the C compiler to use for compilations of programs to run on
318 # the host that is building the library. If you set CC to a
319 # cross-compiler, you must set this to the normal compiler.
320 ifndef BUILD_CC
321 BUILD_CC = $(CC)
322 endif
323
324 # Default flags to pass the C compiler.
325 ifndef default_cflags
326 ifeq ($(release),stable)
327 default_cflags := -g -O2
328 else
329 default_cflags := -g -O
330 endif
331 endif
332
333 # Flags to pass the C compiler when assembling preprocessed assembly code
334 # (`.S' files).
335 ifndef asm-CPPFLAGS
336 asm-CPPFLAGS =
337 endif
338
339 # Must be supported by the linker.
340 no-whole-archive = -Wl,--no-whole-archive
341 whole-archive = -Wl,--whole-archive
342
343 # Installed name of the startup code.
344 # The ELF convention is that the startfile is called crt1.o
345 start-installed-name = crt1.o
346 # On systems that do not need a special startfile for statically linked
347 # binaries, simply set it to the normal name.
348 ifndef static-start-installed-name
349 static-start-installed-name = $(start-installed-name)
350 endif
351
352 ifeq (yes,$(enable-static-pie))
353 # Link with rcrt1.o, instead of crt1.o, to call _dl_relocate_static_pie
354 # to relocate static PIE.
355 real-static-start-installed-name = r$(static-start-installed-name)
356 else
357 real-static-start-installed-name = $(static-start-installed-name)
358 endif
359
360 ifeq (yesyes,$(build-shared)$(have-z-combreloc))
361 combreloc-LDFLAGS = -Wl,-z,combreloc
362 LDFLAGS.so += $(combreloc-LDFLAGS)
363 LDFLAGS-rtld += $(combreloc-LDFLAGS)
364 endif
365
366 relro-LDFLAGS = -Wl,-z,relro
367 LDFLAGS.so += $(relro-LDFLAGS)
368 LDFLAGS-rtld += $(relro-LDFLAGS)
369
370 ifeq (yes,$(have-hash-style))
371 # For the time being we unconditionally use 'both'. At some time we
372 # should declare statically linked code as 'out of luck' and compile
373 # with --hash-style=gnu only.
374 hashstyle-LDFLAGS = -Wl,--hash-style=both
375 LDFLAGS.so += $(hashstyle-LDFLAGS)
376 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
377 endif
378
379 ifeq (yes,$(enable-static-pie))
380 pic-default = -DPIC
381 # Compile libc.a and libc_p.a with -fPIE/-fpie for static PIE.
382 pie-default = $(pie-ccflag)
383 ifeq (yes,$(have-static-pie))
384 default-pie-ldflag = -static-pie
385 else
386 # Static PIE can't have dynamic relocations in read-only segments since
387 # static PIE is mapped into memory by kernel. --eh-frame-hdr is needed
388 # for PIE to support exception.
389 default-pie-ldflag = -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text
390 endif
391 endif
392
393 # If lazy relocations are disabled, add the -z now flag. Use
394 # LDFLAGS-lib.so instead of LDFLAGS.so, to avoid adding the flag to
395 # test modules.
396 ifeq ($(bind-now),yes)
397 LDFLAGS-lib.so += -Wl,-z,now
398 # Extra flags for dynamically linked non-test main programs.
399 link-extra-flags += -Wl,-z,now
400 endif
401
402 # Command to run after every final link (executable or shared object).
403 # This is invoked with $(call after-link,...), so it should operate on
404 # the file $1. This can be set to do some sort of post-processing on
405 # binaries, or to perform some sort of static sanity check.
406 ifndef after-link
407 after-link =
408 endif
409
410 # Additional libraries to link into every test.
411 link-extra-libs-tests = $(libsupport)
412
413 # Command for linking PIE programs with the C library.
414 ifndef +link-pie
415 +link-pie-before-libc = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
416 -Wl,-O1 -nostdlib -nostartfiles -o $@ \
417 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
418 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
419 $(firstword $(CRT-$(@F)) $(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)
426 +link-pie-after-libc = $(+postctorS) $(+postinit)
427 define +link-pie
428 $(CC) $(link-libc-rpath-link) $(+link-pie-before-libc) $(rtld-LDFLAGS) \
429 $(link-extra-flags) $(link-libc) $(+link-pie-after-libc)
430 $(call after-link,$@)
431 endef
432 define +link-pie-tests
433 $(CC) $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
434 $(+link-pie-after-libc)
435 $(call after-link,$@)
436 endef
437 define +link-pie-printers-tests
438 $(CC) $(+link-pie-before-libc) $(built-rtld-LDFLAGS) \
439 $(link-libc-printers-tests) $(+link-pie-after-libc)
440 $(call after-link,$@)
441 endef
442 endif
443 # Command for statically linking programs with the C library.
444 ifndef +link-static
445 +link-static-before-libc = -nostdlib -nostartfiles -static -o $@ \
446 $(if $($(@F)-no-pie),$(no-pie-ldflag),$(default-pie-ldflag)) \
447 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
448 $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
449 $(+preinit) $(+prectorT) \
450 $(filter-out $(addprefix $(csu-objpfx),start.o \
451 $(start-installed-name))\
452 $(+preinit) $(link-extra-libs-static) \
453 $(common-objpfx)libc% $(+postinit),$^) \
454 $(link-extra-libs-static)
455 +link-static-after-libc = $(+postctorT) $(+postinit)
456 define +link-static
457 $(CC) $(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) \
458 $(+link-static-after-libc)
459 $(call after-link,$@)
460 endef
461 define +link-static-tests
462 $(CC) $(+link-static-before-libc) $(link-libc-static-tests) \
463 $(+link-static-after-libc)
464 $(call after-link,$@)
465 endef
466 endif
467 # Commands for linking programs with the C library.
468 ifndef +link
469 ifeq (yes,$(build-shared))
470 ifeq (yes,$(cc-pie-default))
471 no-pie-ldflag = -no-pie
472 endif
473 ifeq (yes,$(build-pie-default))
474 +link = $(+link-pie)
475 +link-tests = $(+link-pie-tests)
476 +link-printers-tests = $(+link-pie-printers-tests)
477 else # not build-pie-default
478 +link-before-libc = -nostdlib -nostartfiles -o $@ \
479 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
480 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
481 $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
482 $(+preinit) $(+prector) \
483 $(filter-out $(addprefix $(csu-objpfx),start.o \
484 $(start-installed-name))\
485 $(+preinit) $(link-extra-libs) \
486 $(common-objpfx)libc% $(+postinit),$^) \
487 $(link-extra-libs)
488 +link-after-libc = $(+postctor) $(+postinit)
489 define +link
490 $(CC) $(link-libc-rpath-link) $(+link-before-libc) $(rtld-LDFLAGS) \
491 $(link-extra-flags) $(link-libc) $(+link-after-libc)
492 $(call after-link,$@)
493 endef
494 define +link-tests
495 $(CC) $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
496 $(+link-after-libc)
497 $(call after-link,$@)
498 endef
499 define +link-printers-tests
500 $(CC) $(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
501 $(+link-after-libc)
502 $(call after-link,$@)
503 endef
504 endif # build-pie-default
505 else # build-static
506 +link = $(+link-static)
507 +link-tests = $(+link-static-tests)
508 +link-printers-tests = $(+link-static-tests)
509 endif # build-shared
510 endif # +link
511
512 # The pretty printer test programs need to be compiled without optimizations
513 # so they won't confuse gdb. We could use either the 'GCC optimize' pragma
514 # or the 'optimize' function attribute to achieve this; however, at least on
515 # ARM, gcc always produces different debugging symbols when invoked with
516 # a -O greater than 0 than when invoked with -O0, regardless of anything else
517 # we're using to suppress optimizations. Therefore, we need to explicitly pass
518 # -O0 to it through CFLAGS.
519 # Additionally, the build system will try to -include $(common-objpfx)/config.h
520 # when compiling the tests, which will throw an error if some special macros
521 # (such as __OPTIMIZE__ and IS_IN_build) aren't defined. To avoid this, we
522 # tell gcc to define IS_IN_build.
523 CFLAGS-printers-tests := -O0 -ggdb3 -DIS_IN_build
524
525 ifeq (yes,$(build-shared))
526 # These indicate whether to link using the built ld.so or the installed one.
527 installed-rtld-LDFLAGS = -Wl,-dynamic-linker=$(rtlddir)/$(rtld-installed-name)
528 built-rtld-LDFLAGS = -Wl,-dynamic-linker=$(elf-objpfx)ld.so
529
530 ifndef rtld-LDFLAGS
531 rtld-LDFLAGS = $(installed-rtld-LDFLAGS)
532 endif
533
534 ifndef rtld-tests-LDFLAGS
535 ifeq (yes,$(build-hardcoded-path-in-tests))
536 rtld-tests-LDFLAGS = $(built-rtld-LDFLAGS)
537 else
538 rtld-tests-LDFLAGS = $(installed-rtld-LDFLAGS)
539 endif # build-hardcoded-path-in-tests
540 endif # rtld-tests-LDFLAGS
541
542 endif # build-shared
543
544 ifndef link-libc
545 ifeq (yes,$(build-shared))
546 # We need the versioned name of libc.so in the deps of $(others) et al
547 # so that the symlink to libc.so is created before anything tries to
548 # run the linked programs.
549 link-libc-rpath = -Wl,-rpath=$(rpath-link)
550 link-libc-rpath-link = -Wl,-rpath-link=$(rpath-link)
551
552 # For programs which are not tests, $(link-libc-rpath-link) is added
553 # directly in $(+link), $(+link-pie) above, so that -Wl,-rpath-link
554 # comes before the expansion of LDLIBS-* and affects libraries added
555 # there. For shared objects, -Wl,-rpath-link is added via
556 # $(build-shlib-helper) and $(build-module-helper) in Makerules (also
557 # before the expansion of LDLIBS-* variables).
558
559 # Tests use -Wl,-rpath instead of -Wl,-rpath-link for
560 # build-hardcoded-path-in-tests.
561 ifeq (yes,$(build-hardcoded-path-in-tests))
562 link-libc-tests-rpath-link = $(link-libc-rpath)
563 else
564 link-libc-tests-rpath-link = $(link-libc-rpath-link)
565 endif # build-hardcoded-path-in-tests
566
567 link-libc-between-gnulib = $(common-objpfx)libc.so$(libc.so-version) \
568 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
569 -Wl,--as-needed $(elf-objpfx)ld.so \
570 -Wl,--no-as-needed
571 link-libc = $(link-libc-between-gnulib) $(gnulib)
572
573 link-libc-tests-after-rpath-link = $(gnulib-tests) $(link-libc-between-gnulib) $(gnulib-tests)
574 link-libc-tests = $(link-libc-tests-rpath-link) \
575 $(link-libc-tests-after-rpath-link)
576 # Pretty printer test programs always require rpath instead of rpath-link.
577 link-libc-printers-tests = $(link-libc-rpath) \
578 $(link-libc-tests-after-rpath-link)
579
580 # This is how to find at build-time things that will be installed there.
581 rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support
582 rpath-link = \
583 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
584 else # build-static
585 link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
586 link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
587 endif # build-shared
588 endif # link-libc
589
590 # Differences in the linkers on the various platforms.
591 LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
592 LDFLAGS-soname-fname = -Wl,-soname,$(@F)
593 LDFLAGS-rdynamic = -rdynamic
594 LDFLAGS-Bsymbolic = -Bsymbolic
595
596 # Choose the default search path for the dynamic linker based on
597 # where we will install libraries.
598 ifneq ($(libdir),$(slibdir))
599 default-rpath = $(slibdir):$(libdir)
600 else
601 default-rpath = $(libdir)
602 endif
603
604 ifndef link-extra-libs
605 link-extra-libs = $(LDLIBS-$(@F))
606 link-extra-libs-static = $(link-extra-libs)
607 endif
608
609 # The static libraries.
610 link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
611 link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib-tests) -Wl,--end-group
612
613 # How to link against libgcc. Some libgcc functions, such as those
614 # for "long long" arithmetic or software floating point, can always be
615 # built without use of C library headers and do not have any global
616 # state so can safely be linked statically into any executable or
617 # shared library requiring them; these functions are in libgcc.a.
618 # Other functions, relating to exception handling, may require C
619 # library headers to build and it may not be safe to have more than
620 # one copy of them in a process; these functions are only in
621 # libgcc_s.so and libgcc_eh.a.
622 #
623 # To avoid circular dependencies when bootstrapping, it is desirable
624 # to avoid use of libgcc_s and libgcc_eh in building glibc. Where any
625 # glibc functionality (in particular, thread cancellation) requires
626 # exception handling, this is implemented through dlopen of libgcc_s
627 # to avoid unnecessary dependencies on libgcc_s by programs not using
628 # that functionality; executables built with glibc do not use
629 # exception handling other than through thread cancellation.
630 #
631 # Undefined references to functions from libgcc_eh or libgcc_s may
632 # arise for code built with -fexceptions. In the case of statically
633 # linked programs installed by glibc, unwinding will never actually
634 # occur at runtime and the use of elf/static-stubs.c to resolve these
635 # references is safe. In the case of statically linked test programs
636 # and test programs built with -fexceptions, unwinding may occur in
637 # some cases and it is preferable to link with libgcc_eh or libgcc_s
638 # so that the testing is as similar as possible to how programs will
639 # be built with the installed glibc.
640 #
641 # Some architectures have architecture-specific systems for exception
642 # handling that may involve undefined references to
643 # architecture-specific functions. On those architectures,
644 # gnulib-arch and static-gnulib-arch may be defined in sysdeps
645 # makefiles to use additional libraries for linking executables and
646 # shared libraries built by glibc.
647 ifndef gnulib
648 ifneq ($(have-cc-with-libunwind),yes)
649 libunwind =
650 else
651 libunwind = -lunwind
652 endif
653 libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
654 gnulib-arch =
655 gnulib = -lgcc $(gnulib-arch)
656 gnulib-tests := -lgcc $(libgcc_eh)
657 static-gnulib-arch =
658 # By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
659 # statically link programs. When --disable-shared is used, we use
660 # -lgcc_eh since elf/static-stubs.o isn't sufficient.
661 ifeq (yes,$(build-shared))
662 static-gnulib = -lgcc $(static-gnulib-arch)
663 else
664 static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch)
665 endif
666 static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
667 libc.so-gnulib := -lgcc
668 endif
669 +preinit = $(addprefix $(csu-objpfx),crti.o)
670 +postinit = $(addprefix $(csu-objpfx),crtn.o)
671 +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
672 +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
673 # Variants of the two previous definitions for linking PIE programs.
674 +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
675 +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
676 # Variants of the two previous definitions for statically linking programs.
677 ifeq (yes,$(enable-static-pie))
678 # Static PIE must use PIE variants.
679 +prectorT = $(+prectorS)
680 +postctorT = $(+postctorS)
681 else
682 +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
683 +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
684 endif
685 csu-objpfx = $(common-objpfx)csu/
686 elf-objpfx = $(common-objpfx)elf/
687
688 # A command that, prepended to the name and arguments of a program,
689 # and run on the build system, causes that program with those
690 # arguments to be run on the host for which the library is built.
691 ifndef test-wrapper
692 test-wrapper =
693 endif
694 # Likewise, but the name of the program is preceded by
695 # <variable>=<value> assignments for environment variables.
696 ifndef test-wrapper-env
697 test-wrapper-env = $(test-wrapper) env
698 endif
699 # Likewise, but the program's environment will be empty except for any
700 # explicit <variable>=<value> assignments preceding the program name.
701 ifndef test-wrapper-env-only
702 test-wrapper-env-only = $(test-wrapper) env -i
703 endif
704
705 # Whether to run test programs built for the library's host system.
706 ifndef run-built-tests
707 ifeq (yes|,$(cross-compiling)|$(test-wrapper))
708 run-built-tests = no
709 else
710 run-built-tests = yes
711 endif
712 endif
713
714 # Whether to stop immediately when a test fails. Nonempty means to
715 # stop, empty means not to stop.
716 ifndef stop-on-test-failure
717 stop-on-test-failure =
718 endif
719
720 # How to run a program we just linked with our library.
721 # The program binary is assumed to be $(word 2,$^).
722 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
723 rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
724 --library-path \
725 $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
726 ifeq (yes,$(build-shared))
727 comma = ,
728 sysdep-library-path = \
729 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
730 $(filter -Wl$(comma)-rpath-link=%,\
731 $(sysdep-LDFLAGS)))))
732 # $(run-via-rtld-prefix) is a command that, when prepended to the name
733 # of a program built with the newly built library, produces a command
734 # that, executed on the host for which the library is built, runs that
735 # program. For tests listed in tests-static or xtests-static, it is
736 # empty.
737 run-via-rtld-prefix = \
738 $(if $(strip $(filter $(notdir $(built-program-file)), \
739 $(tests-static) $(xtests-static))),, $(rtld-prefix))
740 else
741 run-via-rtld-prefix =
742 endif
743 # $(run-program-env) is the default environment variable settings to
744 # use when running a program built with the newly built library.
745 run-program-env = GCONV_PATH=$(common-objpfx)iconvdata \
746 LOCPATH=$(common-objpfx)localedata LC_ALL=C
747 # $(run-program-prefix) is a command that, when prepended to the name
748 # of a program built with the newly built library, produces a command
749 # that, executed on the build system on which "make" is run, runs that
750 # program. $(run-program-prefix-before-env) and
751 # $(run-program-prefix-after-env) are similar, but separate parts
752 # before and after a list of environment variables.
753 run-program-prefix-before-env = $(test-wrapper-env)
754 run-program-prefix-after-env = $(run-via-rtld-prefix)
755 run-program-prefix = $(run-program-prefix-before-env) $(run-program-env) \
756 $(run-program-prefix-after-env)
757 # $(built-program-cmd) is a command that, executed on the build system
758 # on which "make" is run, runs the newly built program that is the
759 # second dependency of the makefile target in which
760 # $(built-program-cmd) is used. $(built-program-cmd-before-env) and
761 # $(built-program-cmd-after-env) are similar, before and after a list
762 # of environment variables.
763 built-program-cmd-before-env = $(test-wrapper-env)
764 built-program-cmd-after-env = $(run-via-rtld-prefix) $(built-program-file)
765 built-program-cmd = $(built-program-cmd-before-env) $(run-program-env) \
766 $(built-program-cmd-after-env)
767 # $(host-built-program-cmd) is a command that, executed on the host
768 # for which the library is built, runs the newly built program that is
769 # the second dependency of the makefile target in which
770 # $(host-built-program-cmd) is used.
771 host-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file)
772 # $(ld-library-path) is the common content to be set in LD_LIBRARY_PATH
773 # for running static binaries that may load dynamic objects.
774 ld-library-path = $(objpfx):$(common-objpfx)$(addprefix :,$(sysdep-ld-library-path))
775
776 ifndef LD
777 LD := ld -X
778 endif
779
780 # $(test-via-rtld-prefix) is a command that, when prepended to the name
781 # of a test program built with the newly built library, produces a command
782 # that, executed on the host for which the library is built, runs that
783 # program. For tests listed in tests-static or xtests-static as well
784 # as when test programs are hardcoded to the newly built libraries, it
785 # is empty.
786
787 # $(test-program-prefix) is a command that, when prepended to the name
788 # of a test program built with the newly built library, produces a command
789 # that, executed on the build system on which "make" is run, runs that
790 # test program. $(test-program-prefix-before-env) and
791 # $(test-program-prefix-after-env) are similar, before and after a
792 # list of environment variables.
793
794 # $(test-program-cmd) is a command that, executed on the build system
795 # on which "make" is run, runs the newly built test program that is the
796 # second dependency of the makefile target in which
797 # $(test-program-cmd) is used. $(test-program-cmd-before-env) and
798 # $(test-program-cmd-after-env) are similar, before and after a list
799 # of environment variables.
800
801 # $(host-test-program-cmd) is a command that, executed on the host
802 # for which the library is built, runs the newly built test program that
803 # is the second dependency of the makefile target in which
804 # $(host-test-program-cmd) is used.
805
806 ifeq (yes,$(build-hardcoded-path-in-tests))
807 test-via-rtld-prefix =
808 test-program-prefix-before-env = $(test-wrapper-env)
809 test-program-prefix-after-env =
810 test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \
811 $(test-program-prefix-after-env)
812 test-program-cmd-before-env = $(test-wrapper-env)
813 test-program-cmd-after-env = $(built-program-file)
814 test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \
815 $(test-program-cmd-after-env)
816 host-test-program-cmd = $(built-program-file)
817 else
818 test-via-rtld-prefix = $(run-via-rtld-prefix)
819 test-program-prefix-before-env = $(run-program-prefix-before-env)
820 test-program-prefix-after-env = $(run-program-prefix-after-env)
821 test-program-prefix = $(run-program-prefix)
822 test-program-cmd-before-env = $(built-program-cmd-before-env)
823 test-program-cmd-after-env = $(built-program-cmd-after-env)
824 test-program-cmd = $(built-program-cmd)
825 host-test-program-cmd = $(host-built-program-cmd)
826 endif
827
828 # Extra flags to pass to GCC.
829 ifeq ($(all-warnings),yes)
830 +gccwarn := -Wall -Wwrite-strings -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
831 else
832 +gccwarn := -Wall -Wwrite-strings
833 endif
834 +gccwarn += -Wundef
835 ifeq ($(enable-werror),yes)
836 +gccwarn += -Werror
837 endif
838 +gccwarn-c = -Wstrict-prototypes -Wold-style-definition
839
840 # We do not depend on the address of constants in different files to be
841 # actually different, so allow the compiler to merge them all.
842 +merge-constants = -fmerge-all-constants
843
844 # We have to assume that glibc functions are called in any rounding
845 # mode and also change the rounding mode in a few functions. So,
846 # disable any optimization that assume default rounding mode.
847 +math-flags = -frounding-math
848
849 # Logically only "libnldbl", "nonlib" and "testsuite" should be using
850 # -fno-math-errno. However due to GCC bug #88576, only "libm" can use
851 # -fno-math-errno.
852 +extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)
853
854 # We might want to compile with some stack-protection flag.
855 ifneq ($(stack-protector),)
856 +stack-protector=$(stack-protector)
857 endif
858
859 # Some routines are unsafe to build with stack-protection since they're called
860 # before the stack check guard is set up. Provide a way to disable stack
861 # protector. The first argument is the extension (.o, .os, .oS) and the second
862 # is a list of routines that this path should be applied to.
863 define elide-stack-protector
864 $(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector))
865 endef
866
867 # This is the program that generates makefile dependencies from C source files.
868 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
869 # targets for headers so that removed headers don't break the build.
870 ifndef +mkdep
871 +mkdep = $(CC) -M -MP
872 endif
873
874 # The program that makes Emacs-style TAGS files.
875 ETAGS := etags
876
877 # The `xgettext' program for producing .pot files from sources.
878 ifndef XGETTEXT
879 XGETTEXT = xgettext
880 endif
881
882 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
883 # perhaps others) to preprocess assembly code in some cases.
884 M4 = m4
885
886 # To force installation of files even if they are older than the
887 # installed files. This variable is included in the dependency list
888 # of all installation targets.
889 ifeq ($(force-install),yes)
890 +force = force-install
891 else
892 +force =
893 endif
894
895 ####
896 #### End of configuration variables.
897 ####
898 \f
899 # This tells some versions of GNU make before 3.63 not to export all variables.
900 .NOEXPORT:
901
902 # We want to echo the commands we're running without
903 # umpteen zillion filenames along with it (we use `...' instead)
904 # but we don't want this echoing done when the user has said
905 # he doesn't want to see commands echoed by using -s.
906 ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
907 +cmdecho := echo >/dev/null
908 else # not -s
909 +cmdecho := echo
910 endif # -s
911
912 # These are the flags given to the compiler to tell
913 # it what sort of optimization and/or debugging output to do.
914 ifndef +cflags
915 # If `CFLAGS' was defined, use that.
916 ifdef CFLAGS
917 +cflags := $(filter-out -I%,$(CFLAGS))
918 endif # CFLAGS
919 endif # +cflags
920
921 # If none of the above worked, default to "-g -O".
922 ifeq "$(strip $(+cflags))" ""
923 +cflags := $(default_cflags)
924 endif # $(+cflags) == ""
925
926 +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \
927 $(+stack-protector)
928 +gcc-nowarn := -w
929
930 # Each sysdeps directory can contain header files that both will be
931 # used to compile and will be installed. Each can also contain an
932 # include/ subdirectory, whose header files will be used to compile
933 # but will not be installed, and will take precedence over the
934 # installed files. This mirrors the top-level include/ subdirectory.
935 +sysdep-includes := $(foreach dir,$(+sysdep_dirs),\
936 $(addprefix -I,$(wildcard $(dir)/include) $(dir)))
937
938 # These are flags given to the C compiler to tell it to look for
939 # include files (including ones given in angle brackets) in the parent
940 # library source directory, in the include directory, and in the
941 # current directory.
942 +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
943 $(+sysdep-includes) $(includes) \
944 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
945
946 # Since libio has several internal header files, we use a -I instead
947 # of many little headers in the include directory.
948 libio-include = -I$(..)libio
949
950 # List of non-library modules that we build.
951 built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
952 libSegFault libpcprofile librpcsvc locale-programs \
953 memusagestat nonlib nscd extramodules libnldbl libsupport \
954 testsuite
955
956 in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
957 $(libof-$(<F)) \
958 $(libof-$(@F)) \
959 libc))
960
961 # Build ld.so, libc.so and libpthread.so with -ftls-model=initial-exec
962 tls-model = $(if $(filter libpthread rtld \
963 libc,$(in-module)),-ftls-model=initial-exec,)
964
965 module-cppflags-real = -include $(common-objpfx)libc-modules.h \
966 -DMODULE_NAME=$(in-module)
967
968 # We don't need libc-modules.h and the MODULE_NAME definition for .v.i
969 # files. These targets don't (and will likely never need to) use the IS_IN
970 # facility. In fact, shlib-versions should not use it because that will
971 # create a circular dependency as libc-modules.h is generated from
972 # shlib-versions.
973 module-cppflags = $(if $(filter %.v.i,$(@F)),,$(module-cppflags-real))
974
975 # These are the variables that the implicit compilation rules use.
976 # Note that we can't use -std=* in CPPFLAGS, because it overrides
977 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
978 # it causes cpp to stop predefining __ASSEMBLER__.
979 CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
980 $($(subdir)-CPPFLAGS) \
981 $(+includes) $(defines) $(module-cppflags) \
982 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
983 $(CPPFLAGS-$(suffix $@)) \
984 $(foreach lib,$(libof-$(basename $(@F))) \
985 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
986 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
987
988 ifneq (no,$(have-tunables))
989 CPPFLAGS += -DTOP_NAMESPACE=glibc
990 endif
991
992 override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
993 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
994 $(+extra-math-flags) \
995 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
996 $(CFLAGS-$(@F)) $(tls-model) \
997 $(foreach lib,$(libof-$(basename $(@F))) \
998 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
999 # Use our copies of cstdlib and cmath.
1000 override CXXFLAGS = -I$(common-objpfx) $(c++-sysincludes) \
1001 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
1002 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
1003
1004 # If everything is compiled with -fPIC (implicitly) we must tell this by
1005 # defining the PIC symbol.
1006 ifeq (yes,$(build-pic-default))
1007 pic-default = -DPIC
1008 endif
1009
1010 # Enable object files for different versions of the library.
1011 # Various things use $(object-suffixes) to know what all to make.
1012 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
1013 # to pass different flags for each flavor.
1014 libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
1015 # .op may be added to all-object-suffixes below.
1016 all-object-suffixes := .o .os .oS
1017 object-suffixes :=
1018 CPPFLAGS-.o = $(pic-default)
1019 # libc.a must be compiled with -fPIE/-fpie for static PIE.
1020 CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) $(pie-default)
1021 libtype.o := lib%.a
1022 object-suffixes += .o
1023 ifeq (yes,$(build-shared))
1024 # Under --enable-shared, we will build a shared library of PIC objects.
1025 # The PIC object files are named foo.os.
1026 object-suffixes += .os
1027 CPPFLAGS-.os = -DPIC -DSHARED
1028 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
1029 libtype.os := lib%_pic.a
1030 # This can be changed by a sysdep makefile
1031 pic-ccflag = -fPIC
1032 # This one should always stay like this unless there is a very good reason.
1033 PIC-ccflag = -fPIC
1034 endif
1035 # This can be changed by a sysdep makefile
1036 pie-ccflag = -fpie
1037 # This one should always stay like this unless there is a very good reason.
1038 PIE-ccflag = -fPIE
1039 ifeq (yes,$(build-profile))
1040 # Under --enable-profile, we will build a static library of profiled objects.
1041 # The profiled object files are named foo.op.
1042 all-object-suffixes += .op
1043 object-suffixes += .op
1044 CPPFLAGS-.op = -DPROF $(pic-default)
1045 # libc_p.a must be compiled with -fPIE/-fpie for static PIE.
1046 CFLAGS-.op = -pg $(pie-default)
1047 libtype.op = lib%_p.a
1048 endif
1049
1050 # Convenience variable for when we want to treat shared-library cases
1051 # differently from the rest.
1052 object-suffixes-noshared := $(filter-out .os,$(object-suffixes))
1053
1054 object-suffixes-for-libc := $(object-suffixes)
1055
1056 ifeq (yes,$(build-shared))
1057 # Build special library that contains the static-only routines for libc.
1058 object-suffixes-for-libc += .oS
1059
1060 # Must build the routines as PIC, though, because they can end up in (users')
1061 # shared objects. We don't want to use CFLAGS-os because users may, for
1062 # example, make that processor-specific.
1063 CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags)
1064 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
1065 libtype.oS = lib%_nonshared.a
1066 endif
1067
1068 # The assembler can generate debug information too.
1069 ifndef ASFLAGS
1070 ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
1071 endif
1072 override ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
1073
1074 ifndef BUILD_CC
1075 BUILD_CC = $(CC)
1076 endif
1077
1078 move-if-change = $(SHELL) $(..)scripts/move-if-change
1079 \f
1080 -include $(common-objpfx)sysd-sorted
1081 subdirs = $(sorted-subdirs)
1082 subdir-srcdirs = $(foreach dir,$(subdirs),\
1083 $(firstword $($(dir)-srcdir) $(..)$(dir)))
1084
1085 # This is a pair of implicit rules to preprocess a file with # comments,
1086 # %ifdef et al, based on config.h settings or other %include'd files.
1087 # We use chained rules instead of a pipeline here so that we can properly
1088 # check the exit status of cpp rather than using its bad output when there
1089 # is a preprocessing error. Another rule should depend on the output file
1090 # `FOO.v', and along with that `FOO.v.i' should be given dependencies
1091 # listing both its input files, and any header files that it may reference
1092 # (but no commands).
1093 %.v.i: $(common-objpfx)config.h $(..)Makeconfig
1094 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
1095 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
1096 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
1097 > $@T
1098 mv -f $@T $@
1099 %.v: %.v.i
1100 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
1101 mv -f $@T $@
1102
1103 ifeq (yes, $(build-shared))
1104
1105 # To generate a header to support more than one ABI for different
1106 # architecture variants, the CPU/Makefile defines abi-variants to be a
1107 # list of names for those variants (e.g. 32 64), and, for each variant,
1108 # defines abi-$(variant)-condition to be the condition for those options
1109 # to use in a C #if condition. abi-includes may be defined to a list of
1110 # headers to include in the generated header, if the default does not
1111 # suffice. default-abi is defined to be the ABI for the current glibc
1112 # build.
1113
1114 ifndef abi-includes
1115 abi-includes := bits/wordsize.h
1116 endif
1117
1118 # Process the shlib-versions file, which tells us what shared library
1119 # version numbers to use when we install shared objects on this system.
1120 # We need to wait until $(subdirs) is complete.
1121 ifeq ($(sysd-sorted-done),t)
1122 -include $(common-objpfx)soversions.mk
1123 ifndef avoid-generated
1124 $(common-objpfx)shlib-versions.v.i: \
1125 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
1126 $(subdir-srcdirs:=/shlib-versions)) \
1127 $(..)shlib-versions
1128
1129 $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
1130 $(common-objpfx)shlib-versions.v
1131 $(AWK) -f $^ > $@T
1132 mv -f $@T $@
1133 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
1134 (while read which lib number setname; do \
1135 eval seen_$$which=1; \
1136 test x"$$which" = xDEFAULT || continue; \
1137 case $$number in \
1138 [0-9]*) echo "$$lib.so-version=.$$number"; \
1139 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
1140 *) echo "$$lib.so-version=$$number"; \
1141 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
1142 esac; \
1143 done; \
1144 echo soversions.mk-done = t;) < $< > $@T; exit 0
1145 mv -f $@T $@
1146 endif
1147 endif
1148
1149 postclean-generated += soversions.mk soversions.i \
1150 shlib-versions.v shlib-versions.v.i
1151
1152 before-compile += $(common-objpfx)libc-modules.h
1153 common-generated += libc-modules.h libc-modules.stmp
1154 ifeq ($(soversions.mk-done),t)
1155 # Generate a header with macro definitions for use with the IS_IN macro.
1156 # These are the possible values for the MODULE_NAME macro defined when building
1157 # sources, to identify which module the translation unit is going to be built
1158 # into.
1159 $(common-objpfx)libc-modules.h: $(common-objpfx)libc-modules.stmp; @:
1160 $(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \
1161 $(common-objpfx)soversions.i
1162 $(AWK) -v buildlist="$(subst -,_,$(built-modules))" -f $^ > ${@:stmp=T}
1163 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
1164 touch $@
1165
1166 endif
1167
1168 # Build the tunables list header early since it could be used by any module in
1169 # glibc.
1170 ifneq (no,$(have-tunables))
1171 before-compile += $(common-objpfx)dl-tunable-list.h
1172 common-generated += dl-tunable-list.h dl-tunable-list.stmp
1173
1174 $(common-objpfx)dl-tunable-list.h: $(common-objpfx)dl-tunable-list.stmp; @:
1175 $(common-objpfx)dl-tunable-list.stmp: \
1176 $(..)scripts/gen-tunables.awk \
1177 $(..)elf/dl-tunables.list \
1178 $(wildcard $(subdirs:%=$(..)%/dl-tunables.list)) \
1179 $(wildcard $(sysdirs:%=%/dl-tunables.list))
1180 $(AWK) -f $^ > ${@:stmp=T}
1181 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
1182 touch $@
1183 endif
1184
1185 # Generate version maps, but wait until sysdep-subdirs is known
1186 ifeq ($(sysd-sorted-done),t)
1187 ifeq ($(build-shared),yes)
1188 -include $(common-objpfx)sysd-versions
1189 -include $(common-objpfx)Versions.mk
1190 $(addprefix $(common-objpfx),$(version-maps)): $(common-objpfx)sysd-versions
1191 common-generated += $(version-maps)
1192 postclean-generated += sysd-versions Versions.all abi-versions.h \
1193 Versions.def Versions.v.i Versions.v Versions.mk
1194
1195 ifndef avoid-generated
1196 ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
1197 sysd-versions-force = FORCE
1198 FORCE:
1199 endif
1200
1201 $(common-objpfx)Versions.def: $(..)scripts/versionlist.awk \
1202 $(common-objpfx)Versions.v
1203 LC_ALL=C $(AWK) -f $^ > $@T
1204 mv -f $@T $@
1205
1206 $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
1207 $(common-objpfx)soversions.i \
1208 $(common-objpfx)Versions.def
1209 { while read which lib version setname; do \
1210 test x"$$which" = xDEFAULT || continue; \
1211 test -z "$$setname" || echo "$$lib : $$setname"; \
1212 done < $(word 2,$^); \
1213 cat $(word 3,$^); \
1214 } | LC_ALL=C $(AWK) -f $< > $@T
1215 mv -f $@T $@
1216 $(common-objpfx)Versions.mk: $(..)scripts/haveversions.awk \
1217 $(common-objpfx)Versions.all
1218 $(AWK) -f $^ > $@T
1219 mv -f $@T $@
1220 # See %.v/%.v.i implicit rules in Makeconfig.
1221 $(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
1222 $(wildcard $(sysdirs:%=%/Versions)) \
1223 $(sysd-versions-force)
1224 $(common-objpfx)sysd-versions: $(common-objpfx)versions.stmp
1225 $(common-objpfx)versions.stmp: $(common-objpfx)Versions.all \
1226 $(common-objpfx)Versions.v \
1227 $(..)scripts/versions.awk
1228 ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
1229 cat $(word 2,$^) \
1230 | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
1231 -v move_if_change='$(move-if-change)' \
1232 -f $(word 3,$^); \
1233 ) > $(common-objpfx)sysd-versionsT
1234 mv -f $(common-objpfx)sysd-versionsT $(common-objpfx)sysd-versions
1235 touch $@
1236 endif # avoid-generated
1237 endif # $(build-shared) = yes
1238 endif # sysd-sorted-done
1239
1240 # The name under which the run-time dynamic linker is installed.
1241 # We are currently going for the convention that `/lib/ld.so.1'
1242 # names the SVR4/ELF ABI-compliant dynamic linker.
1243 ifndef rtld-installed-name
1244 ifdef ld.so-version
1245 rtld-installed-name = $(ld.so-version)
1246 else
1247 rtld-installed-name = ld.so.1
1248 endif
1249 endif
1250
1251 ifndef rtld-version-installed-name
1252 rtld-version-installed-name = ld-$(version).so
1253 endif
1254
1255 endif # build-shared
1256
1257
1258 ifeq ($(build-shared),yes)
1259 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
1260 else
1261 libdl = $(common-objpfx)dlfcn/libdl.a
1262 endif
1263
1264 ifeq ($(build-shared),yes)
1265 libm = $(common-objpfx)math/libm.so$(libm.so-version)
1266 libmvec = $(common-objpfx)mathvec/libmvec.so$(libmvec.so-version)
1267 else
1268 libm = $(common-objpfx)math/libm.a
1269 libmvec = $(common-objpfx)mathvec/libmvec.a
1270 endif
1271
1272 ifeq ($(build-shared),yes)
1273 libsupport = $(common-objpfx)support/libsupport_nonshared.a
1274 else
1275 libsupport = $(common-objpfx)support/libsupport.a
1276 endif
1277
1278 # This is a partial list of subdirectories containing the library source.
1279 # The order is more or less arbitrary. The sorting step will take care of the
1280 # dependencies and generate sorted-subdirs dynamically.
1281 all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
1282 stdlib stdio-common libio malloc string wcsmbs time dirent \
1283 grp pwd posix io termios resource misc socket sysvipc gmon \
1284 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
1285 localedata timezone rt conform debug mathvec support \
1286 dlfcn elf
1287
1288 ifeq ($(build-crypt),yes)
1289 all-subdirs += crypt
1290 rpath-dirs += crypt
1291 endif
1292
1293 ifndef avoid-generated
1294 # sysd-sorted itself will contain rules making the sysd-sorted target
1295 # depend on Depend files. But if you just added a Depend file to an
1296 # existing directory not in all-subdirs, then sysd-sorted needs to
1297 # be regenerated, so it depends on existing $(sorted-subdirs:=/Depend) files.
1298 all-Depend-files := $(wildcard $(sort \
1299 $(foreach dir,$(all-subdirs),\
1300 $(firstword $($(dir)-srcdir) \
1301 $(..)$(dir))/Depend) \
1302 $(sorted-subdirs:=/Depend)))
1303 $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
1304 $(common-objpfx)config.make $(..)Makeconfig \
1305 $(wildcard $(sysdirs:=/Subdirs)) \
1306 $(all-Depend-files)
1307 $(AWK) -f $< \
1308 -v subdirs='$(all-subdirs)' \
1309 -v srcpfx='$(..)' \
1310 $(filter %/Subdirs %/Depend,$^) > $@-tmp
1311 mv -f $@-tmp $@
1312 $(all-Depend-files): ;
1313 endif
1314
1315 # This gives partial TARGET:SOURCE pattern pairs to have rules
1316 # emitted into sysd-rules. A sysdeps Makeconfig fragment can
1317 # add its own special object file prefix to this list with e.g. foo-%:%
1318 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
1319 sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
1320
1321 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
1322 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
1323 ifneq (,$(sysdep-makeconfigs))
1324 include $(sysdep-makeconfigs)
1325 endif
1326
1327 # Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
1328 sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
1329 $(firstword $(subst :, ,$p))))
1330
1331 # A sysdeps Makeconfig fragment may set libc-reentrant to yes.
1332 ifeq (yes,$(libc-reentrant))
1333 defines += -D_LIBC_REENTRANT
1334
1335 libio-mtsafe = -D_IO_MTSAFE_IO
1336 endif
1337
1338 # The name to give to a test in test results summaries.
1339 test-name = $(strip $(patsubst %.out, %, $(patsubst $(common-objpfx)%, %, $@)))
1340
1341 # Likewise, in XFAIL variable names.
1342 test-xfail-name = $(strip $(patsubst %.out, %, $(patsubst $(objpfx)%, %, $@)))
1343
1344 # Command to output a test status line (such as PASS: test-name). If
1345 # test-xfail-$(test-xfail-name) has a nonempty value, the status will be
1346 # XPASS or XFAIL rather than PASS or FAIL.
1347 evaluate-test = $(..)scripts/evaluate-test.sh $(test-name) $$? \
1348 $(if $(test-xfail-$(test-xfail-name)),true,false) \
1349 $(if $(stop-on-test-failure),true,false) \
1350 > $(common-objpfx)$(test-name).test-result
1351
1352 endif # Makeconfig not yet included
1353
1354 # Local Variables:
1355 # mode: makefile
1356 # End: