PennMUSH Community

root/1.8.3/tags/p1/Configure

Revision 718, 156.7 kB (checked in by penndev, 2 years ago)

PennMUSH 1.8.3p1 release candidate.

  • Property svn:executable set to *
Line 
1 #! /bin/sh
2 #
3 # If these # comments don't work, trim them. Don't worry about any other
4 # shell scripts, Configure will trim # comments from them for you.
5 #
6 # (If you are trying to port this package to a machine without sh,
7 # I would suggest you have a look at the prototypical config_h.SH file
8 # and edit it to reflect your system. Some packages may include samples
9 # of config.h for certain machines, so you might look for one of those.)
10 #
11 # Yes, you may rip this off to use in other distribution packages. This
12 # script belongs to the public domain and cannot be copyrighted.
13 #
14 # (Note: this Configure script was generated automatically. Rather than
15 # working with this copy of Configure, you may wish to get metaconfig.
16 # The dist-3.0 package (which contains metaconfig) was posted in
17 # comp.sources.misc and is available on CPAN under authors/id/RAM so
18 # you may fetch it yourself from your nearest archive site.)
19 #
20
21 # $Id: Head.U 1.3 Mon, 10 Nov 2003 14:51:32 -0600 dunemush $
22 #
23 # Generated on Fri Mar 24 14:36:30 CST 2006 [metaconfig 3.0 PL70]
24
25 cat >/tmp/c1$$ <<EOF
26 ARGGGHHHH!!!!!
27
28 SCO csh still thinks true is false.  Write to SCO today and tell them that next
29 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
30
31 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
32 we'd have to do is go in and swap the && and || tokens, wherever they are.)
33
34 [End of diatribe. We now return you to your regularly scheduled programming...]
35 EOF
36 cat >/tmp/c2$$ <<EOF
37
38 OOPS!  You naughty creature!  You didn't run Configure with sh!
39 I will attempt to remedy the situation by running sh for you...
40 EOF
41
42 true || cat /tmp/c1$$ /tmp/c2$$
43 true || exec sh $0 $argv:q
44
45 (exit $?0) || cat /tmp/c2$$
46 (exit $?0) || exec sh $0 $argv:q
47 rm -f /tmp/c1$$ /tmp/c2$$
48
49 : compute my invocation name
50 me=$0
51 case "$0" in
52 */*)
53     me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
54     test "$me" || me=$0
55     ;;
56 esac
57
58 : Proper PATH separator
59 p_=:
60 : On OS/2 this directory should exist if this is not floppy only system :-]
61 if test -d c:/.; then
62     : Check for cygwin32 emulation
63     case "x$OSTYPE$OS" in
64     x*msys*Windows*)
65         echo 'Running on Windows? Using the MinGW MSys tools...'
66         ;;
67     x*win32*)
68         echo 'Running on Windows?  Assuming cygwin32 emulation tools...'
69         ;;
70     x*windows*)
71         echo 'Running on Windows?  Assuming cygwin32 emulation tools...'
72         ;;
73     x*cygwin*)
74         echo 'Looks like cygwin32...'
75         ;;
76     x*)
77         p_=\;
78         PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
79         OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
80         ;;
81     esac
82 fi
83
84 : Proper PATH setting
85 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
86 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
87 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
88 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
89 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
90 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
91 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
92 paths="$paths /sbin /usr/sbin /usr/libexec /gnuwin32/b18/H-i386-cygwin32/bin"
93
94 case "x$OSTYPE$OS" in
95     x*msys*Windows*)
96         PATH='/usr/local/bin:/mingw/bin:/bin:/perl/bin'
97         ;;
98     x*)
99         for p in $paths
100         do
101             case "$p_$PATH$p_" in
102                 *$p_$p$p_*) ;;
103                 *) test -d $p && PATH=$PATH$p_$p ;;
104             esac           
105         done
106
107         PATH=.$p_$PATH
108         export PATH
109         ;;
110 esac
111
112 : shall we be using ksh?
113 inksh=''
114 needksh=''
115 avoidksh=''
116 newsh=/bin/ksh
117 changesh=''
118 if (PATH=.; alias -x) >/dev/null 2>&1; then
119         inksh=true
120 fi
121 if test -f /hp-ux -a -f /bin/ksh; then
122     needksh='to avoid sh bug in "here document" expansion'
123 fi
124 if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
125     if test X`/usr/bin/uname -v` = X4; then
126         avoidksh="to avoid AIX 4's /bin/sh"
127         newsh=/usr/bin/bsh
128     fi
129 fi
130 case "$inksh/$needksh" in
131 /[a-z]*)
132         unset ENV
133         changesh=true
134         reason="$needksh"
135     ;;
136 esac
137 case "$inksh/$avoidksh" in
138 true/[a-z]*)
139     changesh=true
140     reason="$avoidksh"
141     ;;
142 esac
143 case "$inksh/$needksh-$avoidksh-" in
144 true/--)
145         cat <<EOM
146 (I see you are using the Korn shell.  Some ksh's blow up on $me,
147 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
148 EOM
149     ;;
150 esac
151 case "$changesh" in
152 true)
153     echo "(Feeding myself to $newsh $reason.)"
154     case "$0" in
155     Configure|*/Configure) exec $newsh $0 "$@";;
156     *) exec $newsh Configure "$@";;
157     esac
158     ;;
159 esac
160
161 : Configure runs within the UU subdirectory
162 test -d UU || mkdir UU
163 unset CDPATH
164 cd UU && rm -f ./*
165
166 d_bsd=''
167 d_eunice=''
168 d_xenix=''
169 eunicefix=''
170 Mcc=''
171 ar=''
172 awk=''
173 bash=''
174 bison=''
175 byacc=''
176 cat=''
177 chgrp=''
178 chmod=''
179 chown=''
180 comm=''
181 compress=''
182 cp=''
183 cpio=''
184 cpp=''
185 csh=''
186 date=''
187 echo=''
188 egrep=''
189 emacs=''
190 expr=''
191 find=''
192 flex=''
193 gcc=''
194 grep=''
195 gzip=''
196 inews=''
197 ksh=''
198 less=''
199 line=''
200 lint=''
201 ln=''
202 lp=''
203 lpr=''
204 ls=''
205 mail=''
206 mailx=''
207 make=''
208 mkdir=''
209 more=''
210 mv=''
211 nroff=''
212 perl=''
213 pg=''
214 pmake=''
215 pr=''
216 rm=''
217 rmail=''
218 sed=''
219 sendmail=''
220 shar=''
221 sleep=''
222 smail=''
223 sort=''
224 submit=''
225 tail=''
226 tar=''
227 tbl=''
228 test=''
229 touch=''
230 tr=''
231 troff=''
232 uname=''
233 uniq=''
234 uptime=''
235 uuname=''
236 vi=''
237 zcat=''
238 zip=''
239 hint=''
240 myuname=''
241 osname=''
242 osvers=''
243 Author=''
244 Date=''
245 Header=''
246 Id=''
247 Locker=''
248 Log=''
249 RCSfile=''
250 Revision=''
251 Source=''
252 State=''
253 archobjs=''
254 firstmakefile=''
255 cc=''
256 gccversion=''
257 ccflags=''
258 cppflags=''
259 ldflags=''
260 lkflags=''
261 locincpth=''
262 optimize=''
263 warnings=''
264 cdecl=''
265 cf_email=''
266 cf_name=''
267 cf_by=''
268 cf_time=''
269 contains=''
270 cpplast=''
271 cppminus=''
272 cpprun=''
273 cppstdin=''
274 d_gettblsz=''
275 nofile=''
276 tablesize=''
277 d_access=''
278 d_argsinfp=''
279 d_assert=''
280 d_attribut=''
281 d_bcopy=''
282 d_bindtextdomain=''
283 d_bzero=''
284 d_const=''
285 cryptlib=''
286 d_crypt=''
287 i_crypt=''
288 d_force_ipv4=''
289 d_fpsetmask=''
290 d_fpsetround=''
291 i_floatingpoint=''
292 d_gaistr=''
293 d_getadinf=''
294 d_getdate=''
295 d_gethbynm2=''
296 d_getnminf=''
297 d_getpagsz=''
298 pagesize=''
299 d_getprior=''
300 d_gettext=''
301 d_gnulibc=''
302 d_huge=''
303 d_huge_val=''
304 d_int_max=''
305 d_maxdouble=''
306 d_maxint=''
307 d_ieee=''
308 d_in2p=''
309 d_internet=''
310 d_ipv6=''
311 d_itimer=''
312 d_keepsig=''
313 d_memcpy=''
314 d_memmove=''
315 d_memset=''
316 d_newstyle=''
317 d_open3=''
318 d_portable=''
319 d_lrand48=''
320 d_rand=''
321 d_random=''
322 d_rename=''
323 d_rlimit=''
324 d_rusage=''
325 d_select=''
326 d_sendmail=''
327 d_setlocale=''
328 d_setpgid=''
329 d_bsdsetpgrp=''
330 d_setpgrp=''
331 d_setprior=''
332 d_sigaction=''
333 d_sigchld=''
334 d_sigcld=''
335 d_signalproto=''
336 d_sigprocmask=''
337 d_snprintf=''
338 d_oldsock=''
339 d_socket=''
340 d_sockpair=''
341 sockethdr=''
342 socketlib=''
343 d_socklen=''
344 d_strccmp=''
345 d_index=''
346 d_strchr=''
347 d_strcoll=''
348 d_strdup=''
349 d_strxfrm=''
350 d_sysconf=''
351 d_sysctl=''
352 d_sysctlbyname=''
353 d_tcl=''
354 i_tcl=''
355 d_textdomain=''
356 d_timelocal=''
357 d_toupper=''
358 d_uint32_t=''
359 d_uptime=''
360 d_urandom=''
361 d_uwait3=''
362 d_uwait=''
363 d_voidsig=''
364 signal_t=''
365 d_volatile=''
366 d_vsnprintf=''
367 d_waitpid=''
368 h_fcntl=''
369 h_sysfile=''
370 i_arpainet=''
371 i_arpanameser=''
372 i_errno=''
373 i_syserrno=''
374 i_fcntl=''
375 i_libintl=''
376 i_limits=''
377 i_locale=''
378 i_malloc=''
379 i_memory=''
380 i_netdb=''
381 i_niin=''
382 i_sysin=''
383 i_nitcp=''
384 i_setjmp=''
385 i_stddef=''
386 i_stdint=''
387 i_stdlib=''
388 i_string=''
389 strings=''
390 i_sysfile=''
391 d_voidtty=''
392 i_bsdioctl=''
393 i_sysfilio=''
394 i_sysioctl=''
395 i_syssockio=''
396 i_sysmman=''
397 i_syspage=''
398 i_sysparam=''
399 i_sysresrc=''
400 i_sysselct=''
401 i_syssock=''
402 i_sysstat=''
403 i_systypes=''
404 i_sysvlimit=''
405 i_syswait=''
406 i_sgtty=''
407 i_termio=''
408 i_termios=''
409 i_systime=''
410 i_systimek=''
411 i_time=''
412 timeincl=''
413 i_unistd=''
414 i_values=''
415 i_stdarg=''
416 i_varargs=''
417 i_varhdr=''
418 install=''
419 installdir=''
420 libc=''
421 d_mysql=''
422 libmysqlclient=''
423 d_postgresql=''
424 libpq=''
425 glibpth=''
426 libpth=''
427 loclibpth=''
428 plibpth=''
429 xlibpth=''
430 libs=''
431 d_openssl=''
432 libssl=''
433 lns=''
434 mailer=''
435 make_set_make=''
436 d_mymalloc=''
437 freetype=''
438 mallocobj=''
439 mallocsrc=''
440 malloctype=''
441 usemymalloc=''
442 mydomain=''
443 myhostname=''
444 phostname=''
445 c=''
446 n=''
447 d_berknames=''
448 d_passnames=''
449 d_usgnames=''
450 nametype=''
451 groupcat=''
452 hostcat=''
453 passcat=''
454 package=''
455 spackage=''
456 pidtype=''
457 prototype=''
458 sh=''
459 sizetype=''
460 so=''
461 d_keepalive=''
462 d_keepidle=''
463 sharpbang=''
464 shsharp=''
465 spitshell=''
466 src=''
467 startsh=''
468 sysman=''
469 nm_opt=''
470 nm_so_opt=''
471 runnm=''
472 usenm=''
473 incpath=''
474 mips=''
475 mips_type=''
476 usrinc=''
477 defvoidused=''
478 voidflags=''
479 CONFIG=''
480
481 define='define'
482 undef='undef'
483 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
484 rmlist=''
485
486 : We must find out about Eunice early
487 eunicefix=':'
488 if test -f /etc/unixtovms; then
489     eunicefix=/etc/unixtovms
490 fi
491 if test -f /etc/unixtovms.exe; then
492     eunicefix=/etc/unixtovms.exe
493 fi
494
495 : list of known cpp symbols, sorted alphabetically
496 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
497 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
498 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
499 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
500 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
501 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
502 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
503 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
504 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
505 al="$al VMS Xenix286"
506 al="$al _AIX _AIX32 _AIX370 _AM29000 _COFF _CRAY _CX_UX _EPI"
507 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET"
508 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
509 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
510 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
511 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
512 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
513 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
514 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
515 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
516 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
517 al="$al __SVR4_2__ __UMAXV__"
518 al="$al ____386BSD____ __alpha __alpha__ __amiga"
519 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
520 al="$al __host_mips__"
521 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
522 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
523 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
524 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
525 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
526 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
527 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
528 al="$al __mc88100 __mc88100__ __mips __mips__"
529 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
530 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
531 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
532 al="$al _host_mips _mips _unix"
533 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
534 al="$al apollo ardent att386 att3b"
535 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
536 al="$al cadmus clipper concurrent convex cray ctix"
537 al="$al dmert encore gcos gcx gimpel gould"
538 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
539 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
540 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
541 al="$al i186 i286 i386 i486 i8086"
542 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
543 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
544 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
545 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
546 al="$al mc88000 mc88100 merlin mert mips mvs n16"
547 al="$al ncl_el ncl_mr"
548 al="$al news1500 news1700 news1800 news1900 news3700"
549 al="$al news700 news800 news900 ns16000 ns32000"
550 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
551 al="$al parisc pc532 pdp11 plexus posix pyr"
552 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
553 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
554 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
555 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
556 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
557 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
558 al="$al xenix z8000"
559
560 : No trailing extension on UNIX executables
561 _exe=''
562 : Extra object files, if any, needed on this platform.
563 archobjs=''
564 gccversion=''
565 : change the next line if compiling for Xenix/286 on Xenix/386
566 xlibpth='/usr/lib/386 /lib/386'
567
568 : Possible local library directories to search.
569 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
570 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
571
572 : general looking path for locating libraries
573 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
574 glibpth="$glibpth /lib /usr/lib $xlibpth"
575 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
576 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
577
578 : Private path used by Configure to find libraries.  Its value
579 : is prepended to libpth. This variable takes care of special
580 : machines, like the mips.  Usually, it should be empty.
581 plibpth=''
582
583 large=''
584 : full support for void wanted by default
585 defvoidused=15
586
587 : Possible local include directories to search.
588 : Set locincpth to "" in a hint file to defeat local include searches.
589 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
590 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
591 locincpth="$locincpth /usr/kerberos/include"
592 :
593 : no include file wanted by default
594 inclwanted=''
595
596 : default library list
597 libswanted=''
598 defvoidused=15
599 libswanted='nsl socket m c crypt bind resolv ld dl tcl intl'
600
601 : Find the basic shell for Bourne shell scripts
602 case "$sh" in
603 '')
604     case "$SYSTYPE" in
605     *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
606     *) xxx='/bin/sh';;
607     esac
608     if test -f "$xxx"; then
609         sh="$xxx"
610     else
611         : Build up a list and do a single loop so we can 'break' out.
612         pth=`echo $PATH | sed -e "s/$p_/ /g"`
613         for xxx in sh bash ksh pdksh ash; do
614             for p in $pth; do
615                 try="$try ${p}/${xxx}"
616             done
617         done
618         for xxx in $try; do
619             if test -f "$xxx"; then
620                 sh="$xxx";
621                 break
622             elif test -f "$xxx.exe"; then
623                 sh="$xxx";
624                 break
625             fi
626         done
627     fi
628     ;;
629 esac
630
631 case "$sh" in
632 '') cat <<EOM >&2
633 $me:  Fatal Error:  I can't find a Bourne Shell anywhere. 
634
635 Usually it's in /bin/sh.  How did you even get this far?
636 Please contact me (PennMUSH developers) at pennmush-developers@pennmush.org and
637 we'll try to straighten this all out.
638 EOM
639     exit 1
640     ;;
641 esac
642
643 : see if sh knows # comments
644 if `$sh -c '#' >/dev/null 2>&1`; then
645     shsharp=true
646     spitshell=cat
647     xcat=/bin/cat
648     test -f $xcat || xcat=/usr/bin/cat
649     echo "#!$xcat" >try
650     $eunicefix try
651     chmod +x try
652     ./try > today
653     if test -s today; then
654         sharpbang='#!'
655     else
656         echo "#! $xcat" > try
657         $eunicefix try
658         chmod +x try
659         ./try > today
660         if test -s today; then
661             sharpbang='#! '
662         else
663             sharpbang=': use '
664         fi
665     fi
666 else
667     echo " "
668     echo "Your $sh doesn't grok # comments--I will strip them later on."
669     shsharp=false
670     cd ..
671     echo "exec grep -v '^[  ]*#'" >spitshell
672     chmod +x spitshell
673     $eunicefix spitshell
674     spitshell=`pwd`/spitshell
675     cd UU
676     echo "I presume that if # doesn't work, #! won't work either!"
677     sharpbang=': use '
678 fi
679 rm -f try today
680
681 : figure out how to guarantee sh startup
682 case "$startsh" in
683 '') startsh=${sharpbang}${sh} ;;
684 *)
685 esac
686 cat >try <<EOSS
687 $startsh
688 set abc
689 test "$?abc" != 1
690 EOSS
691
692 chmod +x try
693 $eunicefix try
694 if ./try; then
695     : echo "Yup, it does."
696 else
697     echo "Hmm... '$startsh' does not guarantee sh startup..."
698     echo "You may have to fix up the shell scripts to make sure $sh runs them."
699 fi
700 rm -f try
701
702 : produce awk script to parse command line options
703 cat >options.awk <<'EOF'
704 BEGIN {
705     optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
706
707     len = length(optstr);
708     for (i = 1; i <= len; i++) {
709         c = substr(optstr, i, 1);
710         if (i < len) a = substr(optstr, i + 1, 1); else a = "";
711         if (a == ":") {
712             arg[c] = 1;
713             i++;
714         }
715         opt[c] = 1;
716     }
717 }
718 {
719     expect = 0;
720     str = $0;
721     if (substr(str, 1, 1) != "-") {
722         printf("'%s'\n", str);
723         next;
724     }
725     len = length($0);
726     for (i = 2; i <= len; i++) {
727         c = substr(str, i, 1);
728         if (!opt[c]) {
729             printf("-%s\n", substr(str, i));
730             next;
731         }
732         printf("-%s\n", c);
733         if (arg[c]) {
734             if (i < len)
735                 printf("'%s'\n", substr(str, i + 1));
736             else
737                 expect = 1;
738             next;
739         }
740     }
741 }
742 END {
743     if (expect)
744         print "?";
745 }
746 EOF
747
748 : process the command line options
749 set X `for arg in "$@"; do echo "X$arg"; done |
750     sed -e s/X// | awk -f options.awk`
751 eval "set $*"
752 shift
753 rm -f options.awk
754
755 : set up default values
756 fastread=''
757 reuseval=false
758 config_sh=''
759 alldone=''
760 error=''
761 silent=''
762 extractsh=''
763 override=''
764 knowitall=''
765 rm -f optdef.sh
766 cat >optdef.sh <<EOS
767 $startsh
768 EOS
769
770
771 : option parsing
772 while test $# -gt 0; do
773     case "$1" in
774     -d) shift; fastread=yes;;
775     -e) shift; alldone=cont;;
776     -f)
777         shift
778         cd ..
779         if test -r "$1"; then
780             config_sh="$1"
781         else
782             echo "$me: cannot read config file $1." >&2
783             error=true
784         fi
785         cd UU
786         shift;;
787     -h) shift; error=true;;
788     -r) shift; reuseval=true;;
789     -s) shift; silent=true; realsilent=true;;
790     -E) shift; alldone=exit;;
791     -K) shift; knowitall=true;;
792     -O) shift; override=true;;
793     -S) shift; silent=true; extractsh=true;;
794     -D)
795         shift
796         case "$1" in
797         *=)
798             echo "$me: use '-U symbol=', not '-D symbol='." >&2
799             echo "$me: ignoring -D $1" >&2
800             ;;
801         *=*) echo "$1" | \
802                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
803         *) echo "$1='define'" >> optdef.sh;;
804         esac
805         shift
806         ;;
807     -U)
808         shift
809         case "$1" in
810         *=) echo "$1" >> optdef.sh;;
811         *=*)
812             echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
813             echo "$me: ignoring -U $1" >&2
814             ;;
815         *) echo "$1='undef'" >> optdef.sh;;
816         esac
817         shift
818         ;;
819     -V) echo "$me generated by metaconfig 3.0 PL70." >&2
820         exit 0;;
821     --) break;;
822     -*) echo "$me: unknown option $1" >&2; shift; error=true;;
823     *) break;;
824     esac
825 done
826
827 case "$error" in
828 true)
829     cat >&2 <<EOM
830 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
831                  [-U symbol] [-U symbol=]
832   -d : use defaults for all answers.
833   -e : go on without questioning past the production of config.sh.
834   -f : specify an alternate default configuration file.
835   -h : print this help message and exit (with an error status).
836   -r : reuse C symbols value if possible (skips costly nm extraction).
837   -s : silent mode, only echoes questions and essential information.
838   -D : define symbol to have some value:
839          -D symbol         symbol gets the value 'define'
840          -D symbol=value   symbol gets the value 'value'
841   -E : stop at the end of questions, after having produced config.sh.
842   -K : do not use unless you know what you are doing.
843   -O : let -D and -U override definitions from loaded configuration file.
844   -S : perform variable substitutions on all .SH files (can mix with -f)
845   -U : undefine symbol:
846          -U symbol    symbol gets the value 'undef'
847          -U symbol=   symbol gets completely empty
848   -V : print version number and exit (with a zero status).
849 EOM
850     exit 1
851     ;;
852 esac
853
854 : Sanity checks
855 case "$fastread$alldone" in
856 yescont|yesexit) ;;
857 *)
858     if test ! -t 0; then
859         echo "Say 'sh Configure', not 'sh <Configure'"
860         exit 1
861     fi
862     ;;
863 esac
864
865 exec 4>&1
866 case "$silent" in
867 true) exec 1>/dev/null;;
868 esac
869
870 : run the defines and the undefines, if any, but leave the file out there...
871 touch optdef.sh
872 . ./optdef.sh
873
874 : set package name
875 package=pennmush
876
877 : Some greps do not return status, grrr.
878 echo "grimblepritz" >grimble
879 if grep blurfldyick grimble >/dev/null 2>&1 ; then
880     contains=contains
881 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
882     contains=grep
883 else
884     contains=contains
885 fi
886 rm -f grimble
887 : the following should work in any shell
888 case "$contains" in
889 contains*)
890     echo " "
891     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
892     cat >contains <<'EOSS'
893 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
894 EOSS
895 chmod +x contains
896 esac
897
898 : first determine how to suppress newline on echo command
899 echo " "
900 echo "Checking echo to see how to suppress newlines..."
901 (echo "hi there\c" ; echo " ") >.echotmp
902 if $contains c .echotmp >/dev/null 2>&1 ; then
903     echo "...using -n."
904     n='-n'
905     c=''
906 else
907     cat <<'EOM'
908 ...using \c
909 EOM
910     n=''
911     c='\c'
912 fi
913 echo $n "The star should be here-->$c"
914 echo '*'
915 rm -f .echotmp
916
917 : compute the number of columns on the terminal for proper question formatting
918 case "$COLUMNS" in
919 '') COLUMNS='80';;
920 esac
921
922 : set up the echo used in my read
923 myecho="case \"\$xxxm\" in
924 '') echo $n \"\$rp $c\" >&4;;
925 *) case \"\$rp\" in
926     '') echo $n \"[\$xxxm] $c\";;
927     *)
928         if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
929             echo \"\$rp\" >&4
930             echo $n \"[\$xxxm] $c\" >&4
931         else
932             echo $n \"\$rp [\$xxxm] $c\" >&4
933         fi
934         ;;
935     esac;;
936 esac"
937
938 : now set up to do reads with possible shell escape and default assignment
939 cat <<EOSC >myread
940 $startsh
941 xxxm=\$dflt
942 $myecho
943 ans='!'
944 case "\$fastread" in
945 yes) case "\$dflt" in
946     '') ;;
947     *) ans='';
948         case "\$silent-\$rp" in
949         true-) ;;
950         *) echo " " >&4;;
951         esac;;
952     esac;;
953 *) case "\$silent" in
954     true) case "\$rp" in
955         '') ans='';;
956         esac;;
957     esac;;
958 esac
959 while expr "X\$ans" : "X!" >/dev/null; do
960     read answ
961     set x \$xxxm
962     shift
963     aok=''; eval "ans=\\"\$answ\\"" && aok=y
964     case  "\$answ" in
965     "!")
966         sh 1>&4
967         echo " "
968         $myecho
969         ;;
970     !*)
971         set x \`expr "X\$ans" : "X!\(.*\)\$"\`
972         shift
973         sh 1>&4 -c "\$*"
974         echo " "
975         $myecho
976         ;;
977     "\$ans")
978         case "\$ans" in
979         \\&*)
980             set x \`expr "X\$ans" : "X&\(.*\)\$"\`
981             shift
982             case "\$1" in
983             -d)
984                 fastread=yes
985                 echo "(OK, I'll run with -d after this question.)" >&4
986                 ;;
987             -*)
988                 echo "*** Sorry, \$1 not supported yet." >&4
989                 ;;
990             esac
991             $myecho
992             ans=!
993             ;;
994         esac;;
995     *)
996         case "\$aok" in
997         y)
998             echo "*** Substitution done -- please confirm."
999             xxxm="\$ans"
1000             ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
1001             xxxm="\$ans"
1002             ans=!
1003             ;;
1004         *)
1005             echo "*** Error -- try again."
1006             ans=!
1007             ;;
1008         esac
1009         $myecho
1010         ;;
1011     esac
1012     case "\$ans\$xxxm\$nostick" in
1013     '')
1014         ans=!
1015         $myecho
1016         ;;
1017     esac
1018 done
1019 case "\$ans" in
1020 '') ans="\$xxxm";;
1021 esac
1022 EOSC
1023
1024 : Find the path to the source tree
1025 case "$src" in
1026 '') src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1027 esac
1028 case "$src" in
1029 '')
1030     src=.
1031     rsrc=..
1032     ;;
1033 /*) rsrc="$src/..";;
1034 *) rsrc="../$src";;
1035 esac
1036 if test -f $rsrc/Configure && \
1037     $contains "^package=$package" $rsrc/Configure >/dev/null 2>&1
1038 then
1039    : found it, so we are ok.
1040 else
1041     rsrc=''
1042     for src in . .. ../.. ../../.. ../../../..; do
1043         if test -f ../$src/Configure && \
1044             $contains "^package=$package" ../$src/Configure >/dev/null 2>&1
1045         then
1046             rsrc=../$src
1047             break
1048         fi
1049     done
1050 fi
1051 case "$rsrc" in
1052 '')
1053     echo " "
1054     dflt=
1055     rp="Directory where sources for $package are located?"
1056     . ./myread
1057     src="$ans"
1058     rsrc="$src"
1059     if test -f $rsrc/Configure && \
1060         $contains "^package=$package" $rsrc/Configure >/dev/null 2>&1
1061     then
1062         echo "Ok, I've found them under $src"
1063     else
1064         echo "Sorry, I can't seem to be able to locate $package sources." >&4
1065         exit 1
1066     fi
1067     ;;
1068 ../.) ;;
1069 *)
1070     echo " "
1071     echo "Sources for $package found in $src" >&4
1072     ;;
1073 esac
1074
1075 : script used to extract .SH files with variable substitutions
1076 cat >extract <<'EOS'
1077 CONFIG=true
1078 echo "Doing variable substitutions on .SH files..."
1079 if test -f $src/MANIFEST; then
1080     set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH'`
1081 else
1082     echo "(Looking for .SH files under the source directory.)"
1083     set x `(cd $src; find . -name "*.SH" -print)`
1084 fi
1085 shift
1086 case $# in
1087 0) set x `(cd $src; echo *.SH)`; shift;;
1088 esac
1089 if test ! -f $src/$1; then
1090     shift
1091 fi
1092 mkdir_p='
1093 name=$1;
1094 create="";
1095 while test $name; do
1096     if test ! -d "$name"; then
1097         create="$name $create";
1098         name=`echo $name | sed -e "s|^[^/]*$||"`;
1099         name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1100     else
1101         name="";
1102     fi;
1103 done;
1104 for file in $create; do
1105     mkdir $file;
1106 done
1107 '
1108 for file in $*; do
1109     case "$src" in
1110     ".")
1111         case "$file" in
1112         */*)
1113             dir=`expr X$file : 'X\(.*\)/'`
1114             file=`expr X$file : 'X.*/\(.*\)'`
1115             (cd $dir && . ./$file)
1116             ;;
1117         *)
1118             . ./$file
1119             ;;
1120         esac
1121         ;;
1122     *)
1123         case "$file" in
1124         */*)
1125             dir=`expr X$file : 'X\(.*\)/'`
1126             file=`expr X$file : 'X.*/\(.*\)'`
1127             (set x $dir; shift; eval $mkdir_p)
1128             sh <$src/$dir/$file
1129             ;;
1130         *)
1131             sh <$src/$file
1132             ;;
1133         esac
1134         ;;
1135     esac
1136 done
1137 if test -f $src/config_h.SH; then
1138     if test ! -f config.h; then
1139     : oops, they left it out of MANIFEST, probably, so do it anyway.
1140     . $src/config_h.SH
1141     fi
1142 fi
1143 EOS
1144
1145 : extract files and exit if asked to do so
1146 case "$extractsh" in
1147 true)
1148     case "$realsilent" in
1149     true) ;;
1150     *) exec 1>&4;;
1151     esac
1152     case "$config_sh" in
1153     '') config_sh='config.sh'; config="$rsrc/config.sh";;
1154     /*) config="$config_sh";;
1155     *) config="$rsrc/$config_sh";;
1156     esac
1157     echo " "
1158     echo "Fetching answers from $config_sh..."
1159     . $config
1160     test "$override" && . ./optdef.sh
1161     echo " "
1162     cd ..
1163     . UU/extract
1164     rm -rf UU
1165     echo "Done."
1166     exit 0
1167     ;;
1168 esac
1169
1170 : Eunice requires " " instead of "", can you believe it
1171 echo " "
1172 : Here we go...
1173 echo "Beginning of configuration questions for $package."
1174
1175 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1176
1177 : Now test for existence of everything in MANIFEST
1178 echo " "
1179 if test -f $rsrc/MANIFEST; then
1180     echo "First let's make sure your kit is complete.  Checking..." >&4
1181     awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1182     rm -f missing
1183     tmppwd=`pwd`
1184     for filelist in x??; do
1185         (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1186     done
1187     if test -s missing; then
1188         cat missing >&4
1189         cat >&4 <<'EOM'
1190
1191 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1192
1193 You have the option of continuing the configuration process, despite the
1194 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1195 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1196 and contact the author (pennmush-developers@pennmush.org).
1197
1198 EOM
1199         echo $n "Continue? [n] $c" >&4
1200         read ans
1201         case "$ans" in
1202         y*)
1203             echo "Continuing..." >&4
1204             rm -f missing
1205             ;;
1206         *)
1207             echo "ABORTING..." >&4
1208             kill $$
1209             ;;
1210         esac
1211     else
1212         echo "Looks good..."
1213     fi
1214 else
1215     echo "There is no MANIFEST file.  I hope your kit is complete !"
1216 fi
1217 rm -f missing x??
1218
1219 : create .config dir to save info across Configure sessions
1220 test -d ../.config || mkdir ../.config
1221 cat >../.config/README <<EOF
1222 This directory created by Configure to save information that should
1223 persist across sessions for $package.
1224
1225 You may safely delete it if you wish.
1226 EOF
1227
1228 : general instructions
1229 needman=true
1230 firsttime=true
1231 user=`(logname) 2>/dev/null`
1232 case "$user" in
1233 '') user=`whoami 2>&1`;;
1234 esac
1235 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1236     firsttime=false
1237     echo " "
1238     rp='Would you like to see the instructions?'
1239     dflt=n
1240     . ./myread
1241     case "$ans" in
1242     [yY]*) ;;
1243     *) needman=false;;
1244     esac
1245 fi
1246 if $needman; then
1247     cat <<EOH
1248  
1249 This installation shell script will examine your system and ask you questions
1250 to determine how the pennmush package should be installed. If you get
1251 stuck on a question, you may use a ! shell escape to start a subshell or
1252 execute a command.  Many of the questions will have default answers in square
1253 brackets; typing carriage return will give you the default.
1254
1255 On some of the questions which ask for file or directory names you are allowed
1256 to use the ~name construct to specify the login directory belonging to "name",
1257 even if you don't have a shell which knows about that.  Questions where this is
1258 allowed will be marked "(~name ok)".
1259
1260 EOH
1261     rp=''
1262     dflt='Type carriage return to continue'
1263     . ./myread
1264     cat <<'EOH'
1265
1266 The prompter used in this script allows you to use shell variables and
1267 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1268 in the default answer, as if the default line was a set of arguments given to a
1269 script shell.  This means you may also use $* to repeat the whole default line,
1270 so you do not have to re-type everything to add something to the default.
1271
1272 Everytime there is a substitution, you will have to confirm.  If there is an
1273 error (e.g. an unmatched backtick), the default answer will remain unchanged
1274 and you will be prompted again.
1275
1276 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1277 the questions and use the computed defaults (or the previous answers if there
1278 was already a config.sh file). Type 'Configure -h' for a list of options.
1279 You may also start interactively and then answer '& -d' at any prompt to turn
1280 on the non-interactive behaviour for the remaining of the execution.
1281
1282 EOH
1283     . ./myread
1284     cat <<EOH
1285
1286 Much effort has been expended to ensure that this shell script will run on any
1287 Unix system.  If despite that it blows up on yours, your best bet is to edit
1288 Configure and run it again.  If you can't run Configure for some reason,
1289 you'll have to generate a config.sh file by hand.  Whatever problems you
1290 have, let me (pennmush-developers@pennmush.org) know how I blew it.
1291
1292 This installation script affects things in two ways:
1293
1294 1) it may do direct variable substitutions on some of the files included
1295    in this kit.
1296 2) it builds a config.h file for inclusion in C programs.  You may edit
1297    any of these files as the need arises after running this script.
1298
1299 If you make a mistake on a question, there is no easy way to back up to it
1300 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1301 files.  Configure will offer to let you do this before it runs the SH files.
1302
1303 EOH
1304     dflt='Type carriage return to continue'
1305     . ./myread
1306     case "$firsttime" in
1307     true) echo $user >>../.config/instruct;;
1308     esac
1309 fi
1310
1311 : find out where common programs are
1312 echo " "
1313 echo "Locating common programs..." >&4
1314 cat <<EOSC >loc
1315 $startsh
1316 case \$# in
1317 0) exit 1;;
1318 esac
1319 thing=\$1
1320 shift
1321 dflt=\$1
1322 shift
1323 for dir in \$*; do
1324     case "\$thing" in
1325     .)
1326     if test -d \$dir/\$thing; then
1327         echo \$dir
1328         exit 0
1329     fi
1330     ;;
1331     *)
1332     for thisthing in \$dir/\$thing; do
1333         : just loop through to pick last item
1334     done
1335     if test -f \$thisthing; then
1336         echo \$thisthing
1337         exit 0
1338     elif test -f \$dir/\$thing.exe; then
1339         : on Eunice apparently
1340         echo \$dir/\$thing
1341         exit 0
1342     fi
1343     ;;
1344     esac
1345 done
1346 echo \$dflt
1347 exit 1
1348 EOSC
1349 chmod +x loc
1350 $eunicefix loc
1351 loclist="
1352 awk
1353 cat
1354 chmod
1355 comm
1356 cp
1357 echo