home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 197_01 / comp < prev    next >
Text File  |  1979-12-31  |  2KB  |  84 lines

  1. #*****************************************************************************
  2. #
  3. #        COMPILER AND LINK SPECIFIED SOURCE FILES
  4. #                (comp)
  5. #
  6. #            Copyright (C) 1987 J. Manzai
  7. #            All Rights Reserved
  8. #
  9. #    Date Created:     March 28, 1987 @(#) comp Version 1.0
  10. #
  11. #    Modifications:    16-Jan-88    Created a new library for the AIMS
  12. #                    Application and changed this script 
  13. #                    to link with this new library of object
  14. #                    modules.
  15. #
  16. #            23-Feb-88    Added test to look for the -O option
  17. #                    on the command line.
  18. #
  19. #            20-Mar-88    Added code to control storage of
  20. #                    compilation errors for EMACS development
  21. #                    environment.
  22. #
  23. #    This shell script eases the compiling and linking of source code.
  24. #    Especially the linking is easier when need to link several libraries.
  25. #
  26. #    This shell script should be used in conjunction with an Emacs start-up
  27. #    file ".emacsrc".
  28. #******************************************************************************
  29.  
  30. #    tput clear
  31.  
  32. CFLAGS="-Ms"
  33. LFLAGS="-laims -ld -lx -lct -lm"
  34.  
  35. # Test command line for -O option...
  36.  
  37. if [ "$1" = "-O" -o "$1" = "-o" ];then
  38.     CFLAGS=`echo "$CFLAGS -O"`
  39.     shift
  40. fi
  41.  
  42. # Test command line for -g option...
  43.  
  44. if [ "$1" = "-g" ]; then
  45.     CFLAGS=`echo "$CFLAGS -g"`
  46.     shift
  47. fi
  48.  
  49. if [ -r $1.c ]; then            # Source file readable ?
  50.     if [ -r $1 ]; then        # Object file readable(exists)?
  51.         rm -f $1        # Remove object and binary
  52.         rm -f $1.o
  53.     fi
  54.     echo "compiling with $CFLAGS: $1.c"
  55.     rm -f $1.e            # Remove previous error file
  56.     cc -c ${CFLAGS} $1.c 2> $1.e    # Compile it...
  57.     if [ $? -ne "O" ]; then        # Error in compilation ?
  58.         head -10 $1.e > temp$$    # Get first 10 lines of errors
  59.         mv temp$$ $1.e
  60.         cat $1.e        # Send it to the screen
  61.         exit 1
  62.     else
  63.         rm -f $1.e            # Remove any error file
  64.         echo "linking with $LFLAGS: $1.o"
  65.         cc $1.o $LFLAGS -o$1 2> $1.e     # Link it, errors to error file
  66.         if [ $? -ne "O" ]; then        # Error in linkage ?
  67.             head -10 $1.e > temp$$    # Get 1st 10 errors
  68.             mv temp$$ $1.e
  69.             cat $1.e        # Send errors to screen
  70.             exit 1
  71.         else 
  72.             rm -f $1.e
  73.             size $1            # Show its size
  74.             exit 0
  75.         fi
  76.     fi
  77. else
  78.     echo "Usage:comp filename"
  79.     exit 1
  80. fi
  81.  
  82.             
  83.  
  84.