# Universal Unix Makefile for Python extensions (for use with Autoconf) # ===================================================================== # Note that this is not the same file as that distributed with Python 1.4. # It has been slightly modified so that it can be used with scripts created # by autoconf (using some extra commands written by James Henstridge) # Also note that this file will also work with Python 1.5 or 1.5.1 # Short Instructions # ------------------ # 1. Build and install Python (1.4 or newer). # 2. run "./configure" # 3. run "make" # You should now have a shared library. # Long Instructions # ----------------- # Build *and install* the basic Python 1.4 distribution. See the # Python README for instructions. # Create a file Setup.in for your extension. This file follows the # format of the Modules/Setup.in file; see the instructions there. # The first line should just have the string # *shared* # For a simple module called "spam" on file "spammodule.c", it only needs # to contain one extra 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. # # Note that when configure is run, The file Setup.in is parsed for @VARNAME@ # expressions, and after they are expanded, the output is put in the file # Setup. Every time configure is run, Setup is overwritten each time # configure is run. # Copy this file (Misc/Makefile.pre.in) to the directory containing # your extension. Also create a configure script. You may wish to use the # generic one supplied with this file. (This should be done by the one # writing the extension -- not the user). # Run "./configure". This creates Makefile # (producing Makefile.pre 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 # ./configure --with-python=/python # or # ./configure --with-python-version= --with-python-prefix= \ # --with-python-exec-prefix= # where is the prefix used to install Python # 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.in, you must run # "./configure" before running "make". # Hint: if you want to use VPATH, you can start in an empty # subdirectory and type (where is the location of the source): # /configure --srcdir= # make # === Bootstrap variables (edited through "./configure") === # The prefix used by "make inclinstall libainstall" of core python prefix= @prefix@ # The exec_prefix used by the same exec_prefix= @exec_prefix@ # Source directory and VPATH (for VPATH builds). srcdir= @srcdir@ VPATH= @srcdir@ # === Variables that you may want to customize (rarely) === # (Static) build target TARGET= python # Add more -I and -D options here CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(LIBPL) $(DEFS) # 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 === VERSION= @VERSION@ CC= @CC@ LINKCC= @LINKCC@ SGI_ABI= @SGI_ABI@ OPT= @OPT@ LDFLAGS= @LDFLAGS@ LDLAST= @LDLAST@ DEFS= @DEFS@ LIBS= @LIBS@ LIBM= @LIBM@ LIBC= @LIBC@ RANLIB= @RANLIB@ MACHDEP= @MACHDEP@ SO= @SO@ LDSHARED= @LDSHARED@ CCSHARED= @CCSHARED@ LINKFORSHARED= @LINKFORSHARED@ @SET_CCC@ #the python executable (from configure) PYTHON = @PYTHON@ # Install Stuff INSTALL = @INSTALL@ PY_LIB_DIR = @PYTHON_LIBRARY_DIR@ PY_MOD_DIR = @PYTHON_MODULE_DIR@ # === Fixed definitions === # Shell used by make (some versions default to the login shell, which is bad) SHELL= /bin/sh # Expanded directories BINDIR= $(exec_prefix)/bin LIBDIR= $(exec_prefix)/lib MANDIR= $(prefix)/man INCLUDEDIR= $(prefix)/include SCRIPTDIR= $(prefix)/lib # Detailed destination directories BINLIBDEST= $(LIBDIR)/python$(VERSION) LIBDEST= $(SCRIPTDIR)/python$(VERSION) INCLUDEPY= $(INCLUDEDIR)/python$(VERSION) LIBP= $(exec_prefix)/lib/python$(VERSION) LIBPL= $(LIBP)/config # === Fixed rules === # Default target. This builds shared libraries. default: sharedmods # Build shared libraries from our extension modules sharedmods: $(SHAREDMODS) # Target to build a pyc file from a py file: .py.pyc: $(PYTHON) -c "import py_compile; py_compile.compile('$<')" .SUFFIXES: .py .pyc # Target to install scripts and modules install: install-shmods install-scripts install-shmods: $(SHAREDMODS) @echo 'Installing shared modules...' @if [ -n "$(SHAREDMODS)" ]; then \ for mod in $(SHAREDMODS); do \ echo " install -m 555 $$mod $(PY_MOD_DIR)"; \ $(INSTALL) -m 555 $$mod $(PY_MOD_DIR); \ done; \ fi install-scripts: $(SCRIPTS) @if [ -n "$(SCRIPTS)" ]; then \ echo 'Installing scripts...'; \ for script in $(SCRIPTS); do \ dir=`dirname $$script`; \ if [ ! -d $(PY_LIB_DIR)/$$dir ]; then \ $(INSTALL) -d $(PY_LIB_DIR)/$$dir; \ fi; \ echo " install -m 644 $$script $(PY_LIB_DIR)/$$dir"; \ $(INSTALL) -m 644 $$script $(PY_LIB_DIR)/$$dir; \ done; \ echo "Compiling..."; \ for script in $(SCRIPTS); do \ $(PYTHON) -c "import py_compile; py_compile.compile(\"$(PY_LIB_DIR)/$$script\")"; \ done; \ fi # Handy target to remove intermediate files and backups clean: -rm -f *.o *~ # Handy target to remove everything that is easily regenerated clobber: clean -rm -f *.a tags TAGS config.c Makefile.pre python -rm -f *.so *.sl so_locations # Handy target to remove everything you don't want to distribute distclean: clobber -rm -f Makefile Setup -rm -f config.status config.log config.cache