aboutsummaryrefslogtreecommitdiffstats
path: root/src/SConscript
blob: abf299cafcc08828cc0d70ea15677286fcbb7999 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-

import os
from distutils.sysconfig import get_python_inc, get_python_lib
import SCons.Util

env = Environment()

# Take environment variables into account
# (see https://bugs.launchpad.net/pyexiv2/+bug/249835)
if os.environ.has_key('CXX'):
    env['CXX'] = os.environ['CXX']
if os.environ.has_key('CXXFLAGS'):
    env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
if os.environ.has_key('LDFLAGS'):
    env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])

# Include directories to look for 'Python.h' in
env.Append(CPPPATH=[get_python_inc(plat_specific=True)])

# Libraries to link against
# On some systems, boost_python is actually called boost_python-mt.
# Use the BOOSTLIB argument to override the default value.
# See https://bugs.launchpad.net/pyexiv2/+bug/523858.
libs = [ARGUMENTS.get('BOOSTLIB', 'boost_python'), 'exiv2']
env.Append(LIBS=libs)

# Build shared library libpyexiv2
cpp_sources = ['exiv2wrapper.cpp', 'exiv2wrapper_python.cpp']
libpyexiv2 = env.SharedLibrary('exiv2python', cpp_sources)
env.Alias('lib', libpyexiv2)

# Install the shared library and the Python modules, 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 = get_python_lib(plat_specific=True)
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])
env.Install(os.path.join(install_dir, 'pyexiv2'), Glob('pyexiv2/*.py'))
env.Alias('install', install_dir)