INSTALL 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #!/bin/sh
  2. # installation of fast ACK compilers fcc, fm2, and fpc
  3. # is the call correct?
  4. case $# in
  5. 1)
  6. if [ -d $1 ]
  7. then
  8. :
  9. else
  10. echo $0: $1 is not a directory >&2
  11. exit 1
  12. fi
  13. ;;
  14. *)
  15. echo $0: Call is $0 \<bin directory\> >&2
  16. exit 1
  17. ;;
  18. esac
  19. # investigate machine: either vax or sun(3)
  20. echo $0: determining type of machine ...
  21. cat > t.c <<'EOF'
  22. main() {
  23. #ifdef sun
  24. printf("sun\n");
  25. #endif
  26. #ifdef vax
  27. printf("vax\n");
  28. #endif
  29. }
  30. EOF
  31. if cc t.c
  32. then
  33. :
  34. else
  35. $0: compilation failed >&2
  36. exit 1
  37. fi
  38. m=`./a.out`
  39. rm -f a.out t.[co]
  40. case $m in
  41. sun|vax)
  42. echo $0: Starting installation for a $m ...
  43. ;;
  44. *)
  45. echo $0: machine must be sun or vax >&2
  46. exit 1
  47. ;;
  48. esac
  49. # make links to proper bin and lib directories
  50. echo $0: creating bin and lib directories ...
  51. rm -f bin lib
  52. ln -s bin.$m bin
  53. ln -s lib.$m lib
  54. # edit manual page
  55. sed s@CHANGE_ME@`pwd`/def@ < man/fm2.1.src > man/fm2.1
  56. # now compile the driver program
  57. echo $0: compiling driver program ...
  58. rm -f fcc fm2 fpc
  59. SunOs4=
  60. if [ -f /usr/lib/ld.so ]
  61. then
  62. # different options for the loader on SunOs 4.0
  63. SunOs4=-DSunOs4
  64. fi
  65. if cc -O -DFASTDIR=\"`pwd`\" $SunOs4 -DFCC -o fcc driver.c &&
  66. cc -O -DFASTDIR=\"`pwd`\" $SunOs4 -DFM2 -o fm2 driver.c &&
  67. cc -O -DFASTDIR=\"`pwd`\" $SunOs4 -DFPC -o fpc driver.c
  68. then
  69. :
  70. else
  71. echo $0: compilation of driver program failed >&2
  72. exit 1
  73. fi
  74. if cc -o str_change str_change.c
  75. then
  76. case $m in
  77. vax)
  78. ./str_change CHANGE_ME `pwd` < bin.vax/m2mm > fm2mm
  79. ;;
  80. sun)
  81. ./str_change CHANGE_ME `pwd` < bin.sun/m2mm > fm2mm
  82. ;;
  83. esac
  84. rm -f str_change.o str_change
  85. chmod +x fm2mm
  86. else
  87. echo "$0: compilation of string patching program failed; cannot create fm2mm" >&2
  88. fi
  89. #now run simple tests
  90. echo $0: run some simple tests
  91. failed=false
  92. cat > test.mod <<'EOF'
  93. MODULE test;
  94. FROM InOut IMPORT WriteString, WriteLn;
  95. BEGIN
  96. WriteString("Hello World");
  97. WriteLn
  98. END test.
  99. EOF
  100. if ./fm2 test.mod 2>/dev/null
  101. then
  102. case `a.out` in
  103. "Hello World")
  104. ;;
  105. *)
  106. echo $0: fm2 test failed >&2
  107. failed=true
  108. ;;
  109. esac
  110. else
  111. echo $0: fm2 compilation failed >&2
  112. failed=true
  113. fi
  114. cat > test.c <<'EOF'
  115. main() { printf("Hello World\n"); }
  116. EOF
  117. if ./fcc test.c 2>/dev/null
  118. then
  119. case `a.out` in
  120. "Hello World")
  121. ;;
  122. *)
  123. echo $0: fcc test failed >&2
  124. failed=true
  125. ;;
  126. esac
  127. else
  128. echo $0: fcc compilation failed >&2
  129. failed=true
  130. fi
  131. cat > test.p <<'EOF'
  132. program p(output); begin writeln('Hello World') end.
  133. EOF
  134. if ./fpc test.p 2>/dev/null
  135. then
  136. case `a.out` in
  137. "Hello World")
  138. ;;
  139. *)
  140. echo $0: fpc test failed >&2
  141. failed=true
  142. ;;
  143. esac
  144. else
  145. echo $0: fpc compilation failed >&2
  146. failed=true
  147. fi
  148. rm -f test.* a.out
  149. case $failed in
  150. true)
  151. echo $0: some tests failed, installation aborted >&2
  152. exit 1
  153. ;;
  154. false)
  155. rm -f $1/fm2 $1/fcc $1/fpc
  156. cp fm2 fcc fpc $1
  157. if [ -f fm2mm ]
  158. then
  159. rm -f $1/fm2mm
  160. cp fm2mm $1/fm2mm
  161. fi
  162. rm -f fm2 fpc fcc fm2mm
  163. echo $0: Installation completed
  164. exit 0
  165. ;;
  166. esac