]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - Makerules
Enhance --enable-tunables to select tunables frontend at build time
[thirdparty/glibc.git] / Makerules
index ca238f1c6e9dc3e7ca56468113931b43914158e2..61a0240439abeece5453faed228643a863cff6c1 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2015 Free Software Foundation, Inc.
+# Copyright (C) 1991-2016 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
@@ -109,6 +109,26 @@ endif # avoid-generated
 endif # $(build-shared) = yes
 
 ifndef avoid-generated
+ifneq (,$(CXX))
+# If C++ headers <cstdlib> or <cmath> are used, GCC 6 will include
+# /usr/include/stdlib.h or /usr/include/math.h from "#include_next"
+# (instead of stdlib/stdlib.h or math/math.h in the glibc source
+# directory), and this turns up as a make dependency.  An implicit
+# rule will kick in and make will try to install stdlib/stdlib.h or
+# math/math.h as /usr/include/stdlib.h or /usr/include/math.h because
+# the target is out of date.  We make a copy of <cstdlib> and <cmath>
+# in the glibc build directory so that stdlib/stdlib.h and math/math.h
+# will be used instead of /usr/include/stdlib.h and /usr/include/math.h.
+before-compile := $(common-objpfx)cstdlib $(common-objpfx)cmath \
+                 $(before-compile)
+$(common-objpfx)cstdlib: $(c++-cstdlib-header)
+       $(INSTALL_DATA) $< $@T
+       $(move-if-change) $@T $@
+$(common-objpfx)cmath: $(c++-cmath-header)
+       $(INSTALL_DATA) $< $@T
+       $(move-if-change) $@T $@
+endif
+
 before-compile := $(common-objpfx)libc-abis.h $(before-compile)
 $(common-objpfx)libc-abis.h: $(common-objpfx)libc-abis.stamp; @:
 $(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \
@@ -123,6 +143,16 @@ $(common-objpfx)libc-abis.stamp: $(..)scripts/gen-libc-abis \
 common-generated += $(common-objpfx)libc-abis.h
 endif # avoid-generated
 
+ifeq (yes,$(build-shared))
+$(common-objpfx)runtime-linker.h: $(common-objpfx)runtime-linker.stamp; @:
+$(common-objpfx)runtime-linker.stamp: $(common-objpfx)config.make
+       $(make-target-directory)
+       echo '#define RUNTIME_LINKER "$(rtlddir)/$(rtld-installed-name)"' \
+               > ${@:stamp=T}
+       $(move-if-change) ${@:stamp=T} ${@:stamp=h}
+       touch $@
+endif
+
 # Make sure the subdirectory for object files gets created.
 ifdef objpfx
 ifeq (,$(wildcard $(objpfx).))
@@ -180,6 +210,52 @@ sed-remove-dotdot := -e 's@  *\([^         \/$$][^         \]*\)@ $$(..)\1@g' \
                     -e 's@^\([^        \/$$][^         \]*\)@$$(..)\1@g'
 endif
 
+ifdef gen-py-const-headers
+# We'll use a static pattern rule to match .pysym files with their
+# corresponding generated .py files.
+# The generated .py files go in the submodule's dir in the glibc build dir.
+py-const-files := $(patsubst %.pysym,%.py,$(gen-py-const-headers))
+py-const-dir := $(objpfx)
+py-const := $(addprefix $(py-const-dir),$(py-const-files))
+py-const-script := $(..)scripts/gen-py-const.awk
+
+# This is a hack we use to generate .py files with constants for Python
+# pretty printers.  It works the same way as gen-as-const.
+# See scripts/gen-py-const.awk for details on how the awk | gcc mechanism
+# works.
+#
+# $@.tmp and $@.tmp2 are temporary files we use to store the partial contents
+# of the target file.  We do this instead of just writing on $@ because, if the
+# build process terminates prematurely, re-running Make wouldn't run this rule
+# since Make would see that the target file already exists (despite it being
+# incomplete).
+#
+# The sed line replaces "@name@SOME_NAME@value@SOME_VALUE@" strings from the
+# output of 'gcc -S' with "SOME_NAME = SOME_VALUE" strings.
+# The '-n' option, combined with the '/p' command, makes sed output only the
+# modified lines instead of the whole input file.  The output is redirected
+# to a .py file; we'll import it in the pretty printers file to read
+# the constants generated by gen-py-const.awk.
+# The regex has two capturing groups, for SOME_NAME and SOME_VALUE
+# respectively.  Notice SOME_VALUE may be prepended by a special character,
+# depending on the assembly syntax (e.g. immediates are prefixed by a '$'
+# in AT&T x86, and by a '#' in ARM).  We discard it using a complemented set
+# before the second capturing group.
+$(py-const): $(py-const-dir)%.py: %.pysym $(py-const-script) \
+            $(common-before-compile)
+       $(make-target-directory)
+       $(AWK) -f $(py-const-script) $< \
+              | $(CC) -S -o $@.tmp $(CFLAGS) $(CPPFLAGS) -x c -
+       echo '# GENERATED FILE\n' > $@.tmp2
+       echo '# Constant definitions for pretty printers.' >> $@.tmp2
+       echo '# See gen-py-const.awk for details.\n' >> $@.tmp2
+       sed -n -r 's/^.*@name@([^@]+)@value@[^[:xdigit:]Xx-]*([[:xdigit:]Xx-]+)@.*/\1 = \2/p' \
+           $@.tmp >> $@.tmp2
+       mv -f $@.tmp2 $@
+       rm -f $@.tmp
+
+generated += $(py-const)
+endif  # gen-py-const-headers
 
 ifdef gen-as-const-headers
 # Generating headers for assembly constants.
@@ -463,7 +539,6 @@ elide-routines.os += $(static-only-routines)
 # static libraries.
 elide-routines.o  += $(shared-only-routines)
 elide-routines.op += $(shared-only-routines)
-elide-routines.og += $(shared-only-routines)
 \f
 # Shared library building.
 
@@ -505,9 +580,10 @@ link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
 # to be as similar as possible to a default link with an installed libc.
 lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(link-libc-deps)
        $(build-shlib) $(link-libc-args)
+       $(call after-link,$@)
 
 define build-shlib-helper
-$(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \
+$(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \
          $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(rtld-LDFLAGS) \
          $(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
          $(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
@@ -551,6 +627,9 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
                 PROVIDE(__start___libc_thread_subfreeres = .);\
                 __libc_thread_subfreeres : { *(__libc_thread_subfreeres) }\
                 PROVIDE(__stop___libc_thread_subfreeres = .);\
+                PROVIDE(__start___libc_IO_vtables = .);\
+                __libc_IO_vtables : { *(__libc_IO_vtables) }\
+                PROVIDE(__stop___libc_IO_vtables = .);\
                 /DISCARD/ : { *(.gnu.glibc-stub.*) }@'
        test -s $@T
        mv -f $@T $@
@@ -566,7 +645,7 @@ $(build-shlib-helper) -o $@ $(shlib-lds-flags) \
 endef
 
 define build-module-helper
-$(LINK.o) -shared $(static-libgcc) $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
+$(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
          $(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
          -B$(csu-objpfx) $(load-map-file) \
          $(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
@@ -580,12 +659,14 @@ endef
 define build-module
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
          $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
+$(call after-link,$@)
 endef
 define build-module-asneeded
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
          $(csu-objpfx)abi-note.o \
          -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
          $(link-libc-args)
+$(call after-link,$@)
 endef
 
 build-module-helper-objlist = \
@@ -666,6 +747,7 @@ $(common-objpfx)libc.so: $(elf-objpfx)soinit.os \
                         $(elf-objpfx)ld.so \
                         $(shlib-lds)
        $(build-shlib)
+       $(call after-link,$@)
 
 $(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \
                         $(common-objpfx)linkobj/libc_pic.a \
@@ -674,6 +756,7 @@ $(common-objpfx)linkobj/libc.so: $(elf-objpfx)soinit.os \
                         $(elf-objpfx)ld.so \
                         $(shlib-lds)
        $(build-shlib)
+       $(call after-link,$@)
 
 ifeq ($(build-shared),yes)
 $(common-objpfx)libc.so: $(common-objpfx)libc.map
@@ -901,6 +984,26 @@ endef
 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
                             $(inst_libdir)/$(patsubst %,$(libtype$o),\
                                                     $(libprefix)$(libc-name)))
+
+.PHONY: check-install-supported
+check-install-supported:
+
+# Check to see if the prefix or exec_prefix GNU standard variable
+# has been overridden on the command line and, if so, fail with
+# an error message since doing so is not supported (set DESTDIR
+# instead).
+ifeq ($(origin prefix),command line)
+check-install-supported:
+       $(error Overriding prefix is not supported. Set DESTDIR instead.)
+endif
+
+ifeq ($(origin exec_prefix),command line)
+check-install-supported:
+       $(error Overriding exec_prefix is not supported. Set DESTDIR instead.)
+endif
+
+install: check-install-supported
+
 install: $(installed-libcs)
 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
        $(make-target-directory)
@@ -1097,7 +1200,8 @@ endif
 
 define do-install-so
 $(do-install-program)
-$(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
+$(patsubst %,$(LN_S) -f $(@F) \
+                       $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\
           $(filter-out %.so,$@))
 endef
 
@@ -1133,6 +1237,7 @@ $(addprefix $(inst_sbindir)/,$(install-sbin)): \
 endif
 ifdef install-lib
 install-lib.a := $(filter lib%.a,$(install-lib))
+install-lib.a := $(filter-out $(install-lib-ldscripts),$(install-lib.a))
 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
 ifdef install-lib-non.a
 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
@@ -1311,25 +1416,54 @@ define update-abi
  fi
 endef
 
-.PHONY: update-abi check-abi
+# Patch all .abilist files for one DSO.  The find command locates
+# abilist files for all architectures.  The regular expression in the
+# find invocation is needed to separate libc.abilist and
+# libcrypt.abilist, for example.  It assumes that abilist-pattern, if
+# set, is of the form "%-SUFFIX", and not "%SUFFIX", that is, there is
+# a non-alphanumeric seperator between the pattern and the suffix
+# added.  The abilist files in /generic/ are filtered out because
+# these are expected to remain empty.
+define update-all-abi
+$(SHELL) $(..)scripts/update-abilist.sh $^ \
+  $$(find $(..)sysdeps \
+    -regextype posix-egrep -regex '.*/$*([^a-z0-9].*)?\.abilist$$' \
+    \! -regex '.*/generic/.*')
+endef
+ifdef abilist-pattern
+update-all-abi-%: $(abilist-pattern) $(objpfx)%.symlist
+       $(update-all-abi)
+update-all-abi-%: $(abilist-pattern) $(common-objpfx)%.symlist
+       $(update-all-abi)
+endif
+update-all-abi-%: %.abilist $(objpfx)%.symlist
+       $(update-all-abi)
+update-all-abi-%: %.abilist $(common-objpfx)%.symlist
+       $(update-all-abi)
+
+.PHONY: update-abi update-all-abi check-abi
 update-abi: $(patsubst %.so,update-abi-%,$(install-lib.so-versioned))
+update-all-abi: $(patsubst %.so,update-all-abi-%,$(install-lib.so-versioned))
 check-abi-list = $(patsubst %.so,$(objpfx)check-abi-%.out, \
                                 $(install-lib.so-versioned))
 check-abi: $(check-abi-list)
 ifdef subdir
 subdir_check-abi: check-abi
 subdir_update-abi: update-abi
+subdir_update-all-abi: update-all-abi
 else
 check-abi: subdir_check-abi
        if grep -q '^FAIL:' $(objpfx)*/check-abi*.test-result; then \
                cat $(objpfx)*/check-abi*.out && exit 1; fi
 update-abi: subdir_update-abi
+update-all-abi: subdir_update-all-abi
 endif
 
 ifeq ($(subdir),elf)
 check-abi: $(objpfx)check-abi-libc.out
 tests-special += $(objpfx)check-abi-libc.out
 update-abi: update-abi-libc
+update-all-abi: update-all-abi-libc
 common-generated += libc.symlist
 endif