home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume2 / 3b1-cc next >
Internet Message Format  |  1991-08-07  |  3KB

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