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