aboutsummaryrefslogtreecommitdiff
path: root/Install.in
blob: fc3433a01cd0e79620b0e32bac0e1d1a4b1d0c76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
#!/bin/sh
### Copyright (C) 1991, 1992, Cygnus Support
### All Rights Reserved.

### This really needs to nestle up snuggly to the Release notes.  If you change
### this script, please be sure the release notes get coordinated too.

set -e

### this is our version number.
VERSION=cygnus-sol2-||RELNO||

### this is the default installation repository. We use this to test whether or
### not GCC_EXEC_PREFIX should be set when doing "Install test comp-tools".
#INSTALLDIR_DEFAULT=/giga/rich/tmp/installdir
INSTALLDIR_REAL=/opt
INSTALLDIR_DEFAULT=${INSTALLDIR_REAL}
### this is where we install into.  (useful for testing).
INSTALLDIR=${INSTALLDIR_DEFAULT}

### where to write the log files
LOGDIR=${INSTALLDIR}/${VERSION}

### who to call in bad situations
HOTLINE="the Cygnus Support Hotline at +1 415 322 7836"

### what the release doc is called and a few sections thereof
NOTES="the Installation Notes"
CHANGING_PATHS="\"Changing the Paths\""
NO_ACCESS="\"No Access to ${INSTALLDIR}\?\""
MIGHT_WRONG="\"Some Things that Might go Wrong\""
WHY_FIXINCLUDES="Why Convert System Header Files\?"
ANOTHER_TAPE="\"Steps to install with another machine\'s tape drive\""

### for debugging
#PATH=/bin:/usr/bin ; export PATH

### default the tape device
case "${TAPE}" in
  "") TAPE=||DEVdflt|| 
      ;;
  *) 
      ;;
esac # ${TAPE}

### clear and/or initialize some variables
ARCH=
TOOLS=
FTPRELEASE=no

REMOVE=no
EXTRACT=no
FIXINCLUDES=no
TESTINSTALLATION=no

INSTALLHOST=default
ERROR=

### where the binaries are in the release
#EXECDIR=${VERSION}/H-${INSTALLHOST}
EXECDIR=${VERSION}

### some tool defaults
### perhaps these should be hard coded to absolute paths instead?
TAR=tar
TARKEYS="xvvopf -"
SED=sed
MT=mt

### trigger words on the command line are:
###     bin, src
###     emacs, comp-tools
###     -tape=/dev/device
###     -installdir=/foo
###     extract, fixincludes, test-installation, remove

for arg in $* ; do
        case "${arg}" in
### options
        -tape=* | --tape=* | --tap=* | --ta=* | --t=*)
                TAPE=`echo ${arg} | ${SED} 's/-*t[a-z]*=//'`
                ;;

        -installdir=* | --installdir=* | --installdi=* | --installd=* | --install=* | --instal=* | --insta=* | --inst=* | --ins=* | --in=* | --i=*)
                INSTALLDIR=`echo ${arg} | ${SED} 's/-*i[a-z]*=//'`
		# we will make it an absolute path shortly.
                ;;

### actions
        *remove* | rm | -rm | --rm)     ACTIONS="${ACTIONS} rm" ;;
        *extract*)      ACTIONS="${ACTIONS} extract" ;;
        *fix*)          ACTIONS="${ACTIONS} fix" ;;
        *test*)         ACTIONS="${ACTIONS} test" ;;
### hosts
        *src* | *sour*) ARCH="${ARCH} src" ;;
        *bin*)          ARCH="${ARCH} bin" ;;

### packages
        *emacs*)        TOOLS="${TOOLS} emacs" ;;
        *comp*)         TOOLS="${TOOLS} comp" ;;
        *help*) ERROR=true ;;
        *)
                echo '***' I do not understand the option \"${arg}\".
                ERROR=true
                ;;
        esac # ${arg}
done # arg in $*

###
###
### check for a myriad of sins
###
###

if [ ! -d "${INSTALLDIR}" ] ; then
	echo '*** ' Can not cd to \"${INSTALLDIR}\" because it does not exist.
	echo '*** ' Try creating it with \"mkdir ${INSTALLDIR}\" and then try running Install again.
	exit 1
else
	if (cd "${INSTALLDIR}") ; then 
		true
	else
		echo '*** ' Can not cd to \"${INSTALLDIR}\" because I do not have execute permission.
		ls -lad ${INSTALLDIR}
		echo '*** ' Please fix this and then try running Install again.
		exit 1
	fi   # ! cd ${INSTALLDIR}
fi   # ! -d ${INSTALLDIR}

# Make INSTALLDIR absolute (parts below might need it that way).
# FIXME, do they really?
# FIXME, handle pwd failure from upper dir permission
INSTALLDIR=`cd ${INSTALLDIR} ; pwd`
LOGDIR=${INSTALLDIR}/${VERSION}

case "${ERROR}" in
  "")
### default tools
        case "${TOOLS}" in
          "") TOOLS="||BUNDLE||" ;;
          *) ;;
        esac # ${TOOLS}

        INSTALLHOST=

### decide where we are: try arch first.
        if (arch) > /dev/null 2>&1 ; then
                MAYBE=`arch`
        else
                true
        fi # (arch)

        case "${MAYBE}" in
          sun3) INSTALLHOST=${MAYBE} 
		;;
          *)
### next try uname
                if (uname > /dev/null) 2>&1 ; then
                        UNAME=`echo \`uname -s\`\`uname -m\`\`uname -r\``
                else
                        UNAME="machine without a uname command (type of machine unknown)"
                fi # (uname)

### map into names we recognize
                case "${UNAME}" in
                  AIX*)
                  	INSTALLHOST=rs6000
                        MT=tctl
                        ;;
                  ULTRIXRISC)     INSTALLHOST=decstation ;;
                  SunOSsun4*5*)   INSTALLHOST=sparc-sun-solaris2 ;;
                  SunOSsun4*)     INSTALLHOST=sun4 ;;
                  SunOSsun3*)     INSTALLHOST=sun3 ;;
                  IRIX*)          INSTALLHOST=iris4 ;;
                  *)              INSTALLHOST=unknown ;;
                esac # ${UNAME}
                ;;
        esac # ${MAYBE}

### default arch
        case "${ARCH}" in
          "")     ARCH="bin src" ;;
          *) ;;
        esac # ${ARCH}

### default actions

        case "${ACTIONS}" in
          "")
                case "${FTPRELEASE}" in
                  "yes") ACTIONS="test" ;;
                  "no" ) ACTIONS="extract test" ;;
                esac # ${FTPRELEASE}


### fixincludes only if comp-tools
                for tool in ${TOOLS} ; do
                        case ${tool} in
                          comp)
                                if echo ${ARCH} | grep bin > /dev/null 2>&1 ; then
                                        ACTIONS="${ACTIONS} fix"
                                fi
                                ;;
                          *) ;;
                        esac # ${TOOLS}
                done # for tool in ${TOOLS}
                ;;
        *) ;;
        esac # ${ACTIONS}
        ;;
  *) ;;
esac  # ${ERROR}

case "${ERROR}" in
  "")
### if binaries are not intended for this machine
        case "${INSTALLHOST}" in
        "||HOSTstr||") ### binaries are intended for this machine
                for action in ${ACTIONS} ; do
                        case ${action} in
                        test)
                                for tool in ${TOOLS} ; do
					OURWD=`(cd ${INSTALLDIR}; pwd) 2>/dev/null`
					DEFAULTWD=`(cd ${INSTALLDIR_REAL}; pwd) 2>/dev/null`
                                        case ${tool} in
                                        comp)
                                                case "${OURWD}" in
                                                  "${DEFAULTWD}") ;;
                                                  *)
        echo '***' If you want to use the compilation tools in an alternate
        echo '***   ' directory, GCC_EXEC_PREFIX must be set.  You probably
        echo '***   ' want to set it with:
        echo GCC_EXEC_PREFIX=${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/ ; export GCC_EXEC_PREFIX
        GCC_EXEC_PREFIX=${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/ ; export GCC_EXEC_PREFIX
        echo '***   ' This is what I will use for the installation tests.
						   # skip C++ msg on Solaris
						   case "${INSTALLHOST}" in
						   sparc-sun-solaris2) ;;
						   *)
        echo '***   ' And for g++ I will use the options:
        echo '***   '   -I${INSTALLDIR}/${EXECDIR}/lib/g++-include
        echo '***   '        -L${INSTALLDIR}/${EXECDIR}/lib
							;;
						   esac # ${INSTALLHOST}
        echo '***   ' For further help, please refer to ${CHANGING_PATHS}
        echo '***   ' in ${NOTES}.

        GPLUSOPTIONS="-I${INSTALLDIR}/${EXECDIR}/lib/g++-include -L${INSTALLDIR}/${EXECDIR}/lib"
                                                  ;;
                                                esac # ${INSTALLDIR}
                                                ;;
                                        emacs)
                                                case "${OURWD}" in
                                                  "${DEFAULTWD}") ;;
                                                  *)
                                                        echo '***' I cannot test Emacs.
                                                        echo '***   ' The provided Emacs binary can only run from the default
                                                        echo '***   ' installation directory.  If you wish to run emacs, please
                                                        echo '***   ' refer to ${CHANGING_PATHS} in ${NOTES}.
                                                        exit 1
                                                        ;;
                                                esac # ${INSTALLDIR}
                                                ;;
                                          *) true ;;
                                        esac # ${tool}
                                done # for tool in ${TOOLS}
                                ;;
                          *) true ;;
                        esac # ${action}
                done # for action in ${ACTIONS}
                ;;

        *)
                for action in ${ACTIONS} ; do
                        case ${action} in
                          rm | extract)   true ;;
                          fix)
                                if echo ${TOOLS} | grep comp > /dev/null ; then
                                        NOTFIXED="fixincludes"
                                        if echo ${ACTIONS} | grep test > /dev/null ; then
                                                JOINER=" or "
                                        else
                                                true
                                        fi # echo ${ACTIONS}
                                else
