This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate changes from dist-4
[metaconfig.git] / U / modified / Head.U
CommitLineData
cf070538 1?RCS: $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $
959f3c4c 2?RCS:
cf070538 3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4c42341b 4?RCS:
959f3c4c
JH
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
cf070538 9?RCS: of the source tree for dist 4.0.
959f3c4c
JH
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:
4c42341b 45?X:
959f3c4c
JH
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.
4c42341b 48?X:
df0bcc5d 49?MAKE:Head:
959f3c4c 50?MAKE: -pick wipe $@ %<
cf070538 51?V:PATH p_ _exe me newsh
959f3c4c
JH
52?T:argv Id p paths OS2_SHELL DJGPP
53?T:inksh needksh avoidksh newsh changesh reason
cf070538 54?F:!*
1056f0f3 55?LINT:extern ENV CDPATH SHELL MACHTYPE _exe is_os2
4c42341b 56?LINT:change ENV CDPATH is_os2
cf070538 57?LINT:nocomment
959f3c4c
JH
58#! /bin/sh
59#
60# If these # comments don't work, trim them. Don't worry about any other
61# shell scripts, Configure will trim # comments from them for you.
62#
63# (If you are trying to port this package to a machine without sh,
64# I would suggest you have a look at the prototypical config_h.SH file
65# and edit it to reflect your system. Some packages may include samples
66# of config.h for certain machines, so you might look for one of those.)
67#
68?X:
69?X: NOTE THAT A CONFIGURE SCRIPT IS IN THE PUBLIC DOMAIN (whether or not
70?X: the software which uses it is in the public domain).
71?X:
72# Yes, you may rip this off to use in other distribution packages. This
73# script belongs to the public domain and cannot be copyrighted.
74#
75?X:
76?X: WE ASK YOU NOT TO REMOVE OR ALTER THE FOLLOWING PARAGRAPH, PLEASE:
77?X:
cf070538 78# Note: this Configure script was generated automatically. Rather than
959f3c4c 79# working with this copy of Configure, you may wish to get metaconfig.
cf070538
MB
80# The dist package (which contains metaconfig) is available via SVN:
81# svn co https://svn.sourceforge.net/svnroot/dist/trunk/dist
959f3c4c 82#
434d6b7f
MS
83?X: OK, I'll not alter, but I'll add to it then ...
84#
85# Though this script was generated by metaconfig, it is OK to send
86# patches against it. It's up to the Configure pumpkin to backport
87# the patch to the metaunits if it is accepted.
88# See Porting/pumpkin.pod for more information on metaconfig.
89#
959f3c4c
JH
90?X:
91?X: NOTA BENE:
92?X: If you develop you own version of metaconfig based on this work,
93?X: you have to add some comments telling that the script was generated
94?X: by your version, not mine: It credits your work.
95?X:
96
cf070538 97# $Id: Head.U 6 2006-08-25 22:21:46Z rmanfredi $
959f3c4c
JH
98#
99# Generated on <DATE> [metaconfig <VERSION> PL<PATCHLEVEL>]
100# (with additional metaconfig patches by <MAINTLOC>)
101
7d2a10a8 102cat >c1$$ <<EOF
959f3c4c
JH
103ARGGGHHHH!!!!!
104
105SCO csh still thinks true is false. Write to SCO today and tell them that next
106year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
107
108(Actually, Configure ought to just patch csh in place. Hmm. Hmmmmm. All
109we'd have to do is go in and swap the && and || tokens, wherever they are.)
110
111[End of diatribe. We now return you to your regularly scheduled programming...]
112EOF
7d2a10a8 113cat >c2$$ <<EOF
959f3c4c
JH
114
115OOPS! You naughty creature! You didn't run Configure with sh!
116I will attempt to remedy the situation by running sh for you...
117EOF
118
7d2a10a8 119true || cat c1$$ c2$$
959f3c4c
JH
120true || exec sh $0 $argv:q
121
7d2a10a8 122(exit $?0) || cat c2$$
959f3c4c 123(exit $?0) || exec sh $0 $argv:q
7d2a10a8 124rm -f c1$$ c2$$
959f3c4c 125
0d7cd3e2 126if test -f /dev/cputype -a -f /dev/drivers -a -f /dev/osversion; then
c077ffd0
JH
127 cat >&4 <<EOF
128***
129*** I'm sorry but this system looks like Plan 9 and Plan 9 doesn't do
130*** Configure that well. (Plan 9 is close to UNIX but not close enough.)
131*** Please read the README.plan9 for further instructions.
132*** Cannot continue, aborting.
133***
134EOF
135 exit 1
136fi
137
e786dad8
MC
138if test ! -c /dev/null ; then
139 cat >&4 <<EOF
140***
141*** I'm sorry, but /dev/null appears to be a file rather than a device.
142*** Please consult your operating sytem's notes for making a device
143*** in /dev.
144*** Cannot continue, aborting.
145***
146EOF
147 exit 1
148fi
149
959f3c4c
JH
150: compute my invocation name
151me=$0
152case "$0" in
153*/*)
154 me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
155 test "$me" || me=$0
156 ;;
157esac
158
159?X:
160?X: To be able to run under OS/2, we must detect that early enough to use
161?X: the proper path separator, stored in $p_. It is : on UNIX and ; on
162?X: DOSish systems such as OS/2.
163?X:
164: Proper separator for the PATH environment variable
165p_=:
cf070538 166: On OS/2 this directory should exist if this is not floppy only system ":-]"
1056f0f3 167if test -d c:/. || ( uname -a | grep -i 'os\(/\|\)2' ) 2>&1 >/dev/null ; then
cf070538 168 if test -n "$OS2_SHELL"; then
959f3c4c
JH
169 p_=\;
170 PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
171?X: That's a bug in ksh5.22
172 OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
1056f0f3 173 is_os2=yes
959f3c4c 174 elif test -n "$DJGPP"; then
b5f73a83
JH
175 case "X${MACHTYPE:-nonesuchmach}" in
176 *cygwin) ;;
177 *) p_=\; ;;
178 esac
959f3c4c
JH
179 fi
180fi
181
182?X:
183?X: There are two schools of thoughts here. Some people correctly argue that
184?X: the user has a better chance than we do of setting a reasonable PATH and
185?X: others argue that Configure is the best place there is to set up a suitable
186?X: PATH. Well, here we try to compromize by keeping the user's PATH and
187?X: appending some directories which are known to work on some machine or the
188?X: other. The rationale behind this being that a novice user might not have a
189?X: proper environment variable set, and some directories like /etc (where
190?X: chown is located on some BSD systems) may be missing--RAM.
191?X:
192?X: SVR4 adds an /opt directory for optional packages. Some sites use
193?X: various permutations on /opt as opposed to /usr or /usr/local.-- ADO
194?X:
195?X: We only add directories that are not already in the PATH of the
196?X: user and the directories must exist also.
197?X:
604d9ba3
MB
198?X: 20040627, Merijn, HP-UX's ANSI compiler is in /opt/ansic/bin if present
199?X: and should be before /usr/ccs/bin, where the braindead bundled compiler
cf070538 200?X: can be found. The /usr/ccs/bin compiler cannot be used to build perl.
604d9ba3 201?X:
959f3c4c
JH
202: Proper PATH setting
203paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
204paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
205paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
206paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
207paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
604d9ba3 208paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /opt/ansic/bin /usr/ccs/bin"
959f3c4c
JH
209paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
210paths="$paths /sbin /usr/sbin /usr/libexec"
8c387d2d 211paths="$paths /system/gnu_library/bin"
959f3c4c
JH
212
213for p in $paths
214do
215 case "$p_$PATH$p_" in
216 *$p_$p$p_*) ;;
217 *) test -d $p && PATH=$PATH$p_$p ;;
218 esac
219done
220
221PATH=.$p_$PATH
222export PATH
223
224: shall we be using ksh?
225inksh=''
226needksh=''
227avoidksh=''
228newsh=/bin/ksh
229changesh=''
230?X: Use (alias -x) and not (alias) since zsh and bash recognize the alias
231?X: builtin but not the -x option which is typically ksh...
232?X: We need to set up PATH before calling the "alias" built-in since some
233?X: systems like HP-UX have a binary called /bin/alias.
234if (PATH=.; alias -x) >/dev/null 2>&1; then
235 inksh=true
236fi
237?X: On HP-UX, large Configure scripts may exercise a bug in /bin/sh, use ksh
238if test -f /hp-ux -a -f /bin/ksh; then
239 needksh='to avoid sh bug in "here document" expansion'
240fi
241?X: On AIX4, /bin/sh is really ksh and it causes problems, use sh
242if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
243 if test X`/usr/bin/uname -v` = X4; then
244 avoidksh="to avoid AIX 4's /bin/sh"
245 newsh=/usr/bin/bsh
246 fi
247fi
248?X: On Digital UNIX, /bin/sh may start up buggy /bin/ksh, use sh
249if test -f /osf_boot -a -f /usr/sbin/setld; then
250 if test X`/usr/bin/uname -s` = XOSF1; then
cf070538
MB
251 avoidksh="to avoid Digital UNIX' ksh"
252 newsh=/bin/sh
253?X: if BIN_SH is set to 'xpg4', sh will start up ksh
254 unset BIN_SH
959f3c4c
JH
255 fi
256fi
257?X: If we are not in ksh and need it, then feed us back to it
258case "$inksh/$needksh" in
259/[a-z]*)
cf070538
MB
260?X: Clear ENV to avoid any ~/.kshrc that could alias cd or whatever...
261?X: Don't use "unset ENV", that is not portable enough
959f3c4c
JH
262 ENV=''
263 changesh=true
264 reason="$needksh"
265 ;;
266esac
267?X: If we are in ksh and must avoid it, then feed us back to a new shell
268case "$inksh/$avoidksh" in
269true/[a-z]*)
270 changesh=true
271 reason="$avoidksh"
272 ;;
273esac
274?X: Warn them if they use ksh on other systems, which are those where
275?X: we don't need ksh nor want to avoid it explicitely, yet are using it.
276case "$inksh/$needksh-$avoidksh-" in
277true/--)
278 cat <<EOM
279(I see you are using the Korn shell. Some ksh's blow up on $me,
280mainly on older exotic systems. If yours does, try the Bourne shell instead.)
281EOM
282 ;;
283esac
284case "$changesh" in
285true)
26074dbd 286 export newsh
959f3c4c
JH
287 echo "(Feeding myself to $newsh $reason.)"
288?X: Make sure they didn't say sh <Configure by checking whether $0 ends
289?X: with Configure or not. If they did say sh <../../Configure, then too
290?X: bad for them anyway, since we lost that path indication...
291?X: Otherwise, execing $0 ensures we keep the full remote source dir
292?X: indication for src.U.
293 case "$0" in
294 Configure|*/Configure) exec $newsh $0 "$@";;
295 *) exec $newsh Configure "$@";;
296 esac
297 ;;
298esac
8230624a
MHM
299?X: 2004.06.09 rac
300?X: having $newsh persist as ksh here is bad news if ksh doesn't really
301?X: exist. this causes us to toss away a perfectly good working test in
302?X: bash in favour of more exotic external options. see bug 42665.
303test -x "${newsh}" || unset newsh
959f3c4c
JH
304
305?X: Unset CDPATH to avoid surprises when using cd under some shells
306?X: Can't unset it because that's not portable to very old shells.
307?X: Can't set it to '' because then bash 2.02 won't do "cd UU" --AD 6/98.
308?X: Don't want to set it to '.' because then ksh prints out the
309?X: name of the directory every time you cd to it. --AD 6/98
310?X: In order to inflict the least harm, change it only if it's set.
cf070538 311: if needed, set CDPATH to a harmless value that is not chatty
959f3c4c
JH
312: avoid bash 2.02 problems with empty CDPATH.
313case "$CDPATH" in
314'') ;;
315*) case "$SHELL" in
cf070538
MB
316 *bash*) CDPATH='.' ;;
317 *) CDPATH='' ;;
959f3c4c
JH
318 esac
319 ;;
320esac
cf070538 321
959f3c4c
JH
322: Configure runs within the UU subdirectory
323test -d UU || mkdir UU
324?X: Use ./* to avoid any confirmation prompts from enhanced shells -- WED
325cd UU && rm -f ./*
326