-# Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
+# Copyright (C) 1991-1999,2000 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
endif
# Complete path to sysdep dirs.
-full-config-sysdirs := $(filter /%, $(config-sysdirs)) \
- $(addprefix $(..), $(filter-out /%, $(config-sysdirs)))
-export full-config-sysdirs := $(full-config-sysdirs)
+export full-config-sysdirs := $(addprefix $(..),$(config-sysdirs))
# Run config.status to update config.make and config.h. We don't show the
# dependence of config.h to Make, because it is only touched when it
endif
inst_zonedir = $(install_root)$(zonedir)
-# Where to install the locale and message catalog data files (which are
-# machine-independent).
+# Where to install the locale files.
ifndef localedir
-localedir = $(datadir)/locale
+localedir = $(libdir)/locale
endif
inst_localedir = $(install_root)$(localedir)
+# Where to install the message catalog data files (which are
+# machine-independent).
+ifndef msgcatdir
+msgcatdir = $(datadir)/locale
+endif
+inst_msgcatdir = $(install_root)$(msgcatdir)
+
# Where to install the locale charmap source files.
ifndef i18ndir
i18ndir = $(datadir)/i18n
# some additional bizarre files.
start-installed-name = crt1.o
endif
-
+# On systems that do not need a special startfile for statically linked
+# binaries, simply set it to the normal name.
+ifndef static-start-installed-name
+static-start-installed-name = $(start-installed-name)
+endif
# Command for linking programs with the C library.
ifndef +link
+link = $(CC) -nostdlib -nostartfiles -o $@ \
- $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) \
+ $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
$(addprefix $(csu-objpfx),$(start-installed-name)) \
$(+preinit) $(+prector) \
$(filter-out $(addprefix $(csu-objpfx),start.o \
ifndef +link-static
+link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
$(sysdep-LDFLAGS) $(LDFLAGS) \
- $(addprefix $(csu-objpfx),$(start-installed-name)) \
+ $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
$(+preinit) $(+prector) \
$(filter-out $(addprefix $(csu-objpfx),start.o \
$(start-installed-name))\
# run the linked programs.
link-libc = -Wl,-rpath-link=$(rpath-link) \
$(common-objpfx)libc.so$(libc.so-version) \
- $(elfobjdir)/$(rtld-installed-name) \
- $(common-objpfx)libc.a $(gnulib)
+ $(common-objpfx)$(patsubst %,$(libtype.oS),c) $(gnulib)
+# This is how to find at build-time things that will be installed there.
+rpath-dirs = math elf dlfcn nss nis rt resolv
+rpath-link = \
+$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
+elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
+else
+nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
+resolvobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)resolv)
+link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
+endif
+endif
+
# Choose the default search path for the dynamic linker based on
# where we will install libraries.
ifneq ($(libdir),$(slibdir))
else
default-rpath = $(libdir)
endif
-# This is how to find at build-time things that will be installed there.
-rpath-link = $(common-objdir):$(mathobjdir):$(elfobjdir):$(nssobjdir):$(nisobjdir):$(dbobjdir)
-mathobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)math)
-elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
-nssobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nss)
-nisobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)nis)
-dbobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)db2)
-else
-link-libc = $(common-objpfx)libc.a $(gnulib) $(common-objpfx)libc.a
-endif
-endif
ifndef link-extra-libs
ifeq (yes,$(build-shared))
endif
# The static libraries.
+ifeq (yes,$(build-static))
link-libc-static = $(common-objpfx)libc.a $(gnulib) $(common-objpfx)libc.a
link-extra-libs-static = $(foreach lib,$(LDLIBS-$(@F)),$(common-objpfx)$(lib).a)
+else
+ifeq (yes,$(build-shared))
+# We can try to link the programs with lib*_pic.a...
+link-libc-static = $(gnulib) $(common-objpfx)libc_pic.a
+link-extra-libs-static = $(link-extra-libs)
+endif
+endif
ifndef gnulib
gnulib := -lgcc
+postinit = $(addprefix $(csu-objpfx),crtn.o)
+prector = `$(CC) --print-file-name=crtbegin.o`
+postctor = `$(CC) --print-file-name=crtend.o`
++interp = $(addprefix $(elf-objpfx),interp.os)
endif
csu-objpfx = $(common-objpfx)csu/
elf-objpfx = $(common-objpfx)elf/
-db-objpfx = $(common-objpfx)db/
# How to run a program we just linked with our library.
# The program binary is assumed to be $(word 2,$^).
endif
# Extra flags to pass to GCC.
-+gccwarn := -Wall -Wwrite-strings -Wno-parentheses -Winline -Wstrict-prototypes
++gccwarn := -Wall -Wwrite-strings -Winline -Wstrict-prototypes
# This is the program that generates makefile
# dependencies from C source files.
# perhaps others) to preprocess assembly code in some cases.
M4 = m4
+# To force installation of files even if they are older than the
+# installed files. This variable is included in the dependency list
+# of all installation targets.
+ifeq ($(force-install),yes)
++force = force-install
+else
++force =
+endif
+
####
#### End of configuration variables.
####
# files (including ones given in angle brackets) in the current directory,
# in the parent library source directory and in the include directory.
# `+sysdep-includes' will be defined by Makerules.
-+includes = -I. $(patsubst %/,-I%,$(objpfx)) $(patsubst %/,-I%,$(..)) \
- -I$(..)include $($(stdio)-include) $(includes) \
- $(+sysdep-includes) $(last-includes)
++includes = -I$(..)include -I. \
+ $(patsubst %/,-I%,$(objpfx)) $(patsubst %/,-I%,$(..)) \
+ $($(stdio)-include) $(includes) \
+ $(+sysdep-includes) $(last-includes) $(sysincludes)
# Since libio has several internal header files, we use a -I instead
# of many little headers in the include directory.
libio-include = -I$(..)libio
# These are the variables that the implicit compilation rules use.
-CPPFLAGS = $(+includes) $(defines) -include $(..)include/libc-symbols.h \
- $(sysdep-CPPFLAGS) $(CPPFLAGS-$(suffix $@)) $(CPPFLAGS-$(<F)) \
- $(CPPFLAGS-$(@F))
+CPPFLAGS = $($(subdir)-CPPFLAGS) $(+includes) $(defines) \
+ -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
+ $(CPPFLAGS-$(suffix $@)) $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F))
override CFLAGS = $(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
$(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
-
-# This is the macro that the implicit linking rules use.
-ifneq "$(filter -g,$(+cflags))" "" # -g is in $(+cflags)
-LDFLAGS := -g
-endif
-
-
# If everything is compiled with -fPIC (implicitly) we must tell this by
# defining the PIC symbol.
ifeq (yes,$(build-pic-default))
# Various things use $(object-suffixes) to know what all to make.
# The compilation rules use $(CPPFLAGS-${SUFFIX}) and $(CFLAGS-${SUFFIX})
# to pass different flags for each flavor.
-libtypes = $(foreach o,$(object-suffixes),$(libtype$o))
-all-object-suffixes := .o .os .op .og .ob
+libtypes = $(foreach o,$(object-suffixes-for-libc),$(libtype$o))
+all-object-suffixes := .o .os .op .og .ob .oS
object-suffixes :=
-ifeq (yes,$(build-static))
CPPFLAGS-.o = $(pic-default)
CFLAGS-.o = $(filter %frame-pointer,$(+cflags))
+ifeq (yes,$(build-static))
libtype.o := lib%.a
object-suffixes += .o
endif
libtype.ob = lib%_b.a
endif
+object-suffixes-for-libc := $(object-suffixes)
+
+ifeq (yes,$(build-shared))
+# Build special library that contains the static-only routines for libc.
+object-suffixes-for-libc += .oS
+
+# Must build the routines as PIC, though, because they can end up in (users')
+# shared objects. We don't want to use CFLAGS-os because users may, for
+# example, make that processor-specific.
+CFLAGS-.oS = $(CFLAGS-.o) $(pic-ccflag)
+CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC
+libtype.oS = lib%_nonshared.a
+endif
+
+gnu-stabs = $(shell echo>&2 '*** BARF ON ME')
ifndef BUILD_CC
BUILD_CC = $(CC)
endif
-\f
-# Figure out the version numbers from version.h.
-$(common-objpfx)version.mk: $(..)version.h $(..)Makeconfig
- sed -n -e 's/^.*RELEASE.*"\([^"]*\)".*$$/release=\1/p' \
- -e 's/^.*VERSION.*"\([^"]*\)".*$$/version=\1/p' \
- < $< > $@-new
- mv -f $@-new $@
+move-if-change = $(SHELL) $(..)scripts/move-if-change
+\f
+-include $(common-objpfx)sysd-dirs
-common-generated += version.mk
+ifeq ($(sysd-dirs-done),t)
+-include $(common-objpfx)sysd-sorted
+subdirs = $(sorted-subdirs)
+endif
ifeq (yes, $(build-shared))
# Process the shlib-versions file, which tells us what shared library
# version numbers to use when we install shared objects on this system.
+# We need to wait until $(subdirs) is complete.
+ifeq ($(sysd-sorted-done),t)
-include $(common-objpfx)soversions.mk
ifndef avoid-generated
$(common-objpfx)soversions.mk: $(..)shlib-versions $(..)Makeconfig \
$(wildcard $(patsubst %, $(..)%/shlib-versions,\
- $(add-ons))) \
+ $(add-ons) \
+ $(subdirs))) \
$(common-objpfx)config.make
(file="$(wildcard $(patsubst %,$(..)%/shlib-versions,$(add-ons))) \
+ $(wildcard $(patsubst %,$(..)%/shlib-versions,$(subdirs))) \
$(..)shlib-versions"; \
for f in $$file; do \
sed 's/#.*$$//' $$f | while read conf versions; do \
done;) > $@T; exit 0
mv -f $@T $@
endif
+endif
postclean-generated += soversions.mk
-ifndef avoid-generated
-# Get $(version) defined with the release version number.
--include $(common-objpfx)version.mk
-endif
-
# Generate the header containing the names of all shared libraries.
# We use a stamp file to avoid uncessary recompilations.
before-compile += $(common-objpfx)gnu/lib-names.h
done;) | sort; \
echo; \
echo '#endif /* gnu/lib-names.h */';) > ${@:stmp=T}
- if test -r ${@:stmp=h} && cmp -s ${@:stmp=h} ${@:stmp=T}; \
- then rm -f ${@:stmp=T}; \
- else mv -f ${@:stmp=T} ${@:stmp=h}; fi
+ $(move-if-change) ${@:stmp=T} ${@:stmp=h}
touch $@
common-generated += gnu/lib-names.h gnu/lib-names.stmp
shared-thread-library = $(common-objpfx)linuxthreads/libpthread.so
static-thread-library = $(common-objpfx)linuxthreads/libpthread.a
have-thread-library = yes
+rpath-dirs += linuxthreads
+endif
+
+ifeq ($(elf),yes)
+dlfcn = dlfcn
+ifeq ($(build-shared),yes)
+libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version)
+else
+libdl = $(common-objpfx)dlfcn/libdl.a
+endif
+else
+# No ELF - no libdl, at least for now.
+dlfcn =
+libdl =
+endif
+
+# These are the subdirectories containing the library source. The order
+# is more or less arbitrary. The sorting step will take care of the
+# dependencies. Only the $(binfmt-subdir) should always be kept at the
+# end of the list.
+all-subdirs = csu assert ctype locale intl catgets math setjmp signal \
+ stdlib stdio-common $(stdio) malloc string wcsmbs time dirent \
+ grp pwd posix io termios resource misc socket sysvipc gmon \
+ gnulib iconv iconvdata wctype manual shadow md5-crypt po argp \
+ $(add-ons) nss localedata timezone rt debug $(sysdep-subdirs) \
+ $(dlfcn) $(binfmt-subdir)
+all-subdirs := $(filter-out $(sysdep-inhibit-subdirs),$(all-subdirs))
+
+# The mach and hurd subdirectories have many generated header files which
+# much of the rest of the library depends on, so it is best to build them
+# first (and mach before hurd, at that). The before-compile additions in
+# sysdeps/{mach,hurd}/Makefile should make it reliably work for these files
+# not to exist when making in other directories, but it will be slower that
+# way with more somewhat expensive `make' invocations.
+subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
+ $(filter-out mach hurd,$(subdirs))
+
+ifndef avoid-generated
+all-Subdirs-files = $(wildcard $(config-sysdirs:%=$(..)%/Subdirs))
+$(common-objpfx)sysd-dirs: $(common-objpfx)config.make $(all-Subdirs-files)
+ $(AWK) 'BEGIN { subdirs = ""; inhibit = "" }; \
+ /^#/ { next }; \
+ /^[^-]/ { subdirs = subdirs " " $$0 }; \
+ /^-/ { inhibit = inhibit " " substr($$0, 2) }; \
+ END { printf "sysdep-subdirs =%s\n", subdirs; \
+ printf "sysdep-inhibit-subdirs =%s\n", inhibit; \
+ print "sysd-dirs-done = t" }' \
+ $(patsubst $<,/dev/null,$^) > $@-tmp
+ mv -f $@-tmp $@
+
+all-Depend-files = $(wildcard $(..)*/Depend)
+$(common-objpfx)sysd-sorted: $(..)scripts/gen-sorted.awk $(all-Depend-files) \
+ $(common-objpfx)sysd-dirs $(..)Makeconfig
+ { { dirs='$(patsubst $(..)%/Depend,$(..)%,$(filter %/Depend,$^))';\
+ for d in $$dirs; do \
+ while read on; do \
+ echo "depend $$d $$on"; \
+ done < $$d/Depend; \
+ done; \
+ for f in $(all-subdirs); do \
+ echo $$f; \
+ done; \
+ } | $(AWK) -f $< && \
+ echo sysd-sorted-done = t; \
+ } > $@-tmp
+ mv -f $@-tmp $@
endif
endif # Makeconfig not yet included