]> granicus.if.org Git - imagemagick/blob - config/lndir.sh
Removed object file and modified .gitignore
[imagemagick] / config / lndir.sh
1 #! /bin/sh
2
3 # lndir - create shadow link tree
4 #
5 # Time stamp <89/11/28 18:56:54 gildea>
6 # By Stephen Gildea <gildea@bbn.com> based on
7 #  XConsortium: lndir.sh,v 1.1 88/10/20 17:37:16 jim Exp
8 #
9 # Modified slightly for ImageMagick by Bob Friesenhahn, 1999
10 #
11 # Used to create a copy of the a directory tree that has links for all
12 # non- directories.  If you are building the distribution on more than
13 # one machine, you should use this script.
14 #
15 # If your master sources are located in /usr/local/src/X and you would like
16 # your link tree to be in /usr/local/src/new-X, do the following:
17 #
18 #       %  mkdir /usr/local/src/new-X
19 #       %  cd /usr/local/src/new-X
20 #       %  lndir ../X
21 #
22 # Note: does not link files beginning with "."  Is this a bug or a feature?
23 #
24 # Improvements over R3 version:
25 #   Allows the fromdir to be relative: usually you want to say "../dist"
26 #   The name is relative to the todir, not the current directory.
27 #
28 # Bugs in R3 version fixed:
29 #   Do "pwd" command *after* "cd $DIRTO".
30 #   Don't try to link directories, avoiding error message "<dir> exists".
31 #   Barf with Usage message if either DIRFROM *or* DIRTO is not a directory.
32
33 USAGE="Usage: $0 fromdir [todir]"
34
35 if [ $# -lt 1 -o $# -gt 2 ]
36 then
37     echo "$USAGE"
38     exit 1
39 fi
40
41 DIRFROM=$1
42
43 if [ $# -eq 2 ];
44 then
45     DIRTO=$2
46 else
47     DIRTO=.
48 fi
49
50 if [ ! -d $DIRTO ]
51 then
52     echo "$0: $DIRTO is not a directory"
53     echo "$USAGE"
54     exit 2
55 fi
56
57 cd $DIRTO
58
59 if [ ! -d $DIRFROM ]
60 then
61     echo "$0: $DIRFROM is not a directory"
62     echo "$USAGE"
63     exit 2
64 fi
65
66 pwd=`pwd`
67
68 if [ `(cd $DIRFROM; pwd)` = $pwd ]
69 then
70     echo "$pwd: FROM and TO are identical!"
71     exit 1
72 fi
73
74 for file in `ls $DIRFROM`
75 do
76     if [ ! -d $DIRFROM/$file ]
77     then
78         test -r $file || ln -s $DIRFROM/$file .
79     else
80         #echo $file:
81         test -d $file || mkdir $file && chmod 777 $file
82         (cd $file
83         pwd=`pwd`
84         case "$DIRFROM" in
85             /*) ;;
86             *)  DIRFROM=../$DIRFROM ;;
87         esac
88         if [ `(cd $DIRFROM/$file; pwd)` = $pwd ]
89         then
90             echo "$pwd: FROM and TO are identical!"
91             exit 1
92         fi
93         $0 $DIRFROM/$file
94         )
95     fi
96 done