This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Plan 9: No Configure.
[metaconfig.git] / U / modified / Head.U
1 ?RCS: $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 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: Head.U,v $
12 ?RCS: Revision 3.0.1.9  1997/02/28  15:02:09  ram
13 ?RCS: patch61: make sure we unset CDPATH for shells that support this
14 ?RCS: patch61: improved Korn shell detection and handling
15 ?RCS:
16 ?RCS: Revision 3.0.1.8  1995/07/25  13:40:02  ram
17 ?RCS: patch56: added SVR4-ish /opt directories to path list (ADO)
18 ?RCS: patch56: OS/2 platforms are using another path separator
19 ?RCS:
20 ?RCS: Revision 3.0.1.7  1995/03/21  08:46:15  ram
21 ?RCS: patch52: definition of paths wrongly added spurious ':' chars
22 ?RCS:
23 ?RCS: Revision 3.0.1.6  1994/10/29  15:54:19  ram
24 ?RCS: patch36: make sure ENV is unset before calling /bin/ksh
25 ?RCS:
26 ?RCS: Revision 3.0.1.5  1994/08/29  16:03:44  ram
27 ?RCS: patch32: now sets PATH only using existing directories
28 ?RCS:
29 ?RCS: Revision 3.0.1.4  1994/06/20  06:54:28  ram
30 ?RCS: patch30: now computes its invocation name into 'me'
31 ?RCS: patch30: symbol me is made visible to all units read-only
32 ?RCS:
33 ?RCS: Revision 3.0.1.3  1993/12/15  08:15:07  ram
34 ?RCS: patch15: added /sbin:/usr/sbin:/usr/libexec in PATH for BSD/386
35 ?RCS:
36 ?RCS: Revision 3.0.1.2  1993/11/10  17:32:35  ram
37 ?RCS: patch14: ensure PATH is reset to '.' before testing for alias
38 ?RCS:
39 ?RCS: Revision 3.0.1.1  1993/08/27  14:38:07  ram
40 ?RCS: patch7: not all 'test' programs support the -x option
41 ?RCS:
42 ?RCS: Revision 3.0  1993/08/18  12:04:58  ram
43 ?RCS: Baseline for dist 3.0 netwide release.
44 ?RCS:
45 ?X: 
46 ?X: This is the very first unit in the Configure script.  It is mostly just
47 ?X: things to keep people from getting into a tizzy right off the bat.
48 ?X: 
49 ?MAKE:Head:
50 ?MAKE:  -pick wipe $@ %<
51 ?V:PATH p_ me
52 ?T:argv Id p paths OS2_SHELL DJGPP
53 ?T:inksh needksh avoidksh newsh changesh reason
54 ?LINT:extern ENV CDPATH SHELL MACHTYPE _exe
55 ?LINT:change ENV CDPATH _exe
56 #! /bin/sh
57 #
58 # If these # comments don't work, trim them. Don't worry about any other
59 # shell scripts, Configure will trim # comments from them for you.
60 #
61 # (If you are trying to port this package to a machine without sh,
62 # I would suggest you have a look at the prototypical config_h.SH file
63 # and edit it to reflect your system. Some packages may include samples
64 # of config.h for certain machines, so you might look for one of those.)
65 #
66 ?X:
67 ?X: NOTE THAT A CONFIGURE SCRIPT IS IN THE PUBLIC DOMAIN (whether or not
68 ?X: the software which uses it is in the public domain).
69 ?X:
70 # Yes, you may rip this off to use in other distribution packages. This
71 # script belongs to the public domain and cannot be copyrighted.
72 #
73 ?X:
74 ?X: WE ASK YOU NOT TO REMOVE OR ALTER THE FOLLOWING PARAGRAPH, PLEASE:
75 ?X:
76 # (Note: this Configure script was generated automatically. Rather than
77 # working with this copy of Configure, you may wish to get metaconfig.
78 # The dist-3.0 package (which contains metaconfig) was posted in
79 # comp.sources.misc and is available on CPAN under authors/id/RAM so
80 # you may fetch it yourself from your nearest archive site.)
81 #
82 ?X:
83 ?X: NOTA BENE:
84 ?X: If you develop you own version of metaconfig based on this work,
85 ?X: you have to add some comments telling that the script was generated
86 ?X: by your version, not mine: It credits your work.
87 ?X:
88
89 # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
90 #
91 # Generated on <DATE> [metaconfig <VERSION> PL<PATCHLEVEL>]
92 # (with additional metaconfig patches by <MAINTLOC>)
93
94 cat >c1$$ <<EOF
95 ARGGGHHHH!!!!!
96
97 SCO csh still thinks true is false.  Write to SCO today and tell them that next
98 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
99
100 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
101 we'd have to do is go in and swap the && and || tokens, wherever they are.)
102
103 [End of diatribe. We now return you to your regularly scheduled programming...]
104 EOF
105 cat >c2$$ <<EOF
106
107 OOPS!  You naughty creature!  You didn't run Configure with sh!
108 I will attempt to remedy the situation by running sh for you...
109 EOF
110
111 true || cat c1$$ c2$$
112 true || exec sh $0 $argv:q
113
114 (exit $?0) || cat c2$$
115 (exit $?0) || exec sh $0 $argv:q
116 rm -f c1$$ c2$$
117
118 if test -e /dev/cputype -a -e /dev/drivers -a -e /dev/osversion -a -e /dev/bintime; then
119         cat >&4 <<EOF
120 ***
121 *** I'm sorry but this system looks like Plan 9 and Plan 9 doesn't do
122 *** Configure that well.  (Plan 9 is close to UNIX but not close enough.)
123 *** Please read the README.plan9 for further instructions.
124 *** Cannot continue, aborting.
125 ***
126 EOF
127         exit 1
128 fi
129
130 : compute my invocation name
131 me=$0
132 case "$0" in
133 */*)
134         me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
135         test "$me" || me=$0
136         ;;
137 esac
138
139 ?X:
140 ?X: To be able to run under OS/2, we must detect that early enough to use
141 ?X: the proper path separator, stored in $p_. It is : on UNIX and ; on
142 ?X: DOSish systems such as OS/2.
143 ?X:
144 : Proper separator for the PATH environment variable
145 p_=:
146 : On OS/2 this directory should exist if this is not floppy only system :-]
147 if test -d c:/. ; then
148     if test -n "$OS2_SHELL"; then
149                 p_=\;
150                 PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
151 ?X: That's a bug in ksh5.22
152                 OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
153         elif test -n "$DJGPP"; then
154                 case "X${MACHTYPE:-nonesuchmach}" in
155                 *cygwin) ;;
156                 *) p_=\; ;;
157                 esac
158         fi
159 fi
160
161 ?X:
162 ?X: There are two schools of thoughts here. Some people correctly argue that
163 ?X: the user has a better chance than we do of setting a reasonable PATH and
164 ?X: others argue that Configure is the best place there is to set up a suitable
165 ?X: PATH. Well, here we try to compromize by keeping the user's PATH and
166 ?X: appending some directories which are known to work on some machine or the
167 ?X: other. The rationale behind this being that a novice user might not have a
168 ?X: proper environment variable set, and some directories like /etc (where
169 ?X: chown is located on some BSD systems) may be missing--RAM.
170 ?X:
171 ?X: SVR4 adds an /opt directory for optional packages.  Some sites use
172 ?X: various permutations on /opt as opposed to /usr or /usr/local.-- ADO
173 ?X:
174 ?X: We only add directories that are not already in the PATH of the
175 ?X: user and the directories must exist also.
176 ?X:
177 : Proper PATH setting
178 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
179 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
180 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
181 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
182 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
183 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
184 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
185 paths="$paths /sbin /usr/sbin /usr/libexec"
186 paths="$paths /system/gnu_library/bin"
187
188 for p in $paths
189 do
190         case "$p_$PATH$p_" in
191         *$p_$p$p_*) ;;
192         *) test -d $p && PATH=$PATH$p_$p ;;
193         esac
194 done
195
196 PATH=.$p_$PATH
197 export PATH
198
199 : shall we be using ksh?
200 inksh=''
201 needksh=''
202 avoidksh=''
203 newsh=/bin/ksh
204 changesh=''
205 ?X: Use (alias -x) and not (alias) since zsh and bash recognize the alias
206 ?X: builtin but not the -x option which is typically ksh...
207 ?X: We need to set up PATH before calling the "alias" built-in since some
208 ?X: systems like HP-UX have a binary called /bin/alias.
209 if (PATH=.; alias -x) >/dev/null 2>&1; then
210                 inksh=true
211 fi
212 ?X: On HP-UX, large Configure scripts may exercise a bug in /bin/sh, use ksh
213 if test -f /hp-ux -a -f /bin/ksh; then
214         needksh='to avoid sh bug in "here document" expansion'
215 fi
216 ?X: On AIX4, /bin/sh is really ksh and it causes problems, use sh
217 if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
218         if test X`/usr/bin/uname -v` = X4; then
219                 avoidksh="to avoid AIX 4's /bin/sh"
220                 newsh=/usr/bin/bsh
221         fi
222 fi
223 ?X: On Digital UNIX, /bin/sh may start up buggy /bin/ksh, use sh
224 if test -f /osf_boot -a -f /usr/sbin/setld; then
225         if test X`/usr/bin/uname -s` = XOSF1; then
226                 avoidksh="to avoid Digital UNIX' ksh"
227                 newsh=/bin/sh
228                 unset BIN_SH # if this is 'xpg4' sh will start up ksh
229         fi
230 fi
231 ?X: If we are not in ksh and need it, then feed us back to it
232 case "$inksh/$needksh" in
233 /[a-z]*)
234 ?X: Unset ENV to avoid any ~/.kshrc that could alias cd or whatever...
235                 ENV=''
236                 changesh=true
237                 reason="$needksh"
238         ;;
239 esac
240 ?X: If we are in ksh and must avoid it, then feed us back to a new shell
241 case "$inksh/$avoidksh" in
242 true/[a-z]*)
243         changesh=true
244         reason="$avoidksh"
245         ;;
246 esac
247 ?X: Warn them if they use ksh on other systems, which are those where
248 ?X: we don't need ksh nor want to avoid it explicitely, yet are using it.
249 case "$inksh/$needksh-$avoidksh-" in
250 true/--)
251                 cat <<EOM
252 (I see you are using the Korn shell.  Some ksh's blow up on $me,
253 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
254 EOM
255         ;;
256 esac
257 case "$changesh" in
258 true)
259         export newsh
260         echo "(Feeding myself to $newsh $reason.)"
261 ?X: Make sure they didn't say sh <Configure by checking whether $0 ends
262 ?X: with Configure or not. If they did say sh <../../Configure, then too
263 ?X: bad for them anyway, since we lost that path indication...
264 ?X: Otherwise, execing $0 ensures we keep the full remote source dir
265 ?X: indication for src.U.
266         case "$0" in
267         Configure|*/Configure) exec $newsh $0 "$@";;
268         *) exec $newsh Configure "$@";;
269         esac
270         ;;
271 esac
272
273 ?X: Unset CDPATH to avoid surprises when using cd under some shells
274 ?X: Can't unset it because that's not portable to very old shells.
275 ?X: Can't set it to '' because then bash 2.02 won't do "cd UU"  --AD  6/98.
276 ?X: Don't want to set it to '.' because then ksh prints out the
277 ?X: name of the directory every time you cd to it. --AD 6/98
278 ?X: In order to inflict the least harm, change it only if it's set.
279 : if needed set CDPATH to a harmless value that is not chatty
280 : avoid bash 2.02 problems with empty CDPATH.
281 case "$CDPATH" in
282 '')     ;;
283 *)      case "$SHELL" in
284         *bash*) CDPATH='.' ;;
285         *)              CDPATH='' ;;
286         esac
287         ;;
288 esac
289 : Configure runs within the UU subdirectory
290 test -d UU || mkdir UU
291 ?X: Use ./* to avoid any confirmation prompts from enhanced shells -- WED
292 cd UU && rm -f ./*
293