home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zip21.zip / unix / configure next >
Text File  |  1996-04-24  |  6KB  |  224 lines

  1. :
  2. #!/bin/sh
  3. # The above : is necessary on some buggy systems.
  4.  
  5. # configure: Guess values for system-dependent variables
  6. # Output the flag definitions to the file "flags".
  7. # Parameters: $1 = $CC, $2 = $CFLAGS
  8. # To construct zip automatically using this file, type
  9. # "make -f unix/Makefile generic".
  10. # If this fails, then type "make list" to get a list of special targets.
  11.  
  12.  
  13. trap "rm -f conftest* core a.out; exit 1" 1 2 3 15
  14.  
  15. CC=${1-cc}
  16. CFLAGS=${2-"-O -I. -DUNIX"}
  17. LFLAGS1="-s"
  18.  
  19. # This one is needed for the ultrix and OSF/1 optimizer
  20. echo Check for -Olimit option
  21. echo "int main() { return 0;}" > conftest.c
  22. $CC -Olimit 1000 conftest.c >/dev/null 2>/dev/null
  23. [ $? -eq 0 ] && CFLAGS="${CFLAGS} -Olimit 1000"
  24.  
  25. echo Check for the C preprocessor
  26. # on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
  27. CPP="${CC} -E"
  28. # solaris as(1) needs -P, maybe others as well ?
  29. [ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
  30. [ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
  31. [ -f /lib/cpp ] && CPP=/lib/cpp
  32. [ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
  33.  
  34. echo Check if we can use asm code
  35. OBJA=""
  36. if eval "$CPP match.S > _match.s 2>/dev/null"; then
  37.   if test ! -s _match.s || grep error < _match.s > /dev/null; then
  38.     :
  39.   elif eval "$CC -c _match.s >/dev/null 2>/dev/null" && test -f _match.o; then
  40.     CFLAGS="${CFLAGS} -DASMV"
  41.     OBJA=match.o
  42.     echo "int foo() { return 0;}" > conftest.c
  43.     $CC -c conftest.c >/dev/null 2>/dev/null
  44.     echo Check if compiler generates underlines
  45.     nm conftest.o | egrep "(^|[^_])foo" >/dev/null 2>/dev/null
  46.     [ $? -eq 0 ] && CPP="${CPP} -DNO_UNDERLINE"
  47.   fi
  48. fi
  49. rm -f _match.s _match.o
  50.  
  51. # Ansi options for systems that don't have __STDC__ defined by default
  52. # Currently HPUX, pyramid, dnix, AIX, OSF/1 and ultrix
  53.  
  54. echo Check for Ansi options
  55. cat > conftest.c << _EOF_
  56. int main()
  57. {
  58. #ifndef __STDC__
  59.    forget it
  60. #endif
  61.    return 0;
  62. }
  63. _EOF_
  64. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  65. if [ $? -ne 0 ]; then
  66.   for OPT in "-Aa -D_HPUX_SOURCE" -Xa -qlanglvl=ansi -std1 -std
  67.   do
  68.     $CC $CFLAGS $OPT -c conftest.c > /dev/null 2>/dev/null
  69.     [ $? -eq 0 ] && CFLAGS="${CFLAGS} ${OPT}" && break
  70.   done
  71. fi
  72.  
  73. echo Check for prototypes
  74. echo "int main(int argc, char *argv[]) { return 0; }" > conftest.c
  75. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  76. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_PROTO"
  77.  
  78. # const check currently handles mips cc and non ANSI compilers.
  79. # does it need more ?
  80. echo Check the handling of const
  81. cat > conftest.c << _EOF_
  82. typedef int charset[2];
  83. int main()
  84. {
  85.   const charset x;
  86.   const char *foo;
  87.   return 0;
  88. }  
  89. _EOF_
  90. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  91. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_CONST"
  92.  
  93. echo Check for time_t
  94. cat > conftest.c << _EOF_
  95. #include <sys/types.h>
  96. #include <time.h>
  97. int main()
  98. {
  99.   time_t t;
  100.   return 0;
  101. }
  102. _EOF_
  103. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  104. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_TIME_T"
  105.   
  106. echo Check for size_t
  107. cat > conftest.c << _EOF_
  108. #include <sys/types.h>
  109. int main()
  110. {
  111.   size_t s;
  112.   return 0;
  113. }
  114. _EOF_
  115. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  116. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_SIZE_T"
  117.  
  118. # Check for missing functions
  119. # add NO_'function_name' to flags if missing
  120. for func in rmdir strrchr rename mktemp mktime
  121. do
  122.   echo Check for $func
  123.   echo "int main(){ $func(); return 0; }" > conftest.c
  124.   $CC conftest.c >/dev/null 2>/dev/null
  125.   [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
  126. done
  127.  
  128. echo Check for memset
  129. echo "int main(){ memset(); return 0; }" > conftest.c
  130. $CC conftest.c >/dev/null 2>/dev/null
  131. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM"
  132.  
  133. echo Check for errno declaration
  134. cat > conftest.c << _EOF_
  135. #include <errno.h>
  136. main()
  137. {
  138.   errno = 0;
  139.   return 0;
  140. }
  141. _EOF_
  142. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  143. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_ERRNO"
  144.  
  145. echo Check for directory libraries
  146. cat > conftest.c << _EOF_
  147. int main() { return closedir(opendir(".")); }
  148. _EOF_
  149.  
  150. $CC conftest.c >/dev/null 2>/dev/null
  151. if [ $? -ne 0 ]; then
  152.   OPT=""
  153.   for lib in ndir dir ucb bsd BSD PW x
  154.   do
  155.     $CC conftest.c -l$lib >/dev/null 2>/dev/null
  156.     [ $? -eq 0 ] && OPT=$lib && break
  157.   done
  158.   if [ ${OPT} ]; then
  159.     LFLAGS2="${LFLAGS2} -l${OPT}"
  160.   else
  161.     CFLAGS="${CFLAGS} -DNO_DIR"
  162.   fi
  163. fi
  164.  
  165. # Dynix/ptx 1.3 needed this
  166. echo Check for readlink
  167. echo "int main(){ return readlink(); }" > conftest.c
  168. $CC conftest.c >/dev/null 2>/dev/null
  169. if [ $? -ne 0 ]; then 
  170.   $CC conftest.c -lseq >/dev/null 2>/dev/null
  171.   [ $? -eq 0 ] && LFLAGS2="${LFLAGS2} -lseq"
  172. fi
  173.  
  174. echo Check for directory include file
  175. OPT=""
  176. for inc in sys/ndir.h ndir.h sys/dir.h dirent.h
  177. do
  178.    echo "#include <$inc>" > conftest.c
  179.    $CPP conftest.c > /dev/null 2>/dev/null
  180.    [ $? -eq 0 ] && OPT="HAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`"
  181. done
  182. CFLAGS="${CFLAGS} -D${OPT}"
  183.  
  184. echo Check for non existing include files
  185. for inc in stdlib.h stddef.h unistd.h fcntl.h string.h
  186. do
  187.    echo "#include <$inc>" > conftest.c
  188.    $CPP conftest.c >/dev/null 2>/dev/null
  189.    [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $inc | tr '[a-z]./' '[A-Z]__'`"
  190. done
  191.  
  192. echo Check for term i/o include file
  193. OPT=""
  194. for inc in sys/termio.h termio.h termios.h
  195. do
  196.    echo "#include <$inc>" > conftest.c
  197.    $CPP conftest.c > /dev/null 2>/dev/null
  198.    [ $? -eq 0 ] && OPT="HAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`"
  199. done
  200. CFLAGS="${CFLAGS} -D${OPT}"
  201.  
  202. echo Check for /usr/local/bin and /usr/local/man
  203. BINDIR=$HOME/bin
  204. [ -d /usr/local/bin ] && BINDIR=/usr/local/bin
  205.  
  206. MANDIR=manl
  207. [ -d /usr/man/manl ]       && MANDIR=/usr/man/manl
  208. [ -d /usr/local/man/manl ] && MANDIR=/usr/local/man/manl
  209. [ -d /usr/local/man/man1 ] && MANDIR=/usr/local/man/man1
  210.  
  211. echo Check for NeXT
  212. if test -f /usr/bin/hostinfo; then
  213.   if /usr/bin/hostinfo | grep NeXT > /dev/null; then
  214.     CFLAGS="${CFLAGS} -posix"
  215.     LFLAGS1="${LFLAGS1} -posix -object"
  216.   fi
  217. fi
  218.  
  219. rm -f conftest.c conftest.o a.out
  220.  
  221. echo CC=\"${CC}\" CFLAGS=\"${CFLAGS}\"  CPP=\"${CPP}\" OBJA=\"${OBJA}\" \
  222.        BINDIR=${BINDIR} MANDIR=${MANDIR} LFLAGS1=\"${LFLAGS1}\" \
  223.        LFLAGS2=\"${LFLAGS2}\" > flags
  224.