1#!/bin/sh
2
3fndir=$DESTDIR$fndir
4scriptdir=$DESTDIR$scriptdir
5
6/bin/sh $sdir_top/mkinstalldirs $fndir || exit 1;
7
8allfuncs="`grep ' functions=.' ${dir_top}/config.modules |
9  sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`"
10
11allfuncs="`cd $sdir_top; echo ${allfuncs}`"
12
13test -d installfnsdir || mkdir installfnsdir
14
15# We now have a list of files, but we need to use `test -f' to check
16# (1) the glob got expanded (2) we are not looking at directories.
17for file in $allfuncs; do
18  if test -f $sdir_top/$file; then
19    case "$file" in
20      */CVS/*) continue;;
21    esac
22    if test x$FUNCTIONS_SUBDIRS != x && test x$FUNCTIONS_SUBDIRS != xno; then
23      case "$file" in
24      Completion/*/*)
25        subdir="`echo $file | sed -e 's%/[^/]*/[^/]*$%%'`"
26        instdir="$fndir/$subdir"
27        ;;
28      Completion/*)
29        instdir="$fndir/Completion"
30        ;;
31      Scripts/*)
32        instdir="$scriptdir"
33	;;
34      *)
35        subdir="`echo $file | sed -e 's%/[^/]*$%%' -e 's%^Functions/%%'`"
36        instdir="$fndir/$subdir"
37        ;;
38      esac
39    else
40      case "$file" in
41      Scripts/*)
42        instdir="$scriptdir"
43	;;
44      *)
45        instdir="$fndir"
46        ;;
47      esac
48    fi
49    basename=`basename $file`
50    ok=0
51    if test -d $instdir || /bin/sh $sdir_top/mkinstalldirs $instdir; then
52      if sed "s|@runhelpdir@|$runhelpdir|" <$sdir_top/$file \
53        >installfnsdir/$basename; then
54	if $INSTALL_DATA installfnsdir/$basename $instdir; then
55	  ok=1
56	fi
57      fi
58    fi
59    case $ok in
60      0)
61      rm -rf installfnsdir
62      exit 1
63      ;;
64    esac
65    read line < $sdir_top/$file
66    case "$line" in
67      '#!'*)
68      chmod +x $instdir/`echo $file | sed -e 's%^.*/%%'`
69      ;;
70    esac
71  fi
72done
73
74rm -rf installfnsdir
75