aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-10-09 18:06:06 +0000
committerlloyd <[email protected]>2009-10-09 18:06:06 +0000
commit997e6c97b8ace857d00f9fd57f621ba9323c75df (patch)
treed5b65a4fc28a51a66a64fdf75055aab916c59db7
parentc4264a0404cd9b0b9dcba66a2ca157174d934b09 (diff)
Add more or less functional integration with Boost.Python. Use
--use-boost-python to enable creating a second makefile, Makefile.python, which has targets for building and installing the Python module.
-rw-r--r--.mtn-ignore2
-rwxr-xr-xconfigure.py42
-rw-r--r--src/build-data/makefile/python.in29
-rw-r--r--src/build-data/makefile/unix.in2
-rw-r--r--src/build-data/makefile/unix_shr.in2
-rw-r--r--src/wrap/python/__init__.py (renamed from wrappers/boost-python/botan/__init__.py)0
-rw-r--r--src/wrap/python/core.cpp (renamed from wrappers/boost-python/src/core.cpp)0
-rw-r--r--src/wrap/python/filter.cpp (renamed from wrappers/boost-python/src/filter.cpp)2
-rw-r--r--src/wrap/python/pk.cpp (renamed from wrappers/boost-python/src/pk.cpp)0
-rw-r--r--src/wrap/python/python_botan.h (renamed from wrappers/boost-python/src/python_botan.h)0
-rw-r--r--src/wrap/python/x509.cpp (renamed from wrappers/boost-python/src/x509.cpp)0
-rw-r--r--wrappers/boost-python/Makefile20
12 files changed, 86 insertions, 13 deletions
diff --git a/.mtn-ignore b/.mtn-ignore
index 63acd11e3..ec8588da0 100644
--- a/.mtn-ignore
+++ b/.mtn-ignore
@@ -1,4 +1,4 @@
-^Makefile$
+^Makefile.*$
^botan-config$
^botan.pc$
^build$
diff --git a/configure.py b/configure.py
index 0f5e1502d..857cab7e7 100755
--- a/configure.py
+++ b/configure.py
@@ -55,6 +55,12 @@ class BuildConfigurationInformation(object):
self.checkobj_dir = os.path.join(self.build_dir, 'checks')
self.libobj_dir = os.path.join(self.build_dir, 'lib')
+ self.python_dir = os.path.join(options.src_dir, 'wrap', 'python')
+
+ self.use_boost_python = options.boost_python
+
+ self.pyobject_dir = os.path.join(self.build_dir, 'python')
+
self.include_dir = os.path.join(self.build_dir, 'include')
self.full_include_dir = os.path.join(self.include_dir, 'botan')
@@ -71,6 +77,10 @@ class BuildConfigurationInformation(object):
[os.path.join(checks_dir, file) for file in os.listdir(checks_dir)
if file.endswith('.cpp')])
+ self.python_sources = sorted(
+ [os.path.join(self.python_dir, file) for file in os.listdir(self.python_dir)
+ if file.endswith('.cpp')])
+
def doc_files(self):
docs = ['readme.txt']
@@ -87,6 +97,14 @@ class BuildConfigurationInformation(object):
return 'botan-%d.%d.pc' % (self.version_major,
self.version_minor)
+ def build_dirs(self):
+ dirs = [self.checkobj_dir,
+ self.libobj_dir,
+ self.full_include_dir]
+ if self.use_boost_python:
+ dirs.append(self.pyobject_dir)
+ return dirs
+
def username(self):
return getpass.getuser()
@@ -146,6 +164,10 @@ def process_command_line(args):
build_group.add_option('--disable-debug', dest='debug_build',
action='store_false', help=SUPPRESS_HELP)
+ build_group.add_option('--use-boost-python', dest='boost_python',
+ default=False, action='store_true',
+ help='enable Boost.Python wrapper')
+
build_group.add_option('--with-tr1-implementation', metavar='WHICH',
dest='with_tr1', default=None,
help='enable TR1 (options: none, system, boost)')
@@ -781,6 +803,14 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
build_commands(build_config.check_sources,
build_config.checkobj_dir, 'CHECK')),
+ 'python_objs': makefile_list(
+ objectfile_list(build_config.python_sources,
+ build_config.pyobject_dir)),
+
+ 'python_build_cmds': '\n'.join(
+ build_commands(build_config.python_sources,
+ build_config.pyobject_dir, 'PYTHON')),
+
'ar_command': cc.ar_command or osinfo.ar_command,
'ranlib_command': osinfo.ranlib_command(),
'install_cmd_exec': osinfo.install_cmd_exec,
@@ -802,6 +832,8 @@ def create_template_vars(build_config, options, modules, cc, arch, osinfo):
'mod_list': '\n'.join(['%s (%s)' % (m.basename, m.realname)
for m in sorted(modules)]),
+
+ 'python_version': '.'.join(map(str, sys.version_info[0:2]))
}
"""
@@ -988,10 +1020,8 @@ def setup_build(build_config, options, template_vars):
except OSError, e:
logging.debug('Error while removing build dir: %s' % (e))
- for dirs in [build_config.checkobj_dir,
- build_config.libobj_dir,
- build_config.full_include_dir]:
- os.makedirs(dirs)
+ for dir in build_config.build_dirs():
+ os.makedirs(dir)
makefile_template = os.path.join(
options.makefile_dir,
@@ -1010,6 +1040,10 @@ def setup_build(build_config, options, template_vars):
templates_to_proc[os.path.join(options.build_data, template)] = \
os.path.join(build_config.build_dir, sink)
+ if options.boost_python:
+ templates_to_proc[
+ os.path.join(options.makefile_dir, 'python.in')] = 'Makefile.python'
+
for (template, sink) in templates_to_proc.items():
try:
f = open(sink, 'w')
diff --git a/src/build-data/makefile/python.in b/src/build-data/makefile/python.in
new file mode 100644
index 000000000..ee95f8d78
--- /dev/null
+++ b/src/build-data/makefile/python.in
@@ -0,0 +1,29 @@
+CXX = g++
+
+PYTHON_ROOT = /usr/lib/python%{python_version}/config
+PYTHON_INC = -I/usr/include/python%{python_version}
+PYTHON_SITE_PACKAGE_DIR = /tmp/usr/lib/python%{python_version}/site-packages/
+
+PYTHON_FLAGS = -Isrc/wrap/python -Os -fPIC -ftemplate-depth-255 -Wall -Wno-unused $(PYTHON_INC)
+
+PYTHON_OBJS = %{python_objs}
+
+BOTAN_PYTHON_MODDIR = build/botan-python
+
+all: $(BOTAN_PYTHON_MODDIR)/_botan.so
+
+%{python_build_cmds}
+
+$(BOTAN_PYTHON_MODDIR)/_botan.so: $(PYTHON_OBJS)
+ rm -rf $(BOTAN_PYTHON_MODDIR)
+ mkdir $(BOTAN_PYTHON_MODDIR)
+ cp src/wrap/python/*.py $(BOTAN_PYTHON_MODDIR)
+ $(CXX) -shared -o $@ $(PYTHON_OBJS) -L. -L$(PYTHON_ROOT) -lbotan -lboost_python -Wl,-rpath-link,. -Wl,-soname,$@
+
+clean:
+ rm -f $(PYTHON_OBJS) $(BOTAN_PYTHON_MODDIR)
+
+install:
+ mkdir -p $(PYTHON_SITE_PACKAGE_DIR)/botan
+ cp $(BOTAN_PYTHON_MODDIR)/* $(PYTHON_SITE_PACKAGE_DIR)/botan
+ chmod -R u=rwX,go=rX $(PYTHON_SITE_PACKAGE_DIR)/botan
diff --git a/src/build-data/makefile/unix.in b/src/build-data/makefile/unix.in
index a48a5a17e..8e0e35b87 100644
--- a/src/build-data/makefile/unix.in
+++ b/src/build-data/makefile/unix.in
@@ -101,7 +101,7 @@ clean:
distclean: clean
$(RM_R) %{build_dir}
$(RM_R) %{doc_src_dir}/doxygen %{doc_src_dir}/botan.doxy
- $(RM) Makefile $(CONFIG_SCRIPT) $(PKGCONFIG)
+ $(RM) Makefile* $(CONFIG_SCRIPT) $(PKGCONFIG)
install: $(LIBRARIES)
$(ECHO) "Installing Botan into $(DESTDIR)... "
diff --git a/src/build-data/makefile/unix_shr.in b/src/build-data/makefile/unix_shr.in
index f718d1160..cfc8e3223 100644
--- a/src/build-data/makefile/unix_shr.in
+++ b/src/build-data/makefile/unix_shr.in
@@ -115,7 +115,7 @@ clean:
distclean: clean
$(RM_R) %{build_dir}
$(RM_R) %{doc_src_dir}/doxygen %{doc_src_dir}/botan.doxy
- $(RM) Makefile $(CONFIG_SCRIPT) $(PKGCONFIG)
+ $(RM) Makefile* $(CONFIG_SCRIPT) $(PKGCONFIG)
install: $(LIBRARIES)
$(ECHO) "Installing Botan into $(DESTDIR)... "
diff --git a/wrappers/boost-python/botan/__init__.py b/src/wrap/python/__init__.py
index 2df9a456f..2df9a456f 100644
--- a/wrappers/boost-python/botan/__init__.py
+++ b/src/wrap/python/__init__.py
diff --git a/wrappers/boost-python/src/core.cpp b/src/wrap/python/core.cpp
index 1992e3d61..1992e3d61 100644
--- a/wrappers/boost-python/src/core.cpp
+++ b/src/wrap/python/core.cpp
diff --git a/wrappers/boost-python/src/filter.cpp b/src/wrap/python/filter.cpp
index 830e090de..a678af9e5 100644
--- a/wrappers/boost-python/src/filter.cpp
+++ b/src/wrap/python/filter.cpp
@@ -159,8 +159,10 @@ void export_filters()
class_<Pipe, boost::noncopyable>("PipeObj")
.def(init<>())
+ /*
.def_readonly("LAST_MESSAGE", &Pipe::LAST_MESSAGE)
.def_readonly("DEFAULT_MESSAGE", &Pipe::DEFAULT_MESSAGE)
+ */
.add_property("default_msg", &Pipe::default_msg, &Pipe::set_default_msg)
.add_property("msg_count", &Pipe::message_count)
.def("append", append_filter)
diff --git a/wrappers/boost-python/src/pk.cpp b/src/wrap/python/pk.cpp
index 72d3294b8..72d3294b8 100644
--- a/wrappers/boost-python/src/pk.cpp
+++ b/src/wrap/python/pk.cpp
diff --git a/wrappers/boost-python/src/python_botan.h b/src/wrap/python/python_botan.h
index 18c51dbb1..18c51dbb1 100644
--- a/wrappers/boost-python/src/python_botan.h
+++ b/src/wrap/python/python_botan.h
diff --git a/wrappers/boost-python/src/x509.cpp b/src/wrap/python/x509.cpp
index 90c2bba1c..90c2bba1c 100644
--- a/wrappers/boost-python/src/x509.cpp
+++ b/src/wrap/python/x509.cpp
diff --git a/wrappers/boost-python/Makefile b/wrappers/boost-python/Makefile
index e3a1acf37..2d2c38e58 100644
--- a/wrappers/boost-python/Makefile
+++ b/wrappers/boost-python/Makefile
@@ -2,8 +2,8 @@ CXX = g++
LANG_FLAGS = -fPIC -Wall -Wno-unused -ftemplate-depth-255
OPT_FLAGS = -g -Os
-PYTHON_ROOT = /usr/lib/python2.5/config
-PYTHON_INC = -I/usr/include/python2.5
+PYTHON_ROOT = /usr/lib/python2.6/config
+PYTHON_INC = -I/usr/include/python2.6
PYTHON_DEF = -DBOOST_PYTHON_DYNAMIC_LIB -DBOOST_PYTHON_SOURCE
WRAPPER_CFLAGS = $(shell botan-config --cflags)
@@ -11,13 +11,21 @@ SHARED_CFLAGS = $(LANG_FLAGS) $(OPT_FLAGS) $(PYTHON_INC)
BOOST_CFLAGS = $(PYTHON_DEF) $(SHARED_CFLAGS)
-WRAP_SRC = $(wildcard src/*.cpp)
-WRAP_OBJS = $(patsubst src/%.cpp,build/%.o,$(WRAP_SRC))
+WRAP_OBJS = build/python/core.o build/python/filter.o build/python/pk.o build/python/x509.o
all: botan/_botan.so
-build/%.o: src/%.cpp
- $(CXX) -Isrc/ $(SHARED_CFLAGS) $(WRAPPER_CFLAGS) -c $< -o $@
+build/python/core.o: src/wrap/python/core.cpp
+ $(CXX) -Isrc/wrap/python $(SHARED_CFLAGS) $(WRAPPER_CFLAGS) -c $< -o $@
+
+build/python/filter.o: src/wrap/python/filter.cpp
+ $(CXX) -Isrc/wrap/python $(SHARED_CFLAGS) $(WRAPPER_CFLAGS) -c $< -o $@
+
+build/python/pk.o: src/wrap/python/pk.cpp
+ $(CXX) -Isrc/wrap/python $(SHARED_CFLAGS) $(WRAPPER_CFLAGS) -c $< -o $@
+
+build/python/x509.o: src/wrap/python/x509.cpp
+ $(CXX) -Isrc/wrap/python $(SHARED_CFLAGS) $(WRAPPER_CFLAGS) -c $< -o $@
botan/_botan.so: $(WRAP_OBJS)
$(CXX) -shared -o $@ $(shell botan-config --libs) -L$(PYTHON_ROOT) $(WRAP_OBJS) -lboost_python -Wl,-rpath-link,. -Wl,-soname,$@