symlink-tree 2.2 KB

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