]> git.ipfire.org Git - thirdparty/glibc.git/blob - Makeconfig
Add rules to build libresolv with SSP flags
[thirdparty/glibc.git] / Makeconfig
1 # Copyright (C) 1991-2003,2004,2005,2006,2007,2008,2009,2010,2011
2 # Free Software Foundation, Inc.
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, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
19
20 #
21 # Makefile configuration options for the GNU C library.
22 #
23 ifneq (,)
24 This makefile requires GNU Make.
25 endif
26
27 all: # Make this the default goal
28
29 ifneq "$(origin +included-Makeconfig)" "file"
30
31 +included-Makeconfig := yes
32
33 ifdef subdir
34 .. := ../
35 endif
36
37 # If config.make exists, the source directory was configured,
38 # so don't try to be clever and find another directory to build in.
39 ifneq (,$(wildcard $(..)config.make))
40 ARCH =
41 machine =
42 else # Not configured.
43 ifndef ARCH
44 ifdef machine
45 ARCH = $(machine)
46 endif # machine
47 endif # ARCH
48 endif # config.make
49
50 # Directory for object files and libc.a. If this is not defined, the
51 # object files live in the subdirectories where their sources live, and
52 # libc.a lives in the parent directory (this probably doesn't work any
53 # more).
54 ifdef ARCH
55 ifeq ($(filter /%,$(ARCH)),)
56 objdir := $(..)$(ARCH)
57 else
58 objdir = $(ARCH)
59 endif
60 endif
61
62 # $(common-objdir) is the place to put objects and
63 # such that are not specific to a single subdir.
64 ifdef objdir
65 objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
66 common-objpfx = $(objdir)/
67 common-objdir = $(objdir)
68 else
69 objpfx :=
70 ifdef ..
71 common-objpfx = $(..)
72 common-objdir = ..
73 else
74 # This is a kludge. make wizards might grok.
75 common-objpfx = sysdeps/../
76 common-objdir = .
77 endif
78 endif
79
80 # Root of the sysdeps tree.
81 sysdep_dir := $(..)sysdeps
82 export sysdep_dir := $(sysdep_dir)
83
84 # Get the values defined by options to `configure'.
85 include $(common-objpfx)config.make
86
87 # What flags to give to sources which call user provided callbacks
88 uses-callbacks = $(exceptions)
89
90 # What flags to give to tests which test stack alignment
91 stack-align-test-flags =
92
93 # We have a special subdir for each binary format.
94 # For now, only ELF is fully supported.
95 ifeq ($(elf),yes)
96 binfmt-subdir = elf
97 else
98 # This is probably better than nothing.
99 binfmt-subdir = aout
100 endif
101
102 # Complete path to sysdep dirs.
103 # `configure' writes a definition of `config-sysdirs' in `config.make'.
104 sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
105
106 # Add-ons that contribute sysdeps trees get added to the include list
107 # after sysdeps/generic. This makes #include <sysdeps/...> work right
108 # to find specific add-on files without assuming the add-on directory name.
109 # It also means that headers can go into an add-on's base directory
110 # instead of the add-on needing a sysdeps/generic of its own.
111 sysdeps-srcdirs := $(foreach add-on,$(sysdeps-add-ons),\
112 $(firstword $(filter /%,$(add-on)) \
113 $(..)$(add-on)))
114 +sysdep_dirs = $(sysdirs) $(sysdeps-srcdirs)
115 ifdef objdir
116 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
117 endif
118
119 # Run config.status to update config.make and config.h. We don't show the
120 # dependence of config.h to Make, because it is only touched when it
121 # changes and so config.status would be run every time; the dependence of
122 # config.make should suffice to force regeneration and re-exec, and the new
123 # image will notice if config.h changed.
124 $(common-objpfx)config.make: $(common-objpfx)config.status \
125 $(..)config.make.in $(..)config.h.in
126 cd $(<D); $(SHELL) $(<F)
127
128 # Find all the add-on and sysdeps configure fragments, to make sure we
129 # re-run configure when any of them changes.
130 $(common-objpfx)config.status: $(..)version.h $(..)configure \
131 $(foreach dir,$(sysdirs),\
132 $(wildcard $(dir)/Implies) \
133 $(patsubst %.in,%,\
134 $(firstword $(wildcard \
135 $(addprefix $(dir)/,configure configure.in))))) \
136 $(patsubst %.in,%,\
137 $(foreach add-on,$(add-ons),\
138 $(firstword $(wildcard \
139 $(addprefix $(firstword $(filter /%,$(add-on)) $(..)$(add-on))/,\
140 configure configure.in)))))
141 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
142 echo The GNU C library has not been configured. >&2; \
143 echo Run \`configure\' to configure it before building. >&2; \
144 echo Try \`configure --help\' for more details. >&2; \
145 exit 1; fi
146
147 # We don't want CPPFLAGS to be exported to the command running configure.
148 unexport CPPFLAGS
149
150 # Get the user's configuration parameters.
151 ifneq ($(wildcard $(..)configparms),)
152 include $(..)configparms
153 endif
154 ifneq ($(objpfx),)
155 ifneq ($(wildcard $(common-objpfx)configparms),)
156 include $(common-objpfx)configparms
157 endif
158 endif
159 \f
160 ####
161 #### These are the configuration variables. You can define values for
162 #### the variables below in the file `configparms'.
163 #### Do NOT edit this file.
164 ####
165
166
167 # Common prefix for machine-independent installation directories.
168 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
169 prefix = /usr/local
170 endif
171
172 # Decide whether we shall build the programs or not. We always do this
173 # unless the user tells us (in configparms) or we are building for a
174 # standalone target.
175 ifndef build-programs
176 ifneq ($(config-os),none)
177 build-programs=yes
178 else
179 build-programs=no
180 endif
181 endif
182
183 # Common prefix for machine-dependent installation directories.
184 ifeq ($(origin exec_prefix),undefined)
185 exec_prefix = $(prefix)
186 endif
187
188 # Where to install the library and object files.
189 ifndef libdir
190 libdir = $(exec_prefix)/lib
191 endif
192 inst_libdir = $(install_root)$(libdir)
193
194 # Where to install the shared library and dynamic linker.
195 ifndef slibdir
196 slibdir = $(exec_prefix)/lib
197 endif
198 inst_slibdir = $(install_root)$(slibdir)
199
200 # Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
201 # the prefix is spliced between `lib' and the name, so the linker switch
202 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
203 # just prepended to the whole file name.
204 ifeq ($(origin libprefix),undefined)
205 libprefix =
206 endif
207
208 # Where to install the header files.
209 ifndef includedir
210 includedir = $(prefix)/include
211 endif
212 inst_includedir = $(install_root)$(includedir)
213
214 # Where to install machine-independent data files.
215 # These are the timezone database, and the locale database.
216 ifndef datadir
217 datadir = $(prefix)/share
218 endif
219 inst_datadir = $(install_root)$(datadir)
220
221 # Where to install the timezone data files (which are machine-independent).
222 ifndef zonedir
223 zonedir = $(datadir)/zoneinfo
224 endif
225 inst_zonedir = $(install_root)$(zonedir)
226
227 # Where to install the locale files.
228 ifndef localedir
229 localedir = $(libdir)/locale
230 endif
231 inst_localedir = $(install_root)$(localedir)
232
233 # Where to install the message catalog data files (which are
234 # machine-independent).
235 ifndef msgcatdir
236 msgcatdir = $(datadir)/locale
237 endif
238 inst_msgcatdir = $(install_root)$(msgcatdir)
239
240 # Where to install the locale charmap source files.
241 ifndef i18ndir
242 i18ndir = $(datadir)/i18n
243 endif
244 inst_i18ndir = $(install_root)$(i18ndir)
245
246 # Where to install the shared object for charset transformation.
247 ifndef gconvdir
248 gconvdir = $(libdir)/gconv
249 endif
250 inst_gconvdir = $(install_root)$(gconvdir)
251
252 # Where to install programs.
253 ifndef bindir
254 bindir = $(exec_prefix)/bin
255 endif
256 inst_bindir = $(install_root)$(bindir)
257
258 # Where to install internal programs.
259 ifndef libexecdir
260 libexecdir = $(exec_prefix)/libexec
261 endif
262 inst_libexecdir = $(install_root)$(libexecdir)
263
264 # Where to install administrative programs.
265 ifndef rootsbindir
266 rootsbindir = $(exec_prefix)/sbin
267 endif
268 inst_rootsbindir = $(install_root)$(rootsbindir)
269
270 ifndef sbindir
271 sbindir = $(exec_prefix)/sbin
272 endif
273 inst_sbindir = $(install_root)$(sbindir)
274
275 # Where to install the Info files.
276 ifndef infodir
277 infodir = $(prefix)/info
278 endif
279 inst_infodir = $(install_root)$(infodir)
280
281 # Where to install audit libraries.
282 ifndef auditdir
283 auditdir = $(libdir)/audit
284 endif
285 inst_auditdir = $(install_root)$(auditdir)
286
287 # Where to install default configuration files. These include the local
288 # timezone specification and network data base files.
289 ifndef sysconfdir
290 sysconfdir = $(prefix)/etc
291 endif
292 inst_sysconfdir = $(install_root)$(sysconfdir)
293
294 # Directory for the database files and Makefile for nss_db.
295 ifndef vardbdir
296 vardbdir = /var/db
297 endif
298 inst_vardbdir = $(install_root)$(vardbdir)
299
300 # What timezone should be the installed default (e.g., US/Eastern).
301 # Run `make -C time echo-zonenames' to see a list of available zone names.
302 # The local timezone can be changed with `zic -l TIMEZONE' at any time.
303 ifndef localtime
304 localtime = Factory
305 endif
306
307 # Where to install the "localtime" timezone file; this is the file whose
308 # contents $(localtime) specifies. If this is a relative pathname, it is
309 # relative to $(zonedir). It is a good idea to put this somewhere
310 # other than there, so the zoneinfo directory contains only universal data,
311 # localizing the configuration data elsewhere.
312 ifndef localtime-file
313 localtime-file = $(sysconfdir)/localtime
314 inst_localtime-file = $(install_root)$(localtime-file)
315 endif
316
317 # What to use for leap second specifications in compiling the default
318 # timezone files. Set this to `/dev/null' for no leap second handling as
319 # 1003.1 requires, or to `leapseconds' for proper leap second handling.
320 # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
321 # This variable determines the default: if it's `/dev/null',
322 # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
323 ifndef leapseconds
324 leapseconds = /dev/null
325 endif
326
327 # What timezone's DST rules should be used when a POSIX-style TZ
328 # environment variable doesn't specify any rules. For 1003.1 compliance
329 # this timezone must use rules that are as U.S. federal law defines DST.
330 # Run `make -C time echo-zonenames' to see a list of available zone names.
331 # This setting can be changed with `zic -p TIMEZONE' at any time.
332 # If you want POSIX.1 compatibility, use `America/New_York'.
333 ifndef posixrules
334 posixrules = America/New_York
335 endif
336
337 # Where to install the "posixrules" timezone file; this is file
338 # whose contents $(posixrules) specifies. If this is a relative
339 # pathname, it is relative to $(zonedir).
340 ifndef posixrules-file
341 posixrules-file = posixrules
342 endif
343
344
345 # Directory where your system's native header files live.
346 # This is used on Unix systems to generate some GNU libc header files.
347 ifndef sysincludedir
348 sysincludedir = /usr/include
349 endif
350
351
352 # Commands to install files.
353 ifndef INSTALL_DATA
354 INSTALL_DATA = $(INSTALL) -m 644
355 endif
356 ifndef INSTALL_SCRIPT
357 INSTALL_SCRIPT = $(INSTALL)
358 endif
359 ifndef INSTALL_PROGRAM
360 INSTALL_PROGRAM = $(INSTALL)
361 endif
362 ifndef INSTALL
363 INSTALL = install
364 endif
365
366
367 # The name of the C compiler.
368 # If you've got GCC, and it works, use it.
369 ifeq ($(origin CC),default)
370 CC := gcc
371 endif
372
373 # The name of the C compiler to use for compilations of programs to run on
374 # the host that is building the library. If you set CC to a
375 # cross-compiler, you must set this to the normal compiler.
376 ifndef BUILD_CC
377 BUILD_CC = $(CC)
378 endif
379
380 # Default flags to pass the C compiler.
381 ifndef default_cflags
382 ifeq ($(release),stable)
383 default_cflags := -g -O2
384 else
385 default_cflags := -g -O
386 endif
387 endif
388
389 # Flags to pass the C compiler when assembling preprocessed assembly code
390 # (`.S' files). On some systems the assembler doesn't understand the `#' line
391 # directives the preprocessor produces. If you have troubling compiling
392 # assembly code, try using -P here to suppress these directives.
393 ifndef asm-CPPFLAGS
394 asm-CPPFLAGS =
395 endif
396
397 # ELF always supports init/fini sections
398 ifeq ($(elf),yes)
399 have-initfini = yes
400 endif
401
402 ifeq ($(have-as-needed),yes)
403 as-needed := -Wl,--as-needed
404 no-as-needed := -Wl,--no-as-needed
405 else
406 as-needed :=
407 no-as-needed :=
408 endif
409
410 # Installed name of the startup code.
411 ifneq ($(have-initfini),yes)
412 # When not having init/fini, there is just one startfile, called crt0.o.
413 start-installed-name = crt0.o
414 else
415 # On systems having init/fini, crt0.o is called crt1.o, and there are
416 # some additional bizarre files.
417 start-installed-name = crt1.o
418 endif
419 # On systems that do not need a special startfile for statically linked
420 # binaries, simply set it to the normal name.
421 ifndef static-start-installed-name
422 static-start-installed-name = $(start-installed-name)
423 endif
424
425 ifeq (yesyesyes,$(build-shared)$(elf)$(have-z-combreloc))
426 combreloc-LDFLAGS = -Wl,-z,combreloc
427 LDFLAGS.so += $(combreloc-LDFLAGS)
428 LDFLAGS-rtld += $(combreloc-LDFLAGS)
429 endif
430
431 relro-LDFLAGS = -Wl,-z,relro
432 LDFLAGS.so += $(relro-LDFLAGS)
433 LDFLAGS-rtld += $(relro-LDFLAGS)
434
435 ifeq (yes,$(have-hash-style))
436 # For the time being we unconditionally use 'both'. At some time we
437 # should declare statically linked code as 'out of luck' and compile
438 # with --hash-style=gnu only.
439 hashstyle-LDFLAGS = -Wl,--hash-style=both
440 LDFLAGS.so += $(hashstyle-LDFLAGS)
441 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
442 endif
443
444 # Command for linking programs with the C library.
445 ifndef +link
446 +link = $(CC) -nostdlib -nostartfiles -o $@ \
447 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
448 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
449 $(addprefix $(csu-objpfx),$(start-installed-name)) \
450 $(+preinit) $(+prector) \
451 $(filter-out $(addprefix $(csu-objpfx),start.o \
452 $(start-installed-name))\
453 $(+preinit) $(link-extra-libs) \
454 $(common-objpfx)libc% $(+postinit),$^) \
455 $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
456 endif
457 # Command for linking PIE programs with the C library.
458 ifndef +link-pie
459 +link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
460 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
461 $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
462 $(addprefix $(csu-objpfx),S$(start-installed-name)) \
463 $(+preinit) $(+prectorS) \
464 $(filter-out $(addprefix $(csu-objpfx),start.o \
465 S$(start-installed-name))\
466 $(+preinit) $(link-extra-libs) \
467 $(common-objpfx)libc% $(+postinit),$^) \
468 $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit)
469 endif
470 # Command for statically linking programs with the C library.
471 ifndef +link-static
472 +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
473 $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
474 $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
475 $(+preinit) $(+prector) \
476 $(filter-out $(addprefix $(csu-objpfx),start.o \
477 $(start-installed-name))\
478 $(+preinit) $(link-extra-libs-static) \
479 $(common-objpfx)libc% $(+postinit),$^) \
480 $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
481 endif
482 # Command for statically linking bounded-pointer programs with the C library.
483 ifndef +link-bounded
484 +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
485 $(sysdep-LDFLAGS) $(LDFLAGS) \
486 $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
487 $(+preinit) $(+prector) \
488 $(filter-out $(addprefix $(csu-objpfx),start.ob \
489 $(start-installed-name))\
490 $(+preinit) $(link-extra-libs-bounded) \
491 $(common-objpfx)libc% $(+postinit),$^) \
492 $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
493 endif
494 ifndef config-LDFLAGS
495 ifeq (yesyes,$(build-shared)$(elf))
496 config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
497 endif
498 endif
499 ifndef link-libc
500 ifeq (yes,$(build-shared))
501 ifeq ($(elf),yes)
502 # We need the versioned name of libc.so in the deps of $(others) et al
503 # so that the symlink to libc.so is created before anything tries to
504 # run the linked programs.
505 link-libc = -Wl,-rpath-link=$(rpath-link) \
506 $(common-objpfx)libc.so$(libc.so-version) \
507 $(common-objpfx)$(patsubst %,$(libtype.oS),c) \
508 $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) $(gnulib)
509 # This is how to find at build-time things that will be installed there.
510 rpath-dirs = math elf dlfcn nss nis rt resolv crypt
511 endif
512 rpath-link = \
513 $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
514 elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
515 else
516 nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
517 resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
518 link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
519 endif
520 endif
521
522 # Differences in the linkers on the various platforms.
523 ifeq ($(elf),yes)
524 LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
525 LDFLAGS-soname-fname = -Wl,-soname,$(@F)
526 LDFLAGS-rdynamic = -rdynamic
527 LDFLAGS-Bsymbolic = -Bsymbolic
528 endif
529
530 # Choose the default search path for the dynamic linker based on
531 # where we will install libraries.
532 ifneq ($(libdir),$(slibdir))
533 default-rpath = $(slibdir):$(libdir)
534 else
535 default-rpath = $(libdir)
536 endif
537
538 ifndef link-extra-libs
539 link-extra-libs = $(LDLIBS-$(@F))
540 link-extra-libs-static = $(link-extra-libs)
541 link-extra-libs-bounded = $(link-extra-libs)
542 endif
543
544 # The static libraries.
545 ifeq (yes,$(build-static))
546 link-libc-static = -Wl,--start-group $(common-objpfx)libc.a $(static-gnulib) -Wl,--end-group
547 else
548 ifeq (yes,$(build-shared))
549 # We can try to link the programs with lib*_pic.a...
550 link-libc-static = $(static-gnulib) $(common-objpfx)libc_pic.a
551 endif
552 endif
553 link-libc-bounded = $(common-objpfx)libc_b.a $(gnulib) $(common-objpfx)libc_b.a
554
555 ifndef gnulib
556 ifneq ($(have-cc-with-libunwind),yes)
557 libunwind =
558 else
559 libunwind = -lunwind
560 endif
561 ifneq ($(have-as-needed),yes)
562 libgcc_eh := -lgcc_eh $(libunwind)
563 else
564 libgcc_eh := -Wl,--as-needed -lgcc_s$(libgcc_s_suffix) $(libunwind) -Wl,--no-as-needed
565 endif
566 gnulib := -lgcc $(libgcc_eh)
567 static-gnulib := -lgcc -lgcc_eh $(libunwind)
568 libc.so-gnulib := -lgcc
569 endif
570 ifeq ($(elf),yes)
571 +preinit = $(addprefix $(csu-objpfx),crti.o)
572 +postinit = $(addprefix $(csu-objpfx),crtn.o)
573 +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
574 +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
575 # Variants of the two previous definitions for linking PIE programs.
576 +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
577 +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
578 +interp = $(addprefix $(elf-objpfx),interp.os)
579 endif
580 csu-objpfx = $(common-objpfx)csu/
581 elf-objpfx = $(common-objpfx)elf/
582
583 # How to run a program we just linked with our library.
584 # The program binary is assumed to be $(word 2,$^).
585 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
586 ifeq (yesyes,$(build-shared)$(elf))
587 comma = ,
588 sysdep-library-path = \
589 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
590 $(filter -Wl$(comma)-rpath-link=%,\
591 $(sysdep-LDFLAGS)))))
592 run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
593 $(tests-static) $(xtests-static)),, \
594 $(elf-objpfx)$(rtld-installed-name) \
595 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
596 else
597 run-program-prefix =
598 endif
599 # Never use $(run-program-prefix) for the statically-linked %-bp test programs
600 built-program-cmd = $(patsubst %,$(run-program-prefix),\
601 $(filter-out %-bp,$(built-program-file))) \
602 $(built-program-file)
603
604 ifndef LD
605 LD := ld -X
606 endif
607
608 # Extra flags to pass to GCC.
609 ifeq ($(all-warnings),yes)
610 +gccwarn := -Wall -Wwrite-strings -Winline -Wcast-qual -Wbad-function-cast -Wmissing-noreturn -Wmissing-prototypes -Wmissing-declarations -Wcomment -Wcomments -Wtrigraphs -Wsign-compare -Wfloat-equal -Wmultichar
611 else
612 +gccwarn := -Wall -Wwrite-strings -Winline
613 endif
614 +gccwarn-c = -Wstrict-prototypes
615
616 # We do not depend on the address of constants in different files to be
617 # actually different, so allow the compiler to merge them all.
618 +merge-constants = -fmerge-all-constants
619
620 # This is the program that generates makefile dependencies from C source files.
621 # The -MP flag tells GCC >= 3.2 (which we now require) to produce dummy
622 # targets for headers so that removed headers don't break the build.
623 ifndef +mkdep
624 +mkdep = $(CC) -M -MP
625 endif
626
627 # The program that makes Emacs-style TAGS files.
628 ETAGS := etags
629
630 # The `xgettext' program for producing .pot files from sources.
631 ifndef XGETTEXT
632 XGETTEXT = xgettext
633 endif
634
635 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
636 # perhaps others) to preprocess assembly code in some cases.
637 M4 = m4
638
639 # To force installation of files even if they are older than the
640 # installed files. This variable is included in the dependency list
641 # of all installation targets.
642 ifeq ($(force-install),yes)
643 +force = force-install
644 else
645 +force =
646 endif
647
648 ####
649 #### End of configuration variables.
650 ####
651 \f
652 # This tells some versions of GNU make before 3.63 not to export all variables.
653 .NOEXPORT:
654
655 # We want to echo the commands we're running without
656 # umpteen zillion filenames along with it (we use `...' instead)
657 # but we don't want this echoing done when the user has said
658 # he doesn't want to see commands echoed by using -s.
659 ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
660 +cmdecho := echo >/dev/null
661 else # not -s
662 +cmdecho := echo
663 endif # -s
664
665 # These are the flags given to the compiler to tell
666 # it what sort of optimization and/or debugging output to do.
667 ifndef +cflags
668 # If `CFLAGS' was defined, use that.
669 ifdef CFLAGS
670 +cflags := $(filter-out -I%,$(CFLAGS))
671 endif # CFLAGS
672 endif # +cflags
673
674 # If none of the above worked, default to "-g -O".
675 ifeq "$(strip $(+cflags))" ""
676 +cflags := $(default_cflags)
677 endif # $(+cflags) == ""
678
679 +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants)
680 +gcc-nowarn := -w
681
682 # Don't duplicate options if we inherited variables from the parent.
683 +cflags := $(sort $(+cflags))
684
685 # These are flags given to the C compiler to tell it to look for
686 # include files (including ones given in angle brackets) in the parent
687 # library source directory, in the include directory, and in the
688 # current directory.
689 +sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
690 +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
691 $(+sysdep-includes) $(includes) \
692 $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
693
694 # Since libio has several internal header files, we use a -I instead
695 # of many little headers in the include directory.
696 libio-include = -I$(..)libio
697
698 # These are the variables that the implicit compilation rules use.
699 # Note that we can't use -std=* in CPPFLAGS, because it overrides
700 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
701 # it causes cpp to stop predefining __ASSEMBLER__.
702 CPPFLAGS = $($(subdir)-CPPFLAGS) $(+includes) $(defines) \
703 -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
704 $(CPPFLAGS-$(suffix $@)) \
705 $(foreach lib,$(libof-$(basename $(@F))) \
706 $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
707 $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
708 override CFLAGS = -std=gnu99 $(gnu89-inline-CFLAGS) \
709 $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
710 $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) \
711 $(CFLAGS-$(@F)) \
712 $(foreach lib,$(libof-$(basename $(@F))) \
713 $(libof-$(<F)) $(libof-$(@F)),$(CFLAGS-$(lib)))
714 override CXXFLAGS = $(c++-sysincludes) \
715 $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
716 $(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
717
718 # If everything is compiled with -fPIC (implicitly) we must tell this by
719 # defining the PIC symbol.
720 ifeq (yes,$(build-pic-default))
721 pic-default = -DPIC
722 endif
723
724 # Enable object files for different versions of the library.
725 # Various things use $(object-suffixes) to know what all to make.
726 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
727 # to pass different flags for each flavor.
728 libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
729 all-object-suffixes := .o .os .op .og .ob .oS
730 object-suffixes :=
731 CPPFLAGS-.o = $(pic-default)
732 CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
733 ifeq (yes,$(build-static))
734 libtype.o := lib%.a
735 object-suffixes += .o
736 endif
737 ifeq (yes,$(build-shared))
738 # Under --enable-shared, we will build a shared library of PIC objects.
739 # The PIC object files are named foo.os.
740 object-suffixes += .os
741 CPPFLAGS-.os = -DPIC -DSHARED
742 CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
743 libtype.os := lib%_pic.a
744 # This can be changed by a sysdep makefile
745 pic-ccflag = -fPIC
746 # This one should always stay like this unless there is a very good reason.
747 PIC-ccflag = -fPIC
748 endif
749 # This can be changed by a sysdep makefile
750 pie-ccflag = -fpie
751 # This one should always stay like this unless there is a very good reason.
752 PIE-ccflag = -fPIE
753 ifeq (yes,$(build-profile))
754 # Under --enable-profile, we will build a static library of profiled objects.
755 # The profiled object files are named foo.op.
756 object-suffixes += .op
757 CPPFLAGS-.op = -DPROF $(pic-default)
758 CFLAGS-.op = -pg
759 libtype.op = lib%_p.a
760 endif
761 ifeq (yes,$(build-omitfp))
762 # Under --enable-omitfp, we build the library optimized without
763 # debugging information using -fomit-frame-pointer, and build an extra
764 # library with debugging information. The debuggable objects are named foo.og.
765 object-suffixes += .og
766 CPPFLAGS-.og = $(pic-default)
767 CFLAGS-.og = -g
768 CFLAGS-.o = $(filter %frame-pointer,$(+cflags)) -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES
769 CFLAGS-.os += -g0 -O99 -fomit-frame-pointer -D__USE_STRING_INLINES
770 libtype.og = lib%_g.a
771 endif
772
773 bppfx = BP-
774 ifeq (yes,$(build-bounded))
775 # Under --enable-bounded, we build the library with `-fbounded-pointers -g'
776 # to runtime bounds checking. The bounded-pointer objects are named foo.ob.
777 # We disable sibling-call optimizations so that stack traces will be complete
778 # and thus aid debugging, since after all, BPs are a debugging tool.
779 object-suffixes += .ob
780 CPPFLAGS-.ob = -fbounded-pointers $(pic-default)
781 CFLAGS-.ob = -g -O2 -fno-optimize-sibling-calls -fno-strict-aliasing
782 libtype.ob = lib%_b.a
783 endif
784
785 object-suffixes-for-libc := $(object-suffixes)
786
787 ifeq (yes,$(build-shared))
788 # Build special library that contains the static-only routines for libc.
789 object-suffixes-for-libc += .oS
790
791 # Must build the routines as PIC, though, because they can end up in (users')
792 # shared objects. We don't want to use CFLAGS-os because users may, for
793 # example, make that processor-specific.
794 CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
795 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
796 libtype.oS = lib%_nonshared.a
797 endif
798
799 # The assembler can generate debug information too.
800 ifndef ASFLAGS
801 ifeq ($(have-cpp-asm-debuginfo),yes)
802 ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
803 else
804 ASFLAGS :=
805 endif
806 endif
807 ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
808
809 ifndef BUILD_CC
810 BUILD_CC = $(CC)
811 endif
812
813 move-if-change = $(SHELL) $(..)scripts/move-if-change
814 \f
815 -include $(common-objpfx)sysd-sorted
816 subdirs = $(sorted-subdirs)
817 subdir-srcdirs = $(foreach dir,$(subdirs),\
818 $(firstword $($(dir)-srcdir) $(..)$(dir)))
819
820 ifeq (yes, $(build-shared))
821
822 # This is a pair of implicit rules to preprocess a file with # comments,
823 # %ifdef et al, based on config.h settings or other %include'd files.
824 # We use chained rules instead of a pipeline here so that we can properly
825 # check the exit status of cpp rather than using its bad output when there
826 # is a preprocessing error. Another rule should depend on the output file
827 # `FOO.v', and along with that `FOO.v.i' should be given dependencies
828 # listing both its input files, and any header files that it may reference
829 # (but no commands).
830 %.v.i: $(common-objpfx)config.h $(..)Makeconfig
831 sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' \
832 $(filter-out FORCE %.h $(..)Makeconfig,$^) \
833 | $(CC) -E -undef $(CPPFLAGS) -x assembler-with-cpp - \
834 > $@T
835 mv -f $@T $@
836 %.v: %.v.i
837 sed '/^[ ]*#/d;/^[ ]*$$/d' $< > $@T
838 mv -f $@T $@
839
840 # Process the shlib-versions file, which tells us what shared library
841 # version numbers to use when we install shared objects on this system.
842 # We need to wait until $(subdirs) is complete.
843 ifeq ($(sysd-sorted-done),t)
844 -include $(common-objpfx)soversions.mk
845 ifndef avoid-generated
846 # This lets add-ons give more-specific matches that override defaults
847 # in the top-level file.
848 $(common-objpfx)shlib-versions.v.i: \
849 $(wildcard $(+sysdep_dirs:=/shlib-versions) \
850 $(subdir-srcdirs:=/shlib-versions)) \
851 $(..)shlib-versions
852
853 soversions-default-setname = $(patsubst %, %,\
854 $(filter-out %_default,\
855 $(oldest-abi:%=GLIBC_%)))
856 $(common-objpfx)soversions.i: $(..)scripts/soversions.awk \
857 $(common-objpfx)shlib-versions.v
858 $(AWK) -v default_setname='$(soversions-default-setname)' \
859 -v cpu='$(config-machine)' \
860 -v vendor='$(config-vendor)' \
861 -v os='$(config-os)' \
862 -f $^ > $@T
863 mv -f $@T $@
864 $(common-objpfx)soversions.mk: $(common-objpfx)soversions.i $(..)Makeconfig
865 (seen_DEFAULT=0; seen_WORDSIZE32=0; seen_WORDSIZE64=0; \
866 while read which lib number setname; do \
867 eval seen_$$which=1; \
868 test x"$$which" != xABI || echo abi-name = "$$lib"; \
869 test x"$$which" = xDEFAULT || continue; \
870 case $$number in \
871 [0-9]*) echo "$$lib.so-version=.$$number"; \
872 echo "all-sonames+=$$lib=$$lib.so\$$($$lib.so-version)";;\
873 *) echo "$$lib.so-version=$$number"; \
874 echo "all-sonames+=$$lib=\$$($$lib.so-version)";;\
875 esac; \
876 done; \
877 case "$$seen_DEFAULT$$seen_WORDSIZE32$$seen_WORDSIZE64" in \
878 100) echo biarch = no;; \
879 101) echo biarch = 32;; \
880 ?1?) echo biarch = 64;; \
881 *) echo >&2 BUG; exit 2;; \
882 esac; \
883 echo soversions.mk-done = t;) < $< > $@T; exit 0
884 mv -f $@T $@
885 endif
886 endif
887
888 postclean-generated += soversions.mk soversions.i \
889 shlib-versions.v shlib-versions.v.i
890
891 # Generate the header containing the names of all shared libraries.
892 # We use a stamp file to avoid unnecessary recompilations.
893 before-compile += $(common-objpfx)gnu/lib-names.h
894 ifeq ($(soversions.mk-done),t)
895 $(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp; @:
896 $(common-objpfx)gnu/lib-names.stmp: $(..)scripts/lib-names.awk \
897 $(common-objpfx)soversions.i
898 $(make-target-directory)
899 @rm -f ${@:stmp=T} $@
900 LC_ALL=C $(AWK) -f $^ > ${@:stmp=T}
901 $(move-if-change) ${@:stmp=T} ${@:stmp=h}
902 touch $@
903 endif
904
905 common-generated += gnu/lib-names.h gnu/lib-names.stmp
906
907 # The name under which the run-time dynamic linker is installed.
908 # We are currently going for the convention that `/lib/ld.so.1'
909 # names the SVR4/ELF ABI-compliant dynamic linker.
910 ifndef rtld-installed-name
911 ifdef ld.so-version
912 rtld-installed-name = $(ld.so-version)
913 else
914 rtld-installed-name = ld.so.1
915 endif
916 endif
917
918 ifndef rtld-version-installed-name
919 rtld-version-installed-name = ld-$(version).so
920 endif
921
922 endif # build-shared
923
924
925 ifeq ($(elf),yes)
926 dlfcn = dlfcn
927 ifeq ($(build-shared),yes)
928 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
929 else
930 libdl = $(common-objpfx)dlfcn/libdl.a
931 endif
932 else
933 ifneq (,$(findstring aix,$(config-os)))
934 ifeq ($(build-shared),yes)
935 dlfcn = dlfcn
936 libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
937 else
938 # No libdl without shared libs on AIX
939 dlfcn =
940 libdl =
941 endif
942 else
943 # No ELF, no AIX - no libdl, at least for now.
944 dlfcn =
945 libdl =
946 endif
947 endif
948
949 # These are the subdirectories containing the library source. The order
950 # is more or less arbitrary. The sorting step will take care of the
951 # dependencies.
952 all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
953 stdlib stdio-common libio malloc string wcsmbs time dirent \
954 grp pwd posix io termios resource misc socket sysvipc gmon \
955 gnulib iconv iconvdata wctype manual shadow gshadow po argp \
956 crypt nss localedata timezone rt conform debug \
957 $(add-on-subdirs) $(dlfcn) $(binfmt-subdir)
958
959 ifndef avoid-generated
960 all-Depend-files := $(wildcard $(foreach dir,$(all-subdirs),\
961 $(firstword $($(dir)-srcdir) \
962 $(..)$(dir))/Depend))
963 $(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk \
964 $(common-objpfx)config.make $(..)Makeconfig \
965 $(wildcard $(sysdirs:=/Subdirs)) \
966 $(all-Depend-files)
967 $(AWK) -f $< \
968 -v subdirs='$(all-subdirs)' \
969 -v srcpfx='$(..)' \
970 $(filter %/Subdirs %/Depend,$^) > $@-tmp
971 mv -f $@-tmp $@
972 $(all-Depend-files): ;
973 endif
974
975 # This gives partial TARGET:SOURCE pattern pairs to have rules
976 # emitted into sysd-rules. A sysdeps Makeconfig fragment can
977 # add its own special object file prefix to this list with e.g. foo-%:%
978 # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS).
979 sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_%
980
981 # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here.
982 sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig))
983 ifneq (,$(sysdep-makeconfigs))
984 include $(sysdep-makeconfigs)
985 endif
986
987 # Compute just the target patterns. Makeconfig has set sysd-rules-patterns.
988 sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\
989 $(firstword $(subst :, ,$p))))
990
991 endif # Makeconfig not yet included
992
993 # Local Variables:
994 # mode: makefile
995 # End: