From 130ac68ca25c9aa65e027e3e37337bc048205c69 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Wed, 19 Nov 2014 12:16:00 +0530 Subject: 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. --- scripts/gen-libc-modules.awk | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 scripts/gen-libc-modules.awk (limited to 'scripts') diff --git a/scripts/gen-libc-modules.awk b/scripts/gen-libc-modules.awk new file mode 100644 index 0000000000..2f92cd41b2 --- /dev/null +++ b/scripts/gen-libc-modules.awk @@ -0,0 +1,34 @@ +# Generate a header file that defines the MODULE_* macros for each library and +# module we build in glibc. The library names are pulled in from soversions.i +# and the additional modules are passed in the BUILDLIST variable. +BEGIN { + # BUILDLIST is set from the build-list variable in Makeconfig and is a space + # separated list of non-library modules that we build in glibc. + num = split (buildlist, libs, " ") + # Separate the built modules from the libraries. + libs[++num] = "LIBS_BEGIN" +} + +# Skip over comments. +$1 == "#" { + next +} + +# We have only one special case in soversions.i parsing, which is to replace ld +# with rtld since that's what we call it throughout the sources. +match (FILENAME, ".*soversions.i") { + name = $2 + if (name == "ld") + name = "rtld" + + # Library names are not duplicated in soversions.i. + libs[++num] = name +} + +# Finally, print out the header file. +END { + printf ("/* AUTOGENERATED BY gen-libc-modules.awk, DO NOT EDIT. */\n\n") + for (l in libs) { + printf ("#define MODULE_%s %d\n", libs[l], l) + } +} -- cgit 1.4.1