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