#                                       echo '***' If you only install Emacs you do not need to run fixincludes.
#                                       ERROR=true
                                        true
                                fi # echo ${TOOLS}
                                ;;
                          test)   NOTTESTED="the installation tests" ;;
                        esac # ${action}
                done # for action in ${ACTIONS}
                ;;
        esac # ${INSTALLHOST}
        ;;
  *) ;;
esac # ${ERROR}

if [ -n "${NOTFIXED}" -o -n "${NOTTESTED}" ] ; then
        case "${INSTALLHOST}" in
          "||HOSTstr||") ;;
          *)
                echo '***   ' This machine appears to be a \"${INSTALLHOST}\".
                echo '***   ' You may still run \"$0 -extract ...\" on this machine and then
                echo '***   ' run the other steps on the machine on which you wish to install.
                echo '***   ' You will need to do these steps separately.
                echo '***   ' For more information, please refer to
                echo '***   ' ${ANOTHER_TAPE} in ${NOTES}.
                ERROR=true
                ;;
        esac # ${INSTALLHOST}
fi # [ -n ${NOTFIXED -o -n ${NOTTESTED} ]

### if we can't read the tape drive...
popdir=`pwd`

if [ ! -d "${LOGDIR}" ] ; then
	if mkdir ${LOGDIR}; then
		true
	else
		echo '*** ' Can not write logs to \"${LOGDIR}\" because it does not exist.
		echo '*** ' Try creating it with \"mkdir ${LOGDIR}\" and then try running Install again.
		exit 1
	fi
else
        if [ ! -w "${LOGDIR}" ] ; then
                echo '*** ' Can not write logs to \"${LOGDIR}\" because I do not have write permission.
                ls -lad ${LOGDIR}
                echo '*** ' Please fix this and then try running Install again.
                exit 1
        fi   # ! -r ${LOGDIR}
fi   # ! -d ${LOGDIR}


cd ${INSTALLDIR}

### There is a window here that I don't know how to handle gracefully from
### shell.  If the directory DID exist and WAS executable but dissappeared
### before we could cd into it, we're kinda hosed.  If you get a call about
### this, make sure the directory exists, is readable, is executable, is the
### either the default installation directory or the -installdir=directory
### given on the command line.  Then ask them to just try again.  A few times.
### If you get the same error every time, we've got a very strange bug.  I
### can't help you.

if [ "$?" != "0" ] ; then
        echo '***' Cannot cd to \"${INSTALLDIR}\".  This is a problem.
        echo '***   ' For further help, please refer to
        echo '***   ' ${NO_ACCESS} in ${NOTES} or call
        echo '***   ' ${HOTLINE}
        exit 1
fi

if echo ${ACTIONS} | grep extract > /dev/null ; then
        if [ -z "${ERROR}" -a ! -r "${TAPE}" ] ; then
        ### try checking for a relative tape path
                if [ -r ${popdir}/${TAPE} ] ; then
                        TAPE=${popdir}/${TAPE}
                        echo '***' Using TAPE device \"${TAPE}\".
                else
                        echo '***' Can not read from TAPE device, \"${TAPE}\".
                        cd ${popdir} ; ls -lasd ${TAPE}
                        echo '***   ' Try using \"./Install -tape=/dev/something ...\" to name your tape
                        echo '***   ' drive or refer to ${MIGHT_WRONG} in
                        echo '***   ' ${NOTES}.
                        exit 1
                fi  # ! -r ${popdir}/${TAPE}
        fi   # -z ${ERROR}
fi   # extract in ${ACTIONS}

cd ${popdir}

### bail out

case "${ERROR}" in
"") ;;
*)
        cat <<EOF
You may supply at least one format on the command line.  Recognized formats
are:
    binaries    for binaries
    source      for source code
The default is both source and binaries.

You may also supply actions.  Recognized actions are:
    extract     read the appropriate files from tape
    fixincludes build a directory of corrected header files for comp-tools 
    test        run a very brief verification of your installation
Default actions are extract, fixincludes, and test, although fixincludes is not
necessary for emacs.

There are two other options:
    -tape=DEVICE   asks Install to read the necessary files from DEVICE. The
                   default DEVICE is ||DEVdflt||, the ||TAPdflt||, cartridge tape
                   drive on most ||HOSTstr||s.
    -installdir=DIRECTORY       asks Install to install files into DIRECTORY.
                                The default DIRECTORY is ${INSTALLDIR_DEFAULT}.
No action has been taken.
EOF
        exit 1
        ;;
esac


###
###
### build a file list
###     (easy this round because we have only one package).
###

FILE_LIST=
TRIGGERS=

for arch in ${ARCH} ; do
        case ${arch} in
        bin)
                FILE_LIST="${FILE_LIST} \
                        ${VERSION}/Install \
                        ${VERSION}/CYGNUS \
                        ${EXECDIR}/lib \
                        ${EXECDIR}/bin \
                        ${VERSION}/include \
                        ${VERSION}/info \
                        ${VERSION}/lib \
                        ${VERSION}/man"
                for tool in ${TOOLS} ; do
                        case ${tool} in
                        comp)   TRIGGERS="${TRIGGERS} ${EXECDIR}/bin/gcc" ;;
                        emacs)  TRIGGERS="${TRIGGERS} ${EXECDIR}/bin/emacs" ;;
                        *)
                                echo '***' Oops.  Sanity failure on triggers for binaries for ${tool}.
                                exit 1
                                ;;
                        esac
                done
                ;;
        src)
                FILE_LIST="${FILE_LIST} \
                        ${VERSION}/Install \
                        ${VERSION}/CYGNUS \
                        ${VERSION}/src"
                for tool in ${TOOLS} ; do
                        case ${tool} in
                        comp)   TRIGGERS="${TRIGGERS} ${VERSION}/src/gcc/gcc.c" ;;
                        emacs)  TRIGGERS="${TRIGGERS} ${VERSION}/src/emacs/src/emacs.c" ;;
                        *)
                                echo '***' Oops.  Sanity failure on triggers for source for ${tool}.
                                exit 1
                                ;;
                        esac
                done
                ;;
        *)
                echo '***' Oops.  Sanity failure on triggers for arch ${arch}.
                ;;
        esac
done

###
###
### removal
###
###

if echo ${ACTIONS} | grep rm > /dev/null 2>&1 ; then
        if [ ! -d "${INSTALLDIR}" ] ; then
                echo '***' Cannot remove anything from \"${INSTALLDIR}\" because it does not exist.
                echo '***   ' You probably do not need to remove anything.
        else
                popdir=`pwd`
                if [ ! -d "${INSTALLDIR}" ] ; then
                        echo '***' Can not cd to \"${INSTALLDIR}\" because it does not exist.
                        echo '***   ' You probably do not need to remove anything.
                        exit 1
                else
                        if [ ! -r "${INSTALLDIR}" ] ; then
                                echo '***' Can not cd to \"${INSTALLDIR}\" because I do not have execute permission.
                                ls -lad ${INSTALLDIR}
                                echo '***   ' Please fix this and then try running Install again.  For
                                echo '***   ' more information, please refer to ${NO_ACCESS}
                                echo '***   ' in ${NOTES}.
                                exit 1
                        fi
                fi

                cd ${INSTALLDIR}

