home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAWK113.ZIP / mawk113 / build_mawk < prev    next >
Text File  |  1993-02-04  |  4KB  |  216 lines

  1. #!/bin/sh
  2. #
  3. # build_mawk -- build mawk for a known configuration
  4. #
  5. #  usage:  build_mawk configuration  [CC=your_cc]  
  6. #       build_mawk MF
  7. #
  8. #  example:  build_mawk sun_os40  CC=gcc 
  9. #
  10. #            build_mawk MF -- to get a generic Makefile
  11. #
  12.  
  13. #$Id: build_mawk,v 1.16 1993/02/05 01:56:33 mike Exp $
  14.  
  15. progname=`basename $0`
  16.  
  17.  
  18. if [ $# = 0 ]
  19.    then
  20.     echo usage: $progname  configuration [CC=your_cc]  1>&2
  21.     echo "       $progname MF"     1>&2
  22.     echo  1>&2
  23.     echo tested configurations are listed in UCONFIG  1>&2
  24.     echo MF builds a fresh Makefile  1>&2
  25.     exit 1 
  26. fi
  27.  
  28. arg1=$1
  29. shift
  30.  
  31. [ $# != 0 ] && eval "$@"
  32.  
  33.  
  34. [ "$CC" = "" ] && CC=cc
  35.  
  36.  
  37. case $arg1 in
  38.  
  39.  
  40. sun_os40)
  41.     if  sun3 && [ $CC = cc ]
  42.         then cflags='-O -f68881'
  43.     fi
  44.     config=sun_os40.h ;;
  45.  
  46. sun3_os40_no68881)
  47.     config=sun_os40.h  ;;
  48.  
  49.  
  50. sun_os41)    
  51.     if  sun3 && [ $CC = cc ]
  52.         then cflags='-O -f68881'
  53.     fi
  54.     config=sun_os41.h ;;
  55.  
  56. sun3_os41_no68881)
  57.     config=sun_os41.h ;;
  58.  
  59. bsd43_vax)
  60.     config=bsd43_vax.h ;;
  61.  
  62. 386bsd)
  63.     config=386bsd.h ;;
  64.  
  65. ultrix41_mips)
  66.     config=generic.h  ;;
  67.  
  68. ultrix42_mips)
  69.     config=ultrix42mips.h
  70.     cflags='-O -Olimit 700' ;;
  71.  
  72. ultrix41_vax)
  73.     config=ultrix_vax.h 
  74.     cflags='-O -YSYSTEM_FIVE' ;;
  75.  
  76. ultrix31_vax)
  77.     config=ultrix_vax.h
  78.     cflags='-O -YSYSTEM_FIVE -DHAVE_VOID_PTR=0' ;;
  79.  
  80. stardentVr3)
  81.     config=generic.h  ;;
  82.  
  83. xenix_r2)
  84.     config=xenix_r2.h   ;;
  85.  
  86. sysV)
  87.     config=sysV.h  ;;
  88.  
  89. sysV_ieeefp)
  90.     config=sysV_ieeefp.h ;;
  91.  
  92. sysVr4i386)
  93.     config=sysVr4i386.h  ;;
  94.  
  95. # SCO UNIX has ranlib, but doesn't use it for native UNIX libraries
  96. sysVsco)
  97.     config=sysV.h
  98.     ranlib=: ;;
  99.  
  100. #apolloSR10.3)  #does not work anymore
  101. #    config=apollo.h  ;;
  102.  
  103. dynix)
  104.     config=dynix.h  ;;
  105.  
  106. atarist)
  107.     config=atarist.h
  108.         ranlib=:
  109.     ar=car
  110.         mathlib=-lpml
  111.     CC=cgcc ;;
  112.     
  113. mips)
  114.     config=mips.h
  115.     cflags='-O -Olimit 700 -systype bsd43' ;;
  116.  
  117. sgi)
  118.     config=sgi.h
  119.     cflags='-O -cckr -w' ;;
  120.  
  121. next)
  122.     config=next.h  ;;
  123.  
  124. aix)
  125.     config=aix.h ;;
  126.  
  127. convex)
  128.     config=convex.h
  129.     cflags='-O2 -std' ;;
  130.  
  131. hpux)
  132.     config=generic.h ;;
  133.  
  134. coherent)
  135.     echo Coherent will not pass fpe_test
  136.     echo overflow cannot be detected
  137.     echo
  138.         config=coherent.h
  139.         cflags='-O -f' ;;
  140.  
  141. linux)
  142.     config=linux.h
  143.     CC=gcc ;;
  144.  
  145. MF)  ;;
  146.  
  147. *)  echo "$progname: $arg1: unrecognized configuration" 1>&2
  148.     exit 1 ;;
  149. esac
  150.  
  151. [ "$cflags" = "" ] && cflags=-O
  152. [ "$ranlib" = "" ] && ranlib=ranlib
  153. [ "$ar" = "" ] && ar=ar
  154. [ "$mathlib" = "" ] && mathlib=-lm
  155.  
  156. # set CFLAGS for gcc
  157. if [ $CC = gcc ]
  158.    then  #determine gcc version
  159.    if gcc -v  2>&1 | egrep 'version 2' >/dev/null
  160.       then  cflags=-O2
  161.       else  cflags='-O -traditional'
  162.    fi
  163. fi
  164.  
  165. echo generating a Makefile
  166.  
  167. (
  168. echo "# This Makefile was generated by"
  169. echo '#'"   $0 $arg1 $*"
  170. sed -e 1,5d   \
  171.     -e "s/%CC%/$CC/" \
  172.     -e "s/%CFLAGS%/$cflags/" \
  173.     -e "s/%RANLIB%/$ranlib/" \
  174.     -e "s/%AR%/$ar/" \
  175.     -e "s/%MATHLIB%/$mathlib/"  Makefile.in
  176. ) > Makefile
  177.  
  178.  
  179. # make sure distribution parse.c is newer than parse.y
  180. if [ -f parse.c ]  # should be true
  181.    then
  182.    echo touching parse.c  ; touch parse.c
  183. fi
  184.  
  185.  
  186. [ $arg1 = MF ]  &&   exit 0
  187.  
  188.  
  189. if [ -f config.h ]
  190.   then
  191.      echo moving config.h to config.h.old
  192.      mv  config.h  config.h.old
  193. fi
  194. echo linking config/$config to config.h
  195. ln   config/$config  config.h
  196.  
  197.  
  198. echo 'ready to run: make -f Makefile'
  199. # echo without newline differs from system to system
  200. awk 'BEGIN{
  201. printf "do you want to check or edit the Makefile first? [n] "
  202. }' < /dev/null  # some old awks need the /dev/null
  203.  
  204. read answer
  205. case "$answer" in
  206.   [yY]*)  echo 
  207.       echo 'To restart run:  make -f Makefile'
  208.       echo
  209.       exit 0 ;;
  210. esac
  211.  
  212. echo make -f Makefile
  213. make -f Makefile
  214.  
  215.  
  216.