aboutsummaryrefslogtreecommitdiff
path: root/Makeconfig
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2014-11-19 12:16:00 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2014-11-19 12:16:00 +0530
commit130ac68ca25c9aa65e027e3e37337bc048205c69 (patch)
tree14b5c6ef5c52c1e466952961bcb35356a5d51bc4 /Makeconfig
parent286663c34b006c1409df4a71f89d6d4d5d01df09 (diff)
downloadglibc-130ac68ca25c9aa65e027e3e37337bc048205c69.zip
glibc-130ac68ca25c9aa65e027e3e37337bc048205c69.tar.gz
glibc-130ac68ca25c9aa65e027e3e37337bc048205c69.tar.bz2
Auto-generate libc-modules.h
Remove libc-modules.h from the tree and auto-generate it from soversions.i and the list of modules in the built-modules variable defined in Makeconfig. Macros generated have increasing numbered values, with built-modules having lower values starting from 1, following which a separator value LIBS_BEGIN is added and then finally the library names from soversions.i are appended to the list. This allows us to conveniently differentiate between the versioned libraries and other built modules, which is needed in errno.h and netdb.h to decide whether to use an internal symbol or an external one. Verified that generated code remains unchanged on x86_64. * Makeconfig (built-modules): List non-library modules to be built. (module-cppflags): Include libc-modules.h for everything except shlib-versions.v.i. (CPPFLAGS): Use it. (before-compile): Add libc-modules.h. ($(common-objpfx)libc-modules.h, $(common-objpfx)libc-modules.stmp): New targets. (common-generated): Add libc-modules.h and libc-modules.stmp. ($(common-objpfx)Versions.v.i): Depend on libc-modules.h. * include/libc-symbols.h: Don't include libc-modules.h. * include/libc-modules.h: Remove file. * scripts/gen-libc-modules.awk: New script to generate libc-modules.h. * sysdeps/unix/Makefile ($(common-objpfx)sysd-syscalls): Depend on libc-modules.stmp.
Diffstat (limited to 'Makeconfig')
-rw-r--r--Makeconfig40
1 files changed, 38 insertions, 2 deletions
diff --git a/Makeconfig b/Makeconfig
index 9f88f7c..1a26cc5 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -813,20 +813,39 @@ endif # $(+cflags) == ""
# of many little headers in the include directory.
libio-include = -I$(..)libio
+# List of non-library modules that we build.
+built-modules = iconvprogs iconvdata ldconfig lddlibc4 libmemusage \
+ libSegFault libpcprofile librpcsvc locale-programs \
+ memusagestat nonlib nscd extramodules libnldbl
+
+# We don't include libc-modules.h when these targets are being built. These
+# targets don't (and will likely never need to) use the IS_IN facility. In
+# fact, shlib-versions should not use it because that will create a circular
+# dependency as libc-modules.h is generated from shlib-versions.
+skip-module-cppflags = shlib-versions.v.i Versions.v.i
+
in-module = $(subst -,_,$(firstword $(libof-$(basename $(@F))) \
$(libof-$(<F)) \
$(libof-$(@F)) \
libc))
+module-cppflags-real = -include $(common-objpfx)libc-modules.h \
+ -DIN_MODULE=MODULE_$(in-module)
+
+# We don't need libc-modules.h and the IN_MODULE definition for
+# shlib-version.v.i.
+module-cppflags = $(if $(filter $(@F),$(skip-module-cppflags)), \
+ ,$(module-cppflags-real))
+
# These are the variables that the implicit compilation rules use.
# Note that we can't use -std=* in CPPFLAGS, because it overrides
# the implicit -lang-asm and breaks cpp behavior for .S files--notably
# it causes cpp to stop predefining __ASSEMBLER__.
CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
$($(subdir)-CPPFLAGS) \
- $(+includes) $(defines) \
+ $(+includes) $(defines) $(module-cppflags) \
-include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
- $(CPPFLAGS-$(suffix $@)) -DIN_MODULE=MODULE_$(in-module) \
+ $(CPPFLAGS-$(suffix $@)) \
$(foreach lib,$(libof-$(basename $(@F))) \
$(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
$(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F)))
@@ -986,6 +1005,23 @@ endif
postclean-generated += soversions.mk soversions.i \
shlib-versions.v shlib-versions.v.i
+before-compile += $(common-objpfx)libc-modules.h
+ifeq ($(soversions.mk-done),t)
+# Generate a header with macro definitions for use with the IS_IN macro.
+# These are the possible values for the IN_MODULE macro defined when building
+# sources, to identify which module the translation unit is going to be built
+# into.
+$(common-objpfx)libc-modules.h: $(common-objpfx)libc-modules.stmp; @:
+$(common-objpfx)libc-modules.stmp: $(..)scripts/gen-libc-modules.awk \
+ $(common-objpfx)soversions.i
+ $(AWK) -v buildlist="$(subst -,_,$(built-modules))" -f $^ > ${@:stmp=T}
+ $(move-if-change) ${@:stmp=T} ${@:stmp=h}
+ touch $@
+
+endif
+
+common-generated += libc-modules.h libc-modules.stmp
+
# The name under which the run-time dynamic linker is installed.
# We are currently going for the convention that `/lib/ld.so.1'
# names the SVR4/ELF ABI-compliant dynamic linker.