Debian Codegraph @

kit/makeSH

raw
1 #!/bin/sh
2
3 # $Id: makeSH,v 3.0.1.1 1993/08/19 06:42:16 ram Exp ram $
4 #
5 # Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
6 #
7 # You may redistribute only under the terms of the Artistic Licence,
8 # as specified in the README file that comes with the distribution.
9 # You may reuse parts of this distribution only within the terms of
10 # that same Artistic Licence; a copy of which may be found at the root
11 # of the source tree for dist 4.0.
12 #
13 # Original Author: Larry Wall <[email protected]>
14 #
15 # $Log: makeSH,v $
16 # Revision 3.0.1.1 1993/08/19 06:42:16 ram
17 # patch1: leading config.sh searching was not aborting properly
18 #
19 # Revision 3.0 1993/08/18 12:04:26 ram
20 # Baseline for dist 3.0 netwide release.
21 #
22
23 for file do
24 if test -f $file.SH; then
25 mv $file.SH $file.SH.old
26 echo "makeSH: renaming $file.SH as $file.SH.old."
27 fi
28 base=`basename $file`
29
30 cat >$file.SH <<BLURFL
31 case \$CONFIG in
32 '')
33 if test -f config.sh; then TOP=.;
34 elif test -f ../config.sh; then TOP=..;
35 elif test -f ../../config.sh; then TOP=../..;
36 elif test -f ../../../config.sh; then TOP=../../..;
37 elif test -f ../../../../config.sh; then TOP=../../../..;
38 else
39 echo "Can't find config.sh."; exit 1
40 fi
41 . \$TOP/config.sh
42 ;;
43 esac
44 : This forces SH files to create target in same directory as SH file.
45 : This is so that make depend always knows where to find SH derivatives.
46 case "\$0" in
47 */*) cd \`expr X\$0 : 'X\(.*\)/'\` ;;
48 esac
49 echo "Extracting $file (with variable substitutions)"
50 : This section of the file will have variable substitutions done on it.
51 : Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
52 : Protect any dollar signs and backticks that you do not want interpreted
53 : by putting a backslash in front. You may delete these comments.
54 \$spitshell >$base <<!GROK!THIS!
55 BLURFL
56
57 case `sed q $file` in
58 */bin/sh) echo '$startsh' >>$file.SH ;;
59 esac
60
61 cat >>$file.SH <<BLURFL
62 !GROK!THIS!
63
64 : In the following dollars and backticks do not need the extra backslash.
65 \$spitshell >>$base <<'!NO!SUBS!'
66 BLURFL
67
68 sed -e '1{' -e '/#!.*\/bin\/sh$/d' -e '}' $file >>$file.SH
69
70 cat >>$file.SH <<BLURFL
71 !NO!SUBS!
72 chmod 755 $base
73 \$eunicefix $base
74 BLURFL
75 chmod 755 $file.SH
76 done