| 1 | ?RCS: $Id: Extract.U,v 3.0.1.2 1997/02/28 14:58:52 ram Exp $ |
| 2 | ?RCS: |
| 3 | ?RCS: Copyright (c) 1991-1993, Raphael Manfredi |
| 4 | ?RCS: |
| 5 | ?RCS: You may redistribute only under the terms of the Artistic Licence, |
| 6 | ?RCS: as specified in the README file that comes with the distribution. |
| 7 | ?RCS: You may reuse parts of this distribution only within the terms of |
| 8 | ?RCS: that same Artistic Licence; a copy of which may be found at the root |
| 9 | ?RCS: of the source tree for dist 3.0. |
| 10 | ?RCS: |
| 11 | ?RCS: $Log: Extract.U,v $ |
| 12 | ?RCS: Revision 3.0.1.2 1997/02/28 14:58:52 ram |
| 13 | ?RCS: patch61: added support for src.U |
| 14 | ?RCS: |
| 15 | ?RCS: Revision 3.0.1.1 1994/10/29 15:51:46 ram |
| 16 | ?RCS: patch36: added ?F: line for metalint file checking |
| 17 | ?RCS: |
| 18 | ?RCS: Revision 3.0 1993/08/18 12:04:52 ram |
| 19 | ?RCS: Baseline for dist 3.0 netwide release. |
| 20 | ?RCS: |
| 21 | ?X: |
| 22 | ?X: This unit produces a shell script which can be doted in order to extract |
| 23 | ?X: .SH files with variable substitutions. |
| 24 | ?X: |
| 25 | ?X: When running Configure from a remote directory ($src is not '.'), |
| 26 | ?X: then the files will be created in that directory, so beware! |
| 27 | ?X: |
| 28 | ?MAKE:Extract: src |
| 29 | ?MAKE: -pick add $@ %< |
| 30 | ?F:./extract |
| 31 | ?T:PERL_CONFIG_SH dir file name create mkdir_p |
| 32 | ?LINT:use PERL_CONFIG_SH |
| 33 | : script used to extract .SH files with variable substitutions |
| 34 | cat >extract <<'EOS' |
| 35 | PERL_CONFIG_SH=true |
| 36 | echo "Doing variable substitutions on .SH files..." |
| 37 | if test -f MANIFEST; then |
| 38 | set x `awk '{print $1}' < MANIFEST | grep '\.SH$'` |
| 39 | else |
| 40 | echo "(Looking for .SH files under the source directory.)" |
| 41 | set x `(cd $src; find . -name "*.SH" -print)` |
| 42 | fi |
| 43 | shift |
| 44 | case $# in |
| 45 | 0) set x `(cd $src; echo *.SH)`; shift;; |
| 46 | esac |
| 47 | if test ! -f $src/$1; then |
| 48 | shift |
| 49 | fi |
| 50 | ?X: script to emulate mkdir -p |
| 51 | mkdir_p=' |
| 52 | name=$1; |
| 53 | create=""; |
| 54 | while test $name; do |
| 55 | if test ! -d "$name"; then |
| 56 | create="$name $create"; |
| 57 | name=`echo $name | sed -e "s|^[^/]*$||"`; |
| 58 | name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`; |
| 59 | else |
| 60 | name=""; |
| 61 | fi; |
| 62 | done; |
| 63 | for file in $create; do |
| 64 | mkdir $file; |
| 65 | done |
| 66 | ' |
| 67 | for file in $*; do |
| 68 | case "$src" in |
| 69 | ".") |
| 70 | case "$file" in |
| 71 | */*) |
| 72 | dir=`expr X$file : 'X\(.*\)/'` |
| 73 | file=`expr X$file : 'X.*/\(.*\)'` |
| 74 | (cd $dir && . ./$file) |
| 75 | ;; |
| 76 | *) |
| 77 | . ./$file |
| 78 | ;; |
| 79 | esac |
| 80 | ;; |
| 81 | *) |
| 82 | ?X: |
| 83 | ?X: When running Configure remotely ($src is not '.'), we cannot source |
| 84 | ?X: the files directly, since that would wrongly cause the extraction |
| 85 | ?X: where the source lie instead of withing the current directory. Therefore, |
| 86 | ?X: we need to 'sh <file' then, which is okay since they will source the |
| 87 | ?X: existing config.sh file. It's not possible to use: |
| 88 | ?X: ../src/Configure -S -O -Dsomething |
| 89 | ?X: unfortunately since no new config.sh with the -Dsomething override |
| 90 | ?X: will be created before running the .SH files. A minor buglet. |
| 91 | ?X: |
| 92 | ?X: Note that we must create the directory hierarchy ourselves if it does |
| 93 | ?X: not exist already, and that is done through a shell emulation of the |
| 94 | ?X: 'mkdir -p' command. We don't want to use the $installdir metaconfig |
| 95 | ?X: symbol here since that would require too much to be configured for |
| 96 | ?X: this simple extraction task that may happen quickly with 'Configure -S'. |
| 97 | ?X: -- RAM, 18/03/96 |
| 98 | ?X: |
| 99 | case "$file" in |
| 100 | */*) |
| 101 | dir=`expr X$file : 'X\(.*\)/'` |
| 102 | file=`expr X$file : 'X.*/\(.*\)'` |
| 103 | (set x $dir; shift; eval $mkdir_p) |
| 104 | sh <$src/$dir/$file |
| 105 | ;; |
| 106 | *) |
| 107 | sh <$src/$file |
| 108 | ;; |
| 109 | esac |
| 110 | ;; |
| 111 | esac |
| 112 | done |
| 113 | if test -f $src/config_h.SH; then |
| 114 | if test ! -f config.h; then |
| 115 | : oops, they left it out of MANIFEST, probably, so do it anyway. |
| 116 | . $src/config_h.SH |
| 117 | fi |
| 118 | fi |
| 119 | EOS |
| 120 | |