view src/mk-pkg-add @ 5534:e107161b8ca3

[project @ 2005-11-11 17:44:05 by jwe]
author jwe
date Fri, 11 Nov 2005 17:45:51 +0000
parents
children b800ae36fc6a
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 --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
# .df files corresponding to the source files that were used to
# create the .oct files.

SED=${SED:-'sed'}

if [ $1 = "--prefix" ]; then
  shift
  prefix="$1"
  shift
fi

for f in "$@"; do
  if [ -f $f ]; then

    ## Compute and print the autoloads.
  
    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 [ -n "$prefix" ]; then
	    echo "autoload (\"$n\", \"$prefix/$base.oct\");"
	  else
	    echo "autoload (\"$n\", \"$base.oct\");"
	  fi
	fi
      done
    fi

    ## Process PKG_ADD directives after autoloads so that all
    ## necessary functions can be found before they are used.

    $SED -n -e 's,^//* *PKG_ADD: *,,p' \
            -e 's,^/\* *PKG_ADD: *\(.*\) *\*/ *$,\1,p' $f

  fi
done

exit $?