home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / perl / Perl / writemain < prev    next >
Text File  |  1995-12-06  |  2KB  |  66 lines

  1. #!/bin/sh
  2. # This script takes the plain miniperlmain.c and writes out perlmain.c
  3. # which includes all the extensions.
  4. # The command line arguments name extensions to be used.
  5. #  E.g.:  sh writemain SDBM_File POSIX > perlmain.c
  6. #
  7.  
  8. orig="$*"
  9. args=''
  10. : Remove any .a suffixes and any leading path components
  11. for file in `echo $orig | sed 's/\.a//g'` ; do
  12.     case "$file" in
  13.     ext/*)    file=`echo $file | sed 's:ext/\(.*\)/[^/]*:\1:'`
  14.         ;;
  15.     lib/auto/*)    file=`echo $file | sed 's:lib/auto/\(.*\)/[^/]*:\1:'`
  16.         ;;
  17.     */*)
  18.         file=`expr X$file : 'X.*/\(.*\)'`
  19.         ;;
  20.     esac
  21.     args="$args $file"
  22. done
  23.  
  24.  
  25. sed '/Do not delete this line--writemain depends on it/q' miniperlmain.c
  26. if test X"$args" != "X" ; then
  27.     echo "    char *file = __FILE__;"
  28.     ai=''
  29.  
  30.     for ext in $args ; do
  31.  
  32.     : $ext will either be 'Name' or 'Name1/Name2' etc
  33.     : convert ext into cname and mname
  34.     mname=`echo $ext   | sed 's!/!::!g'`
  35.     cname=`echo $mname | sed 's!:!_!g'`
  36.  
  37.     echo "    {   extern void boot_${cname} _((CV* cv));"
  38.     if test "$ext" = "DynaLoader"; then
  39.         : Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
  40.         : boot_DynaLoader is called directly in DynaLoader.pm
  41.         echo "        newXS(\"${mname}::boot_${ext}\", boot_${cname}, file);"
  42.     else
  43.         echo "        newXS(\"${mname}::bootstrap\", boot_${cname}, file);"
  44.     fi
  45.     # does this extension wish to supply automatic booting code?
  46.     for aifile in ext/$ext/AutoInit.* ; do
  47.         case $aifile in
  48.         *.c)echo "    /* autoinit code from $aifile follows: */"
  49.             echo "    {"; cat $aifile; echo "    }"
  50.             ;;
  51.         *.pl) ai="$ai `cat $aifile | tr '\012' ' '`;"
  52.             ;;
  53.         esac
  54.     done
  55.     echo "    }"
  56.     done
  57.     if test "X$ai" != "X"; then
  58.     echo "    autoboot_preamble = \"BEGIN { $ai }\";"
  59.     fi
  60. fi
  61.  
  62. cat << 'EOP'
  63. }
  64. EOP
  65.  
  66.