### see also the above note about the timing window.

                if [ "$?" != "0" ] ; then
                        echo '***' Cannot cd to \"${INSTALLDIR}\".  This is a problem.
                        echo '***   ' For further help, please refer to
                        echo '***   ' ${NO_ACCESS} in ${NOTES} or call
                        echo '***   ' ${HOTLINE}
                        exit 1
                else
                        true
                fi

                if [ ! -d "${VERSION}" ] ; then
                        echo '***' Cannot remove anything from \"${INSTALLDIR}/${VERSION}\" because it does not exist.
                        echo '***   ' You probably do not need to remove anything.
                        exit 1
                else
                        true
                fi

                echo Removing from \"${INSTALLDIR}\"...

                if rm -rf ${FILE_LIST} ; then
                        # if neither binaries nor source are installed, remove installdir
                        if [ -d ${INSTALLDIR}/${EXECDIR} \
                                -o -d ${INSTALLDIR}/${VERSION}/src ] ; then
                                true
                        else
                                if rm -rf "${INSTALLDIR}/${VERSION}" ; then
                                        true
                                else
                                        if [ ! -w "${INSTALLDIR}" ] ; then
                                                echo '***' I can not remove ${INSTALLDIR}/${VERSION}
                                                echo '***   ' because I do not have write access to \"${INSTALLDIR}\"
                                                echo '***   ' Please fix this and try running Install again.  For more information
                                                echo '***   ' please refer to ${NO_ACCESS} in ${NOTES}.
                                                exit 1
                                        else
                                                echo '***' I do not know why I can not remove ${INSTALLDIR}/${VERSION}.  This is
                                                echo '***   ' probably not a problem.
                                        fi
                                        exit 1
                                fi
                        fi

                        echo Removed.
                else
                        echo '***' There appears to have been a removal error.
                        echo '***   ' Chances are that this is not a problem, but you might try removing
                        echo '***   ' again.
                        exit 1
                fi
        fi
        echo Cygnus Support software distribution removed!
else
        true
fi # if removing

###
###
### extraction
###
###

if echo ${ACTIONS} | grep extract > /dev/null 2>&1 ; then
        if [ ! -d "${INSTALLDIR}" ] ; then
                echo Trying to create \"${INSTALLDIR}\"...
                if mkdir ${INSTALLDIR} ; then
                        echo Created \"${INSTALLDIR}\".
                else
                        echo '***' I can not make directory, \"${INSTALLDIR}\".

### attempt to diagnose...

                        DIR=`echo ${INSTALLDIR} | ${SED} -e 's:/[^/]*$::'`
                        if [ ! -d "${DIR}" ] ; then
                                echo '***   ' It looks as though \"${DIR}\" does not even exist.
                                exit 1
                        else
                                if [ ! -w "${DIR}" ] ; then
                                        echo '***   ' It looks as though you do not have write access to \"${DIR}\".
                                        echo '***   ' Please fix this and try running Install again.  For more information
                                        echo '***   ' please refer to ${NO_ACCESS} in ${NOTES}.
                                        exit 1
                                else
                                        echo '***   ' I do not know why I can not create \"${INSTALLDIR}\".  This is a problem.
                                        echo '***   ' Please call ${HOTLINE}
                                        exit 1
                                fi  # ! -w ${DIR}
                        fi  # ! -d ${DIR}
                fi  # mkdir ${INSTALLDIR}
        else
                true
        fi  # ! -d ${INSTALLDIR}

        cd ${INSTALLDIR}

        if [ "$?" = "0" ] ; then
                for trigger in ${TRIGGERS} ; do
                        if [ -r "${trigger}" ] ; then
                                echo '***' \"${INSTALLDIR}/${trigger}\" exists and I will not overwrite it.
                                echo '***   ' If you really want to install it again, please remove it first.
                                exit 1
                        else
                                true
                        fi  # -r ${trigger}
                done  # for trigger
        else
                echo '***' I can not cd to \"${INSTALLDIR}\".

### attempt to diagnose...

                if [ ! -r "${INSTALLDIR}" ] ; then
                        echo '***   ' It looks as though you do not have execute permission to \"${INSTALLDIR}\".
                else
                        true
                fi  # ! -r ${INSTALLDIR}

                echo '***   ' For further help, please refer to
                echo '***   ' ${NO_ACCESS} in ${NOTES}.
                exit 1
        fi  # status is zero


### remove redundant names from the list
        echo ${FILE_LIST} ${COMMONS} ${EMACSHIBIN} | tr ' ' '
' | sort | uniq > ${LOGDIR}/extract_list

        echo It will take some time for me to read the tape.
        echo Verbose output will be saved in ${LOGDIR}/tar.log
        echo Extracting into \"${INSTALLDIR}\"... 

### make sure things come off the tape as they were written, but minus what could be a security hole.
        umask 0

### using the no rewind device, so rewind and fsf to be sure.

        if ${MT} -f ${TAPE} rewind > /dev/null 2>&1 ; then
                if ${MT} -f ${TAPE} fsf 1 ; then
                        true
                else
                        echo '***' Could not forward space tape device \"${TAPE}\".
                        exit 1
                fi  
        else
                if test -r ${TAPE} ; then
                        true
                else
                        echo '***' Could not rewind tape device \"${TAPE}\".
                        exit 1
                fi
        fi  # mt ${TAPE} rewind

        if dd if=${TAPE} bs=124b | compress -d | ${TAR} ${TARKEYS} `cat ${LOGDIR}/extract_list` > ${LOGDIR}/tar.log 2>&1 && test -d ${VERSION} ; then
		if [ -d ${INSTALLDIR}/${EXECDIR}/bin ] ; then
			echo Extracted.
		else
			echo '***' The extraction has failed.  The directory
			echo '***' ${INSTALLDIR}/${EXECDIR}/bin was not extracted.
			echo '***   ' The output from the tar command has been logged in ${LOGDIR}/tar.log
			echo '***   ' I do not know how to continue until this problem has been
			echo '***   ' corrected.  If you do not know how to fix it either, please
			echo '***   ' call ${HOTLINE}.
			exit 1
		fi

                if (${MT} -f ${TAPE} rewind > /dev/null 2>&1) ; then
                        true
                else
                        true
                fi  # mt rewind
        else
                echo '***' There appears to have been an extraction error.
                echo '***   ' The output from the tar command has been logged in ${LOGDIR}/tar.log
                echo '***   ' I do not know how to continue until this problem has been
                echo '***   ' corrected.  If you do not know how to fix it either, please
                echo '***   ' call ${HOTLINE}.
                exit 1
        fi  # dd | compress | tar ....

        rm -f ${LOGDIR}/extract_list
        echo Cygnus Support software distribution extracted!
else
        true
fi   # extraction in actions

###
###
### fixincludes
###
###

if echo ${ACTIONS} | grep fix > /dev/null 2>&1 ; then
        echo Running fixincludes for ${INSTALLHOST}.
        echo Verbose output will be stored in ${LOGDIR}/fixincludes.log
        echo This will take some time.
        LIB=${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/include ; export LIB

	if mkdir ${LIB}/tmpdir && mv ${LIB}/*.h ${LIB}/tmpdir ; then
		if ${INSTALLDIR}/${VERSION}/lib/fixincludes ${LIB} /usr/include ${INSTALLDIR}/${VERSION}/src/gcc > ${LOGDIR}/fixincludes.log ; then
			mv ${LIB}/tmpdir/* ${LIB} && rmdir ${LIB}/tmpdir 
			echo Finished with fixincludes.
		else
			echo '***' There seems to have been a problem with fixincludes.
			echo '***   ' The verbose output from the fixincludes script has been logged in
			echo '***   ' ${INSTALLDIR}/${VERSION}/fixincludes.log.
			echo '***   ' I do not know how to continue until this problem has been
			echo '***   ' corrected.  If you do not know how to fix it either, please
			echo '***   ' call ${HOTLINE}.
			mv ${LIB}/tmpdir/* ${LIB} && rmdir ${LIB}/tmpdir
			exit 1
		fi  # 
	else
                echo '***' Not able to create the temporary include dir
                echo '***  ' Please ensure that write permissions for
                echo '***  ' ${LIB} are allowed.
                echo '***  ' Or call ${HOTLINE} for more information.
                exit 1
	fi	
        echo Fixed include files installed!
else
        true
fi  # fix in actions

###
###
### testing the installation
###
###

if echo ${ACTIONS} | grep test > /dev/null 2>&1 && echo ${ARCH} | grep bin > /dev/null 2>&1 ; then
	popdir=`pwd`
	cd ${LOGDIR}
        for tool in ${TOOLS} ; do
                case ${tool} in
                  comp)
                        if [ -f ${INSTALLDIR}/${EXECDIR}/bin/gcc ] ; then
                        cat > ${LOGDIR}/hello.c <<'e!o!f'
#include <stdio.h>

extern int printf();

int main(int argc, char **argv) {
        (void) printf("hello: The compilation tools appear to be installed correctly on your %s.\n",
                MACHINE);
        return(0);
} /* main() */
e!o!f
                        if ${INSTALLDIR}/${EXECDIR}/bin/gcc -Wall -O -g \
                                -DMACHINE=\"${INSTALLHOST}\" ${LOGDIR}/hello.c -o ${LOGDIR}/hello ; then
                                if ${LOGDIR}/hello ; then
                                        echo This is good.
                                else
                                        echo '***' Hello.c fails to run.  This is a problem.
                                        echo '***   ' Please call ${HOTLINE}
                                        exit 1
                                fi  # ./hello
                        else
                                echo '***' Hello.c fails to compile.  This is a problem.
                                echo '***   ' Please call ${HOTLINE}
                                exit 1
                        fi  # run gcc

### now check for fixed includes.
                        cat > ${LOGDIR}/test-ioctl.c << 'e!o!f'
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>

double atof(const char *);

#ifdef __sun__
#include <sys/filio.h>

extern int ioctl();
extern int perror();
#endif /* __sun__ */

extern int printf();

int main(int argc, char **argv) {
#ifdef __sun__
        long l;
        int fd;
        int retval;

        if ((fd = open("/dev/tty", O_RDONLY)) == -1) {
                (void) perror("test-ioctl: can't open /dev/null");
                return(1);
        } else if ((retval = ioctl(fd, FIONREAD, &l)) != 0) {
                (void) perror("test-ioctl: ioctl failed");
                (void) printf("test-ioctl: Most likely, you have not run \"Install fixincludes\" on this machine.\n");
                return(2);
        }
#endif /* __sun__ */

        printf("test-ioctl: Ansi versions of the system header files, (the fixed includes),\n");
        printf("test-ioctl: appear to be installed correctly.\n");

/* that's right.  If closing /dev/tty fails, I don't want to know about it. */

        return(0);
}
e!o!f

                        case "||HOSTstr||" in
                        sun3 | sun4 | decstation)
                                if ${INSTALLDIR}/${EXECDIR}/bin/gcc -Wall -O -g \
                                        -DMACHINE=\"${INSTALLHOST}\" ${LOGDIR}/test-ioctl.c -o ${LOGDIR}/test-ioctl ; then
                                        if ${LOGDIR}/test-ioctl ; then
                                                echo This is good.
                                        else
                                                case "$?" in
                                                1)
                                                        echo '***' test-ioctl.c fails to read /dev/tty.  If you were running Install
                                                        echo '***   ' in batch or from a daemon, please try running it again interactively.
                                                        echo '***   ' If not, please call ${HOTLINE}
                                                        exit 1
                                                        ;;
                                                2)
                                                        echo '***' test-ioctl.c fails to ioctl.
                                                        echo '***   ' Most likely you need to run \"Install fixincludes\".
                                                        echo '***   ' Please run \"Install fixincludes\" and
                                                        echo '***   ' then try this test again.  For an explanation see
                                                        echo '***   ' ${WHY_FIXINCLUDES} in ${NOTES}.
                                                        exit 1
                                                        ;;
                                                *)
                                                        echo '***' test-ioctl.c fails to run.  This is a problem.
                                                        echo '***   ' Please call ${HOTLINE}
                                                        exit 1
                                                        ;;
                                                esac  # $?
                                                exit 1
                                        fi  # test-ioctl
                                else
