blob: 733013f271e1ce1decd690589b42fcecf4c1d58a [file] [log] [blame]
Guido van Rossumb4ae6a31996-08-08 19:05:09 +00001#!/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# 1-Jul-1996 -- added header information
22# Vladimir Marangozov
23#
24# 28-Jun-1996 -- initial code
25# Vladimir Marangozov (Vladimir.Marangozov@imag.fr)
26# ==========================================================================
27
28# Variables
29expFileName=$1
30toAppendStr=$2
31shift; shift;
32inputFiles=$*
33automsg="Generated automatically by makexp_aix"
34notemsg="NOTE: lists _all_ global symbols defined in the above file(s)."
35curwdir=`pwd`
36
37# Create the export file and setup the header info
38echo "#!"$toAppendStr > $expFileName
39echo "*" >> $expFileName
40echo "* $automsg (`date -u`)" >> $expFileName
41echo "*" >> $expFileName
42echo "* Base Directory: $curwdir" >> $expFileName
43echo "* Input File(s) : $inputFiles" >> $expFileName
44echo "*" >> $expFileName
45echo "* $notemsg" >> $expFileName
46echo "*" >> $expFileName
47
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#
69/usr/ccs/bin/nm -Bex $inputFiles \
70| sed -e '/ [^BDT] /d' -e '/\./d' -e 's/.* [BDT] //' \
71| sort | uniq >> $expFileName