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