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