home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 402_01 / cforms-2.2 / Configure < prev    next >
Encoding:
Text File  |  1993-07-20  |  3.3 KB  |  153 lines

  1. #!/bin/sh
  2. # @(#) $Id: Configure,v 1.11 1993/07/21 01:58:08 lasse Exp $
  3. # Configure for cforms.
  4. #
  5. REPL=""
  6. CFLAGS="-g"
  7. config=src/config.h
  8.  
  9. findpath()
  10. {
  11.     dirs=`IFS=: set - $PATH; echo $*`
  12.     for d in $dirs
  13.     do
  14.     if [ -x $d/$1 ]; then
  15.         echo $d/$1
  16.         return 0
  17.     fi
  18.     done
  19.     return 1
  20. }
  21.  
  22. if [ -f /etc/inittab ]; then
  23.     CFLAGS="$CFLAGS -DSIGNAL_VOID -DSYSV"
  24.     if [ -d /proc ]; then
  25.     CFLAGS="$CFLAGS -DSVR4"
  26.     fi
  27. else
  28.     CFLAGS="$CFLAGS -DSIGNAL_INT"
  29. fi
  30.  
  31. rm -f src/config.h
  32. echo "/* Do not edit this file it is created by Configure */" >> $config
  33.  
  34. echo "#include <stdio.h>" >> $config
  35. echo "#include <curses.h>" >> $config
  36. echo "#include <ctype.h>" >> $config
  37. echo "#include <assert.h>" >> $config
  38. echo "#include <signal.h>" >> $config
  39. echo "#include <stdarg.h>" >> $config
  40. if [ -f /usr/include/stdlib.h ]; then
  41.     echo "#include <stdlib.h>" >> $config
  42. elif [ -f /usr/include/malloc.h ]; then
  43.     echo "#include <malloc.h>" >> $config
  44. fi
  45.  
  46. if [ -f /usr/include/string.h ]; then
  47.     echo "#include <string.h>" >> $config
  48. elif [ -f /usr/include/strings.h ]; then
  49.     echo "#include <strings.h>" >> $config
  50. fi
  51.  
  52. if [ -f /usr/include/memory.h ]; then
  53.     echo "#include <memory.h>" >> $config
  54. fi
  55.  
  56. if [ -f /usr/include/unistd.h ]; then
  57.     echo "#include <unistd.h>" >> $config
  58. else
  59.     echo "extern int read(int, void *, unsigned);" >> $config
  60.     echo "extern int write(int, void *, unsigned);" >> $config
  61. fi
  62.  
  63. if [ ! -f /usr/include/stdarg.h ]; then
  64.     echo "You might have problem with the file /usr/include/stdarg.h" >&2
  65. fi
  66.  
  67. CC=`findpath cc`
  68. GCC=`findpath gcc`
  69. CP=`findpath cp`
  70. LATEX=`findpath latex`
  71. RANLIB=`findpath ranlib`
  72. YACC=`findpath yacc`
  73. if [ -z "$YACC" ]; then
  74.     YACC=`findpath bison`
  75.     if [ -z "$YACC" ]; then
  76.     echo "I could not find niether yacc nor bison, you're in trouble"
  77.     else
  78.     YACC="$YACC -y"
  79.     fi
  80. fi
  81.  
  82. #
  83. # CC
  84. #
  85. if [ ! -z "$GCC" ]; then
  86.     REPL="$REPL -e 's%^@CC%CC = $GCC -ansi -Wcast-qual -Wimplicit -Wreturn-type -Wswitch
  87.     -Wcomments -Wtrigraphs -Wpointer-arith%'"
  88. elif [ ! -z "$CC" ]; then
  89.     REPL="$REPL -e 's%^@CC%$CC = CC%'"
  90. else
  91.     echo "no compiler found" >&2
  92.     exit 1
  93. fi
  94.  
  95. #
  96. # CP
  97. #
  98. if [ ! -z "$CP" ]; then
  99.     REPL="$REPL -e 's%^@CP%CP = $CP'%"
  100. else
  101.     echo "the command cp not found" >&2
  102.     exit 1
  103. fi
  104.  
  105. #
  106. # LATEX
  107. #
  108. if [ ! -z "$LATEX" ]; then
  109.     REPL="$REPL -e 's%^@LATEX%LATEX = $LATEX'%"
  110. else
  111.     REPL="$REPL -e 's%^@LATEX%LATEX = echo '%"
  112. fi
  113.  
  114. #
  115. # RANLIB
  116. #
  117. if [ ! -z "$RANLIB" ]; then
  118.     REPL="$REPL -e 's%^@RANLIB%RANLIB = $RANLIB'%"
  119. else
  120.     REPL="$REPL -e 's%^@RANLIB%RANLIB = echo '%"
  121. fi
  122.  
  123. #
  124. # YACC
  125. #
  126. if [ ! -z "$YACC" ]; then
  127.     REPL="$REPL -e 's%^@YACC%YACC = $YACC'%"
  128. else
  129.     echo "the command bison or yacc not found" >&2
  130.     exit 1
  131. fi
  132.  
  133. #
  134. # SUN specific.
  135. #
  136. if [ -f /vmunix -a -f /usr/include/strings.h ]; then
  137.     if [ ! -f /usr/5include/curses.h ]; then
  138.     echo "Your Sun has not got the system 5 compability package" >&2
  139.     exit 1
  140.     fi
  141.  
  142.     REPL="$REPL -e 's%^@CFLAGS%CFLAGS = $CFLAGS -I/usr/5include -I../include \$(DEFINES)%'"
  143.     REPL="$REPL -e 's%^@LDFLAGS%LDFLAGS = -ly -L/usr/5lib -lcurses -ltermlib /usr/5lib/libc.a%'"
  144.     REPL="$REPL -e 's%^@LDFLAGS%LDFLAGS = $CFLAGS -lcurses -ltermlib'%"
  145. else
  146.     REPL="$REPL -e 's%^@CFLAGS%CFLAGS = $CFLAGS -I../include \$(DEFINES)%'"
  147.     REPL="$REPL -e 's%^@LDFLAGS%LDFLAGS = -ly -lcurses -ltermlib'%"
  148. fi
  149.  
  150. ( echo "#"
  151.   echo "# Don't edit in this file, use Makefile.src"
  152.   eval sed $REPL Makefile.src ) > Makefile
  153.