view src/mk-oct-links @ 4220:c20a1e67cef6

[project @ 2002-12-06 22:18:54 by jwe]
author jwe
date Fri, 06 Dec 2002 22:18:55 +0000
parents b908aaa4080a
children 02fcb550f20c
line wrap: on
line source

#! /bin/sh -e

# 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.

# The first non-option arg is taken as the directory where the .oct
# files are installed.  The remaining arguments should be the list of
# .df files corresponding to the source files that were used to
# create the .oct files.

print_only=false
if [ $1 = "-p" ]; then
  print_only=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
  fi
done

exit $?