home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / unix_c / languags / c / ccs.sh < prev    next >
Encoding:
Text File  |  1989-03-21  |  2.4 KB  |  88 lines

  1. From pur-ee!j.cc.purdue.edu!i.cc.purdue.edu!purdue!gatech!bloom-beacon!husc6!necntc!ncoast!allbery Sun Jan 31 20:48:05 EST 1988
  2.  
  3. Comp.sources.misc: Volume 2, Issue 26
  4. Submitted-By: Eric S. Raymond <eric@snark.UUCP>
  5. Archive-Name: 3b1-cc
  6.  
  7. Here's a front end for cc that I use constantly. It acts exactly like cc but
  8. links things to use shared libraries. I posted an earlier version last
  9. year, but the -L option handling turned out to have a bug in it. Also, this
  10. version links things into the fast-loading -F (0413) format -- thanks to Dennis
  11. McCunney for passing me the incredibly obscure little hack necessary to get
  12. that to work (believe it or not, you trigger it with the order of the link
  13. arguments).
  14.  
  15. # ccs -- compile with shared libraries for AT&T 7300 or 3B1 (version 1.2)
  16. #        Written to replace cc by Eric Raymond {cbmvax!snark!eric}
  17.  
  18. CC=/bin/cc        # Standard C compile program
  19. LD=ld            # Standard loader
  20. OSTART=/lib/crt0s.o    # Standard startup code
  21. PSTART=/lib/mcrt0s.o    # Monitored startup code for profiling
  22.  
  23. # Find shared version of libraries
  24. if [ -f shlib.ifile ]
  25. then
  26.     SHLIB=shlib.ifile    # Use local customized version if it exists
  27. else
  28.     SHLIB=/lib/shlib.ifile    # Otherwise use standard ones
  29. fi
  30.  
  31. DEBUG=        # Set this to 'echo' to see actions
  32.  
  33. srclist= objlist= intermediates=
  34. start=$OSTART
  35. lflag=1
  36.  
  37. while [ $# != 0 ]
  38. do
  39.     source= linkarg=
  40.     case $1 in
  41.  
  42.     # Options
  43.     -W*) linkarg=-`expr $1 : "-W\(.*\)"` ;;
  44.     -p)  start=$PSTART ;;
  45.     -c)  lflag=0 ;;
  46.     -[fgOSEPBtPCUDTIH]*) source=$1 ;;
  47.     -y)  source="$1 $2" ; shift ;;
  48.     -[efou] | -VS) linkarg=$1 ; shift ; linkarg="$linkarg $1" ;;
  49.     -[almrsxzMNV]*|-L*) linkarg=$1 ;;
  50.     -*) ;;
  51.  
  52.     # File types
  53.     *.[cs])
  54.         stem=`expr $1 : "\(.*\).[cs]"` ;
  55.         source=$1 linkarg=${stem}.o
  56.         intermediates="$intermediates ${stem}.o"
  57.         ;;
  58.  
  59.     # Everything else
  60.     *) source=$1 linkarg=$1 ;;
  61.  
  62.     esac
  63.     shift
  64.     objlist="$objlist $linkarg"
  65.     srclist="$srclist $source"
  66. done
  67.  
  68. $DEBUG $CC -c $srclist        # Compile everything, suppressing linking
  69.  
  70. # Now, if there was no -c option, link-edit the results
  71. if [ $lflag != 0 ]
  72. then
  73.     $DEBUG $LD $objlist $start $SHLIB
  74.     rm -f $intermediates
  75. fi
  76. # ccs ends here
  77.  
  78. You can call this as ccs or copy it to /usr/bin/cc. It will give you cleaner
  79. cleans, whiter whites, build strong bodies twelve ways, and make your programs
  80. load and execute maybe 10%-15% faster.
  81.  
  82. -- 
  83.       Eric S. Raymond
  84.       UUCP:  {{seismo,ihnp4,rutgers}!cbmvax,sdcrdcf!burdvax,vu-vlsi}!snark!eric
  85.       Post:  22 South Warren Avenue, Malvern, PA 19355    Phone: (215)-296-5718
  86.  
  87.  
  88.