view src/mk-pkg-add @ 5540:cda6a105ae9a before-ov-branch

[project @ 2005-11-17 05:47:13 by jwe]
author jwe
date Thu, 17 Nov 2005 05:47:13 +0000
parents b800ae36fc6a
children d090d39bb82c
line wrap: on
line source

#! /bin/sh -e

SED=${SED:-'sed'}

install=false
if [ $1 = "--prefix" ]; then
  shift
  prefix="$1"
  shift
elif [ $1 = "--install" ]; then
  install=true
  shift
fi

if [ $# -gt 0 ]; then
  if $install; then
    cat <<EOF
__octfiledir__ = strrep (octave_config_info ("octfiledir"),
                         octave_config_info ("prefix"),
                         OCTAVE_HOME);
EOF
  fi
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\", strcat (\"$prefix\", filesep, \"$base.oct\"));"
          elif $install; then
            echo "autoload (\"$n\", strcat (__octfiledir__, filesep, \"$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 $?