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