home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / zip22.zip / unix / configure next >
Text File  |  1997-10-31  |  7KB  |  266 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. trap "rm -f conftest* core a.out; exit 1" 1 2 3 15
  13.  
  14. CC=${1-cc}
  15. CFLAGS=${2-"-O -I. -DUNIX"}
  16. LFLAGS1="-s"
  17. LN="ln -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 ${CFLAGS} -Olimit 1000 -o conftest conftest.c >/dev/null 2>/dev/null
  23. if [ $? -eq 0 ]; then
  24.   CFLAGS="${CFLAGS} -Olimit 1000"
  25. else
  26.   echo Check for +Onolimit option
  27.   $CC ${CFLAGS} +Onolimit -o conftest conftest.c >/dev/null 2>/dev/null
  28.   [ $? -eq 0 ] && CFLAGS="${CFLAGS} +Onolimit"
  29. fi
  30.  
  31. echo Check for the C preprocessor
  32. # on SVR4, cc -E does not produce correct assembler files. Need /lib/cpp.
  33. CPP="${CC} -E"
  34. # solaris as(1) needs -P, maybe others as well ?
  35. [ -f /usr/ccs/lib/cpp ] && CPP="/usr/ccs/lib/cpp -P"
  36. [ -f /usr/lib/cpp ] && CPP=/usr/lib/cpp
  37. [ -f /lib/cpp ] && CPP=/lib/cpp
  38. [ -f /usr/bin/cpp ] && CPP=/usr/bin/cpp
  39. [ -f /xenix ] && CPP="${CC} -E"
  40.  
  41. echo Check if we can use asm code
  42. OBJA=""
  43. if eval "$CPP match.S > _match.s 2>/dev/null"; then
  44.   if test ! -s _match.s || grep error < _match.s > /dev/null; then
  45.     :
  46.   elif eval "$CC -c _match.s >/dev/null 2>/dev/null" && [ -f _match.o ]; then
  47.     CFLAGS="${CFLAGS} -DASMV"
  48.     OBJA="match.o"
  49.     echo "int foo() { return 0;}" > conftest.c
  50.     $CC -c conftest.c >/dev/null 2>/dev/null
  51.     echo Check if compiler generates underlines
  52.     nm conftest.o | grep "(^|[^_])foo" >/dev/null 2>/dev/null
  53.     [ $? -eq 0 ] && CPP="${CPP} -DNO_UNDERLINE"
  54.     if eval "$CPP crc_i386.S > _crc_i386.s 2>/dev/null"; then
  55.       if eval "$CC -c _crc_i386.s >/dev/null 2>/dev/null" && [ -f _crc_i386.o ]
  56.       then
  57.         OBJA="$OBJA crc_i386.o"
  58.         CFLAGS="${CFLAGS} -DASM_CRC"
  59.       fi
  60.     fi
  61.   fi
  62. fi
  63. rm -f _match.s _match.o _crc_i386.s _crc_i386.o
  64.  
  65. # ANSI options for compilers that don't have __STDC__ defined by default
  66. # Currently HPUX, pyramid, dnix, AIX, OSF/1 and ultrix
  67.  
  68. echo Check for ANSI options
  69. cat > conftest.c << _EOF_
  70. int main()
  71. {
  72. #ifndef __STDC__
  73.    forget it
  74. #endif
  75.    return 0;
  76. }
  77. _EOF_
  78. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  79. if [ $? -ne 0 ]; then
  80.   for OPT in "-Aa -D_HPUX_SOURCE" -Xa -qlanglvl=ansi -std1 -std
  81.   do
  82.     $CC $CFLAGS $OPT -c conftest.c > /dev/null 2>/dev/null
  83.     [ $? -eq 0 ] && CFLAGS="${CFLAGS} ${OPT}" && break
  84.   done
  85. fi
  86.  
  87. echo Check for prototypes
  88. echo "int main(int argc, char *argv[]) { return 0; }" > conftest.c
  89. $CC $CFLAGS -c conftest.c > /dev/null 2>/dev/null
  90. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_PROTO"
  91.  
  92. # const check currently handles mips cc and non ANSI compilers.
  93. # does it need more ?
  94. echo Check the handling of const
  95. cat > conftest.c << _EOF_
  96. typedef int charset[2];
  97. int main()
  98. {
  99.   const charset x;
  100.   const char *foo;
  101.   return 0;
  102. }
  103. _EOF_
  104. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  105. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_CONST"
  106.  
  107. echo Check for time_t
  108. cat > conftest.c << _EOF_
  109. #include <sys/types.h>
  110. #include <time.h>
  111. int main()
  112. {
  113.   time_t t;
  114.   return 0;
  115. }
  116. _EOF_
  117. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  118. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_TIME_T"
  119.  
  120. echo Check for size_t
  121. cat > conftest.c << _EOF_
  122. #include <sys/types.h>
  123. int main()
  124. {
  125.   size_t s;
  126.   return 0;
  127. }
  128. _EOF_
  129. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  130. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_SIZE_T"
  131.  
  132. # Check for missing functions
  133. # add NO_'function_name' to flags if missing
  134. for func in rmdir strchr strrchr rename mktemp mktime
  135. do
  136.   echo Check for $func
  137.   echo "int main(){ $func(); return 0; }" > conftest.c
  138.   $CC -o conftest conftest.c >/dev/null 2>/dev/null
  139.   [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
  140. done
  141.  
  142. echo Check for memset
  143. echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
  144. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  145. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM"
  146.  
  147. echo Check for errno declaration
  148. cat > conftest.c << _EOF_
  149. #include <errno.h>
  150. main()
  151. {
  152.   errno = 0;
  153.   return 0;
  154. }
  155. _EOF_
  156. $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
  157. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_ERRNO"
  158.  
  159. echo Check for directory libraries
  160. cat > conftest.c << _EOF_
  161. int main() { return closedir(opendir(".")); }
  162. _EOF_
  163.  
  164. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  165. if [ $? -ne 0 ]; then
  166.   OPT=""
  167.   for lib in ndir dir ucb bsd BSD PW x dirent
  168.   do
  169.     $CC -o conftest conftest.c -l$lib >/dev/null 2>/dev/null
  170.     [ $? -eq 0 ] && OPT=-l$lib && break
  171.   done
  172.   if [ ${OPT} ]; then
  173.     LFLAGS2="${LFLAGS2} ${OPT}"
  174.   else
  175.     CFLAGS="${CFLAGS} -DNO_DIR"
  176.   fi
  177. fi
  178.  
  179. # Dynix/ptx 1.3 needed this
  180. echo Check for readlink
  181. echo "int main(){ return readlink(); }" > conftest.c
  182. $CC -o conftest conftest.c >/dev/null 2>/dev/null
  183. if [ $? -ne 0 ]; then
  184.   $CC -o conftest conftest.c -lseq >/dev/null 2>/dev/null
  185.   [ $? -eq 0 ] && LFLAGS2="${LFLAGS2} -lseq"
  186. fi
  187.  
  188. echo Check for directory include file
  189. OPT=""
  190. for inc in dirent.h sys/ndir.h ndir.h sys/dir.h
  191. do
  192.    echo "#include <$inc>" > conftest.c
  193.    $CPP conftest.c > /dev/null 2>/dev/null
  194.    [ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
  195. done
  196. CFLAGS="${CFLAGS} ${OPT}"
  197.  
  198. echo Check for non existent include files
  199. for inc in stdlib.h stddef.h unistd.h fcntl.h string.h
  200. do
  201.    echo "#include <$inc>" > conftest.c
  202.    $CPP conftest.c >/dev/null 2>/dev/null
  203.    [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $inc | tr '[a-z]./' '[A-Z]__'`"
  204. done
  205.  
  206. echo Check for term I/O include file
  207. OPT=""
  208. for inc in termios.h termio.h sgtty.h
  209. do
  210.    echo "#include <$inc>" > conftest.c
  211.    $CPP conftest.c > /dev/null 2>/dev/null
  212.    [ $? -eq 0 ] && OPT="-DHAVE_`echo $inc | tr '[a-z]./' '[A-Z]__'`" && break
  213. done
  214. CFLAGS="${CFLAGS} ${OPT}"
  215.  
  216. # needed for AIX (and others ?) when mmap is used
  217. echo Check for valloc
  218. cat > conftest.c << _EOF_
  219. main()
  220. {
  221. #ifdef MMAP
  222.     valloc();
  223. #endif
  224. }
  225. _EOF_
  226. $CC ${CFLAGS} conftest.c > /dev/null 2>/dev/null
  227. [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_VALLOC"
  228.  
  229. echo Check for /usr/local/bin and /usr/local/man
  230. BINDIR=$HOME/bin
  231. [ -d /usr/local/bin ] && BINDIR=/usr/local/bin
  232.  
  233. MANDIR=manl
  234. [ -d /usr/man/manl ]       && MANDIR=/usr/man/manl
  235. [ -d /usr/local/man/manl ] && MANDIR=/usr/local/man/manl
  236. [ -d /usr/local/man/man1 ] && MANDIR=/usr/local/man/man1
  237.  
  238. echo Checking for OS specialties
  239. if [ -f /usr/bin/hostinfo ]; then
  240.   if /usr/bin/hostinfo | grep NeXT > /dev/null; then
  241.     CFLAGS="${CFLAGS} -posix"
  242.     LFLAGS1="${LFLAGS1} -posix -object"
  243.   fi
  244. # XXX ATT6300, Cray
  245. elif [ -f /xenix ]; then
  246.   if uname -p | grep 286 > /dev/null; then
  247.     CFLAGS="${CFLAGS} -LARGE -Mel2 -DMEDIUM_MEM -DWSIZE=16384 -DNO_VOID"
  248.     LFLAGS1="${LFLAGS1} -LARGE -Mel2"
  249.   fi
  250. elif uname -X >/dev/null 2>/dev/null; then
  251. # SCO shared library check
  252.   echo "int main() { return 0;}" > conftest.c
  253.   $CC -o conftest conftest.c -lc_s -nointl >/dev/null 2> /dev/null
  254.   [ $? -eq 0 ] && LFLAGS2="-lc_s -nointl"
  255. fi
  256.  
  257. echo Check for symbolic links
  258. ln -s /dev/null null > /dev/null 2>/dev/null
  259. [ $? -ne 0 ] && LN=ln
  260.  
  261. rm -f a.out conftest.c conftest.o conftest null
  262.  
  263. echo CC=\"${CC}\" CFLAGS=\"${CFLAGS}\"  CPP=\"${CPP}\" OBJA=\"${OBJA}\" \
  264.        BINDIR=${BINDIR} MANDIR=${MANDIR} LFLAGS1=\"${LFLAGS1}\" \
  265.        LFLAGS2=\"${LFLAGS2}\" LN=\"${LN}\" > flags
  266.