You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.2 KiB

  1. #!/bin/sh
  2. #
  3. # ===========================================================================
  4. # FILE: makexp_aix
  5. # TYPE: standalone executable
  6. # SYSTEM: AIX 3.2.5 and AIX 4
  7. #
  8. # DESCRIPTION: This script creates an export list of ALL global symbols
  9. # from a list of object or archive files.
  10. #
  11. # USAGE: makexp_aix <OutputFile> "<FirstLine>" <InputFile> ...
  12. #
  13. # where:
  14. # <OutputFile> is the target export list filename.
  15. # <FirstLine> is the path/file string to be appended
  16. # after the "#!" symbols in the first line of the
  17. # export file. Passing "" means deferred resolution.
  18. # <InputFile> is an object (.o) or an archive file (.a).
  19. #
  20. # HISTORY:
  21. # 3-Apr-1998 -- remove C++ entries of the form Class::method
  22. # Vladimir Marangozov
  23. #
  24. # 1-Jul-1996 -- added header information
  25. # Vladimir Marangozov
  26. #
  27. # 28-Jun-1996 -- initial code
  28. # Vladimir Marangozov (Vladimir.Marangozov@imag.fr)
  29. # ==========================================================================
  30. # Variables
  31. expFileName=$1
  32. toAppendStr=$2
  33. shift; shift;
  34. inputFiles=$*
  35. automsg="Generated automatically by makexp_aix"
  36. notemsg="NOTE: lists _all_ global symbols defined in the above file(s)."
  37. curwdir=`pwd`
  38. # Create the export file and setup the header info
  39. echo "#!"$toAppendStr > $expFileName
  40. echo "*" >> $expFileName
  41. echo "* $automsg (`date -u`)" >> $expFileName
  42. echo "*" >> $expFileName
  43. echo "* Base Directory: $curwdir" >> $expFileName
  44. echo "* Input File(s) : $inputFiles" >> $expFileName
  45. echo "*" >> $expFileName
  46. echo "* $notemsg" >> $expFileName
  47. echo "*" >> $expFileName
  48. # Extract the symbol list using 'nm' which produces quite
  49. # different output under AIX 4 than under AIX 3.2.5.
  50. # The following handles both versions by using a common flagset.
  51. # Here are some hidden tricks:
  52. # 1. Use /usr/ccs/bin/nm. Relevant to AIX 3.2.5 which has
  53. # another version under /usr/ucb/bin/nm.
  54. # 2. Use the -B flag to have a standard BSD representation
  55. # of the symbol list on both AIX 3.2.5 and AIX 4. The "-B"
  56. # flag is missing in the AIX 3.2.5 online usage help of 'nm'.
  57. # 3. Use the -x flag to have a hex representation of the symbol
  58. # values. This fills the leading whitespaces on AIX 4,
  59. # thus simplifying the sed statement.
  60. # 4. Eliminate all entries except those with either "B", "D"
  61. # or "T" key letters. We are interested only in the global
  62. # (extern) BSS, DATA and TEXT symbols. With the same statement
  63. # we eliminate object member lines relevant to AIX 4.
  64. # 5. Eliminate entries containing a dot. We can have a dot only
  65. # as a symbol prefix, but such symbols are undefined externs.
  66. # 6. Eliminate everything including the key letter, so that we're
  67. # left with just the symbol name.
  68. # 7. Eliminate all entries containing two colons, like Class::method
  69. #
  70. # Use -X32_64 if it appears to be implemented in this version of 'nm'.
  71. NM=/usr/ccs/bin/nm
  72. xopt=-X32_64
  73. $NM -e $xopt $1 >/dev/null 2>&1 || xopt=""
  74. $NM -Bex $xopt $inputFiles \
  75. | sed -e '/ [^BDT] /d' -e '/\./d' -e 's/.* [BDT] //' -e '/::/d' \
  76. | sort | uniq >> $expFileName