home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / gnu / bin / gnatsplit < prev    next >
Text File  |  1994-06-14  |  2KB  |  54 lines

  1. #!/bin/sh
  2. if test "$1" = ""
  3. then
  4.    echo "Usage : gnatsplit [-ksw] filename [directory]"
  5.    echo " "
  6.    echo "  k         limit filenames to 8 characters"
  7.    echo "  s         generate a compilation script"
  8.    echo "  w         overwrite existing filenames"
  9.    echo "  filename  source file"
  10.    echo "  directory directory to place split files (default is ./)"
  11.    exit 1;
  12. fi
  13. parms=
  14. k8option=
  15. #
  16. # Scan through the options, checking for validity and especially looking for
  17. # the 'k' option since this will be used for the call to gcc to get the offset
  18. # information.
  19. #
  20. while getopts ksw c
  21. do
  22.    case $c in
  23.       k)      k8option="-k8";;
  24.       s | w)  parms="$parms -$c";;
  25.       \?)     echo "Usage : gnatsplit [-ksw] filename [directory]"; exit 1;;
  26.    esac
  27. done
  28. shift `expr $OPTIND - 1`
  29. #
  30. # Check that there is a filename argument after the option list, and that the
  31. # file actually exists.
  32. #
  33. if test "$1" = ""
  34. then
  35.    echo "missing filename"
  36.    echo "Usage : gnatsplit [-ksw] filename [directory]"; exit 1
  37.    exit 1
  38. elif test ! -r $1
  39. then
  40.     echo "$1 not found"; exit 1
  41. fi
  42. # Call gnatf on the source filename argument with special options to generate
  43. # offset information. If this special compilation completes succesfully call
  44. # the gnatchop program to actuall split the source file in one file per
  45. # compilation unit in the optional directory if given otherwise in the current
  46. # directory.
  47. #
  48. gnatf -s -u $k8option $1 2>tmpfile
  49. if [ $? -eq 0 ] ; then
  50.     gnatchop $parms $1 $2 <tmpfile
  51. else
  52.         echo "parse errors detected"; exit 1
  53. fi
  54.