summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/symlink-tree
blob: bd35f8f6401cb73c478eb2d140432e45ae74cfe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# Create a symlink tree.
#
# Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
#
# where srcdir is the directory to create a symlink tree to,
# and "ignoreN" is a list of files/directories to ignore.

prog=$0
srcdir=$1
ignore="$2"

ignore_additional=". .. CVS"

# If we were invoked with a relative path name, adjust ${prog} to work
# in subdirs.
case ${prog} in
/*) ;;
*) prog=../${prog} ;;
esac

# Set newsrcdir to something subdirectories can use.
case ${srcdir} in
/*) newsrcdir=${srcdir} ;;
*) newsrcdir=../${srcdir} ;;
esac

for f in `ls -a ${srcdir}`; do
  if [ -d ${srcdir}/$f ]; then
    found=
    for i in ${ignore} ${ignore_additional}; do
      if [ "$f" = "$i" ]; then
	found=yes
      fi
    done
    if [ -z "${found}" ]; then
      if [ -d $f ]; then true; else mkdir $f; fi
      (cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
    fi
  else
    rm -f $f
    ln -s ${srcdir}/$f .
  fi
done

exit 0