1#!/bin/sh
2#
3# mkldexport
4#	create an AIX exports file from an object file
5#
6# src/backend/port/aix/mkldexport.sh
7#
8# Usage:
9#	mkldexport objectfile [location]
10# where
11#	objectfile is the current location of the object file.
12#	location is the eventual (installed) location of the
13#		object file (if different from the current
14#		working directory).
15#
16# [This file comes from the Postgres 4.2 distribution. - ay 7/95]
17#
18# Header: /usr/local/devel/postgres/src/tools/mkldexport/RCS/mkldexport.sh,v 1.2 1994/03/13 04:59:12 aoki Exp
19#
20
21# setting this to nm -B might be better
22# ... due to changes in AIX 4.x ...
23# ... let us search in different directories - Gerhard Reithofer
24if [ -x /usr/ucb/nm ]
25then NM=/usr/ucb/nm
26elif [ -x /usr/bin/nm ]
27then NM=/usr/bin/nm
28elif [ -x /usr/ccs/bin/nm ]
29then NM=/usr/ccs/bin/nm
30elif [ -x /usr/usg/bin/nm ]
31then NM=/usr/usg/bin/nm
32else echo "Fatal error: cannot find `nm' ... please check your installation."
33     exit 1
34fi
35
36CMDNAME=`basename $0`
37if [ -z "$1" ]; then
38	echo "Usage: $CMDNAME object [location]"
39	exit 1
40fi
41OBJNAME=`basename $1`
42if [ "`basename $OBJNAME`" != "`basename $OBJNAME .o`" ]; then
43	OBJNAME=`basename $OBJNAME .o`.so
44fi
45if [ -z "$2" ]; then
46	echo '#!'
47else
48	if [ "$2" = "." ]; then
49		# for the base executable (AIX 4.2 and up)
50		echo '#! .'
51	else
52		echo '#!' $2
53	fi
54fi
55$NM -BCg $1 | \
56	egrep ' [TDB] ' | \
57	sed -e 's/.* //' | \
58	egrep -v '\$' | \
59	sed -e 's/^[.]//' | \
60	sort | \
61	uniq
62