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