symlink-tree revision 1.1 1 1.1 mrg #!/bin/sh
2 1.1 mrg # Create a symlink tree.
3 1.1 mrg #
4 1.1 mrg # Copyright (C) 1995, 2000, 2003 Free Software Foundation, Inc.
5 1.1 mrg #
6 1.1 mrg # This file is free software; you can redistribute it and/or modify
7 1.1 mrg # it under the terms of the GNU General Public License as published by
8 1.1 mrg # the Free Software Foundation; either version 2 of the License, or
9 1.1 mrg # (at your option) any later version.
10 1.1 mrg #
11 1.1 mrg # This program is distributed in the hope that it will be useful,
12 1.1 mrg # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 1.1 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 1.1 mrg # GNU General Public License for more details.
15 1.1 mrg #
16 1.1 mrg # You should have received a copy of the GNU General Public License
17 1.1 mrg # along with this program; if not, write to the Free Software
18 1.1 mrg # Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 1.1 mrg # Boston, MA 02110-1301, USA.
20 1.1 mrg #
21 1.1 mrg # As a special exception to the GNU General Public License, if you
22 1.1 mrg # distribute this file as part of a program that contains a
23 1.1 mrg # configuration script generated by Autoconf, you may include it under
24 1.1 mrg # the same distribution terms that you use for the rest of that program.
25 1.1 mrg #
26 1.1 mrg # Please report bugs to <gcc-bugs (at] gnu.org>
27 1.1 mrg # and send patches to <gcc-patches (at] gnu.org>.
28 1.1 mrg
29 1.1 mrg # Syntax: symlink-tree srcdir "ignore1 ignore2 ..."
30 1.1 mrg #
31 1.1 mrg # where srcdir is the directory to create a symlink tree to,
32 1.1 mrg # and "ignoreN" is a list of files/directories to ignore.
33 1.1 mrg
34 1.1 mrg prog=$0
35 1.1 mrg srcdir=$1
36 1.1 mrg ignore="$2"
37 1.1 mrg
38 1.1 mrg if test $# -lt 1; then
39 1.1 mrg echo "symlink-tree error: Usage: symlink-tree srcdir \"ignore1 ignore2 ...\""
40 1.1 mrg exit 1
41 1.1 mrg fi
42 1.1 mrg
43 1.1 mrg ignore_additional=". .. CVS"
44 1.1 mrg
45 1.1 mrg # If we were invoked with a relative path name, adjust ${prog} to work
46 1.1 mrg # in subdirs.
47 1.1 mrg case ${prog} in
48 1.1 mrg /* | [A-Za-z]:[\\/]*) ;;
49 1.1 mrg *) prog=../${prog} ;;
50 1.1 mrg esac
51 1.1 mrg
52 1.1 mrg # Set newsrcdir to something subdirectories can use.
53 1.1 mrg case ${srcdir} in
54 1.1 mrg /* | [A-Za-z]:[\\/]*) newsrcdir=${srcdir} ;;
55 1.1 mrg *) newsrcdir=../${srcdir} ;;
56 1.1 mrg esac
57 1.1 mrg
58 1.1 mrg for f in `ls -a ${srcdir}`; do
59 1.1 mrg if [ -d ${srcdir}/$f ]; then
60 1.1 mrg found=
61 1.1 mrg for i in ${ignore} ${ignore_additional}; do
62 1.1 mrg if [ "$f" = "$i" ]; then
63 1.1 mrg found=yes
64 1.1 mrg fi
65 1.1 mrg done
66 1.1 mrg if [ -z "${found}" ]; then
67 1.1 mrg echo "$f ..working in"
68 1.1 mrg if [ -d $f ]; then true; else mkdir $f; fi
69 1.1 mrg (cd $f; ${prog} ${newsrcdir}/$f "${ignore}")
70 1.1 mrg fi
71 1.1 mrg else
72 1.1 mrg echo "$f ..linked"
73 1.1 mrg rm -f $f
74 1.1 mrg ln -s ${srcdir}/$f .
75 1.1 mrg fi
76 1.1 mrg done
77 1.1 mrg
78 1.1 mrg exit 0
79