summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2005-04-21 21:44:37 +0000
committerKen Raeburn <raeburn@mit.edu>2005-04-21 21:44:37 +0000
commitddbc9d85baab7fc1698e215afee7d3970065cfc3 (patch)
tree0c0c8d4b30043753ffe14cb32e5b4859048c58b4 /src/util
parent455cef6a7e8ec4bac9301748b818bf2ed47bee00 (diff)
downloadkrb5-ddbc9d85baab7fc1698e215afee7d3970065cfc3.tar.gz
krb5-ddbc9d85baab7fc1698e215afee7d3970065cfc3.tar.xz
krb5-ddbc9d85baab7fc1698e215afee7d3970065cfc3.zip
Stop generating per-directory sed scripts, and use perl to compute the patterns
on the fly instead. (Next step, someday, integrate this script and depfix.sed, so we only have to run one script.) * config/post.in (depend-dependencies): Use (and depend on) depfix2.pl instead of .depfix2.sed. (.depfix2.sed): Target deleted. (DEPTARGETS): Delete .depfix2.sed and .depfix2.tmp. * util/depgen.sed: Deleted. * util/depfix2.pl: New file. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17187 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util')
-rw-r--r--src/util/ChangeLog5
-rw-r--r--src/util/depfix2.pl108
-rw-r--r--src/util/depgen.sed141
3 files changed, 113 insertions, 141 deletions
diff --git a/src/util/ChangeLog b/src/util/ChangeLog
index 5454b176d..0af5b4fa2 100644
--- a/src/util/ChangeLog
+++ b/src/util/ChangeLog
@@ -1,3 +1,8 @@
+2005-04-21 Ken Raeburn <raeburn@mit.edu>
+
+ * depgen.sed: Deleted.
+ * depfix2.pl: New file.
+
2005-04-20 Ken Raeburn <raeburn@mit.edu>
* depgen.sed: Delete faulty check for $(srcdir), and redundant
diff --git a/src/util/depfix2.pl b/src/util/depfix2.pl
new file mode 100644
index 000000000..0e11b0fde
--- /dev/null
+++ b/src/util/depfix2.pl
@@ -0,0 +1,108 @@
+#!env perl -w
+eval 'exec perl -S $0 ${1+"$@"}'
+ if 0;
+$0 =~ s/^.*?(\w+)[\.\w+]*$/$1/;
+
+# Input: srctop thisdir srcdir buildtop libgccfilename stlibobjs
+
+# Notes: myrelativedir is something like "lib/krb5/asn.1" or ".".
+# stlibobjs will usually be empty, or include spaces.
+
+# A typical set of inputs, produced with srcdir=.. at top level:
+#
+# SRCTOP = ../../../util/et/../..
+# thisdir = util/et
+# srcdir = ../../../util/et
+# BUILDTOP = ../..
+# libgcc file name = /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/libgcc.a
+# STLIBOBJS = error_message.o et_name.o com_err.o
+
+my($SRCTOP,$thisdir,$srcdir,$BUILDTOP,$libgccpath,$STLIBOBJS) = @ARGV;
+
+if (0) {
+ print STDERR "SRCTOP = $SRCTOP\n";
+ print STDERR "BUILDTOP = $BUILDTOP\n";
+ print STDERR "STLIBOBJS = $STLIBOBJS\n";
+}
+
+$libgccincdir = $libgccpath;
+$libgccincdir =~ s,libgcc\.[^ ]*$,include,;
+$libgccincdir = quotemeta($libgccincdir);
+#$srcdirpat = quotemeta($srcdir);
+
+sub my_qm {
+ my($x) = @_;
+ $x = quotemeta($x);
+ $x =~ s,\\/,/,g;
+ return $x;
+}
+
+sub strrep {
+ my($old,$new,$s) = @_;
+ my($l) = "strrep('$old','$new','$s')";
+ my($out) = "";
+ while ($s ne "") {
+ my($i) = index($s, $old);
+ if ($i == -1) {
+ $out .= $s;
+ $s = "";
+ } else {
+ $out .= substr($s, 0, $i) . $new;
+ if (length($s) > $i + length($old)) {
+ $s = substr($s, $i + length($old));
+ } else {
+ $s = "";
+ }
+ }
+ }
+# print STDERR "$l = '$out'\n";
+ return $out;
+}
+
+sub do_subs {
+ local($_) = @_;
+ s,\\$, \\,g; s, + \\$, \\,g;
+ s,//+,/,g; s, \\./, ,g;
+ if ($STLIBOBJS ne "") {
+ # Only care about the additional prefixes if we're building
+ # shared libraries.
+ s,^([a-zA-Z0-9_\-]*)\.o:,$1.so $1.po \$(OUTPRE)$1.\$(OBJEXT):,;
+ } else {
+ s,^([a-zA-Z0-9_\-]*)\.o:,\$(OUTPRE)$1.\$(OBJEXT):,;
+ }
+ # Drop GCC include files, they're basically system headers.
+ s,$libgccincdir/[^ ]* ,,go;
+ s,$libgccincdir/[^ ]*$,,go;
+ # Recognize $(SRCTOP) and variants.
+ my($srct) = $SRCTOP . "/";
+ $_ = strrep(" $srct", " \$(SRCTOP)/", $_);
+# s, $pat, \$(SRCTOP)/,go;
+ while ($srct =~ m,/[a-z][a-zA-Z0-9_.\-]*/\.\./,) {
+ $srct =~ s,/[a-z][a-zA-Z0-9_.\-]*/\.\./,/,;
+ $_ = strrep(" $srct", " \$(SRCTOP)/", $_);
+ }
+ # Now try to produce pathnames relative to $(srcdir).
+ if ($thisdir eq ".") {
+ # blah
+ } else {
+ my($pat) = " \$(SRCTOP)/$thisdir/";
+ my($out) = " \$(srcdir)/";
+ $_ = strrep($pat, $out, $_);
+ while ($pat =~ m,/[a-z][a-zA-Z0-9_.\-]*/$,) {
+ $pat =~ s,/[a-z][a-zA-Z0-9_.\-]*/$,/,;
+ $out .= "../";
+ if ($pat ne " \$(SRCTOP)/") {
+ $_ = strrep($pat, $out, $_);
+ }
+ }
+ }
+ # Now substitute for BUILDTOP:
+ $_ = strrep(" $BUILDTOP/", " \$(BUILDTOP)/", $_);
+ return $_;
+}
+
+while (<STDIN>) {
+ chop;
+ print &do_subs($_), "\n";
+}
+exit 0;
diff --git a/src/util/depgen.sed b/src/util/depgen.sed
deleted file mode 100644
index 29bc986bd..000000000
--- a/src/util/depgen.sed
+++ /dev/null
@@ -1,141 +0,0 @@
-# input srctop myfulldir srcdir buildtop libgccfilename stlibobjs
-# something like ../../../../asrc/lib/krb5/asn.1/../../../ lib/krb5/asn.1
-#
-# output a sequence of sed commands for recognizing and replacing srctop,
-# something like:
-# s; ../../../../asrc/lib/krb5/asn.1/../../../; $(SRCTOP)/;g
-# s; ../../../../asrc/lib/krb5/../../; $(SRCTOP)/;g
-# s; ../../../../asrc/lib/../; $(SRCTOP)/;g
-# s; ../../../../asrc/; $(SRCTOP)/;g
-# s; $(SRCTOP)/lib/krb5/asn.1/; $(srcdir)/;g
-# s; $(SRCTOP)/lib/krb5/; $(srcdir)/../;g
-# ...
-
-# Notes:
-# Keep "s..." and "p" commands on separate lines. The "s///p" form is
-# supposed to print the result if a substitution is done. When we
-# then alter the pattern space and print other stuff, the IRIX sed
-# seems to omit some of the earlier intended output. I think we're
-# always doing the substitutions anyways, so always printing should be
-# fine.
-#
-# STLIBOBJS will usually be empty, or include spaces.
-
-
-# Output some mostly-fixed patterns first
-h
-s|^\([^ ]*\) \([^ ]*\) \([^ ]*\) \([^ ]*\) \([^ ]*\) \(.*\)$|# This file is automatically generated by depgen.sed, do not edit it.\
-#\
-# Parameters used to generate this instance:\
-#\
-# SRCTOP = \1\
-# thisdir = \2\
-# srcdir = \3\
-# BUILDTOP = \4\
-# libgcc file name = \5\
-# STLIBOBJS = \6\
-#\
-\
-# First, remove redundant leading "//" and "./" ...\
-s;///*;/;g\
-s; \\./; ;g\
-\
-# change foo.o -> $(OUTPRE)foo.$(OBJEXT)\
-s;^\\([a-zA-Z0-9_\\-]*\\).o:;$(OUTPRE)\\1.$(OBJEXT):;|
-p
-x
-
-# If the STLIBOBJS argument is not empty, emit a pattern to
-# change the target name into $(OUTPRE)foo.$(OBJEXT) foo.so foo.po.
-h
-s|^[^ ]* [^ ]* [^ ]* [^ ]* [^ ]* ||
-s|^..*$|\
-# Fix up target name for the various different objects we might build.\
-s;^\\\$(OUTPRE)\\([a-zA-Z0-9_\\-]*\\)\\.\\\$(OBJEXT):;\\1.so \\1.po \&;|
-p
-x
-
-# Now throw away STLIBOBJS, we don't need it any more.
-s|^\([^ ]* [^ ]* [^ ]* [^ ]* [^ ]*\) .*$|\1|
-
-h
-s|^[^ ]* [^ ]* [^ ]* [^ ]* ||
-s|libgcc\.[^ ]*$|include|
-s|\.|\\.|g
-s|\([^ ][^ ]*\)|\
-# Remove gcc's include files resulting from "fixincludes";\
-# they're essentially system include files.\
-s;\1/[^ ]* ;;g\
-s;\1/[^ ]*$;;g\
-\
-# Recognize $(SRCTOP) and variants.|
-p
-x
-
-# Drop the last (possibly empty?) word, gcc's prefix. Then save four words.
-s, [^ ]*$,,
-h
-
-# just process first "word"
-s/ .*$//
-# replace multiple slashes with one single one
-s,///*,/,g
-# replace /./ with /
-s,/\./,/,g
-# strip trailing slashes, but not if it'd leave the string empty
-s,\(..*\)///*,\1/,
-# quote dots
-s,\.,\\.,g
-# turn string into sed pattern
-s,^,s; ,
-s,$,/; $(SRCTOP)/;g,
-# emit potentially multiple patterns
-:loop
-/\/[a-z][a-zA-Z0-9_.\-]*\/\\\.\\\.\// {
-p
-s;/[a-z][a-zA-Z0-9_.\-]*/\\\.\\\./;/;
-bloop
-}
-p
-
-x
-h
-s|^.*$|\
-# Now try to produce pathnames relative to $(srcdir).|
-p
-
-# now process second "word"
-x
-h
-s/^[^ ]* //
-s/ [^ ]* [^ ]*$//
-
-# treat "." specially
-/^\.$/{
-d
-q
-}
-# make sed pattern
-s,^,s; $(SRCTOP)/,
-s,$,/; $(srcdir)/;g,
-# emit potentially multiple patterns
-:loop2
-\,[^/)]/; , {
-p
-# strip trailing dirname off first part; append "../" to second part
-s,/[a-z][a-zA-Z0-9_.\-]*/; ,/; ,
-s,/;g,/\.\./;g,
-bloop2
-}
-
-x
-s/^[^ ]* [^ ]* [^ ]* //
-s/\./\\./g
-s|^\(.*\)$|\
-# Now substitute for BUILDTOP:\
-s; \1/; $(BUILDTOP)/;g|
-p
-
-# kill implicit print at end; don't change $(SRCTOP) into .. sequence
-s/^.*$/\
-# end of sed code generated by depgen.sed/