From fb8319e852939509e8a321d2ceb030b2783b8f01 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 27 Oct 2005 07:02:06 +0000 Subject: Rename depfix2.pl to depfix.pl git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17459 dc483132-0cff-0310-8789-dd5450dbe970 --- src/config/ChangeLog | 3 +- src/config/post.in | 4 +- src/util/ChangeLog | 3 +- src/util/depfix.pl | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/util/depfix2.pl | 168 --------------------------------------------------- 5 files changed, 174 insertions(+), 172 deletions(-) create mode 100644 src/util/depfix.pl delete mode 100644 src/util/depfix2.pl (limited to 'src') diff --git a/src/config/ChangeLog b/src/config/ChangeLog index 1faba7cdb..43609e070 100644 --- a/src/config/ChangeLog +++ b/src/config/ChangeLog @@ -1,6 +1,7 @@ 2005-10-27 Ken Raeburn - * post.in (.depend): Don't run sed, just use perl. + * post.in (.depend): Don't run sed, just use perl. Use new name + of perl script. * shlib.conf: Set DYNOBJ_EXPDEPS and DYNOBJ_EXPFLAGS. (*-*-darwin*): Change MAKE_DYNOBJ_COMMAND definition to use diff --git a/src/config/post.in b/src/config/post.in index 76cf59910..1811a8d23 100644 --- a/src/config/post.in +++ b/src/config/post.in @@ -82,9 +82,9 @@ depend-dependencies: # NOTE: This will also generate spurious $(OUTPRE) and $(OBJEXT) # references in rules for non-library objects in a directory where # library objects happen to be built. It's mostly harmless. -.depend: .d $(SRCTOP)/util/depfix.sed $(SRCTOP)/util/depfix2.pl +.depend: .d $(SRCTOP)/util/depfix.sed $(SRCTOP)/util/depfix.pl x=`$(CC) -print-libgcc-file-name` ; \ - perl $(SRCTOP)/util/depfix2.pl \ + perl $(SRCTOP)/util/depfix.pl \ '$(SRCTOP)' '$(myfulldir)' '$(srcdir)' '$(BUILDTOP)' "$$x" '$(STLIBOBJS)' \ < .d > .depend diff --git a/src/util/ChangeLog b/src/util/ChangeLog index 3f1f287d3..0ed9ca291 100644 --- a/src/util/ChangeLog +++ b/src/util/ChangeLog @@ -1,6 +1,7 @@ 2005-10-27 Ken Raeburn - * depfix2.pl: Incorporate all substitutions from depfix.sed. + * depfix.pl: Rename from depfix2.pl, and incorporate all + substitutions from depfix.sed. * depfix.sed: Deleted. 2005-10-25 Tom Yu diff --git a/src/util/depfix.pl b/src/util/depfix.pl new file mode 100644 index 000000000..b17bf9fc2 --- /dev/null +++ b/src/util/depfix.pl @@ -0,0 +1,168 @@ +#!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 $_; +} + +sub do_subs_2 { + local($_) = @_; + # Add a trailing space. + s/$/ /; + # Remove excess spaces. + s/ */ /g; + # Delete Tcl-specific headers. + s;/[^ ]*/tcl\.h ;;g; + s;/[^ ]*/tclDecls\.h ;;g; + s;/[^ ]*/tclPlatDecls\.h ;;g; + # Delete system-specific or compiler-specific files. + s;/os/usr/include/[^ ]* ;;g; + s;/usr/include/[^ ]* ;;g; + s;/usr/lib/[^ ]* ;;g; + # Remove foo/../ sequences. + while (m/\/[a-z][a-z0-9_.\-]*\/\.\.\//) { + s//\//g; + } + # Use VPATH. + s;\$\(srcdir\)/([^ /]* );$1;g; + + # Allow override of some util dependencies in case local tools are used. + s;\$\(BUILDTOP\)/include/com_err.h ;\$(COM_ERR_DEPS) ;g; + s;\$\(BUILDTOP\)/include/ss/ss.h \$\(BUILDTOP\)/include/ss/ss_err.h ;\$(SS_DEPS) ;g; + s;\$\(BUILDTOP\)/include/db.h \$\(BUILDTOP\)/include/db-config.h ;\$(DB_DEPS) ;g; + + # Some krb4 dependencies should only be present if building with krb4 + # enabled. + s;\$\(BUILDTOP\)/include/kerberosIV/krb_err.h ;\$(KRB_ERR_H_DEP) ;g; + + # Delete trailing whitespace. + s; *$;;g; + + return $_; +} + +sub split_lines { + local($_) = @_; + s/(.{50}[^ ]*) /$1 \\\n /g; + return $_ . "\n"; +} + +print <) { + # Strip newline. + chop; + # Do directory-specific path substitutions on each filename read. + $_ = &do_subs($_); + if (m/\\$/) { + chop; + $buf .= $_; + } else { + $buf = &do_subs_2($buf . $_); + print &split_lines($buf); + $buf = ''; + } +} +exit 0; diff --git a/src/util/depfix2.pl b/src/util/depfix2.pl deleted file mode 100644 index b17bf9fc2..000000000 --- a/src/util/depfix2.pl +++ /dev/null @@ -1,168 +0,0 @@ -#!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 $_; -} - -sub do_subs_2 { - local($_) = @_; - # Add a trailing space. - s/$/ /; - # Remove excess spaces. - s/ */ /g; - # Delete Tcl-specific headers. - s;/[^ ]*/tcl\.h ;;g; - s;/[^ ]*/tclDecls\.h ;;g; - s;/[^ ]*/tclPlatDecls\.h ;;g; - # Delete system-specific or compiler-specific files. - s;/os/usr/include/[^ ]* ;;g; - s;/usr/include/[^ ]* ;;g; - s;/usr/lib/[^ ]* ;;g; - # Remove foo/../ sequences. - while (m/\/[a-z][a-z0-9_.\-]*\/\.\.\//) { - s//\//g; - } - # Use VPATH. - s;\$\(srcdir\)/([^ /]* );$1;g; - - # Allow override of some util dependencies in case local tools are used. - s;\$\(BUILDTOP\)/include/com_err.h ;\$(COM_ERR_DEPS) ;g; - s;\$\(BUILDTOP\)/include/ss/ss.h \$\(BUILDTOP\)/include/ss/ss_err.h ;\$(SS_DEPS) ;g; - s;\$\(BUILDTOP\)/include/db.h \$\(BUILDTOP\)/include/db-config.h ;\$(DB_DEPS) ;g; - - # Some krb4 dependencies should only be present if building with krb4 - # enabled. - s;\$\(BUILDTOP\)/include/kerberosIV/krb_err.h ;\$(KRB_ERR_H_DEP) ;g; - - # Delete trailing whitespace. - s; *$;;g; - - return $_; -} - -sub split_lines { - local($_) = @_; - s/(.{50}[^ ]*) /$1 \\\n /g; - return $_ . "\n"; -} - -print <) { - # Strip newline. - chop; - # Do directory-specific path substitutions on each filename read. - $_ = &do_subs($_); - if (m/\\$/) { - chop; - $buf .= $_; - } else { - $buf = &do_subs_2($buf . $_); - print &split_lines($buf); - $buf = ''; - } -} -exit 0; -- cgit