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