home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / lib / tcl8.5 / ldAix < prev    next >
Encoding:
Text File  |  2006-06-17  |  2.8 KB  |  79 lines

  1. #!/bin/sh
  2. #
  3. # ldAix ldCmd ldArg ldArg ...
  4. #
  5. # This shell script provides a wrapper for ld under AIX in order to
  6. # create the .exp file required for linking.  Its arguments consist
  7. # of the name and arguments that would normally be provided to the
  8. # ld command.  This script extracts the names of the object files
  9. # from the argument list, creates a .exp file describing all of the
  10. # symbols exported by those files, and then invokes "ldCmd" to
  11. # perform the real link.
  12. #
  13. # RCS: @(#) $Id: ldAix,v 1.4 2002/09/27 01:28:26 hobbs Exp $
  14.  
  15. # Extract from the arguments the names of all of the object files.
  16.  
  17. args=$*
  18. ofiles=""
  19. for i do
  20.     x=`echo $i | grep '[^.].o$'`
  21.     if test "$x" != ""; then
  22.     ofiles="$ofiles $i"
  23.     fi
  24. done
  25.  
  26. # Extract the name of the object file that we're linking.
  27. outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'`
  28.  
  29. # Create the export file from all of the object files, using nm followed
  30. # by sed editing.  Here are some tricky aspects of this:
  31. #
  32. # 1. Nm produces different output under AIX 4.1 than under AIX 3.2.5;
  33. #    the following statements handle both versions.
  34. # 2. Use the -g switch to nm instead of -e under 4.1 (this shows just
  35. #    externals, not statics;  -g isn't available under 3.2.5, though).
  36. # 3. Use the -X32_64 switch to nm on AIX-4+ to handle 32 or 64bit compiles.
  37. # 4. Eliminate lines that end in ":": these are the names of object
  38. #    files (relevant in 4.1 only).
  39. # 5. Eliminate entries with the "U" key letter;  these are undefined
  40. #    symbols (relevant in 4.1 only).
  41. # 6. Eliminate lines that contain the string "0|extern" preceded by space;
  42. #    in 3.2.5, these are undefined symbols (address 0).
  43. # 7. Eliminate lines containing the "unamex" symbol.  In 3.2.5, these
  44. #    are also undefined symbols.
  45. # 8. If a line starts with ".", delete the leading ".", since this will
  46. #    just cause confusion later.
  47. # 9. Eliminate everything after the first field in a line, so that we're
  48. #    left with just the symbol name.
  49.  
  50. nmopts="-g -C"
  51. osver=`uname -v`
  52. if test $osver -eq 3; then
  53.   nmopts="-e"
  54. fi
  55. if test $osver -gt 3; then
  56.   nmopts="$nmopts -X32_64"
  57. fi
  58. rm -f lib.exp
  59. echo "#! $outputFile" >lib.exp
  60. /usr/ccs/bin/nm $nmopts -h $ofiles | sed -e '/:$/d' -e '/ U /d' -e '/[     ]0|extern/d' -e '/unamex/d' -e 's/^\.//' -e 's/[     |].*//' | sort | uniq >>lib.exp
  61.  
  62. # If we're linking a .a file, then link all the objects together into a 
  63. # single file "shr.o" and then put that into the archive.  Otherwise link 
  64. # the object files directly into the .a file.
  65.  
  66. outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'`
  67. noDotA=`echo $outputFile | sed -e '/\.a$/d'`
  68. echo "noDotA=\"$noDotA\""
  69. if test "$noDotA" = "" ; then
  70.     linkArgs=`echo $args | sed -e 's/-o .*\.a /-o shr.o /'`
  71.     echo $linkArgs
  72.     eval $linkArgs
  73.     echo ar cr $outputFile shr.o
  74.     ar cr $outputFile shr.o
  75.     rm -f shr.o
  76. else
  77.     eval $args
  78. fi
  79.