home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 April / PCO0499.ISO / filesbbs / os2 / apach134.arj / APACH134.ZIP / src / helpers / fmn.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1998-09-16  |  1.4 KB  |  51 lines

  1. #!/bin/sh
  2. ##
  3. ##  fmn.sh -- find a modules (structure) name
  4. ##
  5. ##  Extracted from the Configure script by
  6. ##  Ralf S. Engelschall <rse@apache.org> for use with 
  7. ##  Apache's Autoconf-style Interface (APACI).
  8. ##
  9. #
  10. # This script falls under the Apache License.
  11. # See http://www.apache.org/docs/LICENSE
  12.  
  13.  
  14. #   input: the modules source file
  15. modfile=$1
  16.  
  17. #   the part from the Configure script
  18. tmpfile=/tmp/fmn.tmp.$$
  19. rm -f $tmpfile
  20. modname=''
  21. ext=`echo $modfile | sed 's/^.*\.//'`
  22. modbase=`echo $modfile | sed 's/\.[^.]*$//'`
  23. if [ x$ext = x$modfile ]; then ext=o; modbase=$modfile; modfile=$modbase.o; fi
  24. if [ x$ext = x ] ; then ext=o; modbase=$modfile; fi
  25. if [ x$ext = xc ] ; then ext=o; fi
  26. if [ -r $modbase.module ] ; then
  27.     cat $modbase.module >$tmpfile
  28. else
  29.     if [ -f $modbase.c ] ; then
  30.         modname=`egrep '^module .*;' $modbase.c | head -1 |\
  31.                 sed 's/^module.*[     ][     ]*//' | \
  32.                 sed 's/[     ]*;[     ]*$//'`
  33.         if grep "MODULE-DEFINITION-" $modbase.c >/dev/null; then
  34.             cat $modbase.c | \
  35.             sed '1,/MODULE-DEFINITION-START/d;/MODULE-DEFINITION-END/,$d' >$tmpfile
  36.         fi
  37.     fi
  38. fi              
  39. if [ -r $tmpfile ] ; then
  40.     modname=`grep "Name:" $tmpfile | sed 's/^.*Name:[     ]*//'`
  41. fi
  42. if [ "x$modname" = "x" ] ; then
  43.     modname=`echo $modbase | sed 's/^.*\///' | \
  44.         sed 's/^mod_//' | sed 's/^lib//' | sed 's/$/_module/'`
  45. fi
  46. rm -f $tmpfile
  47.  
  48. #   output: the name of the module structure symbol
  49. echo "$modname"
  50.  
  51.