summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-06-26 21:15:02 (GMT)
committerGuido van Rossum <guido@python.org>1996-06-26 21:15:02 (GMT)
commit7d844a7c8a865f534d8c5bfb2b2fdc2c2e0d9dd6 (patch)
treed021c36c832a2ab80e65742a1350a1923ab6619c /Modules
parent236f62da7a702ce53d349b925ba7510b32f02c99 (diff)
downloadcpython-7d844a7c8a865f534d8c5bfb2b2fdc2c2e0d9dd6.zip
cpython-7d844a7c8a865f534d8c5bfb2b2fdc2c2e0d9dd6.tar.gz
cpython-7d844a7c8a865f534d8c5bfb2b2fdc2c2e0d9dd6.tar.bz2
aix sharedlib helpers
Diffstat (limited to 'Modules')
-rwxr-xr-xModules/bindit33
-rwxr-xr-xModules/make_aix_so122
2 files changed, 155 insertions, 0 deletions
diff --git a/Modules/bindit b/Modules/bindit
new file mode 100755
index 0000000..87dda1f
--- /dev/null
+++ b/Modules/bindit
@@ -0,0 +1,33 @@
+#!/bin/ksh
+
+#################################
+# AIX shared library helper #
+#################################
+
+# ------------------------------------------------------------
+# This script should be in the Modules directory, and I run it
+# (from there) after having built all the shared objects.
+# ------------------------------------------------------------
+
+# --------------------------------------------------
+# Create the export file which will list all symbols
+# that the statically linked python executable has
+# to make available to dynamically loaded modules.
+# --------------------------------------------------
+sort -u *.imp > python.exp
+
+# ---------------------------------------------------------------------
+# Link the python executable. I think this is exactly the same command
+# which the unmodified python makefile comes up with, except for the
+# addition of the -bE: argument.
+# ---------------------------------------------------------------------
+cc -O main.o config.o getpath.o libModules.a ../Python/libPython.a \
+ ../Objects/libObjects.a ../Parser/libParser.a -lm -lc -lg \
+ -H512 -T512 -bE:python.exp \
+ -o python
+
+# -----------------------------------------------------------------
+# Install the Python executable up one directory from Modules (just
+# like the unmodified makefile does).
+# -----------------------------------------------------------------
+mv python ..
diff --git a/Modules/make_aix_so b/Modules/make_aix_so
new file mode 100755
index 0000000..7093df2
--- /dev/null
+++ b/Modules/make_aix_so
@@ -0,0 +1,122 @@
+#!/bin/ksh
+
+#################################
+# AIX shared library helper #
+#################################
+
+# ========================================================================
+# FILENAME: make_aix_so
+# MODULE FOR: standalone executable
+# PLATFORM: AIX (specific)
+# DESCRIPTION: Creates a shareable .o from a pre-compiled (unshared)
+# .o file
+# ARGUMENTS: Same as for "ld". The -bM, -bE, -bI, -H, -T, and -lc
+# arguments of "ld" will be supplied by this script.
+# NOTES: 1. Currently specific to the building of Python
+# interpreter shared objects, in that the entry
+# point name is hardcoded based on the object file
+# name (the "mathmodule.o" file will expect an
+# entry point of "initmath"). This could be remedied
+# by the support (or simple expectation) of a "-e"
+# argument.
+# 2. The resulting shared object file is left in the
+# current directory with the extension .so. It may
+# need to be changed to have a .o extension before
+# it is usable. (At least, Python expects it to
+# have the .o extension, but this is simply because
+# python wants it that way -- it COULD probably be
+# called anything at all).
+# HISTORY: Manus Hand (mhand@csn.net) -- Initial code -- 6/24/96
+# ========================================================================
+
+# ========================================================================
+# SET UP VARIABLES FOR USE IN THIS SCRIPT
+# ------------------------------------------------------------------------
+# Note that the setting of "entry" is Python-build specific. This script
+# is not general-purpose for that reason (although support for a "-e"
+# argument to it could be added, making it usable for any AIX application)
+# ========================================================================
+objfile=$1
+shift
+filename=`echo $objfile | sed -e "s:.*/\([^/]*\)$:\1:" -e "s/\..*$//"`
+entry=init`echo $filename | sed "s/module.*//"`
+ldargs="-e$entry -bE:$filename.exp -bM:SRE -T512 -H512 -lc $objfile $*"
+tmpfile=.py_$$
+
+# ======================================================================
+# EXPORT LIST GENERATION
+# ----------------------------------------------------------------------
+# For the Python modules, this COULD be much simpler, since we know the
+# only exported variable is ".$entry" ("entry" was assigned just above).
+# However, the approach used here for export file generation is more
+# generic and will support all .o's, not just properly formatted Python-
+# importable modules. Here is the rule: any "extern" symbol name which
+# appears in the # output of "nm" which IS resolved (i.e., which does
+# NOT have an address of zero) should go into the export list. Read
+# each line from a temp file containing these symbols. If it begins
+# with a dot, then add it to the list being built. If it does not, then
+# see if the same symbol, with the dot prepended, also appears in the
+# list. If so, DON'T include the current symbol (the one without the
+# prepended dot).
+# ======================================================================
+exec 3>&1 1>$filename.exp
+echo "#!$objfile"
+nm $objfile | grep "|extern|" | grep -v " 0|extern|" | cut -f1 -d"|" > $tmpfile
+while read line ; do
+ echo "$line" | cut -c1 | read prefix
+ if [ "$prefix" = "." ]; then
+ echo "$line"
+ else
+ grep "^\.$line" $tmpfile > /dev/null
+ if [ $? != 0 ]; then
+ echo "$line" ; fi ; fi ; done < $tmpfile
+rm $tmpfile
+
+# ===============================================================
+# IMPORT LIST AND SHARED OBJECT FILE GENERATION
+# ---------------------------------------------------------------
+# Send all output to the to-be-built import file, starting it off
+# with the required "#!" line (which tells it in which loaded
+# binary these symbols are to be found at runtime). Then attempt
+# to ld the object using only the export list built above, and
+# hide the stderr output from "ld". If the ld fails with status
+# code 8 (and in the case of the Python modules, it always does,
+# since each need some symbols from the statically linked portion
+# of the interpreter), this is because an import list should be
+# given containing the symbols which are unresolved. The symbols
+# will have been sent to stdout as a side-effect of the failed ld
+# command, so by redirecting the stdout output, they will have
+# magically been put into the import file being built. Then we
+# simply call ld again with both the import and export lists.
+# ===============================================================
+exec 1>$filename.imp
+echo "#!python"
+ld $ldargs 2>/dev/null
+status=$?
+exec 1>&3
+
+# ================================================================
+# GUIDO: If you want to separate the generation of the import and
+# export lists from the creation of the .so file, here's where the
+# break should be made -- in my mail I mentioned that some of this
+# script belongs in the pre-static link stage of the make and some
+# belongs after it. As I said, here is the dividing line. Now,
+# of course, if there is a module which needs NO statically linked
+# symbols -- but then again, there can't be, because they all need
+# initmodule4() -- the "ld" which is ABOVE this line may actually
+# have succeeded, so the "if" below will fail, but of course,
+# if you separate the script at this point, you won't care about
+# such things.
+# ================================================================
+if [ $status = 8 ] ; then
+ ld $ldargs $filename.imp ; fi
+
+# ======================================================================
+# GUIDO: Remember that at this point, the files (assuming you leave the
+# arguments to LDSHARED totally unchanged) are still named with a .so
+# extension. However, Python looks for them with a .o extension. You
+# can either change this in the core code (#ifdef _AIX) so that it looks
+# for an .so or you can do what I did, which is rename them to .o's when
+# they get mv'ed by the sharedinstall make rule. (Actually, I did it by
+# hand, but you'd do it in sharedinstall.
+# =======================================================================