Commit in lcio/src/python on MAIN
Makefile+44-531.4 -> 1.5
JM: Cleanup Python wrapper makefile

lcio/src/python
Makefile 1.4 -> 1.5
diff -u -r1.4 -r1.5
--- Makefile	15 Mar 2006 00:33:08 -0000	1.4
+++ Makefile	16 Mar 2006 02:11:45 -0000	1.5
@@ -1,14 +1,14 @@
-# $Id: Makefile,v 1.4 2006/03/15 00:33:08 jeremy Exp $
+# $Id: Makefile,v 1.5 2006/03/16 02:11:45 jeremy Exp $
 
 #
-# Makefile to build LCIO Python wrappers to the C++ library, using Swig.
+# Makefile to build LCIO Python wrappers using Swig.
 #
 # --Jeremy McCormick <[log in to unmask]>
 #
 
-# If LCIO is not set, then build env is not sane.
+# LCIO top dir
 ifndef LCIO
-  $(error define LCIO=/path/to/lcio)
+  LCIO = ../..
 endif
 
 # What is Swig called?
@@ -16,34 +16,26 @@
   SWIG = swig
 endif
 
-# Where is Swig's base dir?
-ifndef SWIG_BASE
-  SWIG_BASE = /usr/local/swig
-endif
-
-# Where are Swig's python .i files?
-ifndef SWIG_LIB_DIR
-  SWIG_LIB_DIR = $(SWIG_BASE)/Lib/python/
-endif
-
 # What is python called?
 ifndef PYTHON
   PYTHON = python
 endif
 
-# Where is the python include dir?
-ifndef PYTHON_INCLUDE_DIR
-  PYTHON_INCLUDE_DIR = /usr/local/include/python2.4/
-endif
-
 # Where is Python installed?
 ifndef PYTHONHOME
-  PYTHONHOME = /usr/local
+  # Make a guess at PYTHONHOME based on binary location.
+  PYTHONHOME = $(shell which python | xargs dirname)/..
 endif
 
 # What is the Python version?
 ifndef PYTHONVER
-  PYTHONVER = 2.4
+  # Make a guess at PYTHONVER using version output.
+  PYTHONVER = $(shell python -V 2>&1 | grep -o "[0-9]\.[0-9]")
+endif
+
+# Where is the python include dir?
+ifndef PYTHON_INCLUDE_DIR
+  PYTHON_INCLUDE_DIR = $(PYTHONHOME)/include/python$(PYTHONVER)/
 endif
 
 # What is the Python install dir?
@@ -53,58 +45,57 @@
 
 # End of vars we may take from environment.
 
-# base name for output lib and wrapper file
+# Base name for output lib
 module_name = lcio
+module_lib_name = _$(module_name).so
 
-# base include dir
-lcio_include_dir = $(LCIO)/src/cpp/include
-
-# sio
-sio_dir = $(LCIO)/sio
-sio_include_dir = $(sio_dir)/include
-
-# full paths to all lcio include dirs, including base area
-lcio_include_dirs = $(lcio_include_dir)
-lcio_include_dirs += $(shell for i in $(lcio_include_subdirs); do echo $(lcio_include_dir)/$$i; done)
+# LCIO include dir
+lcio_include_dir =
 
-# swig options
-#swig_opts = -c++ -python -makedefault -shadow
-#swig_opts = -c++ -python -shadow -nodefaultdtor
-swig_opts = -c++ -python -nodefaultctor -nodefaultdtor
+# SIO dir
+SIO = $(LCIO)/sio
 
-# swig include flags
-swig_include_flags = -I$(lcio_include_dir)
-swig_include_flags += -I$(sio_include_dir)
-swig_include_flags += -I$(SWIG_LIB_DIR)
+# lcio include flags
+lcio_include_flags = -I$(LCIO)/src/cpp/include -I$(SIO)/include
 
-# cpp includes
-cpp_include_flags = -I$(PYTHON_INCLUDE_DIR) -I$(lcio_include_dir) -I$(sio_include_dir) -I.
+# combined cpp include flags
+cpp_include_flags = -I. -I$(PYTHON_INCLUDE_DIR) $(lcio_include_flags)
 
-# ld flags
-ldflags = -L$(LCIO)/lib -llcio -L$(sio_dir)/lib -lsio -lz
+# loader flags
+ldflags = -L$(LCIO)/lib -llcio -L$(SIO)/lib -lsio -lz
 
-# wrap file
+# wrapper file naming
 wrap_file = $(module_name)_wrap
+wrap_cc = $(wrap_file).cc
+wrap_obj = $(wrap_file).o
+
+# swig options
+swig_opts = -c++ -python -nodefaultctor -nodefaultdtor
+
+# swig args, flags
+swig_args = -o $(wrap_cc) $(lcio_include_flags) lcio_swig.i
 
+# Default target builds all
 .DEFAULT: all
 .PHONY: all
 
+# Default target executes build and install
 all: swig install
 
-# build target
+# Build the wrapper lib
 swig:
-	$(SWIG) $(swig_opts) -o $(wrap_file).cc $(swig_include_flags) lcio_swig.i; \
-	gcc -c $(wrap_file).cc $(cpp_include_flags) -o $(wrap_file).o; \
-	g++ -shared $(wrap_file).o -L$(LCIO)/lib $(ldflags) -o _$(module_name).so;:
+	$(SWIG) $(swig_opts) $(swig_args) ; \
+	gcc -c $(wrap_cc) $(cpp_include_flags) -o $(wrap_obj); \
+	g++ -shared $(wrap_file).o $(ldflags) -o $(module_lib_name);:
 
-# run test file
+# Run a test file
 test:
 	$(PYTHON) test.py;:
 
-# install to PYTHONHOME
+# Install the wrapper to PYTHONHOME
 install:
 	python -c "import lcio" && cp _lcio.so lcio.pyc lcio.py $(PYTHON_INSTALL_DIR)
 
-# clean up
+# Clean up this directory (does not uninstall from PYTHONHOME)
 clean:
-	@rm -rf *.o *.so *.pyc;:
+	@rm -rf *.o *.so *.pyc $(wrap_cc);:
CVSspam 0.2.8