root/1.8.2/tags/p4/Configure

Revision 525, 155.8 KB (checked in by pennmush, 2 years ago)

PennMUSH 1.8.1p7 Archival

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