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