home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / config / unix / setup.sh < prev   
Linux/UNIX/POSIX Shell Script  |  2002-03-04  |  2KB  |  88 lines

  1. #!/bin/sh
  2. #
  3. #  setup.sh -- invoked by top-level Makefile
  4.  
  5. USAGE="usage: setup.sh configname [No]Graphics [pthreads]"
  6.  
  7. NAME=$1
  8. GPX=$2
  9. CSW=$3
  10. TOP=../..
  11. SRC=$TOP/src
  12.  
  13. # check parameters
  14. case "$GPX" in
  15.    Graphics)    XL='-L../../bin -lXpm $(XLIBS)';;
  16.    NoGraphics)    XL= ;;
  17.    *)        echo "$USAGE" 1>&2; exit 1;;
  18. esac
  19. case "$CSW" in
  20.    custom | "")    ;;
  21.    pthreads)    ;;
  22.    *)        echo "$USAGE" 1>&2; exit 1;;
  23. esac
  24.  
  25. # check that configuration exists
  26. if [ ! -d "$NAME" ]; then
  27.    echo "no configuration directory for $NAME" 1>&2 
  28.    exit 1
  29. fi
  30.  
  31. # find and copy the context switch code.
  32. # use pthreads version if specified, or as a last resort.
  33. # by default, look for `uname -m`.[cs] and then rswitch.[cs].
  34. ARCH=`uname -m`
  35. if [ "$CSW" = "pthreads" ]; then
  36.    RSW=pthreads.c
  37.    COCLEAN="#define CoClean"
  38. elif [ -f $NAME/$ARCH.[cs] ]; then
  39.    RSW=`echo $NAME/$ARCH.[cs]`
  40.    COCLEAN=
  41. elif [ -f $NAME/rswitch.[cs] ]; then
  42.    RSW=`echo $NAME/rswitch.[cs]`
  43.    COCLEAN=
  44. else
  45.    RSW=pthreads.c
  46.    COCLEAN="#define CoClean"
  47. fi
  48. case $RSW in
  49.    *.c)  cp $RSW $SRC/common/rswitch.c;;
  50.    *.s)  cp $RSW $SRC/common/rswitch.s;;
  51. esac
  52.  
  53. if [ "$RSW" = "pthreads.c" ]; then
  54.    TL='$(TLIBS)'
  55. else
  56.    TL=
  57. fi
  58.  
  59. RSN=`echo $RSW | sed 's=.*/=='`
  60.  
  61. # build the "define.h" file
  62. echo "#define Config \"$NAME, $RSN\""         > $SRC/h/define.h
  63. echo "#define $GPX 1"                >> $SRC/h/define.h
  64. echo "$COCLEAN"                    >> $SRC/h/define.h
  65. echo ""                        >> $SRC/h/define.h
  66. cat  $NAME/define.h                >> $SRC/h/define.h
  67.  
  68. # build the "Makedefs" file
  69. echo "#  from config/unix/$NAME"         > $TOP/Makedefs
  70. echo ""                        >> $TOP/Makedefs
  71. cat $NAME/Makedefs                >> $TOP/Makedefs
  72. echo ""                        >> $TOP/Makedefs
  73. echo "TL = $TL"                    >> $TOP/Makedefs
  74. echo ""                        >> $TOP/Makedefs
  75. echo "#  $GPX"                    >> $TOP/Makedefs
  76. echo "XL = $XL"                    >> $TOP/Makedefs
  77.  
  78. # report actions
  79. echo "   configured $NAME"
  80. echo "   with $GPX"
  81. echo "   using $RSW"
  82.  
  83. # run customization script, if one exists
  84. if [ -f $NAME/custom.sh ]; then
  85.    cd $NAME
  86.    sh custom.sh
  87. fi
  88.