diff src/mk-oct-links @ 5307:4c8a2e4e0717

[project @ 2005-04-26 19:24:27 by jwe]
author jwe
date Tue, 26 Apr 2005 19:24:47 +0000
parents 02fcb550f20c
children
line wrap: on
line diff
--- a/src/mk-oct-links	Tue Apr 26 14:41:40 2005 +0000
+++ b/src/mk-oct-links	Tue Apr 26 19:24:47 2005 +0000
@@ -3,7 +3,7 @@
 # Create additional links to .oct files that define more than one
 # function.
 
-# If the first arg is -p, only print the links we need to make.
+# If the first arg is --print, only print the links we need to make.
 
 # The first non-option arg is taken as the directory where the .oct
 # files are installed.  The remaining arguments should be the list of
@@ -13,32 +13,40 @@
 SED=${SED:-'sed'}
 
 print_only=false
-if [ $1 = "-p" ]; then
+delete_links=false
+if [ $1 = "--print" -o $1 = "-p" ]; then
   print_only=true
   shift
+elif [ $1 = "--delete" ]; then
+  delete_links=true
+  shift
 fi
 
 links_dir=$1
 shift
 
 for f in "$@"; do
-  base=`basename $f | $SED 's/\.df$//'`
-  fcns=`grep '^ *XDEFUN_DLD_INTERNAL' $f |\
-        $SED -e 's/XDEFUN_DLD_INTERNAL *( *//' -e 's/ *,.*$//' |\
-        sort -u`
-  if [ -n "$fcns" ]; then
-    for n in $fcns; do
-      if [ "$n" = "$base" ]; then
-        true
-      else
-        if $print_only; then
-          echo $base.oct $n.oct
-        else
-          echo "creating link $n.oct -> $base.oct"
-          ( cd $links_dir; rm -f $n.oct; ln $base.oct $n.oct )
-        fi
-      fi
-    done
+  if [ -f $f ]; then
+    base=`basename $f | $SED 's/\.df$//'`
+    fcns=`grep '^ *XDEFUN_DLD_INTERNAL' $f |\
+	  $SED -e 's/XDEFUN_DLD_INTERNAL *( *//' -e 's/ *,.*$//' |\
+	  sort -u`
+    if [ -n "$fcns" ]; then
+      for n in $fcns; do
+	if [ "$n" = "$base" ]; then
+	  true
+	else
+	  if $print_only; then
+	    echo $base.oct $n.oct
+	  elif $delete_links; then
+	    rm -f $links_dir/$n.oct
+	  else
+	    echo "creating link $n.oct -> $base.oct"
+	    ( cd $links_dir; rm -f $n.oct; ln $base.oct $n.oct )
+	  fi
+	fi
+      done
+    fi
   fi
 done