This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 2/2 roland/sysd-rules] Sort sysd-rules-patterns by descending pattern length.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Thu, 13 Jun 2013 14:44:40 -0700 (PDT)
- Subject: [PATCH 2/2 roland/sysd-rules] Sort sysd-rules-patterns by descending pattern length.
- References: <20130613213642 dot F2A482C09D at topped-with-meat dot com>
This fixes the build for x86_64-linux-gnu using make versions before 3.82.
The chief effect is that within each sysdeps directory's section of
sysd-rules, all the rtld-%.os rules come before all the %.os rules now.
The awk script now requires gawk-3.1.2 or better, so the configure check
and manual section are updated to say so. If anybody thinks this is a
severe problem (we required gawk-3.0 before), we can rework it to be
compatible with gawk-3.0.
If nobody cries bloody murder by Monday, I'll merge this as it is.
Thanks,
Roland
* scripts/sysd-rules.awk: Sort sysd_rules_patterns by descending
length of target pattern, then descending length of dependency pattern.
* configure.in (AWK): Require gawk 3.1.2 or newer.
* manual/install.texi (Tools for Compilation): Say that we do.
* configure: Regenerated.
--- a/configure
+++ b/configure
@@ -4993,7 +4993,7 @@ $as_echo_n "checking version of $AWK... " >&6; }
ac_prog_version=`$AWK --version 2>&1 | sed -n 's/^.*GNU Awk[^0-9]*\([0-9][0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
- [3-9].*)
+ 3.1.[2-9]*|3.[2-9]*|[4-9]*)
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
--- a/configure.in
+++ b/configure.in
@@ -986,7 +986,7 @@ AC_CHECK_PROG_VER(SED, sed, --version,
SED=: aux_missing="$aux_missing sed")
AC_CHECK_PROG_VER(AWK, gawk, --version,
[GNU Awk[^0-9]*\([0-9][0-9.]*\)],
- [[3-9].*], critic_missing="$critic_missing gawk")
+ [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
AC_CHECK_TOOL(NM, nm, false)
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -379,10 +379,11 @@ understand all the tags used in the document, and the installation
mechanism for the info files is not present or works differently.
@item
-GNU @code{awk} 3.0, or higher
+GNU @code{awk} 3.1.2, or higher
-@code{Awk} is used in several places to generate files.
-@code{gawk} 3.0 is known to work.
+@code{awk} is used in several places to generate files.
+Some @code{gawk} extensions are used, including the @code{asorti}
+function, which was introduced in version 3.1.2 of @code{gawk}.
@item
Perl 5
--- a/scripts/sysd-rules.awk
+++ b/scripts/sysd-rules.awk
@@ -14,6 +14,25 @@ BEGIN {
nsysdirs = split(config_sysdirs, sysdirs);
npatterns = split(sysd_rules_patterns, patterns);
+ # Each element of $(sysd-rules-patterns) is a pair TARGET:DEP.
+ # They are no in particular order. We need to sort them so that
+ # the longest TARGET is first, and, among elements with the same
+ # TARGET, the longest DEP is first.
+ for (i = 1; i <= npatterns; ++i) {
+ if (split(patterns[i], td, ":") != 2) {
+ msg = "bad sysd-rules-patterns element '" patterns[i] "'";
+ print msg > "/dev/stderr";
+ exit 2;
+ }
+ target_order = sprintf("%09d", npatterns + 1 - length(td[1]));
+ dep_order = sprintf("%09d", npatterns - length(td[2]));
+ sort_patterns[target_order SUBSEP dep_order] = patterns[i];
+ }
+ asorti(sort_patterns, map_patterns);
+ for (i in map_patterns) {
+ patterns[i] = sort_patterns[map_patterns[i]];
+ }
+
for (sysdir_idx = 1; sysdir_idx <= nsysdirs; ++sysdir_idx) {
dir = sysdirs[sysdir_idx];
if (dir !~ /^\//) dir = "$(..)" dir;
@@ -28,10 +47,7 @@ BEGIN {
o = suffixes[suffix_idx];
for (pattern_idx = 1; pattern_idx <= npatterns; ++pattern_idx) {
pattern = patterns[pattern_idx];
- if (split(pattern, td, ":") != 2) {
- print "bad sysd-rules-patterns element '" pattern "'" > "/dev/stderr";
- exit 2;
- }
+ split(pattern, td, ":");
target_pattern = td[1];
dep_pattern = td[2];
if (target_pattern == "%") {