1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Library General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # License, or (at your option) any later version.
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 # Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB. If not,
16 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
20 # Makefile configuration options for the GNU C library.
23 This makefile requires GNU Make.
26 all: # Make this the default goal
28 ifneq "$(origin +included-Makeconfig)" "file"
30 +included-Makeconfig := yes
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))
41 else # Not configured.
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
54 ifeq ($(filter /%,$(ARCH)),)
55 objdir := $(..)$(ARCH)
61 # $(common-objdir) is the place to put objects and
62 # such that are not specific to a single subdir.
64 objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
65 common-objpfx = $(objdir)/
66 common-objdir = $(objdir)
73 # This is a kludge. make wizards might grok.
74 common-objpfx = sysdeps/../
79 # Root of the sysdeps tree.
80 sysdep_dir := $(..)sysdeps
81 export sysdep_dir := $(sysdep_dir)
83 # Get the values defined by options to `configure'.
84 include $(common-objpfx)config.make
86 # We have a special subdir for each binary format.
87 # For now, only ELF is fully supported.
91 # This is probably better than nothing.
95 # Complete path to sysdep dirs.
96 full-config-sysdirs := $(filter /%, $(config-sysdirs)) \
97 $(addprefix $(..), $(filter-out /%, $(config-sysdirs)))
98 export full-config-sysdirs := $(full-config-sysdirs)
100 # Run config.status to update config.make and config.h. We don't show the
101 # dependence of config.h to Make, because it is only touched when it
102 # changes and so config.status would be run every time; the dependence of
103 # config.make should suffice to force regeneration and re-exec, and the new
104 # image will notice if config.h changed.
105 $(common-objpfx)config.make: $(common-objpfx)config.status \
106 $(..)config.make.in $(..)config.h.in
107 cd $(<D); $(SHELL) $(<F)
109 # Find all the sysdeps configure fragments, to make sure we re-run
110 # configure when any of them changes.
111 $(common-objpfx)config.status: $(..)version.h $(..)configure \
112 $(foreach dir,$(full-config-sysdirs),\
116 $(firstword $(wildcard \
117 $(addprefix $(dir)/,configure configure.in)))))
118 @cd $(@D); if test -f $(@F); then exec $(SHELL) $(@F) --recheck; else \
119 echo The GNU C library has not been configured. >&2; \
120 echo Run \`configure\' to configure it before building. >&2; \
121 echo Try \`configure --help\' for more details. >&2; \
124 # Get the user's configuration parameters.
125 ifneq ($(wildcard $(..)configparms),)
126 include $(..)configparms
129 ifneq ($(wildcard $(common-objpfx)configparms),)
130 include $(common-objpfx)configparms
135 #### These are the configuration variables. You can define values for
136 #### the variables below in the file `configparms'.
137 #### Do NOT edit this file.
141 # Set this to either `stdio' or `libio', to compile in either GNU stdio
147 # Common prefix for machine-independent installation directories.
148 ifeq ($(origin prefix),undefined) # ifndef would override explicit empty value.
152 # Common prefix for machine-dependent installation directories.
153 ifeq ($(origin exec_prefix),undefined)
154 exec_prefix = $(prefix)
157 # Where to install the library and object files.
159 libdir = $(exec_prefix)/lib
161 inst_libdir = $(install_root)$(libdir)
163 # Where to install the shared library and dynamic linker.
165 slibdir = $(exec_prefix)/lib
167 inst_slibdir = $(install_root)$(slibdir)
169 # Prefix to put on files installed in $(libdir). For libraries `libNAME.a',
170 # the prefix is spliced between `lib' and the name, so the linker switch
171 # `-l$(libprefix)NAME' finds the library; for other files the prefix is
172 # just prepended to the whole file name.
173 ifeq ($(origin libprefix),undefined)
177 # Where to install the header files.
179 includedir = $(exec_prefix)/include
181 inst_includedir = $(install_root)$(includedir)
183 # Where to install machine-independent data files.
184 # These are the timezone database, and the locale database.
186 datadir = $(prefix)/share
188 inst_datadir = $(install_root)$(datadir)
190 # Where to install the timezone data files (which are machine-independent).
192 zonedir = $(datadir)/zoneinfo
194 inst_zonedir = $(install_root)$(zonedir)
196 # Where to install the locale and message catalog data files (which are
197 # machine-independent).
199 localedir = $(datadir)/locale
201 inst_localedir = $(install_root)$(localedir)
203 # Where to install the locale charmap source files.
205 i18ndir = $(datadir)/i18n
207 inst_i18ndir = $(install_root)$(i18ndir)
210 # Where to install programs.
212 bindir = $(exec_prefix)/bin
214 inst_bindir = $(install_root)$(bindir)
216 # Where to install administrative programs.
218 rootsbindir = $(exec_prefix)/sbin
220 inst_rootsbindir = $(install_root)$(rootsbindir)
223 sbindir = $(exec_prefix)/sbin
225 inst_sbindir = $(install_root)$(sbindir)
227 # Where to install the Info files.
229 infodir = $(prefix)/info
231 inst_infodir = $(install_root)$(infodir)
233 # Where to install default configuration files. These include the local
234 # timezone specification and network data base files.
236 sysconfdir = $(prefix)/etc
238 inst_sysconfdir = $(install_root)$(sysconfdir)
240 # What timezone should be the installed default (e.g., US/Eastern).
241 # Run `make -C time echo-zonenames' to see a list of available zone names.
242 # The local timezone can be changed with `zic -l TIMEZONE' at any time.
247 # Where to install the "localtime" timezone file; this is the file whose
248 # contents $(localtime) specifies. If this is a relative pathname, it is
249 # relative to $(zonedir). It is a good idea to put this somewhere
250 # other than there, so the zoneinfo directory contains only universal data,
251 # localizing the configuration data elsewhere.
252 ifndef localtime-file
253 localtime-file = $(sysconfdir)/localtime
254 inst_localtime-file = $(install_root)$(localtime-file)
257 # What to use for leap second specifications in compiling the default
258 # timezone files. Set this to `/dev/null' for no leap second handling as
259 # 1003.1 requires, or to `leapseconds' for proper leap second handling.
260 # Both zone flavors are always available as `posix/ZONE' and `right/ZONE'.
261 # This variable determines the default: if it's `/dev/null',
262 # ZONE==posix/ZONE; if it's `leapseconds', ZONE==right/ZONE.
264 leapseconds = /dev/null
267 # What timezone's DST rules should be used when a POSIX-style TZ
268 # environment variable doesn't specify any rules. For 1003.1 compliance
269 # this timezone must use rules that are as U.S. federal law defines DST.
270 # Run `make -C time echo-zonenames' to see a list of available zone names.
271 # This setting can be changed with `zic -p TIMEZONE' at any time.
272 # If you want POSIX.1 compatibility, use `America/New_York'.
274 posixrules = America/New_York
277 # Where to install the "posixrules" timezone file; this is file
278 # whose contents $(posixrules) specifies. If this is a relative
279 # pathname, it is relative to $(zonedir).
280 ifndef posixrules-file
281 posixrules-file = posixrules
285 # Directory where your system's native header files live.
286 # This is used on Unix systems to generate some GNU libc header files.
288 sysincludedir = /usr/include
292 # Commands to install files.
294 INSTALL_DATA = $(INSTALL) -m 644
296 ifndef INSTALL_PROGRAM
297 INSTALL_PROGRAM = $(INSTALL)
304 # The name of the C compiler.
305 # If you've got GCC, and it works, use it.
306 ifeq ($(origin CC),default)
310 # The name of the C compiler to use for compilations of programs to run on
311 # the host that is building the library. If you set CC to a
312 # cross-compiler, you must set this to the normal compiler.
317 # Default flags to pass the C compiler.
318 ifndef default_cflags
319 default_cflags := -g -O
322 # Flags to pass the C compiler when assembling preprocessed assembly code
323 # (`.S' files). On some systems the assembler doesn't understand the `#' line
324 # directives the preprocessor produces. If you have troubling compiling
325 # assembly code, try using -P here to suppress these directives.
330 # Installed name of the startup code.
332 # When not using ELF, there is just one startfile, called crt0.o.
333 start-installed-name = crt0.o
335 # In the ELF universe, crt0.o is called crt1.o, and there are
336 # some additional bizarre files.
337 start-installed-name = crt1.o
342 # Command for linking programs with the C library.
344 +link = $(CC) -nostdlib -nostartfiles -o $@ \
345 $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) \
346 $(addprefix $(csu-objpfx),$(start-installed-name)) \
347 $(+preinit) $(+prector) \
348 $(filter-out $(addprefix $(csu-objpfx),start.o \
349 $(start-installed-name))\
350 $(+preinit) $(link-extra-libs) \
351 $(common-objpfx)libc% $(+postinit),$^) \
352 $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
354 ifndef config-LDFLAGS
355 ifeq (yes,$(build-shared))
356 config-LDFLAGS = -Wl,-dynamic-linker=$(slibdir)/$(rtld-installed-name)
360 ifeq (yes,$(build-shared))
361 # We need the versioned name of libc.so in the deps of $(others) et al
362 # so that the symlink to libc.so is created before anything tries to
363 # run the linked programs.
364 link-libc = -Wl,-rpath-link=$(rpath-link) \
365 $(common-objpfx)libc.so$(libc.so-version) \
366 $(elfobjdir)/$(rtld-installed-name) \
367 $(common-objpfx)libc.a $(gnulib)
368 # Choose the default search path for the dynamic linker based on
369 # where we will install libraries.
370 ifneq ($(libdir),$(slibdir))
371 default-rpath = $(slibdir):$(libdir)
373 default-rpath = $(libdir)
375 # This is how to find at build-time things that will be installed there.
376 rpath-link = $(common-objdir):$(mathobjdir):$(elfobjdir):$(nssobjdir):$(dbobjdir)
377 mathobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)math)
378 elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
379 nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
380 dbobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)db)
382 link-libc = $(common-objpfx)libc.a $(gnulib) $(common-objpfx)libc.a
386 ifndef link-extra-libs
387 ifeq (yes,$(build-shared))
388 ifneq ($(common-objpfx),$(objpfx))
389 link-extra-libs = $(foreach lib,$(LDLIBS-$(@F)),\
390 $(wildcard $(common-objpfx)$(lib).so$($(notdir $(lib)).so-version) \
391 $(objpfx)$(lib).so$($(notdir $(lib)).so-version)))
393 link-extra-libs = $(foreach lib,$(LDLIBS-$(@F)),$(common-objpfx)$(lib).so$($(notdir $(lib)).so-version))
396 link-extra-libs = $(foreach lib,$(LDLIBS-$(@F)),$(common-objpfx)$(lib).a)
403 +preinit = $(addprefix $(csu-objpfx),crti.o)
404 +postinit = $(addprefix $(csu-objpfx),crtn.o)
405 +prector = `$(CC) --print-file-name=crtbegin.o`
406 +postctor = `$(CC) --print-file-name=crtend.o`
408 csu-objpfx = $(common-objpfx)csu/
409 elf-objpfx = $(common-objpfx)elf/
410 db-objpfx = $(common-objpfx)db/
412 # How to run a program we just linked with our library.
413 # The program binary is assumed to be $(word 2,$^).
414 built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
415 ifneq (yes,$(build-shared))
416 built-program-cmd = $(built-program-file)
419 sysdep-library-path = \
420 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
421 $(filter -Wl$(comma)-rpath-link=%,\
422 $(sysdep-LDFLAGS)))))
423 define built-program-cmd
424 LD_LIBRARY_PATH=$(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
425 $(elf-objpfx)$(rtld-installed-name) $(built-program-file)
437 # Extra flags to pass to GCC.
438 +gccwarn := -Wall -Wwrite-strings -Wno-parentheses -Winline -Wstrict-prototypes
440 # This is the program that generates makefile
441 # dependencies from C source files.
446 # The program that makes Emacs-style TAGS files.
449 # The `m4' macro processor; this is used by sysdeps/sparc/Makefile (and
450 # perhaps others) to preprocess assembly code in some cases.
454 #### End of configuration variables.
457 # This tells some versions of GNU make before 3.63 not to export all variables.
460 # We want to echo the commands we're running without
461 # umpteen zillion filenames along with it (we use `...' instead)
462 # but we don't want this echoing done when the user has said
463 # he doesn't want to see commands echoed by using -s.
464 ifneq "$(findstring s,$(MAKEFLAGS))" "" # if -s
465 +cmdecho := echo >/dev/null
470 # These are the flags given to the compiler to tell
471 # it what sort of optimization and/or debugging output to do.
473 # If `CFLAGS' was defined, use that.
475 +cflags := $(filter-out -I%,$(CFLAGS))
479 # If none of the above worked, default to "-g -O".
480 ifeq "$(strip $(+cflags))" ""
481 +cflags := $(default_cflags)
482 endif # $(+cflags) == ""
484 +cflags := $(+cflags) $(+gccwarn)
487 # Don't duplicate options if we inherited variables from the parent.
488 +cflags := $(sort $(+cflags))
491 # These are flags given to the C compiler to tell it to look for include
492 # files (including ones given in angle brackets) in the current directory,
493 # in the parent library source directory and in the include directory.
494 # `+sysdep-includes' will be defined by Makerules.
495 +includes = -I. $(patsubst %/,-I%,$(..)) -I$(..)include $($(stdio)-include) \
496 $(includes) $(+sysdep-includes) $(last-includes)
498 # Since libio has several internal header files, we use a -I instead
499 # of many little headers in the include directory.
500 libio-include = -I$(..)libio
502 # These are the variables that the implicit compilation rules use.
503 CPPFLAGS = $(+includes) $(defines) -include $(..)include/libc-symbols.h \
504 $(sysdep-CPPFLAGS) $(CPPFLAGS-$(suffix $@)) $(CPPFLAGS-$(<F)) \
506 override CFLAGS = $(+cflags) $(sysdep-CFLAGS) $(CFLAGS-$(suffix $@)) \
507 $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
510 # This is the macro that the implicit linking rules use.
511 ifneq "$(filter -g,$(+cflags))" "" # -g is in $(+cflags)
516 # Enable object files for different versions of the library.
517 # Various things use $(object-suffixes) to know what all to make.
518 # The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
519 # to pass different flags for each flavor.
520 libtypes = $(foreach o,$(object-suffixes),$(libtype$o))
521 object-suffixes := .o
522 all-object-suffixes := .o .so .po .go .bo
524 ifeq (yes,$(build-shared))
525 # Under --enable-shared, we will build a shared library of PIC objects.
526 # The PIC object files are named foo.so.
527 object-suffixes += .so
529 CFLAGS-.so = -fPIC -fno-common
530 libtype.so := lib%_pic.a
532 ifeq (yes,$(build-profile))
533 # Under --enable-profile, we will build a static library of profiled objects.
534 # The profiled object files are named foo.po.
535 object-suffixes += .po
536 CPPFLAGS-.po = -DPROF
538 libtype.po = lib%_p.a
540 ifeq (yes,$(build-omitfp))
541 # Under --enable-omitfp, we build an the library optimized without
542 # debugging information using -fomit-frame-pointer, and build an extra
543 # library with debugging information. The debuggable objects are named foo.go.
544 object-suffixes += .go
546 CFLAGS-.o = -g0 -O99 -fomit-frame-pointer
547 CFLAGS-.so += $(CFLAGS-.o)
548 libtype.go = lib%_g.a
550 ifeq (yes,$(build-bounded))
551 # Under --enable-bounded, we build the library with `-fbounded-pointers -g'
552 # to runtime bounds checking. The bounded-pointer objects are named foo.bo.
553 object-suffixes += .bo
554 CPPFLAGS-.bo = -DBOUNDED_POINTERS
555 CFLAGS-.bo = -g -fbounded-pointers
556 libtype.bo = lib%_b.a
560 +gnu-stabs = $(shell echo>&2 '*** BARF ON ME')
566 # Figure out the version numbers from version.h.
568 $(common-objpfx)version.mk: $(..)version.h $(..)Makeconfig
569 sed -n -e 's/^.*RELEASE.*"\([^"]*\)".*$$/release=\1/p' \
570 -e 's/^.*VERSION.*"\([^"]*\)".*$$/version=\1/p' \
574 ifeq (yes, $(build-shared))
576 # Process the shlib-versions file, which tells us what shared library
577 # version numbers to use when we install shared objects on this system.
578 -include $(common-objpfx)soversions.mk
579 $(common-objpfx)soversions.mk: $(..)shlib-versions $(..)Makeconfig \
580 $(wildcard $(patsubst %, $(..)%/shlib-versions,\
582 $(common-objpfx)config.make
583 (file="$(wildcard $(patsubst %,$(..)%/shlib-versions,$(add-ons))) \
584 $(..)shlib-versions"; \
585 for f in $$file; do \
586 sed 's/#.*$$//' $$f | while read conf versions; do \
587 test -n "$$versions" && \
588 test `expr '$(config-machine)-$(config-vendor)-$(config-os)' \
589 : "$$conf"` != 0 || continue; \
590 for v in $$versions; do \
591 lib=`echo $$v | sed 's/=.*$$//'`; \
592 if eval "test -z \"\$$vers_lib$$lib\""; then \
593 eval vers_lib$${lib}=yes; \
594 number=`echo $$v | sed "s/^.*=//"`; \
596 [0-9]*) echo "$$lib.so-version=.$$number"; \
597 echo "all-sonames+=$$lib.so\$$($$lib.so-version)";;\
598 *) echo "$$lib.so-version=$$number"; \
599 echo "all-sonames+=\$$($$lib.so-version)";; \
607 # Get $(version) defined with the release version number.
608 -include $(common-objpfx)version.mk
610 # Generate the header containing the names of all shared libraries.
611 # We use a stamp file to avoid uncessary recompilations.
612 before-compile += $(common-objpfx)gnu/lib-names.h
613 $(common-objpfx)gnu/lib-names.h: $(common-objpfx)gnu/lib-names.stmp
614 $(common-objpfx)gnu/lib-names.stmp: $(common-objpfx)soversions.mk
615 $(make-target-directory)
616 @rm -f ${@:stmp=T} $@
617 (echo '/* This file is automatically generated.';\
618 echo ' It defines macros to allow user program to find the shared';\
619 echo ' library files which come as part of GNU libc. */';\
620 echo '#ifndef __GNU_LIB_NAMES_H'; \
621 echo '#define __GNU_LIB_NAMES_H 1'; \
623 (libs='$(all-sonames)';\
624 for l in $$libs; do \
625 upname=`echo $$l | sed 's/[.]so.*//' | \
626 tr 'abcdefghijklmnopqrstuvwxyz-' \
627 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`; \
628 echo "#define $${upname}_SO \"$$l\""; \
631 echo '#endif /* gnu/lib-names.h */';) > ${@:stmp=T}
632 if test -r ${@:stmp=h} && cmp -s ${@:stmp=h} ${@:stmp=T}; \
633 then rm -f ${@:stmp=T}; \
634 else mv -f ${@:stmp=T} ${@:stmp=h}; fi
637 common-generated += gnu/lib-names.h gnu/lib-names.stmp
639 # The name under which the run-time dynamic linker is installed.
640 # We are currently going for the convention that `/lib/ld.so.1'
641 # names the SVR4/ELF ABI-compliant dynamic linker.
642 ifndef rtld-installed-name
644 rtld-installed-name = $(ld.so-version)
646 rtld-installed-name = ld.so.1
650 ifndef rtld-version-installed-name
651 rtld-version-installed-name = ld-$(version).so
656 endif # Makeconfig not yet included