1996-09-10 18:19:23 +00:00
|
|
|
# Universal Unix Makefile for Python extensions
|
|
|
|
# =============================================
|
|
|
|
|
|
|
|
# Short Instructions
|
|
|
|
# ------------------
|
|
|
|
|
1997-07-19 22:52:43 +00:00
|
|
|
# 1. Build and install Python (1.5 or newer).
|
1996-09-10 18:19:23 +00:00
|
|
|
# 2. "make -f Makefile.pre.in boot"
|
|
|
|
# 3. "make"
|
|
|
|
# You should now have a shared library.
|
|
|
|
|
|
|
|
# Long Instructions
|
|
|
|
# -----------------
|
|
|
|
|
1997-07-19 22:52:43 +00:00
|
|
|
# Build *and install* the basic Python 1.5 distribution. See the
|
|
|
|
# Python README for instructions. (This version of Makefile.pre.in
|
|
|
|
# only withs with Python 1.5, alpha 3 or newer.)
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
# Create a file Setup.in for your extension. This file follows the
|
|
|
|
# format of the Modules/Setup.in file; see the instructions there.
|
|
|
|
# For a simple module called "spam" on file "spammodule.c", it can
|
|
|
|
# contain a single line:
|
|
|
|
# spam spammodule.c
|
|
|
|
# You can build as many modules as you want in the same directory --
|
|
|
|
# just have a separate line for each of them in the Setup.in file.
|
|
|
|
|
|
|
|
# If you want to build your extension as a shared library, insert a
|
|
|
|
# line containing just the string
|
|
|
|
# *shared*
|
|
|
|
# at the top of your Setup.in file.
|
|
|
|
|
|
|
|
# Note that the build process copies Setup.in to Setup, and then works
|
|
|
|
# with Setup. It doesn't overwrite Setup when Setup.in is changed, so
|
|
|
|
# while you're in the process of debugging your Setup.in file, you may
|
|
|
|
# want to edit Setup instead, and copy it back to Setup.in later.
|
|
|
|
# (All this is done so you can distribute your extension easily and
|
|
|
|
# someone else can select the modules they actually want to build by
|
|
|
|
# commenting out lines in the Setup file, without editing the
|
|
|
|
# original. Editing Setup is also used to specify nonstandard
|
|
|
|
# locations for include or library files.)
|
|
|
|
|
|
|
|
# Copy this file (Misc/Makefile.pre.in) to the directory containing
|
|
|
|
# your extension.
|
|
|
|
|
|
|
|
# Run "make -f Makefile.pre.in boot". This creates Makefile
|
|
|
|
# (producing Makefile.pre and sedscript as intermediate files) and
|
|
|
|
# config.c, incorporating the values for sys.prefix, sys.exec_prefix
|
|
|
|
# and sys.version from the installed Python binary. For this to work,
|
|
|
|
# the python binary must be on your path. If this fails, try
|
1997-07-19 22:52:43 +00:00
|
|
|
# make -f Makefile.pre.in Makefile VERSION=1.5 installdir=<prefix>
|
1996-09-10 18:19:23 +00:00
|
|
|
# where <prefix> is the prefix used to install Python for installdir
|
|
|
|
# (and possibly similar for exec_installdir=<exec_prefix>).
|
|
|
|
|
1996-11-27 19:38:53 +00:00
|
|
|
# Note: "make boot" implies "make clobber" -- it assumes that when you
|
|
|
|
# bootstrap you may have changed platforms so it removes all previous
|
|
|
|
# output files.
|
|
|
|
|
1996-09-10 18:19:23 +00:00
|
|
|
# If you are building your extension as a shared library (your
|
|
|
|
# Setup.in file starts with *shared*), run "make" or "make sharedmods"
|
|
|
|
# to build the shared library files. If you are building a statically
|
|
|
|
# linked Python binary (the only solution of your platform doesn't
|
|
|
|
# support shared libraries, and sometimes handy if you want to
|
|
|
|
# distribute or install the resulting Python binary), run "make
|
|
|
|
# python".
|
|
|
|
|
|
|
|
# Note: Each time you edit Makefile.pre.in or Setup, you must run
|
|
|
|
# "make Makefile" before running "make".
|
|
|
|
|
|
|
|
# Hint: if you want to use VPATH, you can start in an empty
|
|
|
|
# subdirectory and say (e.g.):
|
|
|
|
# make -f ../Makefile.pre.in boot srcdir=.. VPATH=..
|
|
|
|
|
|
|
|
|
|
|
|
# === Bootstrap variables (edited through "make boot") ===
|
|
|
|
|
|
|
|
# The prefix used by "make inclinstall libainstall" of core python
|
|
|
|
installdir= /usr/local
|
|
|
|
|
|
|
|
# The exec_prefix used by the same
|
|
|
|
exec_installdir=$(installdir)
|
|
|
|
|
|
|
|
# Source directory and VPATH in case you want to use VPATH.
|
|
|
|
# (You will have to edit these two lines yourself -- there is no
|
|
|
|
# automatic support as the Makefile is not generated by
|
|
|
|
# config.status.)
|
|
|
|
srcdir= .
|
|
|
|
VPATH= .
|
|
|
|
|
|
|
|
# === Variables that you may want to customize (rarely) ===
|
|
|
|
|
1996-10-08 17:21:11 +00:00
|
|
|
# (Static) build target
|
|
|
|
TARGET= python
|
|
|
|
|
1996-11-27 19:38:53 +00:00
|
|
|
# Installed python binary (used only by boot target)
|
|
|
|
PYTHON= python
|
|
|
|
|
1996-09-10 18:19:23 +00:00
|
|
|
# Add more -I and -D options here
|
1997-10-05 03:01:28 +00:00
|
|
|
CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(EXECINCLUDEPY) $(DEFS)
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
# These two variables can be set in Setup to merge extensions.
|
|
|
|
# See example[23].
|
|
|
|
BASELIB=
|
|
|
|
BASESETUP=
|
|
|
|
|
|
|
|
# === Variables set by makesetup ===
|
|
|
|
|
|
|
|
MODOBJS= _MODOBJS_
|
|
|
|
MODLIBS= _MODLIBS_
|
|
|
|
|
|
|
|
# === Definitions added by makesetup ===
|
|
|
|
|
|
|
|
# === Variables from configure (through sedscript) ===
|
|
|
|
|
|
|
|
VERSION= @VERSION@
|
|
|
|
CC= @CC@
|
1997-10-09 20:24:13 +00:00
|
|
|
LINKCC= @LINKCC@
|
|
|
|
SGI_ABI= @SGI_ABI@
|
1996-09-10 18:19:23 +00:00
|
|
|
OPT= @OPT@
|
|
|
|
LDFLAGS= @LDFLAGS@
|
1998-03-11 17:49:55 +00:00
|
|
|
LDLAST= @LDLAST@
|
1996-09-10 18:19:23 +00:00
|
|
|
DEFS= @DEFS@
|
|
|
|
LIBS= @LIBS@
|
|
|
|
LIBM= @LIBM@
|
|
|
|
LIBC= @LIBC@
|
|
|
|
RANLIB= @RANLIB@
|
|
|
|
MACHDEP= @MACHDEP@
|
|
|
|
SO= @SO@
|
|
|
|
LDSHARED= @LDSHARED@
|
|
|
|
CCSHARED= @CCSHARED@
|
|
|
|
LINKFORSHARED= @LINKFORSHARED@
|
1997-10-09 20:24:13 +00:00
|
|
|
#@SET_CCC@
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
# Install prefix for architecture-independent files
|
|
|
|
prefix= /usr/local
|
|
|
|
|
|
|
|
# Install prefix for architecture-dependent files
|
|
|
|
exec_prefix= $(prefix)
|
|
|
|
|
1998-04-30 13:34:12 +00:00
|
|
|
# Uncomment the following two lines for AIX
|
|
|
|
#LINKCC= $(LIBPL)/makexp_aix $(LIBPL)/python.exp "" $(LIBRARY); $(PURIFY) $(CC)
|
|
|
|
#LDSHARED= $(LIBPL)/ld_so_aix $(CC) -bI:$(LIBPL)/python.exp
|
|
|
|
|
1996-09-10 18:19:23 +00:00
|
|
|
# === Fixed definitions ===
|
|
|
|
|
1996-10-24 21:47:45 +00:00
|
|
|
# Shell used by make (some versions default to the login shell, which is bad)
|
|
|
|
SHELL= /bin/sh
|
|
|
|
|
1996-09-10 18:19:23 +00:00
|
|
|
# Expanded directories
|
|
|
|
BINDIR= $(exec_installdir)/bin
|
|
|
|
LIBDIR= $(exec_prefix)/lib
|
|
|
|
MANDIR= $(installdir)/man
|
|
|
|
INCLUDEDIR= $(installdir)/include
|
|
|
|
SCRIPTDIR= $(prefix)/lib
|
|
|
|
|
|
|
|
# Detailed destination directories
|
|
|
|
BINLIBDEST= $(LIBDIR)/python$(VERSION)
|
|
|
|
LIBDEST= $(SCRIPTDIR)/python$(VERSION)
|
|
|
|
INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)
|
1997-10-05 03:01:28 +00:00
|
|
|
EXECINCLUDEPY= $(exec_installdir)/include/python$(VERSION)
|
1996-09-10 18:19:23 +00:00
|
|
|
LIBP= $(exec_installdir)/lib/python$(VERSION)
|
1997-10-04 04:56:40 +00:00
|
|
|
DESTSHARED= $(BINLIBDEST)/site-packages
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
LIBPL= $(LIBP)/config
|
|
|
|
|
1997-07-19 22:52:43 +00:00
|
|
|
PYTHONLIBS= $(LIBPL)/libpython$(VERSION).a
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
MAKESETUP= $(LIBPL)/makesetup
|
|
|
|
MAKEFILE= $(LIBPL)/Makefile
|
|
|
|
CONFIGC= $(LIBPL)/config.c
|
|
|
|
CONFIGCIN= $(LIBPL)/config.c.in
|
2000-06-30 16:04:18 +00:00
|
|
|
SETUP= $(LIBPL)/Setup.config $(LIBPL)/Setup.local $(LIBPL)/Setup
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
SYSLIBS= $(LIBM) $(LIBC)
|
|
|
|
|
1997-07-19 22:52:43 +00:00
|
|
|
ADDOBJS= $(LIBPL)/python.o config.o
|
1996-09-10 18:19:23 +00:00
|
|
|
|
1997-10-04 04:56:40 +00:00
|
|
|
# Portable install script (configure doesn't always guess right)
|
|
|
|
INSTALL= $(LIBPL)/install-sh -c
|
|
|
|
# Shared libraries must be installed with executable mode on some systems;
|
|
|
|
# rather than figuring out exactly which, we always give them executable mode.
|
|
|
|
# Also, making them read-only seems to be a good idea...
|
|
|
|
INSTALL_SHARED= ${INSTALL} -m 555
|
|
|
|
|
1996-09-10 18:19:23 +00:00
|
|
|
# === Fixed rules ===
|
|
|
|
|
|
|
|
# Default target. This builds shared libraries only
|
|
|
|
default: sharedmods
|
|
|
|
|
|
|
|
# Build everything
|
1996-10-08 17:21:11 +00:00
|
|
|
all: static sharedmods
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
# Build shared libraries from our extension modules
|
|
|
|
sharedmods: $(SHAREDMODS)
|
|
|
|
|
|
|
|
# Build a static Python binary containing our extension modules
|
1996-10-08 17:21:11 +00:00
|
|
|
static: $(TARGET)
|
1997-07-19 22:52:43 +00:00
|
|
|
$(TARGET): $(ADDOBJS) lib.a $(PYTHONLIBS) Makefile $(BASELIB)
|
1998-03-11 17:49:55 +00:00
|
|
|
$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) \
|
|
|
|
$(ADDOBJS) lib.a $(PYTHONLIBS) \
|
1996-10-08 17:21:11 +00:00
|
|
|
$(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) \
|
1998-03-11 17:49:55 +00:00
|
|
|
-o $(TARGET) $(LDLAST)
|
1996-09-10 18:19:23 +00:00
|
|
|
|
1997-10-04 04:56:40 +00:00
|
|
|
install: sharedmods
|
|
|
|
if test ! -d $(DESTSHARED) ; then \
|
|
|
|
mkdir $(DESTSHARED) ; else true ; fi
|
|
|
|
-for i in X $(SHAREDMODS); do \
|
|
|
|
if test $$i != X; \
|
|
|
|
then $(INSTALL_SHARED) $$i $(DESTSHARED)/$$i; \
|
|
|
|
fi; \
|
|
|
|
done
|
|
|
|
|
1996-09-10 18:19:23 +00:00
|
|
|
# Build the library containing our extension modules
|
|
|
|
lib.a: $(MODOBJS)
|
|
|
|
-rm -f lib.a
|
|
|
|
ar cr lib.a $(MODOBJS)
|
1997-07-19 22:52:43 +00:00
|
|
|
-$(RANLIB) lib.a
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
# This runs makesetup *twice* to use the BASESETUP definition from Setup
|
|
|
|
config.c Makefile: Makefile.pre Setup $(BASESETUP) $(MAKESETUP)
|
|
|
|
$(MAKESETUP) \
|
|
|
|
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
|
|
|
$(MAKE) -f Makefile do-it-again
|
|
|
|
|
|
|
|
# Internal target to run makesetup for the second time
|
|
|
|
do-it-again:
|
|
|
|
$(MAKESETUP) \
|
|
|
|
-m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP)
|
|
|
|
|
|
|
|
# Make config.o from the config.c created by makesetup
|
|
|
|
config.o: config.c
|
|
|
|
$(CC) $(CFLAGS) -c config.c
|
|
|
|
|
|
|
|
# Setup is copied from Setup.in *only* if it doesn't yet exist
|
|
|
|
Setup:
|
|
|
|
cp $(srcdir)/Setup.in Setup
|
|
|
|
|
|
|
|
# Make the intermediate Makefile.pre from Makefile.pre.in
|
|
|
|
Makefile.pre: Makefile.pre.in sedscript
|
|
|
|
sed -f sedscript $(srcdir)/Makefile.pre.in >Makefile.pre
|
|
|
|
|
|
|
|
# Shortcuts to make the sed arguments on one line
|
|
|
|
P=prefix
|
|
|
|
E=exec_prefix
|
|
|
|
H=Generated automatically from Makefile.pre.in by sedscript.
|
|
|
|
L=LINKFORSHARED
|
|
|
|
|
|
|
|
# Make the sed script used to create Makefile.pre from Makefile.pre.in
|
|
|
|
sedscript: $(MAKEFILE)
|
|
|
|
sed -n \
|
|
|
|
-e '1s/.*/1i\\/p' \
|
|
|
|
-e '2s%.*%# $H%p' \
|
|
|
|
-e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \
|
|
|
|
-e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \
|
1997-10-09 20:24:13 +00:00
|
|
|
-e '/^CCC=/s/^CCC=[ ]*\(.*\)/s%#@SET_CCC[@]%CCC=\1%/p' \
|
|
|
|
-e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \
|
1996-09-10 18:19:23 +00:00
|
|
|
-e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \
|
|
|
|
-e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \
|
1998-05-20 15:53:22 +00:00
|
|
|
-e '/^LDLAST=/s/^LDLAST=[ ]*\(.*\)/s%@LDLAST[@]%\1%/p' \
|
1996-09-10 18:19:23 +00:00
|
|
|
-e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \
|
|
|
|
-e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \
|
|
|
|
-e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \
|
|
|
|
-e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \
|
|
|
|
-e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \
|
|
|
|
-e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \
|
|
|
|
-e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \
|
|
|
|
-e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \
|
|
|
|
-e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \
|
1998-06-08 21:22:12 +00:00
|
|
|
-e '/^SGI_ABI=/s/^SGI_ABI=[ ]*\(.*\)/s%@SGI_ABI[@]%\1%/p' \
|
1996-09-10 18:19:23 +00:00
|
|
|
-e '/^$L=/s/^$L=[ ]*\(.*\)/s%@$L[@]%\1%/p' \
|
|
|
|
-e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \
|
|
|
|
-e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \
|
|
|
|
$(MAKEFILE) >sedscript
|
1997-10-09 20:24:13 +00:00
|
|
|
echo "/^#@SET_CCC@/d" >>sedscript
|
1996-09-10 18:19:23 +00:00
|
|
|
echo "/^installdir=/s%=.*%= $(installdir)%" >>sedscript
|
|
|
|
echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%" >>sedscript
|
|
|
|
echo "/^srcdir=/s%=.*%= $(srcdir)%" >>sedscript
|
|
|
|
echo "/^VPATH=/s%=.*%= $(VPATH)%" >>sedscript
|
|
|
|
echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%" >>sedscript
|
|
|
|
echo "/^BASELIB=/s%=.*%= $(BASELIB)%" >>sedscript
|
|
|
|
echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%" >>sedscript
|
|
|
|
|
|
|
|
# Bootstrap target
|
1996-10-10 19:12:47 +00:00
|
|
|
boot: clobber
|
1996-11-27 19:38:53 +00:00
|
|
|
VERSION=`$(PYTHON) -c "import sys; print sys.version[:3]"`; \
|
|
|
|
installdir=`$(PYTHON) -c "import sys; print sys.prefix"`; \
|
|
|
|
exec_installdir=`$(PYTHON) -c "import sys; print sys.exec_prefix"`; \
|
1996-09-11 12:15:07 +00:00
|
|
|
$(MAKE) -f $(srcdir)/Makefile.pre.in VPATH=$(VPATH) srcdir=$(srcdir) \
|
1996-09-10 18:19:23 +00:00
|
|
|
VERSION=$$VERSION \
|
|
|
|
installdir=$$installdir \
|
1996-09-11 12:15:07 +00:00
|
|
|
exec_installdir=$$exec_installdir \
|
|
|
|
Makefile
|
1996-09-10 18:19:23 +00:00
|
|
|
|
|
|
|
# Handy target to remove intermediate files and backups
|
|
|
|
clean:
|
|
|
|
-rm -f *.o *~
|
|
|
|
|
|
|
|
# Handy target to remove everything that is easily regenerated
|
|
|
|
clobber: clean
|
1996-11-27 19:38:53 +00:00
|
|
|
-rm -f *.a tags TAGS config.c Makefile.pre $(TARGET) sedscript
|
1996-09-10 18:19:23 +00:00
|
|
|
-rm -f *.so *.sl so_locations
|
|
|
|
|
|
|
|
|
|
|
|
# Handy target to remove everything you don't want to distribute
|
|
|
|
distclean: clobber
|
|
|
|
-rm -f Makefile Setup
|