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