3 # ========================================================================
5 # TYPE: executable, uses makexp_aix
8 # DESCRIPTION: Creates a shareable .o from a set of pre-compiled
11 # USAGE: ld_so_aix [CC] [arguments]
13 # ARGUMENTS: Same as for "ld". The following arguments are processed
14 # or supplied by this script (those marked with an asterisk
15 # can be overriden from command line):
17 # Argument Default value
18 # (*) -o [OutputFileName] -o shr.o
19 # (*) -e [EntryPointLabel] -e init[OutputBaseName]
20 # (*) -bE:[ExportFile] -bE:[OutputBaseName].exp
21 # (*) -bI:[ImportFile] -bI:./python.exp
22 # -bM:[ModuleType] -bM:SRE
23 # -bhalt:[Number] -bhalt:4
28 # The compiler specific ("-lc" or "-lc_r", "-lpthreads",...)
29 # arguments will be automatically passed to "ld" according
30 # to the CC command provided as a first argument to this
31 # script. Usually, the same CC command was used to produce
32 # the pre-compiled .o file(s).
34 # NOTES: 1. Since "ld_so_aix" was originally written for building
35 # shared modules for the Python interpreter, the -e and
36 # -bI default values match Python's conventions. In
37 # Python, the entry point for a shared module is based
38 # on the module's name (e.g., the "mathmodule" will
39 # expect an entry point of "initmath").
40 # 2. The script accepts multiple .o or .a input files and
41 # creates a single (shared) output file. The export list
42 # that is created is based on the output file's basename
43 # with the suffix ".exp".
44 # 3. The resulting shared object file is left in the
46 # 4. Uncommenting the "echo" lines gives detailed output
47 # about the commands executed in the script.
50 # HISTORY: Oct-1996 -- Support added for multiple .o files --
51 # -- and optional arguments processing. --
52 # Chris Myers (myers@tc.cornell.edu), Keith Kwok
53 # (kkwok@tc.cornell.edu) and Vladimir Marangozov
55 # Aug-6-1996 -- Take care of the compiler specific --
56 # -- args by leaving CC to invoke "ld". --
59 # Jul-1-1996 -- Make sure to use /usr/ccs/bin/ld --
60 # -- Use makexp_aix for the export list. --
61 # Vladimir Marangozov (Vladimir.Marangozov@imag.fr)
63 # Manus Hand (mhand@csn.net) -- Initial code -- 6/24/96
64 # ========================================================================
67 usage
="Usage: ld_so_aix [CC command] [ld arguments]"
68 if test ! -n "$*"; then
72 makexp
=`dirname $0`/makexp_aix
74 # Check for existence of compiler.
78 if test ! -x "$whichcc"; then
79 echo "ld_so_aix: Compiler '$CC' not found; exiting."
83 if test ! -n "$*"; then
87 # Default import file for Python
88 # Can be overriden by providing a -bI: argument.
89 impfile
="./python.exp"
97 echo "ld_so_aix: The -e flag needs a parameter; exiting."; exit 2
103 entry
=`echo $1 | sed -e "s/-Wl,//" -e "s/-e//"`
106 if test -z "$2"; then
107 echo "ld_so_aix: The -o flag needs a parameter; exiting."; exit 2
113 objfile
=`echo $1 | sed "s/-o//"`
116 impfile
=`echo $1 | sed -e "s/-Wl,//" -e "s/-bI://"`
119 expfile
=`echo $1 | sed -e "s/-Wl,//" -e "s/-bE://"`
125 -bM:* |
-Wl,-bM:* |
-H* |
-Wl,-H* |
-T* |
-Wl,-T* |
-lm)
135 if test -z "$objs"; then
136 echo "ld_so_aix: No input files; exiting."
138 elif test ! -r "$impfile"; then
139 echo "ld_so_aix: Import file '$impfile' not found or not readable; exiting."
143 # If -o wasn't specified, assume "-o shr.o"
144 if test -z "$objfile"; then
148 filename
=`basename $objfile | sed "s/\.[^.]*$//"`
150 # If -bE: wasn't specified, assume "-bE:$filename.exp"
151 if test -z "$expfile"; then
152 expfile
="$filename.exp"
155 # Default entry symbol for Python modules = init[modulename]
156 # Can be overriden by providing a -e argument.
157 if test -z "$entry"; then
158 entry
=init
`echo $filename | sed "s/module.*//"`
161 #echo "ld_so_aix: Debug info section"
162 #echo " -> output file : $objfile"
163 #echo " -> import file : $impfile"
164 #echo " -> export file : $expfile"
165 #echo " -> entry point : $entry"
166 #echo " -> object files: $objs"
167 #echo " -> CC arguments: $args"
169 CCOPT
="-Wl,-e$entry -Wl,-bE:$expfile -Wl,-bI:$impfile -Wl,-bhalt:4"
170 CCOPT
="$CCOPT -Wl,-bM:SRE -Wl,-T512 -Wl,-H512 -lm -o $objfile"
171 # Note: to use dynamic libraries like libtcl8.4.so and libtk8.4.so
172 # you may need to replace the second CCOPT line above with the following:
173 # CCOPT="$CCOPT -Wl,-bM:SRE -Wl,-T512 -Wl,-H512 -brtl -bnortllib -lm -o $objfile"
177 # Export list generation.
178 #echo $makexp $expfile "$objfile" $objs
179 $makexp $expfile "$objfile" $objs
182 #echo $CC $CCOPT $CCARGS
186 # Delete the module's export list file.
187 # Comment this line if you need it.