1130803Smarcel#!/bin/sh 2130803Smarcel# Create a symlink tree. 3130803Smarcel# 4130803Smarcel# Copyright (C) 1995, 2000, 2003 Free Software Foundation, Inc. 5130803Smarcel# 6130803Smarcel# This file is free software; you can redistribute it and/or modify 7130803Smarcel# it under the terms of the GNU General Public License as published by 8130803Smarcel# the Free Software Foundation; either version 2 of the License, or 9130803Smarcel# (at your option) any later version. 10130803Smarcel# 11130803Smarcel# This program is distributed in the hope that it will be useful, 12130803Smarcel# but WITHOUT ANY WARRANTY; without even the implied warranty of 13130803Smarcel# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14130803Smarcel# GNU General Public License for more details. 15130803Smarcel# 16130803Smarcel# You should have received a copy of the GNU General Public License 17130803Smarcel# along with this program; if not, write to the Free Software 18130803Smarcel# Foundation, Inc., 59 Temple Place - Suite 330, 19130803Smarcel# Boston, MA 02111-1307, USA. 20130803Smarcel# 21130803Smarcel# As a special exception to the GNU General Public License, if you 22130803Smarcel# distribute this file as part of a program that contains a 23130803Smarcel# configuration script generated by Autoconf, you may include it under 24130803Smarcel# the same distribution terms that you use for the rest of that program. 25130803Smarcel# 26130803Smarcel# Please report bugs to <gcc-bugs@gnu.org> 27130803Smarcel# and send patches to <gcc-patches@gnu.org>. 28130803Smarcel 29130803Smarcel# Syntax: symlink-tree srcdir "ignore1 ignore2 ..." 30130803Smarcel# 31130803Smarcel# where srcdir is the directory to create a symlink tree to, 32130803Smarcel# and "ignoreN" is a list of files/directories to ignore. 33130803Smarcel 34130803Smarcelprog=$0 35130803Smarcelsrcdir=$1 36130803Smarcelignore="$2" 37130803Smarcel 38130803Smarcelif test $# -lt 1; then 39130803Smarcel echo "symlink-tree error: Usage: symlink-tree srcdir \"ignore1 ignore2 ...\"" 40130803Smarcel exit 1 41130803Smarcelfi 42130803Smarcel 43130803Smarcelignore_additional=". .. CVS" 44130803Smarcel 45130803Smarcel# If we were invoked with a relative path name, adjust ${prog} to work 46130803Smarcel# in subdirs. 47130803Smarcelcase ${prog} in 48130803Smarcel/* | [A-Za-z]:[\\/]*) ;; 49130803Smarcel*) prog=../${prog} ;; 50130803Smarcelesac 51130803Smarcel 52130803Smarcel# Set newsrcdir to something subdirectories can use. 53130803Smarcelcase ${srcdir} in 54130803Smarcel/* | [A-Za-z]:[\\/]*) newsrcdir=${srcdir} ;; 55130803Smarcel*) newsrcdir=../${srcdir} ;; 56130803Smarcelesac 57130803Smarcel 58130803Smarcelfor f in `ls -a ${srcdir}`; do 59130803Smarcel if [ -d ${srcdir}/$f ]; then 60130803Smarcel found= 61130803Smarcel for i in ${ignore} ${ignore_additional}; do 62130803Smarcel if [ "$f" = "$i" ]; then 63130803Smarcel found=yes 64130803Smarcel fi 65130803Smarcel done 66130803Smarcel if [ -z "${found}" ]; then 67130803Smarcel echo "$f ..working in" 68130803Smarcel if [ -d $f ]; then true; else mkdir $f; fi 69130803Smarcel (cd $f; ${prog} ${newsrcdir}/$f "${ignore}") 70130803Smarcel fi 71130803Smarcel else 72130803Smarcel echo "$f ..linked" 73130803Smarcel rm -f $f 74130803Smarcel ln -s ${srcdir}/$f . 75130803Smarcel fi 76130803Smarceldone 77130803Smarcel 78130803Smarcelexit 0 79