home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / clc / part13 / libconf
Encoding:
Text File  |  1993-11-28  |  6.9 KB  |  282 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # Copyright (c) 1993 by Panagiotis Tsirigotis
  5. #
  6.  
  7. #
  8. # $Id: libconf,v 1.1 93/11/26 10:42:45 panos Exp $
  9. #
  10.  
  11. #
  12. # XXX:    a lot of the autoconfiguration stuff would be much less verbose
  13. #            if we could assume that /bin/sh supports functions. In a future
  14. #            version we may choose to make that assumption, or assume that
  15. #            there is also some other shell available (for example, ksh)
  16. #            that supports functions.
  17. #
  18.  
  19. script_name=`basename $0`
  20. usage="Usage: $script_name [-libc pathname] [-v]"
  21.  
  22. #
  23. # The $echo variable should have the pathname for an 'echo' command
  24. # that understands the -n option.
  25. #
  26. echo=echo
  27.  
  28. inc=/usr/include
  29. nm_defined_var=D
  30. nm_defined_func=T
  31.  
  32. #
  33. # Get the options, if any
  34. #
  35. while test $# -gt 0
  36. do
  37.     case "$1" in
  38.         -*) option=$1 ; shift ;;
  39.         *) echo $usage ; exit 1
  40.     esac
  41.  
  42.     case "$option" in
  43.         -libc)
  44.             if test $# -eq 0 ; then
  45.                $echo "$script_name: Argument missing. Exiting..."
  46.                exit 1
  47.             fi
  48.             libc="$1"
  49.             shift
  50.             if test ! -r "$libc" ; then
  51.                $echo "$script_name: File is not readable: $libc"
  52.                exit 1
  53.             fi
  54.             ;;
  55.  
  56.         -v)    verbose=yes
  57.                 ;;
  58.  
  59.         -*)    echo $usage ; exit 1
  60.     esac
  61. done
  62.  
  63.  
  64. #######################################################################
  65. # Get namelist of C library
  66. #######################################################################
  67. $echo "Obtaining name list of C library for autoconfiguration"
  68.  
  69. if test "$libc" = "" ; then
  70.     if test -r /lib/libc.a ; then
  71.         libc=/lib/libc.a
  72.     else
  73.         if test -r /usr/lib/libc.a ; then
  74.             libc=/usr/lib/libc.a
  75.         else
  76.             $echo -n "Please enter the pathname of the C library -> "
  77.             read libc
  78.             if test "$libc" = "" -o ! -r "$libc" ; then
  79.                 $echo "$script_name: bad pathname. Exiting..."
  80.                 exit 1
  81.             fi
  82.         fi
  83.     fi
  84. fi
  85. nmfile=/tmp/libc.nm.$$
  86. nm $libc > $nmfile 2>/dev/null
  87. if test $? -ne 0 ; then
  88.     if test ! -s $nmfile ; then
  89.         $echo "Couldn't get the namelist of C library. Exiting..."
  90.         rm -f $nmfile
  91.         exit 1
  92.     else     # name list file is not empty
  93.         $echo "WARNING: The 'nm' command returned a non-zero exit status"
  94.         $echo "WARNING: so the namelist obtained from the C library may be inco
  95. mplete"
  96.         $echo "Continuing with determination of configuration flags"
  97.     fi
  98. fi
  99.  
  100.  
  101. #######################################################################
  102. #
  103. # TIMER library configuration.
  104. #
  105. #######################################################################
  106.  
  107. #
  108. # Determine supported signal handing
  109. #
  110. lookfor=sigaction
  111. if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  112. found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  113. if test "$found" ; then
  114.     signal_handling=posix
  115. else
  116.     lookfor=sigvec
  117.     if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  118.     found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  119.     if test "$found" ; then
  120.         signal_handling=bsd
  121.     else
  122.         signal_handling=simple
  123.     fi
  124. fi
  125.  
  126.  
  127. #
  128. # Check for setitimer(2)
  129. #
  130. lookfor=setitimer
  131. if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  132. found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  133. if test "$found" ; then
  134.     case "$signal_handling" in
  135.         posix)    timer_defs= ;;
  136.         bsd)        timer_defs=-DNO_POSIX_SIGS ;;
  137.         simple)    no_timers=yes
  138.     esac
  139. else
  140.     no_timers=yes
  141. fi
  142.  
  143.  
  144. #######################################################################
  145. #
  146. # XLOG library configuration.
  147. #
  148. #######################################################################
  149.  
  150. #
  151. # Check for syslog(3)
  152. #
  153. lookfor=syslog
  154. if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  155. found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  156. if test "$found" = "" ; then v=-DNO_SYSLOG ; else v= ; fi
  157. xlog_defs="$xlog_defs $v"
  158.  
  159. #
  160. # Look for syslog.h
  161. #
  162. v=
  163. if test -r $inc/sys/syslog.h ; then
  164.     v=-DSYSLOG_IN_SYS
  165.     if test -r $inc/syslog.h ; then
  166.         cmp -s $inc/syslog.h $inc/sys/syslog.h
  167.         if test $? -eq 0 ; then v= ; fi
  168.     fi
  169. fi
  170. xlog_defs="$xlog_defs $v"
  171.  
  172.  
  173. #######################################################################
  174. #
  175. # MISC library configuration.
  176. #
  177. #######################################################################
  178.  
  179. #
  180. # Check for new directory types
  181. #
  182. if test -r $inc/dirent.h ; then v= ; else v=-DOLD_DIR ; fi
  183. misc_defs="$misc_defs $v"
  184.  
  185. #
  186. # Check for ftw(3)
  187. #
  188. if test -r $inc/ftw.h ; then v= ; else v=-D__FTWX_NO_FTW ; fi
  189. misc_defs="$misc_defs $v"
  190.  
  191.  
  192. #######################################################################
  193. #
  194. # SIO library configuration.
  195. #
  196. # Note that we do not try to find out if the system actually supports
  197. # a generic mmap system call (i.e. an mmap capable of mapping regular
  198. # files).
  199. #
  200. #######################################################################
  201.  
  202. lookfor=on_exit
  203. if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  204. found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  205. if test "$found" ; then v=-DHAS_ONEXIT ; else v= ; fi
  206. sio_defs="$sio_defs $v"
  207.  
  208. lookfor=atexit
  209. if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  210. found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  211. if test "$found" ; then v=-DHAS_ATEXIT ; else v= ; fi
  212. sio_defs="$sio_defs $v"
  213.  
  214. lookfor=memcpy
  215. if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  216. found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  217. if test "$found" ; then v=-DHAS_MEMOPS ; else v= ; fi
  218. sio_defs="$sio_defs $v"
  219.  
  220. lookfor=bcopy
  221. if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  222. found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  223. if test "$found" ; then v=-DHAS_BCOPY ; else v= ; fi
  224. sio_defs="$sio_defs $v"
  225.  
  226. lookfor=isatty
  227. if test "$verbose" ; then $echo "Looking for $lookfor" ; fi
  228. found=`grep $lookfor $nmfile | egrep "$nm_defined_func"`
  229. if test "$found" ; then has_isatty=-DHAS_ISATTY ; else has_isatty= ; fi
  230. sio_defs="$sio_defs $has_isatty"
  231.  
  232. rm -f $nmfile
  233.  
  234. #
  235. # Inform the user about our findings.
  236. #
  237. sio_defs=`echo $sio_defs`
  238. if test "$sio_defs" ; then
  239.     echo
  240.     $echo "For the SIO library, set the following preprocessor flags:"
  241.     $echo "$sio_defs"
  242.     if test "$has_isatty" = "" ; then
  243.         echo "Your system does not have the isatty(3) function which is"
  244.         echo "required by the SIO library. A replacement can be provided"
  245.         echo "by determining if your system supports BSD or System V tty"
  246.         echo "handling. In the former case, use the flag -DHAS_BSDTTY, and"
  247.         echo "in the latter, use the flag -DHAS_SYSVTTY"
  248.     fi
  249. fi
  250.  
  251. xlog_defs=`echo $xlog_defs`
  252. echo
  253. if test "$xlog_defs" ; then
  254.     $echo "For the XLOG library, set the following preprocessor flags:"
  255.     $echo "$xlog_defs"
  256. else
  257.     echo "No flags need to be set for the XLOG library"
  258. fi
  259.  
  260. misc_defs=`echo $misc_defs`
  261. echo
  262. if test "$misc_defs" ; then
  263.     $echo "For the MISC library, set the following preprocessor flags:"
  264.     $echo "$misc_defs"
  265. else
  266.     echo "No flags need to be set for the MISC library"
  267. fi
  268.  
  269. if test "$no_times" = "" ; then
  270.     timer_defs=`echo $timer_defs`
  271.     echo
  272.     if test "$timer_defs" ; then
  273.         $echo "For the TIMER library, set the following preprocessor flags:"
  274.         $echo "$timer_defs"
  275.     else
  276.         echo "No flags need to be set for the TIMER library"
  277.     fi
  278. else
  279.     echo "Your system does not support the necessary facilities needed"
  280.     echo "by the timer library, so that library cannot be compiled"
  281. fi
  282.