### this presupposes that hello.c DID compile.
                                        echo '***' test-ioctl.c fails to compile.  This is a problem.
                                        echo '***   ' Please call ${HOTLINE}
                                        exit 1
                                fi  # run gcc
                                ;;
                        iris4)
                                if [ ! -f ${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/include/sys/cfeiroute.h ]
                                then
                                        echo '***' You seem to be missing ${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/include/sys/cfeiroute.h.
                                        echo '***   ' Most likely you need to run \"Install fixincludes\".
                                        echo '***   ' Please run \"Install fixincludes\" and
                                        echo '***   ' then try this test again.  For an explanation see
                                        echo '***   ' ${WHY_FIXINCLUDES} in ${NOTES}.
                                        exit 1
                                fi  # test fixincluded file
                                ;;
			sparc-sun-solaris2)
                                if [ ! -f ${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/include/ieeefp.h ]
                                then
                                        echo '***' You seem to be missing ${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/include/ieeefp.h.
                                        echo '***   ' Most likely you need to run \"Install fixincludes\".
                                        echo '***   ' Please run \"Install fixincludes\" and
                                        echo '***   ' then try this test again.  For an explanation see
                                        echo '***   ' ${WHY_FIXINCLUDES} in ${NOTES}.
                                        exit 1
				fi
				;;

                        rs6000)
                                if [ ! -f ${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/include/piostruct.h ]
                                then
                                        echo '***' You seem to be missing ${INSTALLDIR}/${EXECDIR}/lib/gcc-lib/||HOSTstr||/||GCCvn||/include/piostruct.h.
                                        echo '***   ' Most likely you need to run \"Install fixincludes\".
                                        echo '***   ' Please run \"Install fixincludes\" and
                                        echo '***   ' then try this test again.  For an explanation see
                                        echo '***   ' ${WHY_FIXINCLUDES} in ${NOTES}.
                                        exit 1
                                fi  # test fixincluded file
                                ;;
                        esac  # ||HOSTstr||
                        else
                                true
                        fi  # test if gcc present

### now check for g++.
                        if [ -f ${INSTALLDIR}/${EXECDIR}/bin/g++ ] ; then
                                cat > ${LOGDIR}/hello.C << 'e!o!f'
#include <iostream.h>

int main(int argc, char**argv)
{
  char *machine = MACHINE;
  cout << "hello: g++ appears to be installed correctly on your "
        << machine << ".\n";
  return(0);
}
e!o!f
                                if ${INSTALLDIR}/${EXECDIR}/bin/gcc ${GPLUSOPTIONS} -Wall -O -g \
                                        -DMACHINE=\"${INSTALLHOST}\" ${LOGDIR}/hello.C -o ${LOGDIR}/Hello -lg++ ; then
                                        if ${LOGDIR}/Hello ; then
                                                echo This is good.
                                        else
                                                echo '***' hello.C fails to run.  This is a problem.
                                                echo '***   ' Please call ${HOTLINE}
                                                exit 1
                                        fi  # ./Hello
                                else
        ### this presupposes that hello.c DID compile.
                                        echo '***' hello.C fails to compile.  This is a problem.
                                        echo '***   ' Please call ${HOTLINE}
                                        exit 1
                                fi  # run g++

        ### now check for static initialization.
                                cat > ${LOGDIR}/static-init.C << 'e!o!f'
#include <iostream.h>
int Three;

struct Foo {
    Foo(int i) { Three = i; }
};

Foo foo(3);

int main(int argc, char**argv)
{
  if (Three != 3) {
        cout << "static-init: static initialization fails.\n";
        return(1);
  }

  cout << "static-init: static initialization appears to work.\n";
  return(0);
}
e!o!f
                                if ${INSTALLDIR}/${EXECDIR}/bin/gcc ${GPLUSOPTIONS} -Wall -O -g \
                                        -DMACHINE=\"${INSTALLHOST}\" ${LOGDIR}/static-init.C -o ${LOGDIR}/static-init -lg++ ; then
                                        if ${LOGDIR}/static-init ; then
                                                echo This is good.
                                        else
                                                echo '***' Static initialization is not working.  This is a problem.
                                                echo '***   ' Please call ${HOTLINE}
                                                exit 1
                                        fi  # run static-init
                                else
        ### this presupposes that it DID compile.
                                        echo '***' static-init.c fails to compile.  This is a problem.
                                        echo '***   ' Please call ${HOTLINE}
                                        exit 1
                                fi  # run g++
                        else # no g++, so don't test it
                                true
                        fi  #  no g++
                        ;;
                emacs)
                        cat > ${LOGDIR}/hello.el <<'e!o!f'
(server-start)
(message "Emacs appears to be installed correctly.")
(kill-emacs 0)
e!o!f
                        if ${INSTALLDIR}/${EXECDIR}/bin/emacs -batch -l ${LOGDIR}/hello.el ; then
                                echo This is good.
                        else
                                echo '***' Emacs fails to run.  This is a problem.
                                echo '***   ' Please call ${HOTLINE}
                                exit 1
                        fi
			;;
		src)  	# if anyone can tell me how to test the installation of source...
			true 
			;;
		*)
			echo '***' I do not know how to test for tool \"${tool}\" because I have never
			echo '***   ' heard of it.  This is a problem.  Please call ${HOTLINE}.
			exit 1
			;;
		esac
	done
	rm -f hello* test-ioctl* static-init* Hello*
	cd ${popdir}
	echo Cygnus Support software distribution tested!
else
	true
fi

echo Done.

exit 0

###
### Local Variables:
### comment-column: 0
### fill-column: 131
### End:
###

### End of Install