aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2007-09-27 17:25:24 +0200
committerOlivier Tilloy <olivier@tilloy.net>2007-09-27 17:25:24 +0200
commit0f59b48f24a0ab6bad382c1c28fd686b65a379c1 (patch)
treebda06905f6a7c3fe032b6bc38b264e7d4bc35339
parent9096f80b4fd5fca506cca77dfe8ab3a2900daa52 (diff)
downloadpyexiv2-0f59b48f24a0ab6bad382c1c28fd686b65a379c1.tar.gz
Added support for DESTDIR in SConscript for installation. This will ease the creation of a Debian package (feature request by Michal Cihar, see http://www.sirena.org.uk/log/?p=58)
-rw-r--r--src/SConscript29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/SConscript b/src/SConscript
index f04b9e9..744f658 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -6,18 +6,27 @@ import os.path
env = Environment()
+# Include directories to look for 'Python.h' in
+python_inc_path = os.path.join(sys.prefix, 'include', 'python' + sys.version[:3])
+env.Append(CPPPATH=[python_inc_path])
+
+# Libraries to link against
libs = ['boost_python', 'exiv2']
env.Append(LIBS=libs)
-pythonIncPath = os.path.join(sys.prefix, 'include', 'python' + sys.version[:3])
-env.Append(CPPPATH=[pythonIncPath])
-
-cppSources = ['libpyexiv2.cpp', 'libpyexiv2_wrapper.cpp']
-
# Build shared library libpyexiv2
-libpyexiv2 = env.SharedLibrary('libpyexiv2', cppSources)
+cpp_sources = ['libpyexiv2.cpp', 'libpyexiv2_wrapper.cpp']
+libpyexiv2 = env.SharedLibrary('libpyexiv2', cpp_sources)
-pythonLibPath = os.path.join(sys.prefix, 'lib', 'python' + sys.version[:3])
-# install the Python module, invoked using 'scons install'
-env.Alias(target='install', source=env.Install(pythonLibPath, libpyexiv2))
-env.Alias(target='install', source=env.Install(pythonLibPath, 'pyexiv2.py'))
+# Install the shared library and the Python module, invoked using
+# 'scons install'. If DESTDIR is specified on the command line when invoking
+# scons, it will be prepended to each installed target file. See
+# http://www.gnu.org/prep/standards/html_node/DESTDIR.html for reference.
+python_lib_path = os.path.join(sys.prefix, 'lib', 'python' + sys.version[:3])
+dest_dir = ARGUMENTS.get('DESTDIR')
+if (dest_dir is None) or (not os.path.isabs(dest_dir)):
+ install_dir = python_lib_path
+else:
+ install_dir = os.path.join(dest_dir, python_lib_path[1:])
+env.Install(install_dir, [libpyexiv2, 'pyexiv2.py'])
+env.Alias('install', install_dir)