* [gentoo-commits] proj/sci:ccp4 commit in: sci-libs/cctbx/files/2013.02.27.0005/, sci-libs/cctbx/files/2012.05.08.2305/, ...
@ 2013-06-01 17:24 Justin Lecher
0 siblings, 0 replies; only message in thread
From: Justin Lecher @ 2013-06-01 17:24 UTC (permalink / raw
To: gentoo-commits
commit: 4dcc9136254923ef49146f459eb013152c907372
Author: Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 1 16:49:03 2013 +0000
Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Sat Jun 1 16:49:03 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=4dcc9136
sci-libs/cctbx: Version Bump
Package-Manager: portage-2.2.0_alpha177
---
sci-libs/cctbx/ChangeLog | 218 ++++
sci-libs/cctbx/cctbx-2012.05.08.2305.ebuild | 81 ++
sci-libs/cctbx/cctbx-2013.02.27.0005.ebuild | 81 ++
.../0001-remove-hardcoded-libtbx_build-env.patch | 24 +
| 51 +
...0003-correct-paths-in-dispatcher-creation.patch | 85 ++
...ream-fix-for-declaration-errors-in-gcc4.7.patch | 442 ++++++++
.../0005-fix-for-gcc4.7-compilation-error.patch | 83 ++
...-for-system-libs-installtarget-and-prefix.patch | 1080 +++++++++++++++++++
.../0007-adding-shlib-versioning.patch | 208 ++++
.../0008-Fix-to-skip-pycbf-build.patch | 52 +
.../0009-build-libann-statically.patch | 27 +
.../2012.05.08.2305/0010-adding-setup_py.patch | 662 ++++++++++++
...011-fix-missing-python-lib-during-linking.patch | 47 +
...12-fix-to-remove-cctbx.python-interpreter.patch | 29 +
...o-support-LDFLAGS-in-use_enviroment_flags.patch | 90 ++
.../0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch | 21 +
.../0016-autogenerate-pkgconfig-files.patch | 305 ++++++
.../0017-Fix-to-use-systems-include-path.patch | 128 +++
...018-Fix-to-skip-build-of-clipper-examples.patch | 52 +
.../files/2012.05.08.2305/0101-system-cbf.patch | 16 +
.../2012.05.08.2305/0101-system-clipper.patch | 185 ++++
.../files/2012.05.08.2305/0102-dontstrip.patch | 25 +
.../0001-remove-hardcoded-libtbx_build-env.patch | 24 +
| 51 +
...0003-correct-paths-in-dispatcher-creation.patch | 86 ++
...-for-system-libs-installtarget-and-prefix.patch | 1099 ++++++++++++++++++++
.../0007-adding-shlib-versioning.patch | 208 ++++
.../0008-Fix-to-skip-pycbf-build.patch | 52 +
.../0009-build-libann-statically.patch | 27 +
.../2013.02.27.0005/0010-adding-setup_py.patch | 662 ++++++++++++
...011-fix-missing-python-lib-during-linking.patch | 47 +
...12-fix-to-remove-cctbx.python-interpreter.patch | 20 +
...o-support-LDFLAGS-in-use_enviroment_flags.patch | 90 ++
.../0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch | 21 +
.../0016-autogenerate-pkgconfig-files.patch | 305 ++++++
.../0017-Fix-to-use-systems-include-path.patch | 128 +++
...018-Fix-to-skip-build-of-clipper-examples.patch | 52 +
.../files/2013.02.27.0005/0101-system-cbf.patch | 16 +
.../2013.02.27.0005/0101-system-clipper.patch | 185 ++++
.../2013.02.27.0005/0101-system-libccp4.patch | 15 +
.../files/2013.02.27.0005/0102-dontstrip.patch | 25 +
.../2013.02.27.0005/0103-respect-cflags.patch | 60 ++
sci-libs/cctbx/metadata.xml | 18 +
44 files changed, 7183 insertions(+)
diff --git a/sci-libs/cctbx/ChangeLog b/sci-libs/cctbx/ChangeLog
new file mode 100644
index 0000000..949d710
--- /dev/null
+++ b/sci-libs/cctbx/ChangeLog
@@ -0,0 +1,218 @@
+# ChangeLog for sci-libs/cctbx
+# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/sci-libs/cctbx/ChangeLog,v 1.33 2013/03/19 07:07:15 jlec Exp $
+
+*cctbx-2013.02.27.0005 (01 Jun 2013)
+*cctbx-2012.05.08.2305 (01 Jun 2013)
+
+ 01 Jun 2013; Justin Lecher <jlec@gentoo.org> +cctbx-2012.05.08.2305.ebuild,
+ +cctbx-2013.02.27.0005.ebuild,
+ +files/2012.05.08.2305/0001-remove-hardcoded-libtbx_build-env.patch,
+ +files/2012.05.08.2305/0002-fix-opengl-header-missing-gltbx.patch,
+ +files/2012.05.08.2305/0003-correct-paths-in-dispatcher-creation.patch,
+ +files/2012.05.08.2305/0004-upstream-fix-for-declaration-errors-in-gcc4.7.pat
+ ch, +files/2012.05.08.2305/0005-fix-for-gcc4.7-compilation-error.patch,
+ +files/2012.05.08.2305/0006-options-for-system-libs-installtarget-and-prefix.
+ patch, +files/2012.05.08.2305/0007-adding-shlib-versioning.patch,
+ +files/2012.05.08.2305/0008-Fix-to-skip-pycbf-build.patch,
+ +files/2012.05.08.2305/0009-build-libann-statically.patch,
+ +files/2012.05.08.2305/0010-adding-setup_py.patch,
+ +files/2012.05.08.2305/0011-fix-missing-python-lib-during-linking.patch,
+ +files/2012.05.08.2305/0012-fix-to-remove-cctbx.python-interpreter.patch,
+ +files/2012.05.08.2305/0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.pa
+ tch, +files/2012.05.08.2305/0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch,
+ +files/2012.05.08.2305/0016-autogenerate-pkgconfig-files.patch,
+ +files/2012.05.08.2305/0017-Fix-to-use-systems-include-path.patch,
+ +files/2012.05.08.2305/0018-Fix-to-skip-build-of-clipper-examples.patch,
+ +files/2012.05.08.2305/0101-system-cbf.patch,
+ +files/2012.05.08.2305/0101-system-clipper.patch,
+ +files/2012.05.08.2305/0102-dontstrip.patch,
+ +files/2013.02.27.0005/0001-remove-hardcoded-libtbx_build-env.patch,
+ +files/2013.02.27.0005/0002-fix-opengl-header-missing-gltbx.patch,
+ +files/2013.02.27.0005/0003-correct-paths-in-dispatcher-creation.patch,
+ +files/2013.02.27.0005/0006-options-for-system-libs-installtarget-and-prefix.
+ patch, +files/2013.02.27.0005/0007-adding-shlib-versioning.patch,
+ +files/2013.02.27.0005/0008-Fix-to-skip-pycbf-build.patch,
+ +files/2013.02.27.0005/0009-build-libann-statically.patch,
+ +files/2013.02.27.0005/0010-adding-setup_py.patch,
+ +files/2013.02.27.0005/0011-fix-missing-python-lib-during-linking.patch,
+ +files/2013.02.27.0005/0012-fix-to-remove-cctbx.python-interpreter.patch,
+ +files/2013.02.27.0005/0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.pa
+ tch, +files/2013.02.27.0005/0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch,
+ +files/2013.02.27.0005/0016-autogenerate-pkgconfig-files.patch,
+ +files/2013.02.27.0005/0017-Fix-to-use-systems-include-path.patch,
+ +files/2013.02.27.0005/0018-Fix-to-skip-build-of-clipper-examples.patch,
+ +files/2013.02.27.0005/0101-system-cbf.patch,
+ +files/2013.02.27.0005/0101-system-clipper.patch,
+ +files/2013.02.27.0005/0101-system-libccp4.patch,
+ +files/2013.02.27.0005/0102-dontstrip.patch,
+ +files/2013.02.27.0005/0103-respect-cflags.patch, +metadata.xml:
+ Version Bump
+
+ 19 Mar 2013; Justin Lecher <jlec@gentoo.org> cctbx-2010.03.29.2334-r7.ebuild:
+ Use more functions from new python eclasses, fixes double prefix on PREFIX
+
+ 17 Mar 2013; Justin Lecher <jlec@gentoo.org> cctbx-2010.03.29.2334-r6.ebuild,
+ cctbx-2010.03.29.2334-r7.ebuild:
+ Add missing multilib.eclass
+
+*cctbx-2010.03.29.2334-r7 (17 Mar 2013)
+
+ 17 Mar 2013; Justin Lecher <jlec@gentoo.org>
+ +cctbx-2010.03.29.2334-r7.ebuild, metadata.xml:
+ Move to new python eclasses, log all file removals; bump to EAPI=5;add
+ missing die; use usex instead of custom check_use
+
+ 19 Oct 2012; Justin Lecher <jlec@gentoo.org> cctbx-2010.03.29.2334-r6.ebuild:
+ Remove virtual/fortran and always call fortran-2_pkg_setup as intend by the
+ updated fortran-2.eclass
+
+ 18 Oct 2012; Justin Lecher <jlec@gentoo.org> cctbx-2010.03.29.2334-r6.ebuild:
+ Remove virtual/fortran and always call fortran-2_pkg_setup as intend by the
+ updated fortran-2.eclass
+
+ 06 Sep 2012; Justin Lecher <jlec@gentoo.org> cctbx-2010.03.29.2334-r6.ebuild:
+ Use bundled scons on prefix, #391377
+
+ 26 Aug 2012; Justin Lecher <jlec@gentoo.org>
+ -cctbx-2010.03.29.2334-r3.ebuild, -cctbx-2010.03.29.2334-r4.ebuild,
+ -cctbx-2010.03.29.2334-r5.ebuild:
+ Drop old
+
+ 19 Jun 2012; Justin Lecher <jlec@gentoo.org>
+ +files/2010.03.29.2334-gcc-4.7.patch, cctbx-2010.03.29.2334-r6.ebuild:
+ Add fix for gcc-4.7
+
+ 14 Jun 2012; Jeff Horelick <jdhore@gentoo.org>
+ cctbx-2010.03.29.2334-r6.ebuild:
+ marked x86 per bug 413815
+
+ 23 May 2012; Agostino Sarubbo <ago@gentoo.org>
+ cctbx-2010.03.29.2334-r6.ebuild:
+ Stable for amd64, wrt bug #413815
+
+ 10 Feb 2012; Markos Chandras <hwoarang@gentoo.org>
+ cctbx-2010.03.29.2334-r3.ebuild, cctbx-2010.03.29.2334-r4.ebuild,
+ cctbx-2010.03.29.2334-r5.ebuild, cctbx-2010.03.29.2334-r6.ebuild:
+ Update Boost dependencies. Thanks to Arfrever
+
+*cctbx-2010.03.29.2334-r6 (10 Feb 2012)
+
+ 10 Feb 2012; Justin Lecher <jlec@gentoo.org>
+ +cctbx-2010.03.29.2334-r6.ebuild:
+ Add fixes for boost-1.48 and its PyABI specific libs, #401393
+
+*cctbx-2010.03.29.2334-r5 (04 Dec 2011)
+
+ 04 Dec 2011; Justin Lecher <jlec@gentoo.org>
+ +cctbx-2010.03.29.2334-r5.ebuild:
+ Create soname symlink, streamelined find and delete of unwanted files
+
+ 07 Oct 2011; Justin Lecher <jlec@gentoo.org> cctbx-2010.03.29.2334-r3.ebuild,
+ cctbx-2010.03.29.2334-r4.ebuild, metadata.xml:
+ Added [python] to dep on dev-libs/boost
+
+ 21 Jun 2011; Justin Lecher <jlec@gentoo.org> cctbx-2010.03.29.2334-r3.ebuild,
+ cctbx-2010.03.29.2334-r4.ebuild:
+ Add dependency on virtual/fortran
+
+ 21 Jun 2011; Justin Lecher <jlec@gentoo.org> cctbx-2010.03.29.2334-r3.ebuild,
+ cctbx-2010.03.29.2334-r4.ebuild:
+ Added fortran-2.eclass support
+
+*cctbx-2010.03.29.2334-r4 (10 Apr 2011)
+
+ 10 Apr 2011; Justin Lecher <jlec@gentoo.org>
+ +files/2010.03.29.2334-gcc-4.6.patch, +cctbx-2010.03.29.2334-r4.ebuild:
+ Fix changes in gcc-4.6
+
+ 24 Jan 2011; Justin Lecher <jlec@gentoo.org>
+ -cctbx-2010.03.29.2334-r1.ebuild:
+ Removed old
+
+ 23 Jan 2011; Thomas Kahle <tomka@gentoo.org> cctbx-2010.03.29.2334-r3.ebuild:
+ x86 stable per bug 351765
+
+ 16 Jan 2011; Markos Chandras <hwoarang@gentoo.org>
+ cctbx-2010.03.29.2334-r3.ebuild:
+ Stable on amd64 wrt bug #351765
+
+ 16 Jan 2011; Kacper Kowalik <xarthisius@gentoo.org>
+ cctbx-2010.03.29.2334-r3.ebuild:
+ marked ~ppc wrt #303931
+
+ 15 Jan 2011; Justin Lecher <jlec@gentoo.org>
+ -cctbx-2009.11.01.0123-r1.ebuild, -cctbx-2010.03.29.2334-r2.ebuild:
+ Removed old
+
+ 15 Jan 2011; Justin Lecher <jlec@gentoo.org>
+ files/2010.03.29.2334-boost.patch, cctbx-2010.03.29.2334-r2.ebuild,
+ cctbx-2010.03.29.2334-r3.ebuild:
+ Prefix boost detection fix
+
+ 29 Dec 2010; Justin Lecher <jlec@gentoo.org> cctbx-2009.11.01.0123-r1.ebuild,
+ cctbx-2010.03.29.2334-r1.ebuild, cctbx-2010.03.29.2334-r2.ebuild,
+ cctbx-2010.03.29.2334-r3.ebuild:
+ Added missing dependency on clipper
+
+ 16 Dec 2010; Justin Lecher <jlec@gentoo.org> cctbx-2009.11.01.0123-r1.ebuild,
+ cctbx-2010.03.29.2334-r1.ebuild, cctbx-2010.03.29.2334-r2.ebuild,
+ cctbx-2010.03.29.2334-r3.ebuild:
+ Added missing RDEPEND on sci-libs/clipper
+
+*cctbx-2010.03.29.2334-r3 (15 Dec 2010)
+
+ 15 Dec 2010; Justin Lecher <jlec@gentoo.org>
+ +cctbx-2010.03.29.2334-r3.ebuild:
+ Fixing all binaray wrappers
+
+ 12 Sep 2010; Justin Lecher <jlec@gentoo.org>
+ cctbx-2009.11.01.0123-r1.ebuild, cctbx-2010.03.29.2334-r1.ebuild,
+ cctbx-2010.03.29.2334-r2.ebuild:
+ Switched to tc-has-openmp and remove built_with_use
+
+*cctbx-2010.03.29.2334-r2 (12 Sep 2010)
+
+ 12 Sep 2010; Justin Lecher <jlec@gentoo.org>
+ +files/2010.03.29.2334-boost.patch, +cctbx-2010.03.29.2334-r2.ebuild,
+ +files/2010.03.29.2334-clipper.patch, +files/2010.03.29.2334-flags.patch,
+ +files/2010.03.29.2334-soname.patch:
+ Big rewrite
+
+*cctbx-2010.03.29.2334-r1 (03 Jul 2010)
+
+ 03 Jul 2010; Justin Lecher <jlec@gentoo.org>
+ +files/2010.03.29.2334-tst_server.py.patch, -cctbx-2010.03.29.2334.ebuild,
+ +cctbx-2010.03.29.2334-r1.ebuild:
+ Fix for invalid python syntax
+
+ 28 Jun 2010; Christoph Mende <angelos@gentoo.org>
+ cctbx-2010.03.29.2334.ebuild:
+ Stable on amd64 wrt bug #325965
+
+ 16 Jun 2010; Justin Lecher <jlec@gentoo.org>
+ cctbx-2009.11.01.0123-r1.ebuild, cctbx-2010.03.29.2334.ebuild:
+ Last fixes for prefix and keyworded for *-linux
+
+*cctbx-2010.03.29.2334 (22 May 2010)
+
+ 22 May 2010; Justin Lecher <jlec@gentoo.org>
+ +cctbx-2010.03.29.2334.ebuild:
+ Version bump
+
+ 14 Feb 2010; Justin Lecher (jlec) <jlec@gentoo.org>
+ -cctbx-2009.11.01.0123.ebuild, +cctbx-2009.11.01.0123-r1.ebuild:
+ Workaround for broken python.eclass
+
+*cctbx-2009.11.01.0123-r1 (13 Feb 2010)
+
+ 13 Feb 2010; Justin Lecher (jlec) <jlec@gentoo.org>
+ +cctbx-2009.11.01.0123-r1.ebuild:
+ Correct usage of new python.eclass
+
+*cctbx-2009.11.01.0123 (04 Feb 2010)
+
+ 04 Feb 2010; Justin Lecher (jlec) <jlec@gentoo.org>
+ +cctbx-2009.11.01.0123.ebuild, +metadata.xml:
+ New ebuild, initialy written by dberkholz
+
diff --git a/sci-libs/cctbx/cctbx-2012.05.08.2305.ebuild b/sci-libs/cctbx/cctbx-2012.05.08.2305.ebuild
new file mode 100644
index 0000000..ac51db7
--- /dev/null
+++ b/sci-libs/cctbx/cctbx-2012.05.08.2305.ebuild
@@ -0,0 +1,81 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sci-libs/cctbx/cctbx-2010.03.29.2334-r7.ebuild,v 1.3 2013/03/19 07:07:15 jlec Exp $
+
+EAPI=5
+
+DISTUTILS_SINGLE_IMPL=true
+PYTHON_COMPAT=( python{2_6,2_7} )
+
+inherit distutils-r1 eutils fortran-2 multilib toolchain-funcs
+
+MY_PV="${PV//./_}"
+
+DESCRIPTION="Computational Crystallography Toolbox"
+HOMEPAGE="http://cctbx.sourceforge.net/"
+SRC_URI="http://cci.lbl.gov/cctbx_build/results/${MY_PV}/${PN}_bundle.tar.gz -> ${P}.tar.gz"
+
+LICENSE="cctbx-2.0"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="+minimal"
+
+RDEPEND="
+ >=dev-libs/boost-1.48[python,${PYTHON_USEDEP}]
+ sci-libs/clipper
+ sci-libs/fftw:2.1
+ sci-libs/libccp4
+ !minimal? (
+ sci-chemistry/cns
+ sci-chemistry/shelx )"
+DEPEND="${RDEPEND}
+ !prefix? ( >=dev-util/scons-1.2[${PYTHON_USEDEP}] )"
+
+S="${WORKDIR}"
+MY_S="${WORKDIR}"/cctbx_sources
+MY_B="${WORKDIR}"/cctbx_build
+
+pkg_setup() {
+ use openmp && FORTRAN_NEED_OPENMP="1"
+ if use openmp && ! tc-has-openmp; then
+ ewarn "You are using gcc and OpenMP is only available with gcc >= 4.2 and icc"
+ ewarn "If you want to build ${PN} with OpenMP, abort now,"
+ ewarn "and switch CC to an OpenMP capable compiler"
+ FORTRAN_NEED_OPENMP=1
+ fi
+ fortran-2_pkg_setup
+ python-single-r1_pkg_setup
+}
+
+python_prepare_all() {
+ local opts
+ local optsld
+
+ EPATCH_OPTS="-p1" \
+ epatch \
+ "${FILESDIR}"/${PV}/*patch
+
+ export MULTILIBDIR=$(get_libdir)
+
+ # Clean sources
+ rm -rf "${MY_S}"/boost/* || die
+ rm -rf "${MY_S}"/PyCifRW/* || die
+ find "${MY_S}"/cbflib -maxdepth 1 -mindepth 1 -not -name examples -exec rm -rf {} + || die
+ find "${MY_S}"/ccp4io/lib -maxdepth 1 -mindepth 1 -not -name ssm -exec rm -rf {} + || die
+ find "${MY_S}"/clipper -maxdepth 1 -mindepth 1 -not -name clipper -exec rm -rf {} + || die
+# find "${MY_S}"/clipper/clipper -maxdepth 1 -mindepth 1 \( -not -name cctbx -a -not -name contrib \) -exec rm -rf {} + || die
+ find "${MY_S}"/clipper/clipper -maxdepth 1 -mindepth 1 -not -name cctbx -exec rm -rf {} + || die
+ rm -rf "${MY_S}"/gui_resources/gl2ps || die
+# rm -rf "${MY_S}"/scons || die
+ rm -rf "${MY_S}"/ucif/antlr3 || die
+# rm -rvf "${MY_S}"/ccp4io/lib/ssm || die
+
+# find "${MY_S}/clipper" -name "*.h" -print -delete >> "${T}"/clean.log || die
+
+ if ! use prefix; then
+ rm -rvf "${MY_S}/scons" >> "${T}"/clean.log || die
+ echo "import os, sys; os.execvp('scons', sys.argv)" > "${MY_S}"/libtbx/command_line/scons.py || die
+ fi
+
+ distutils-r1_python_prepare_all
+}
diff --git a/sci-libs/cctbx/cctbx-2013.02.27.0005.ebuild b/sci-libs/cctbx/cctbx-2013.02.27.0005.ebuild
new file mode 100644
index 0000000..ac51db7
--- /dev/null
+++ b/sci-libs/cctbx/cctbx-2013.02.27.0005.ebuild
@@ -0,0 +1,81 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sci-libs/cctbx/cctbx-2010.03.29.2334-r7.ebuild,v 1.3 2013/03/19 07:07:15 jlec Exp $
+
+EAPI=5
+
+DISTUTILS_SINGLE_IMPL=true
+PYTHON_COMPAT=( python{2_6,2_7} )
+
+inherit distutils-r1 eutils fortran-2 multilib toolchain-funcs
+
+MY_PV="${PV//./_}"
+
+DESCRIPTION="Computational Crystallography Toolbox"
+HOMEPAGE="http://cctbx.sourceforge.net/"
+SRC_URI="http://cci.lbl.gov/cctbx_build/results/${MY_PV}/${PN}_bundle.tar.gz -> ${P}.tar.gz"
+
+LICENSE="cctbx-2.0"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="+minimal"
+
+RDEPEND="
+ >=dev-libs/boost-1.48[python,${PYTHON_USEDEP}]
+ sci-libs/clipper
+ sci-libs/fftw:2.1
+ sci-libs/libccp4
+ !minimal? (
+ sci-chemistry/cns
+ sci-chemistry/shelx )"
+DEPEND="${RDEPEND}
+ !prefix? ( >=dev-util/scons-1.2[${PYTHON_USEDEP}] )"
+
+S="${WORKDIR}"
+MY_S="${WORKDIR}"/cctbx_sources
+MY_B="${WORKDIR}"/cctbx_build
+
+pkg_setup() {
+ use openmp && FORTRAN_NEED_OPENMP="1"
+ if use openmp && ! tc-has-openmp; then
+ ewarn "You are using gcc and OpenMP is only available with gcc >= 4.2 and icc"
+ ewarn "If you want to build ${PN} with OpenMP, abort now,"
+ ewarn "and switch CC to an OpenMP capable compiler"
+ FORTRAN_NEED_OPENMP=1
+ fi
+ fortran-2_pkg_setup
+ python-single-r1_pkg_setup
+}
+
+python_prepare_all() {
+ local opts
+ local optsld
+
+ EPATCH_OPTS="-p1" \
+ epatch \
+ "${FILESDIR}"/${PV}/*patch
+
+ export MULTILIBDIR=$(get_libdir)
+
+ # Clean sources
+ rm -rf "${MY_S}"/boost/* || die
+ rm -rf "${MY_S}"/PyCifRW/* || die
+ find "${MY_S}"/cbflib -maxdepth 1 -mindepth 1 -not -name examples -exec rm -rf {} + || die
+ find "${MY_S}"/ccp4io/lib -maxdepth 1 -mindepth 1 -not -name ssm -exec rm -rf {} + || die
+ find "${MY_S}"/clipper -maxdepth 1 -mindepth 1 -not -name clipper -exec rm -rf {} + || die
+# find "${MY_S}"/clipper/clipper -maxdepth 1 -mindepth 1 \( -not -name cctbx -a -not -name contrib \) -exec rm -rf {} + || die
+ find "${MY_S}"/clipper/clipper -maxdepth 1 -mindepth 1 -not -name cctbx -exec rm -rf {} + || die
+ rm -rf "${MY_S}"/gui_resources/gl2ps || die
+# rm -rf "${MY_S}"/scons || die
+ rm -rf "${MY_S}"/ucif/antlr3 || die
+# rm -rvf "${MY_S}"/ccp4io/lib/ssm || die
+
+# find "${MY_S}/clipper" -name "*.h" -print -delete >> "${T}"/clean.log || die
+
+ if ! use prefix; then
+ rm -rvf "${MY_S}/scons" >> "${T}"/clean.log || die
+ echo "import os, sys; os.execvp('scons', sys.argv)" > "${MY_S}"/libtbx/command_line/scons.py || die
+ fi
+
+ distutils-r1_python_prepare_all
+}
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0001-remove-hardcoded-libtbx_build-env.patch b/sci-libs/cctbx/files/2012.05.08.2305/0001-remove-hardcoded-libtbx_build-env.patch
new file mode 100644
index 0000000..14d3f09
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0001-remove-hardcoded-libtbx_build-env.patch
@@ -0,0 +1,24 @@
+From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca@debian.org>
+Date: Sat, 30 Jun 2012 15:50:22 +0200
+Subject: remove-hardcoded-libtbx_build-env
+
+---
+ cctbx_sources/libtbx/env_config.py | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 9c01e0f..8a62446 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -2147,7 +2147,10 @@ def cold_start(args):
+ env.refresh()
+
+ def unpickle():
+- build_path = os.environ["LIBTBX_BUILD"]
++ if os.environ.has_key("LIBTBX_BUILD"):
++ build_path = os.environ["LIBTBX_BUILD"]
++ else:
++ build_path = "/usr/share/cctbx/python%d.%d"%(sys.version_info[:2])
+ set_preferred_sys_prefix_and_sys_executable(build_path=build_path)
+ libtbx_env = open(op.join(build_path, "libtbx_env"), "rb")
+ env = pickle.load(libtbx_env)
--git a/sci-libs/cctbx/files/2012.05.08.2305/0002-fix-opengl-header-missing-gltbx.patch b/sci-libs/cctbx/files/2012.05.08.2305/0002-fix-opengl-header-missing-gltbx.patch
new file mode 100644
index 0000000..d3684a5
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0002-fix-opengl-header-missing-gltbx.patch
@@ -0,0 +1,51 @@
+From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca@debian.org>
+Date: Sat, 30 Jun 2012 15:51:06 +0200
+Subject: fix-opengl-header-missing-gltbx
+
+---
+ cctbx_sources/gltbx/SConscript | 32 ++++++++++++++++----------------
+ 1 file changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/cctbx_sources/gltbx/SConscript b/cctbx_sources/gltbx/SConscript
+index d02e7a5..4b2213d 100644
+--- a/cctbx_sources/gltbx/SConscript
++++ b/cctbx_sources/gltbx/SConscript
+@@ -45,22 +45,22 @@ if (not env_etc.no_boost_python):
+ env=env,
+ paths=env_etc.gltbx_common_includes + [env_etc.python_include])
+ #
+- env_etc.gltbx_has_usable_opengl = False
+- conf = trial_env.Configure()
+- flag, output = conf.TryRun("""
+-#include <gltbx/include_opengl.h>
+-#include <iostream>
+-int main() { std::cout << GL_POINT << std::endl; return 0; }
+-""", extension=".cpp")
+- conf.Finish()
+- if (flag and len(output.strip()) != 0):
+- conf = env.Configure()
+- if (conf.TryCompile("""
+-#include <gltbx/include_opengl.h>
+-""", extension=".cpp")):
+- env_etc.gltbx_has_usable_opengl = True
+- conf.Finish()
+- #
++ env_etc.gltbx_has_usable_opengl = True
++# conf = trial_env.Configure()
++# flag, output = conf.TryRun("""
++##include <gltbx/include_opengl.h>
++##include <iostream>
++#int main() { std::cout << GL_POINT << std::endl; return 0; }
++#""", extension=".cpp")
++# conf.Finish()
++# if (flag and len(output.strip()) != 0):
++# conf = env.Configure()
++# if (conf.TryCompile("""
++##include <gltbx/include_opengl.h>
++#""", extension=".cpp")):
++# env_etc.gltbx_has_usable_opengl = True
++# conf.Finish()
++# #
+ if (not env_etc.gltbx_has_usable_opengl):
+ print "gltbx: OpenGL headers and/or libraries not available."
+ print "gltbx: Compilation skipped."
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0003-correct-paths-in-dispatcher-creation.patch b/sci-libs/cctbx/files/2012.05.08.2305/0003-correct-paths-in-dispatcher-creation.patch
new file mode 100644
index 0000000..4fe0ea3
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0003-correct-paths-in-dispatcher-creation.patch
@@ -0,0 +1,85 @@
+From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca@debian.org>
+Date: Sat, 30 Jun 2012 16:01:20 +0200
+Subject: correct-paths-in-dispatcher-creation
+
+---
+ cctbx_sources/libtbx/env_config.py | 48 ++++++++++++++++++------------------
+ 1 file changed, 24 insertions(+), 24 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 8a62446..c3e1c7d 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -894,26 +894,26 @@ Wait for the command to finish, then try again.""" % vars())
+ print >> f, '# command at the end.'
+ print >> f, '#'
+ write_do_not_edit(f=f)
+- print >> f, '# To customize this auto-generated script create'
++ #print >> f, '# To customize this auto-generated script create'
+ print >> f, '#'
+- print >> f, '# dispatcher_include*.sh'
++ #print >> f, '# dispatcher_include*.sh'
+ print >> f, '#'
+- print >> f, '# files in %s and run' % show_string(abs(self.build_path))
++ #print >> f, '# files in %s and run' % show_string(abs(self.build_path))
+ print >> f, '#'
+- print >> f, '# libtbx.refresh'
++ #print >> f, '# libtbx.refresh'
+ print >> f, '#'
+ print >> f, '# to re-generate the dispatchers (libtbx.refresh is a subset'
+ print >> f, '# of the functionality of the libtbx/configure.py command).'
+ print >> f, '#'
+- print >> f, '# See also:'
+- print >> f, '# %s' \
+- % show_string(self.under_build("dispatcher_include_template.sh"))
++ #print >> f, '# See also:'
++ #print >> f, '# %s' \
++ # % show_string(self.under_build("dispatcher_include_template.sh"))
+ print >> f, '#'
+ print >> f, 'unset PYTHONHOME'
+ print >> f, 'LC_ALL=C'
+ print >> f, 'export LC_ALL'
+- print >> f, 'LIBTBX_BUILD="$(cd "$(dirname "$0")" && cd .. && pwd -P)"'
+- print >> f, 'export LIBTBX_BUILD'
++ #print >> f, 'LIBTBX_BUILD="$(cd "$(dirname "$0")" && cd .. && pwd -P)"'
++ #print >> f, 'export LIBTBX_BUILD'
+ print >> f, 'LIBTBX_PYEXE_BASENAME="%s"' % self.python_exe.basename()
+ print >> f, 'export LIBTBX_PYEXE_BASENAME'
+ source_is_py = False
+@@ -930,21 +930,21 @@ Wait for the command to finish, then try again.""" % vars())
+ source_is_py = True
+ for line in self.dispatcher_include(where="at_start"):
+ print >> f, line
+- essentials = [("PYTHONPATH", self.pythonpath)]
+- essentials.append((
+- ld_library_path_var_name(),
+- self.ld_library_path_additions()))
+- essentials.append(("PATH", [self.bin_path]))
+- for n,v in essentials:
+- if (len(v) == 0): continue
+- v = ":".join([p.sh_value() for p in v])
+- print >> f, 'if [ -n "$%s" ]; then' % n
+- print >> f, ' %s="%s:$%s"' % (n, v, n)
+- print >> f, ' export %s' % n
+- print >> f, 'else'
+- print >> f, ' %s="%s"' % (n, v)
+- print >> f, ' export %s' % n
+- print >> f, 'fi'
++ # essentials = [("PYTHONPATH", self.pythonpath)]
++ # essentials.append((
++ # ld_library_path_var_name(),
++ # self.ld_library_path_additions()))
++ # essentials.append(("PATH", [self.bin_path]))
++ # for n,v in essentials:
++ # if (len(v) == 0): continue
++ # v = ":".join([p.sh_value() for p in v])
++ # print >> f, 'if [ -n "$%s" ]; then' % n
++ # print >> f, ' %s="%s:$%s"' % (n, v, n)
++ # print >> f, ' export %s' % n
++ # print >> f, 'else'
++ # print >> f, ' %s="%s"' % (n, v)
++ # print >> f, ' export %s' % n
++ # print >> f, 'fi'
+ precall_commands = self.dispatcher_precall_commands()
+ if (precall_commands is not None):
+ for line in precall_commands:
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0004-upstream-fix-for-declaration-errors-in-gcc4.7.patch b/sci-libs/cctbx/files/2012.05.08.2305/0004-upstream-fix-for-declaration-errors-in-gcc4.7.patch
new file mode 100644
index 0000000..a3acee5
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0004-upstream-fix-for-declaration-errors-in-gcc4.7.patch
@@ -0,0 +1,442 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 9 Jul 2012 19:37:49 +0200
+Subject: upstream fix for declaration errors in gcc4.7
+
+---
+ cctbx_sources/mmtbx/bulk_solvent/bulk_solvent.h | 416 +++++++++++------------
+ 1 file changed, 208 insertions(+), 208 deletions(-)
+
+diff --git a/cctbx_sources/mmtbx/bulk_solvent/bulk_solvent.h b/cctbx_sources/mmtbx/bulk_solvent/bulk_solvent.h
+index 6959f18..0be075f 100644
+--- a/cctbx_sources/mmtbx/bulk_solvent/bulk_solvent.h
++++ b/cctbx_sources/mmtbx/bulk_solvent/bulk_solvent.h
+@@ -322,6 +322,214 @@ private:
+ };
+
+ //------------------------------------------------------------------------------
++template <typename FloatType, typename ComplexType>
++FloatType
++scale(af::const_ref<FloatType> const& fo,
++ af::const_ref<ComplexType> const& fc)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ FloatType num=0.0;
++ FloatType denum=0.0;
++ for(std::size_t i=0; i < fo.size(); i++) {
++ FloatType fc_abs = std::abs(fc[i]);
++ num += fo[i] * fc_abs;
++ denum += fc_abs * fc_abs;
++ }
++ return (denum == 0 ? 0 : num/denum);
++};
++
++template <typename FloatType, typename ComplexType>
++FloatType
++scale(af::const_ref<FloatType> const& fo,
++ af::const_ref<ComplexType> const& fc,
++ af::const_ref<bool> const& selection)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ MMTBX_ASSERT(fo.size()==selection.size());
++ FloatType num=0.0;
++ FloatType denum=0.0;
++ for(std::size_t i=0; i < fo.size(); i++) {
++ if(selection[i]) {
++ FloatType fc_abs = std::abs(fc[i]);
++ num += fo[i] * fc_abs;
++ denum += fc_abs * fc_abs;
++ }
++ }
++ return (denum == 0 ? 0 : num/denum);
++};
++
++
++template <typename FloatType>
++FloatType
++scale(af::const_ref<FloatType> const& fo,
++ af::const_ref<FloatType> const& fc)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ FloatType num=0.0;
++ FloatType denum=0.0;
++ for(std::size_t i=0; i < fo.size(); i++) {
++ num += fo[i] * fc[i];
++ denum += fc[i] * fc[i];
++ }
++ return (denum == 0 ? 0 : num/denum);
++};
++
++template <typename FloatType, typename ComplexType>
++FloatType
++scale(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref< std::complex<ComplexType> > const& fc1,
++ af::const_ref< std::complex<ComplexType> > const& fc2,
++ FloatType const& twin_fraction)
++{
++ MMTBX_ASSERT(fo.size()==fc1.size());
++ MMTBX_ASSERT(fo.size()==fc2.size());
++ af::shared<FloatType> fc_abs(fo.size());
++ for(std::size_t i=0; i < fo.size(); i++) {
++ FloatType fc_abs1 = std::abs(fc1[i]);
++ FloatType fc_abs2 = std::abs(fc2[i]);
++ fc_abs[i]=std::sqrt((1-twin_fraction)*fc_abs1*fc_abs1+
++ twin_fraction *fc_abs2*fc_abs2);
++ }
++ return scale(fo,fc_abs.const_ref());
++};
++
++template <typename FloatType>
++FloatType
++r_factor(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref<FloatType> const& fc,
++ FloatType const& scale)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ FloatType num=0.0;
++ FloatType denum=0.0;
++ for(std::size_t i=0; i < fo.size(); i++) {
++ num += std::abs(fo[i] - fc[i] * scale);
++ denum += fo[i];
++ }
++ if(denum == 0) return 1.e+9;
++ return num/denum;
++};
++
++template <typename FloatType>
++FloatType
++r_factor(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref< std::complex<FloatType> > const& fc,
++ FloatType const& scale)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ FloatType num=0.0;
++ FloatType denum=0.0;
++ for(std::size_t i=0; i < fo.size(); i++) {
++ num += std::abs(fo[i] - std::abs(fc[i]) * scale);
++ denum += fo[i];
++ }
++ if(denum == 0) return 1.e+9;
++ return num/denum;
++};
++
++template <typename FloatType>
++FloatType
++r_factor(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref< std::complex<FloatType> > const& fc,
++ af::const_ref<bool> const& selection,
++ FloatType const& scale)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ MMTBX_ASSERT(fo.size()==selection.size());
++ FloatType num=0.0;
++ FloatType denum=0.0;
++ for(std::size_t i=0; i < fo.size(); i++) {
++ if(selection[i]) {
++ num += std::abs(fo[i] - std::abs(fc[i]) * scale);
++ denum += fo[i];
++ }
++ }
++ if(denum == 0) return 1.e+9;
++ return num/denum;
++};
++
++template <typename FloatType>
++FloatType
++r_factor(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref<FloatType> const& fc)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ FloatType sc = scale(fo,fc);
++ return r_factor(fo,fc,sc);
++};
++
++template <typename FloatType, typename ComplexType>
++FloatType
++r_factor(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref<std::complex<ComplexType> > const& fc)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ FloatType sc = scale(fo,fc);
++ return r_factor(fo,fc,sc);
++};
++
++template <typename FloatType, typename ComplexType>
++FloatType
++r_factor(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref<std::complex<ComplexType> > const& fc,
++ af::const_ref<bool> const& selection)
++{
++ MMTBX_ASSERT(fo.size()==fc.size());
++ MMTBX_ASSERT(fo.size()==selection.size());
++ FloatType sc = scale(fo,fc,selection);
++ return r_factor(fo,fc,selection,sc);
++};
++
++template <typename FloatType, typename ComplexType>
++FloatType
++r_factor(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref< std::complex<ComplexType> > const& fc1,
++ af::const_ref< std::complex<ComplexType> > const& fc2,
++ FloatType const& twin_fraction)
++{
++ MMTBX_ASSERT(fo.size()==fc1.size());
++ MMTBX_ASSERT(fo.size()==fc2.size());
++ af::shared<FloatType> fc_abs(fo.size());
++ for(std::size_t i=0; i < fo.size(); i++) {
++ FloatType fc_abs1 = std::abs(fc1[i]);
++ FloatType fc_abs2 = std::abs(fc2[i]);
++ fc_abs[i]=std::sqrt((1-twin_fraction)*fc_abs1*fc_abs1+
++ twin_fraction *fc_abs2*fc_abs2);
++ }
++ FloatType sc = scale(fo,fc_abs.const_ref());
++ return r_factor(fo,fc_abs.const_ref(),sc);
++};
++
++template <typename FloatType, typename ComplexType>
++FloatType
++r_factor(
++ af::const_ref<FloatType> const& fo,
++ af::const_ref< std::complex<ComplexType> > const& fc1,
++ af::const_ref< std::complex<ComplexType> > const& fc2,
++ FloatType const& twin_fraction,
++ FloatType const& scale)
++{
++ MMTBX_ASSERT(fo.size()==fc1.size());
++ MMTBX_ASSERT(fo.size()==fc2.size());
++ af::shared<FloatType> fc_abs(fo.size());
++ for(std::size_t i=0; i < fo.size(); i++) {
++ FloatType fc_abs1 = std::abs(fc1[i]);
++ FloatType fc_abs2 = std::abs(fc2[i]);
++ fc_abs[i]=std::sqrt((1-twin_fraction)*fc_abs1*fc_abs1+
++ twin_fraction *fc_abs2*fc_abs2);
++ }
++ return r_factor(fo,fc_abs.const_ref(),scale);
++};
++
++//------------------------------------------------------------------------------
+ // All scales (overall, overall anisotropic, etc) must be applied.
+ template <
+ typename FloatType=double,
+@@ -744,214 +952,6 @@ template <typename FloatType>
+ };
+
+ //------------------------------------------------------------------------------
+-template <typename FloatType, typename ComplexType>
+-FloatType
+-scale(af::const_ref<FloatType> const& fo,
+- af::const_ref<ComplexType> const& fc)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- FloatType num=0.0;
+- FloatType denum=0.0;
+- for(std::size_t i=0; i < fo.size(); i++) {
+- FloatType fc_abs = std::abs(fc[i]);
+- num += fo[i] * fc_abs;
+- denum += fc_abs * fc_abs;
+- }
+- return (denum == 0 ? 0 : num/denum);
+-};
+-
+-template <typename FloatType, typename ComplexType>
+-FloatType
+-scale(af::const_ref<FloatType> const& fo,
+- af::const_ref<ComplexType> const& fc,
+- af::const_ref<bool> const& selection)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- MMTBX_ASSERT(fo.size()==selection.size());
+- FloatType num=0.0;
+- FloatType denum=0.0;
+- for(std::size_t i=0; i < fo.size(); i++) {
+- if(selection[i]) {
+- FloatType fc_abs = std::abs(fc[i]);
+- num += fo[i] * fc_abs;
+- denum += fc_abs * fc_abs;
+- }
+- }
+- return (denum == 0 ? 0 : num/denum);
+-};
+-
+-
+-template <typename FloatType>
+-FloatType
+-scale(af::const_ref<FloatType> const& fo,
+- af::const_ref<FloatType> const& fc)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- FloatType num=0.0;
+- FloatType denum=0.0;
+- for(std::size_t i=0; i < fo.size(); i++) {
+- num += fo[i] * fc[i];
+- denum += fc[i] * fc[i];
+- }
+- return (denum == 0 ? 0 : num/denum);
+-};
+-
+-template <typename FloatType, typename ComplexType>
+-FloatType
+-scale(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref< std::complex<ComplexType> > const& fc1,
+- af::const_ref< std::complex<ComplexType> > const& fc2,
+- FloatType const& twin_fraction)
+-{
+- MMTBX_ASSERT(fo.size()==fc1.size());
+- MMTBX_ASSERT(fo.size()==fc2.size());
+- af::shared<FloatType> fc_abs(fo.size());
+- for(std::size_t i=0; i < fo.size(); i++) {
+- FloatType fc_abs1 = std::abs(fc1[i]);
+- FloatType fc_abs2 = std::abs(fc2[i]);
+- fc_abs[i]=std::sqrt((1-twin_fraction)*fc_abs1*fc_abs1+
+- twin_fraction *fc_abs2*fc_abs2);
+- }
+- return scale(fo,fc_abs.const_ref());
+-};
+-
+-template <typename FloatType>
+-FloatType
+-r_factor(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref<FloatType> const& fc,
+- FloatType const& scale)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- FloatType num=0.0;
+- FloatType denum=0.0;
+- for(std::size_t i=0; i < fo.size(); i++) {
+- num += std::abs(fo[i] - fc[i] * scale);
+- denum += fo[i];
+- }
+- if(denum == 0) return 1.e+9;
+- return num/denum;
+-};
+-
+-template <typename FloatType>
+-FloatType
+-r_factor(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref< std::complex<FloatType> > const& fc,
+- FloatType const& scale)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- FloatType num=0.0;
+- FloatType denum=0.0;
+- for(std::size_t i=0; i < fo.size(); i++) {
+- num += std::abs(fo[i] - std::abs(fc[i]) * scale);
+- denum += fo[i];
+- }
+- if(denum == 0) return 1.e+9;
+- return num/denum;
+-};
+-
+-template <typename FloatType>
+-FloatType
+-r_factor(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref< std::complex<FloatType> > const& fc,
+- af::const_ref<bool> const& selection,
+- FloatType const& scale)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- MMTBX_ASSERT(fo.size()==selection.size());
+- FloatType num=0.0;
+- FloatType denum=0.0;
+- for(std::size_t i=0; i < fo.size(); i++) {
+- if(selection[i]) {
+- num += std::abs(fo[i] - std::abs(fc[i]) * scale);
+- denum += fo[i];
+- }
+- }
+- if(denum == 0) return 1.e+9;
+- return num/denum;
+-};
+-
+-template <typename FloatType>
+-FloatType
+-r_factor(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref<FloatType> const& fc)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- FloatType sc = scale(fo,fc);
+- return r_factor(fo,fc,sc);
+-};
+-
+-template <typename FloatType, typename ComplexType>
+-FloatType
+-r_factor(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref<std::complex<ComplexType> > const& fc)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- FloatType sc = scale(fo,fc);
+- return r_factor(fo,fc,sc);
+-};
+-
+-template <typename FloatType, typename ComplexType>
+-FloatType
+-r_factor(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref<std::complex<ComplexType> > const& fc,
+- af::const_ref<bool> const& selection)
+-{
+- MMTBX_ASSERT(fo.size()==fc.size());
+- MMTBX_ASSERT(fo.size()==selection.size());
+- FloatType sc = scale(fo,fc,selection);
+- return r_factor(fo,fc,selection,sc);
+-};
+-
+-template <typename FloatType, typename ComplexType>
+-FloatType
+-r_factor(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref< std::complex<ComplexType> > const& fc1,
+- af::const_ref< std::complex<ComplexType> > const& fc2,
+- FloatType const& twin_fraction)
+-{
+- MMTBX_ASSERT(fo.size()==fc1.size());
+- MMTBX_ASSERT(fo.size()==fc2.size());
+- af::shared<FloatType> fc_abs(fo.size());
+- for(std::size_t i=0; i < fo.size(); i++) {
+- FloatType fc_abs1 = std::abs(fc1[i]);
+- FloatType fc_abs2 = std::abs(fc2[i]);
+- fc_abs[i]=std::sqrt((1-twin_fraction)*fc_abs1*fc_abs1+
+- twin_fraction *fc_abs2*fc_abs2);
+- }
+- FloatType sc = scale(fo,fc_abs.const_ref());
+- return r_factor(fo,fc_abs.const_ref(),sc);
+-};
+-
+-template <typename FloatType, typename ComplexType>
+-FloatType
+-r_factor(
+- af::const_ref<FloatType> const& fo,
+- af::const_ref< std::complex<ComplexType> > const& fc1,
+- af::const_ref< std::complex<ComplexType> > const& fc2,
+- FloatType const& twin_fraction,
+- FloatType const& scale)
+-{
+- MMTBX_ASSERT(fo.size()==fc1.size());
+- MMTBX_ASSERT(fo.size()==fc2.size());
+- af::shared<FloatType> fc_abs(fo.size());
+- for(std::size_t i=0; i < fo.size(); i++) {
+- FloatType fc_abs1 = std::abs(fc1[i]);
+- FloatType fc_abs2 = std::abs(fc2[i]);
+- fc_abs[i]=std::sqrt((1-twin_fraction)*fc_abs1*fc_abs1+
+- twin_fraction *fc_abs2*fc_abs2);
+- }
+- return r_factor(fo,fc_abs.const_ref(),scale);
+-};
+-
+-//------------------------------------------------------------------------------
+
+ template <typename DataType, typename TagType>
+ void
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0005-fix-for-gcc4.7-compilation-error.patch b/sci-libs/cctbx/files/2012.05.08.2305/0005-fix-for-gcc4.7-compilation-error.patch
new file mode 100644
index 0000000..f2b9523
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0005-fix-for-gcc4.7-compilation-error.patch
@@ -0,0 +1,83 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 9 Jul 2012 19:58:46 +0200
+Subject: fix for gcc4.7 compilation error
+
+---
+ .../scitbx/math/boost_python/distributions.cpp | 60 +++++++++++++-------
+ 1 file changed, 41 insertions(+), 19 deletions(-)
+
+diff --git a/cctbx_sources/scitbx/math/boost_python/distributions.cpp b/cctbx_sources/scitbx/math/boost_python/distributions.cpp
+index e430cad..3d16a9c 100644
+--- a/cctbx_sources/scitbx/math/boost_python/distributions.cpp
++++ b/cctbx_sources/scitbx/math/boost_python/distributions.cpp
+@@ -75,29 +75,51 @@ namespace {
+ {
+ typedef Distribution wt;
+
++ #define NEW_MEMBER(name) \
++ static FloatType name(wt const &self) { \
++ return boost::math::name(self); \
++ }
++
++ NEW_MEMBER(mean);
++ NEW_MEMBER(median);
++ NEW_MEMBER(mode);
++ NEW_MEMBER(variance);
++ NEW_MEMBER(standard_deviation);
++ NEW_MEMBER(skewness);
++ NEW_MEMBER(kurtosis);
++
++ #undef NEW_MEMBER
++
++ #define NEW_MEMBER(name) \
++ static FloatType name(wt const &self, FloatType arg) { \
++ return boost::math::name(self, arg); \
++ }
++
++ NEW_MEMBER(pdf);
++ NEW_MEMBER(cdf);
++ NEW_MEMBER(quantile);
++
++ #undef NEW_MEMBER
++
++ static scitbx::af::shared<FloatType> quantiles(wt const &self, std::size_t n) {
++ return scitbx::math::quantiles<FloatType>(self, n);
++ }
++
+ static void
+ wrap()
+ {
+ using namespace boost::python;
+- def("mean", (FloatType(*)(wt const&)) boost::math::mean);
+- def("median", (FloatType(*)(wt const&)) boost::math::median);
+- def("mode", (FloatType(*)(wt const&)) boost::math::mode);
+- def("variance", (FloatType(*)(wt const&)) boost::math::variance);
+- def("standard_deviation",
+- (FloatType(*)(wt const&)) boost::math::standard_deviation);
+- def("skewness", (FloatType(*)(wt const&)) boost::math::skewness);
+- def("kurtosis", (FloatType(*)(wt const&)) boost::math::kurtosis);
+- def("pdf", (FloatType(*)(wt const&, FloatType const&)) boost::math::pdf);
+- def("cdf", (FloatType(*)(wt const&, FloatType const&)) boost::math::cdf);
+- def("quantile", (FloatType(*)(wt const&, FloatType const&))
+- boost::math::quantile);
+- def("quantiles",
+-#if BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306))
+- (scitbx::af::shared<FloatType>(*)(wt const&, std::size_t)) quantiles
+-#else
+- quantiles<FloatType, wt>
+-#endif
+- );
++ def("mean" , mean);
++ def("median" , median);
++ def("mode" , mode);
++ def("variance" , variance);
++ def("standard_deviation", standard_deviation);
++ def("skewness" , skewness);
++ def("kurtosis" , kurtosis);
++ def("pdf" , pdf);
++ def("cdf" , cdf);
++ def("quantile" , quantile);
++ def("quantiles" , quantiles);
+ }
+ };
+
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0006-options-for-system-libs-installtarget-and-prefix.patch b/sci-libs/cctbx/files/2012.05.08.2305/0006-options-for-system-libs-installtarget-and-prefix.patch
new file mode 100644
index 0000000..a3a6dd8
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0006-options-for-system-libs-installtarget-and-prefix.patch
@@ -0,0 +1,1080 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 23 Jul 2012 18:28:04 +0200
+Subject: options for system libs installtarget and prefix
+
+---
+ cctbx_sources/boost_adaptbx/SConscript | 26 +-
+ cctbx_sources/cbflib_adaptbx/SConscript | 89 +++---
+ .../detectors/boost_python/SConscript | 4 +-
+ cctbx_sources/ccp4io_adaptbx/SConscript | 284 ++++++++++----------
+ cctbx_sources/cctbx/SConscript | 2 +-
+ cctbx_sources/clipper_adaptbx/SConscript | 94 ++++---
+ cctbx_sources/clipper_adaptbx/clipper/SConscript | 10 +-
+ cctbx_sources/gltbx/SConscript | 20 +-
+ cctbx_sources/iotbx/cif/boost_python/SConscript | 13 +-
+ cctbx_sources/iotbx/mtz/SConscript | 3 +-
+ cctbx_sources/iotbx/pdb/SConscript | 2 +-
+ cctbx_sources/libtbx/SConscript | 86 +++++-
+ cctbx_sources/libtbx/env_config.py | 34 +++
+ cctbx_sources/mmtbx/den/SConscript | 2 +-
+ cctbx_sources/mmtbx/geometry_restraints/SConscript | 2 +-
+ cctbx_sources/mmtbx/secondary_structure/SConscript | 2 +-
+ cctbx_sources/rstbx/SConscript | 2 +-
+ cctbx_sources/scitbx/SConscript | 2 +-
+ cctbx_sources/scitbx/boost_python/SConscript | 4 +-
+ .../smtbx/refinement/boost_python/SConscript | 4 +-
+ .../refinement/constraints/boost_python/SConscript | 4 +-
+ cctbx_sources/spotfinder/SConscript | 2 +-
+ 22 files changed, 431 insertions(+), 260 deletions(-)
+
+diff --git a/cctbx_sources/boost_adaptbx/SConscript b/cctbx_sources/boost_adaptbx/SConscript
+index 866b1c1..68cac89 100644
+--- a/cctbx_sources/boost_adaptbx/SConscript
++++ b/cctbx_sources/boost_adaptbx/SConscript
+@@ -9,7 +9,13 @@ import sys, os
+ op = os.path
+ Import("env_base", "env_etc")
+ env_etc.boost_dist = libtbx.env.dist_path("boost")
+-env_etc.boost_include = env_etc.boost_dist
++if not env_etc.check_syslib(env_etc.boost_python, extra_libs=env_etc.py_lib)\
++ or not env_etc.check_syslib('boost_thread'):
++ env_etc.boost_include = env_etc.boost_dist
++else:
++ # This way the compiler looks in the standard location for includes
++ # should work on all platforms.
++ env_etc.boost_include = ''
+ env_etc.boost_adaptbx_dist = libtbx.env.dist_path("boost_adaptbx")
+ env_etc.boost_adaptbx_include = os.path.dirname(env_etc.boost_adaptbx_dist)
+
+@@ -35,9 +41,10 @@ def build_boost_thread():
+ lo="boost/libs/thread/src/libboost_thread.lo",
+ dylib="lib/libboost_thread.dylib")
+ env.Repository(os.path.dirname(env_etc.boost_dist))
+- env.SharedLibrary(
+- target='#lib/boost_thread',
+- source=source)
++ if not env_etc.check_syslib('boost_thread'):
++ env.SharedLibrary(
++ target='#lib/boost_thread',
++ source=source)
+
+ build_boost_thread()
+
+@@ -50,7 +57,7 @@ if (not env_etc.no_boost_python):
+ env_no_includes_boost_python_ext = env_base.Clone(
+ SHLINKFLAGS=env_etc.shlinkflags_bpl,
+ SHLIBPREFIX="",
+- LIBS=["boost_python"] + env_etc.libs_python + env_etc.libm)
++ LIBS=[env_etc.boost_python] + env_etc.libs_python + env_etc.libm)
+ env_no_includes_boost_python_ext.Append(
+ LIBPATH=env_etc.libpath_python)
+ env_no_includes_boost_python_ext.Append(
+@@ -235,10 +242,11 @@ object/function_doc_signature.cpp
+ bpl_dll_sources = [os.path.join(prefix, path) for path in bpl_dll_sources]
+ #
+ env.Repository(os.path.dirname(env_etc.boost_dist))
+- if (env_etc.static_bpl):
+- env.StaticLibrary(target="#lib/boost_python", source=bpl_dll_sources)
+- else:
+- env.SharedLibrary(target="#lib/boost_python", source=bpl_dll_sources)
++ if not env_etc.check_syslib(env_etc.boost_python, extra_libs=env_etc.py_lib):
++ if (env_etc.static_bpl):
++ env.StaticLibrary(target="#lib/boost_python", source=bpl_dll_sources)
++ else:
++ env.SharedLibrary(target="#lib/boost_python", source=bpl_dll_sources)
+ if (bool(int(ARGUMENTS.get("boost_python_tests", "0")))):
+ warn_if_unexpected_md5_hexdigest(
+ path=libtbx.env.under_dist("boost", "libs/python/test/Jamfile.v2"),
+diff --git a/cctbx_sources/cbflib_adaptbx/SConscript b/cctbx_sources/cbflib_adaptbx/SConscript
+index 4ac6717..334cfc2 100644
+--- a/cctbx_sources/cbflib_adaptbx/SConscript
++++ b/cctbx_sources/cbflib_adaptbx/SConscript
+@@ -3,9 +3,14 @@ import os
+ Import("env_base","env_etc")
+
+ env_etc.cbflib_dist = libtbx.env.dist_path("cbflib")
+-env_etc.cbflib_include = [env_etc.norm_join(env_etc.cbflib_dist,"examples"),
+- env_etc.norm_join(env_etc.cbflib_dist,"include"),
+- ]
++if not env_etc.check_syslib('cbf'):
++ env_etc.cbflib_include = [env_etc.norm_join(env_etc.cbflib_dist,"examples"),
++ env_etc.norm_join(env_etc.cbflib_dist,"include"),
++ ]
++else:
++ env_etc.cbflib_include = [env_etc.norm_join(env_etc.cbflib_dist,"examples"),
++ "",
++ ]
+ env_etc.cbflib_adaptbx_dist = libtbx.env.dist_path("cbflib_adaptbx")
+
+ env_etc.cbflib_common_includes = [
+@@ -34,39 +39,47 @@ cbflib_092_forward = []
+ if os.path.isfile( os.path.join(env_etc.cbflib_dist,"src","cbf_ws.c") ):
+ cbflib_092_forward.append("src/cbf_ws.c")
+
+-env.StaticLibrary(target='#lib/cbf',
+- source = [prefix+"/"+s for s in [
+- "examples/img.c",
+- "src/cbf.c",
+- "src/cbf_alloc.c",
+- "src/cbf_ascii.c",
+- "src/cbf_binary.c",
+- "src/cbf_byte_offset.c",
+- "src/cbf_canonical.c",
+- "src/cbf_codes.c",
+- "src/cbf_compress.c",
+- "src/cbf_context.c",
+- "src/cbf_file.c",
+- "src/cbf_lex.c",
+- "src/cbf_packed.c",
+- "src/cbf_predictor.c",
+- "src/cbf_read_binary.c",
+- "src/cbf_read_mime.c",
+- "src/cbf_simple.c",
+- "src/cbf_string.c",
+- "src/cbf_stx.c",
+- "src/cbf_tree.c",
+- "src/cbf_uncompressed.c",
+- "src/cbf_write.c",
+- "src/cbf_write_binary.c",
+- "src/md5c.c",
+- ] + cbflib_092_forward ] + [
+- "detectors/mar_adaptor.cpp",
+- "detectors/cbf_adaptor.cpp",
+- "detectors/cbf_byte_offset_optimized.cpp",
+- "detectors/buffer_based_service.cpp",
+- ],
+- CPPPATH=env_etc.cbflib_common_includes )
++cbflib_src = ["src/cbf.c",
++ "src/cbf_alloc.c",
++ "src/cbf_ascii.c",
++ "src/cbf_binary.c",
++ "src/cbf_byte_offset.c",
++ "src/cbf_canonical.c",
++ "src/cbf_codes.c",
++ "src/cbf_compress.c",
++ "src/cbf_context.c",
++ "src/cbf_file.c",
++ "src/cbf_lex.c",
++ "src/cbf_packed.c",
++ "src/cbf_predictor.c",
++ "src/cbf_read_binary.c",
++ "src/cbf_read_mime.c",
++ "src/cbf_simple.c",
++ "src/cbf_string.c",
++ "src/cbf_stx.c",
++ "src/cbf_tree.c",
++ "src/cbf_uncompressed.c",
++ "src/cbf_write.c",
++ "src/cbf_write_binary.c",
++ "src/md5c.c",
++ ]
++adaptor_src = ["detectors/mar_adaptor.cpp",
++ "detectors/cbf_adaptor.cpp",
++ "detectors/cbf_byte_offset_optimized.cpp",
++ "detectors/buffer_based_service.cpp",
++ ]
++if not env_etc.check_syslib('cbf'):
++ env.StaticLibrary(target='#lib/cbf',
++ source = [prefix+"/"+s for s in [
++ "examples/img.c"] + cbflib_src + cbflib_092_forward] + adaptor_src,
++ CPPPATH=env_etc.cbflib_common_includes )
++ env_etc.cbf_lib = ['cbf',]
++else:
++ env.StaticLibrary(target='#lib/cbf_adaptor',
++ source = [prefix+"/"+s for s in [
++ "examples/img.c"]] + adaptor_src,
++ CPPPATH=env_etc.cbflib_common_includes )
++ env_etc.cbf_lib = ['cbf','cbf_adaptor']
+
+ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
+@@ -80,7 +93,7 @@ if (not env_etc.no_boost_python):
+ env_cbflib_boost_python_ext.SharedLibrary(
+ target='#lib/_pycbf',
+ source=[prefix+"/pycbf/pycbf_wrap.c"],
+- LIBS=["cbf"]+env_etc.libs_python+env_etc.libm)
++ LIBS=env_etc.cbf_lib+env_etc.libs_python+env_etc.libm)
+
+ Export("env_cbflib_boost_python_ext")
+
+@@ -89,7 +102,7 @@ if (not env_etc.no_boost_python):
+ env_standalone = env.Clone(
+ LIBS = [env_etc.libm,],CPPPATH=env_etc.cbflib_common_includes
+ )
+-env_standalone.Prepend(LIBS=["cbf",])
++env_standalone.Prepend(LIBS=env_etc.cbf_lib)
+
+ for source in ["detectors/tst_memory",]:
+ target = "cbflib."+os.path.basename(source)
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/SConscript b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/SConscript
+index 2027439..8e987cc 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/SConscript
++++ b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/SConscript
+@@ -1,6 +1,6 @@
+-Import("env_cbflib_boost_python_ext")
++Import("env_cbflib_boost_python_ext", "env_etc")
+ env = env_cbflib_boost_python_ext.Clone()
+-env.Prepend(LIBS=["cbf",])
++env.Prepend(LIBS=env_etc.cbf_lib)
+ env.SharedLibrary(
+ target="#lib/cbflib_ext",
+ source=["cbflib_ext.cpp",])
+diff --git a/cctbx_sources/ccp4io_adaptbx/SConscript b/cctbx_sources/ccp4io_adaptbx/SConscript
+index f55cc92..01600d6 100644
+--- a/cctbx_sources/ccp4io_adaptbx/SConscript
++++ b/cctbx_sources/ccp4io_adaptbx/SConscript
+@@ -36,118 +36,152 @@ else:
+ # clean out after completely removing support for
+ # old CCP4 directory structure above
+
+-build_ccp4io_adaptbx = libtbx.env.under_build("ccp4io_adaptbx")
+-if (not op.isdir(build_ccp4io_adaptbx)):
+- os.mkdir(build_ccp4io_adaptbx)
+- assert op.isdir(build_ccp4io_adaptbx)
+-
+-def replace_printf(file_name):
+- full_path = op.join(path_lib_src, file_name)
+- if (not op.isfile(full_path)):
+- full_path = op.join(op.dirname(path_lib_src), "fortran", file_name)
+- result = ["#include <ccp4io_adaptbx/printf_wrappers.h>"]
+- for line in open(full_path).read().splitlines():
+- for key in ["printf", "fprintf"]:
+- matches = list(re.finditer(
+- pattern="[^A-Za-z0-9_]%s[^A-Za-z0-9_]" % key, string=line))
+- if (len(matches) != 0):
+- for m in reversed(matches):
+- s,e = m.start(), m.end()
+- line = line[:s] \
+- + line[s:e].replace(key, "ccp4io_%s" % key) \
+- + line[e:]
+- result.append(line)
+- return "\n".join(result)
+-
+-env = env_base.Clone(
+- SHLINKFLAGS=env_etc.shlinkflags)
+-env.Append(CCFLAGS=env_etc.ccp4io_defines)
+-env.Append(SHCCFLAGS=env_etc.ccp4io_defines)
+-env_etc.include_registry.append(
+- env=env,
+- paths=[
+- "#",
+- op.dirname(env_etc.ccp4io_include),
+- env_etc.ccp4io_include,
+- op.join(env_etc.ccp4io_dist, "lib", mmdb_src),
+- op.join(env_etc.ccp4io_dist, "lib", mmdb_src, "mmdb")])
+-env.Append(LIBS=env_etc.libm)
+-if ( op.normcase(op.dirname(env_etc.ccp4io_dist))
+- != op.normcase("ccp4io")):
+- env.Repository(op.dirname(env_etc.ccp4io_dist))
+ source = []
+-
+ c_files = []
+-c_files.extend(["%s/%s" % (ccp4_src, bn ) for bn in """\
+-library_err.c
+-library_file.c
+-library_utils.c
+-ccp4_array.c
+-ccp4_parser.c
+-ccp4_unitcell.c
+-cvecmat.c
+-cmtzlib.c
+-""".splitlines()])
+-open(op.join(build_ccp4io_adaptbx, "csymlib.c"), "w").write(
+- open(op.join(path_lib_src, "csymlib.c")).read()
+- .replace(
+- "static int reported_syminfo = 0",
+- "static int reported_syminfo = 1"))
+-source.append(op.join("#ccp4io_adaptbx", "csymlib.c"))
++if not env_etc.check_syslib('ccp4c')\
++ or not env_etc.check_syslib('mmdb'):
++ build_ccp4io_adaptbx = libtbx.env.under_build("ccp4io_adaptbx")
++ if (not op.isdir(build_ccp4io_adaptbx)):
++ os.mkdir(build_ccp4io_adaptbx)
++ assert op.isdir(build_ccp4io_adaptbx)
++
++ def replace_printf(file_name):
++ full_path = op.join(path_lib_src, file_name)
++ if (not op.isfile(full_path)):
++ full_path = op.join(op.dirname(path_lib_src), "fortran", file_name)
++ result = ["#include <ccp4io_adaptbx/printf_wrappers.h>"]
++ for line in open(full_path).read().splitlines():
++ for key in ["printf", "fprintf"]:
++ matches = list(re.finditer(
++ pattern="[^A-Za-z0-9_]%s[^A-Za-z0-9_]" % key, string=line))
++ if (len(matches) != 0):
++ for m in reversed(matches):
++ s,e = m.start(), m.end()
++ line = line[:s] \
++ + line[s:e].replace(key, "ccp4io_%s" % key) \
++ + line[e:]
++ result.append(line)
++ return "\n".join(result)
++ env = env_base.Clone(
++ SHLINKFLAGS=env_etc.shlinkflags)
++ env.Append(CCFLAGS=env_etc.ccp4io_defines)
++ env.Append(SHCCFLAGS=env_etc.ccp4io_defines)
++ env_etc.include_registry.append(
++ env=env,
++ paths=[
++ "#",
++ op.dirname(env_etc.ccp4io_include),
++ env_etc.ccp4io_include,
++ op.join(env_etc.ccp4io_dist, "lib", mmdb_src),
++ op.join(env_etc.ccp4io_dist, "lib", mmdb_src, "mmdb")])
++ env.Append(LIBS=env_etc.libm)
++ if ( op.normcase(op.dirname(env_etc.ccp4io_dist))
++ != op.normcase("ccp4io")):
++ env.Repository(op.dirname(env_etc.ccp4io_dist))
+
+-probe_file_name = op.join(path_lib_src, "cmaplib.h")
+-env_etc.ccp4io_has_cmaplib = op.isfile(probe_file_name)
+-if (env_etc.ccp4io_has_cmaplib):
+ c_files.extend(["%s/%s" % (ccp4_src, bn ) for bn in """\
+-cmap_accessor.c
+-cmap_close.c
+-cmap_data.c
+-cmap_header.c
+-cmap_labels.c
+-cmap_open.c
+-cmap_skew.c
+-cmap_stats.c
+-cmap_symop.c
+-""".splitlines()])
++ library_err.c
++ library_file.c
++ library_utils.c
++ ccp4_array.c
++ ccp4_parser.c
++ ccp4_unitcell.c
++ cvecmat.c
++ cmtzlib.c
++ """.splitlines()])
++ open(op.join(build_ccp4io_adaptbx, "csymlib.c"), "w").write(
++ open(op.join(path_lib_src, "csymlib.c")).read()
++ .replace(
++ "static int reported_syminfo = 0",
++ "static int reported_syminfo = 1"))
++ source.append(op.join("#ccp4io_adaptbx", "csymlib.c"))
+
+-c_files.extend(["%s/mmdb/%s.cpp" % ( mmdb_src, bn ) for bn in """\
+-bfgs_min
+-file_
+-hybrid_36
+-linalg_
+-machine_
+-math_
+-mattype_
+-mmdb_align
+-mmdb_atom
+-mmdb_bondmngr
+-mmdb_chain
+-mmdb_cifdefs
+-mmdb_coormngr
+-mmdb_cryst
+-mmdb_ficif
+-mmdb_file
+-mmdb_graph
+-mmdb_manager
+-mmdb_mask
+-mmdb_mmcif
+-mmdb_model
+-mmdb_rwbrook
+-mmdb_sbase
+-mmdb_sbase0
+-mmdb_selmngr
+-mmdb_symop
+-mmdb_tables
+-mmdb_title
+-mmdb_uddata
+-mmdb_utils
+-mmdb_xml
+-random_n
+-stream_
+-""".splitlines()])
+-prefix = "#"+op.join(op.basename(env_etc.ccp4io_dist), "lib")
+-for file_name in c_files:
+- source.append(op.join(prefix, file_name))
++ probe_file_name = op.join(path_lib_src, "cmaplib.h")
++ env_etc.ccp4io_has_cmaplib = op.isfile(probe_file_name)
++ if (env_etc.ccp4io_has_cmaplib):
++ c_files.extend(["%s/%s" % (ccp4_src, bn ) for bn in """\
++ cmap_accessor.c
++ cmap_close.c
++ cmap_data.c
++ cmap_header.c
++ cmap_labels.c
++ cmap_open.c
++ cmap_skew.c
++ cmap_stats.c
++ cmap_symop.c
++ """.splitlines()])
++
++ c_files.extend(["%s/mmdb/%s.cpp" % ( mmdb_src, bn ) for bn in """\
++ bfgs_min
++ file_
++ hybrid_36
++ linalg_
++ machine_
++ math_
++ mattype_
++ mmdb_align
++ mmdb_atom
++ mmdb_bondmngr
++ mmdb_chain
++ mmdb_cifdefs
++ mmdb_coormngr
++ mmdb_cryst
++ mmdb_ficif
++ mmdb_file
++ mmdb_graph
++ mmdb_manager
++ mmdb_mask
++ mmdb_mmcif
++ mmdb_model
++ mmdb_rwbrook
++ mmdb_sbase
++ mmdb_sbase0
++ mmdb_selmngr
++ mmdb_symop
++ mmdb_tables
++ mmdb_title
++ mmdb_uddata
++ mmdb_utils
++ mmdb_xml
++ random_n
++ stream_
++ """.splitlines()])
++ prefix = "#"+op.join(op.basename(env_etc.ccp4io_dist), "lib")
++ for file_name in c_files:
++ source.append(op.join(prefix, file_name))
++
++ need_f_c = (
++ libtbx.env.has_module("solve_resolve")
++ or libtbx.env.find_in_repositories(relative_path="mosflm_fable"))
++ if (need_f_c or os.name != "nt"):
++ source.append(op.join("#ccp4io_adaptbx", "fortran_call_stubs.c"))
++ for file_name in """\
++ ccp4_diskio_f.c
++ ccp4_general.c
++ ccp4_general_f.c
++ ccp4_parser_f.c
++ ccp4_program.c
++ ccp4_unitcell_f.c
++ cmaplib_f.c
++ cmtzlib_f.c
++ csymlib_f.c
++ library_f.c
++ """.splitlines():
++ open(op.join(build_ccp4io_adaptbx, file_name), "w").write(
++ replace_printf(file_name=file_name))
++ source.append(op.join("#ccp4io_adaptbx", file_name))
++ source.append(op.join("#ccp4io_adaptbx", "printf_wrappers.c"))
++ env_etc.ccp4io_lib = "ccp4io"
++ mmdb_path= [ os.path.join( env_etc.ccp4io_dist, "lib", mmdb_src ),
++ os.path.join( env_etc.ccp4io_dist, "lib", mmdb_src, "mmdb" ),
++ ]
++else:
++ env = env_base.Clone(
++ SHLINKFLAGS=env_etc.shlinkflags)
++ env.Append(CCFLAGS=env_etc.ccp4io_defines)
++ env.Append(SHCCFLAGS=env_etc.ccp4io_defines)
++ env_etc.ccp4io_lib = ["ccp4io", "mmdb", "ccp4c"]
++ mmdb_path= []
+
+ ssm_prefix = "#"+op.join(op.basename(env_etc.ccp4io_dist), "lib", "ssm")
+ ssm_sources = """\
+@@ -159,46 +193,20 @@ ssm_superpose.cpp
+ """.splitlines()
+ source.extend( [ op.join( ssm_prefix, f ) for f in ssm_sources ] )
+
+-need_f_c = (
+- libtbx.env.has_module("solve_resolve")
+- or libtbx.env.find_in_repositories(relative_path="mosflm_fable"))
+-if (need_f_c or os.name != "nt"):
+- source.append(op.join("#ccp4io_adaptbx", "fortran_call_stubs.c"))
+- for file_name in """\
+-ccp4_diskio_f.c
+-ccp4_general.c
+-ccp4_general_f.c
+-ccp4_parser_f.c
+-ccp4_program.c
+-ccp4_unitcell_f.c
+-cmaplib_f.c
+-cmtzlib_f.c
+-csymlib_f.c
+-library_f.c
+-""".splitlines():
+- open(op.join(build_ccp4io_adaptbx, file_name), "w").write(
+- replace_printf(file_name=file_name))
+- source.append(op.join("#ccp4io_adaptbx", file_name))
+- source.append(op.join("#ccp4io_adaptbx", "printf_wrappers.c"))
+-
+ # static library for solve_resolve
+ env.StaticLibrary(target='#lib/ccp4io', source=source)
+-env_etc.ccp4io_lib = "ccp4io"
+
+ if ( libtbx.env.has_module("boost")
+ and not env_etc.no_boost_python):
+ Import( "env_no_includes_boost_python_ext" )
+ sources = [ "#ccp4io_adaptbx/ext.cpp" ]
+ env_ext = env_no_includes_boost_python_ext.Clone()
+- env_ext.Prepend( LIBS = "ccp4io" )
++ env_ext.Prepend( LIBS = env_etc.ccp4io_lib )
+ env_etc.include_registry.append(
+ env = env_ext,
+- paths = [
+- os.path.join( env_etc.ccp4io_dist, "lib", mmdb_src ),
+- os.path.join( env_etc.ccp4io_dist, "lib", mmdb_src, "mmdb" ),
+- os.path.join( env_etc.ccp4io_dist, "lib", "ssm"),
+- env_etc.boost_include,
+- env_etc.python_include,
+- ]
++ paths = mmdb_path + [ os.path.join( env_etc.ccp4io_dist, "lib", "ssm"),
++ env_etc.boost_include,
++ env_etc.python_include,
++ ]
+ )
+ env_ext.SharedLibrary( target = "#lib/ccp4io_adaptbx_ext", source = sources )
+diff --git a/cctbx_sources/cctbx/SConscript b/cctbx_sources/cctbx/SConscript
+index af767ae..6ce770c 100644
+--- a/cctbx_sources/cctbx/SConscript
++++ b/cctbx_sources/cctbx/SConscript
+@@ -106,7 +106,7 @@ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
+
+ env_cctbx_boost_python_ext = env_no_includes_boost_python_ext.Clone()
+- env_cctbx_boost_python_ext.Prepend(LIBS=["scitbx_boost_python"])
++ env_cctbx_boost_python_ext.Prepend(LIBS=[env_etc.scitbx_boost_python])
+ env_etc.include_registry.append(
+ env=env_cctbx_boost_python_ext,
+ paths=env_etc.cctbx_common_includes + [env_etc.python_include])
+diff --git a/cctbx_sources/clipper_adaptbx/SConscript b/cctbx_sources/clipper_adaptbx/SConscript
+index 9cce49e..c39047f 100644
+--- a/cctbx_sources/clipper_adaptbx/SConscript
++++ b/cctbx_sources/clipper_adaptbx/SConscript
+@@ -3,54 +3,63 @@ Import("env_base", "env_etc")
+
+ env_etc.clipper_dist = libtbx.env.dist_path("clipper")
+ env_etc.clipper_include = env_etc.clipper_dist
++# This way the compiler looks in the standard location for includes
++# should work on all platforms
++env_etc.clipper_sysinclude = ''
+
+ env = env_base.Clone(
+ SHLINKFLAGS=env_etc.shlinkflags,
+ LIBS=env_etc.libm)
+-env.Prepend(CPPPATH=[env_etc.clipper_include])
+-
+-if (env_etc.static_libraries): builder = env.StaticLibrary
+-else: builder = env.SharedLibrary
+-builder(target='#lib/clipper',
+- source = ["../clipper/clipper/core/"+file_name for file_name in """
+- atomsf.cpp
+- cell.cpp
+- clipper_memory.cpp
+- clipper_message.cpp
+- clipper_stats.cpp
+- clipper_types.cpp
+- clipper_util.cpp
+- container.cpp
+- container_hkl.cpp
+- container_map.cpp
+- container_types.cpp
+- coords.cpp
+- derivs.cpp
+- hkl_compute.cpp
+- hkl_data.cpp
+- hkl_datatypes.cpp
+- hkl_info.cpp
+- hkl_lookup.cpp
+- hkl_operators.cpp
+- map_interp.cpp
+- map_utils.cpp
+- nxmap.cpp
+- nxmap_operator.cpp
+- ramachandran.cpp
+- resol_basisfn.cpp
+- resol_fn.cpp
+- resol_targetfn.cpp
+- rotation.cpp
+- spacegroup.cpp
+- spacegroup_data.cpp
+- symop.cpp
+- xmap.cpp
+-""".split()])
+-# fftmap_sparse.cpp
+-# fftmap.cpp
++if env_etc.check_syslib('clipper-core') and \
++ env_etc.check_syslib('clipper-contrib'):
++ env.Prepend(CPPPATH=[env_etc.clipper_sysinclude])
++ env_etc.clipper_libs=['clipper-core', 'clipper-contrib']
++ env_etc.has_clipper_contrib = True
++else:
++ env.Prepend(CPPPATH=[env_etc.clipper_include])
++ env_etc.clipper_libs=['clipper',]
++ if (env_etc.static_libraries): builder = env.StaticLibrary
++ else: builder = env.SharedLibrary
++ builder(target='#lib/'+env_etc.clipper_libs[0],
++ source = ["../clipper/clipper/core/"+file_name for file_name in """
++ atomsf.cpp
++ cell.cpp
++ clipper_memory.cpp
++ clipper_message.cpp
++ clipper_stats.cpp
++ clipper_types.cpp
++ clipper_util.cpp
++ container.cpp
++ container_hkl.cpp
++ container_map.cpp
++ container_types.cpp
++ coords.cpp
++ derivs.cpp
++ hkl_compute.cpp
++ hkl_data.cpp
++ hkl_datatypes.cpp
++ hkl_info.cpp
++ hkl_lookup.cpp
++ hkl_operators.cpp
++ map_interp.cpp
++ map_utils.cpp
++ nxmap.cpp
++ nxmap_operator.cpp
++ ramachandran.cpp
++ resol_basisfn.cpp
++ resol_fn.cpp
++ resol_targetfn.cpp
++ rotation.cpp
++ spacegroup.cpp
++ spacegroup_data.cpp
++ symop.cpp
++ xmap.cpp
++ """.split()])
++ # fftmap_sparse.cpp
++ # fftmap.cpp
+
+ env_exe = env.Clone()
+-env_exe.Prepend(LIBS=["clipper"])
++env_exe.Prepend(LIBS=[env_etc.clipper_libs[0]])
+
+ exe = env_exe.Program(
+ target='#exe_dev/'+env["PROGPREFIX"]+'clipper.symtest'
+@@ -77,6 +86,7 @@ if (hasattr(env_etc, "cctbx_include")):
+ env=env_clipper_boost_python_ext,
+ paths=[
+ env_etc.clipper_include,
++ env_etc.clipper_sysinclude,
+ env_etc.libtbx_include,
+ env_etc.cctbx_include,
+ env_etc.scitbx_include,
+diff --git a/cctbx_sources/clipper_adaptbx/clipper/SConscript b/cctbx_sources/clipper_adaptbx/clipper/SConscript
+index 9f79f83..1911eb1 100644
+--- a/cctbx_sources/clipper_adaptbx/clipper/SConscript
++++ b/cctbx_sources/clipper_adaptbx/clipper/SConscript
+@@ -1,6 +1,10 @@
+-Import("env_clipper_boost_python_ext")
++Import("env_clipper_boost_python_ext", "env_etc")
+ env = env_clipper_boost_python_ext.Clone()
+-env.Prepend(LIBS=["clipper", "cctbx"])
++env.Prepend(LIBS=env_etc.clipper_libs+["cctbx"])
++if (env_etc.has_clipper_contrib):
++ clipper_contrib_files = []
++else:
++ clipper_contrib_files = ["../../clipper/clipper/contrib/sfweight.cpp",]
+ env.SharedLibrary(
+ target="#lib/clipper_ext",
+ source=[
+@@ -8,4 +12,4 @@ env.SharedLibrary(
+ "hendrickson_lattman_bpl.cpp",
+ "sigmaa_bpl.cpp",
+ "../../clipper/clipper/contrib/sfweight.cpp",
+- "../../clipper/clipper/cctbx/clipper_cctbx.cpp"])
++ "../../clipper/clipper/cctbx/clipper_cctbx.cpp"]+clipper_contrib_files)
+diff --git a/cctbx_sources/gltbx/SConscript b/cctbx_sources/gltbx/SConscript
+index 4b2213d..04e0654 100644
+--- a/cctbx_sources/gltbx/SConscript
++++ b/cctbx_sources/gltbx/SConscript
+@@ -12,14 +12,15 @@ env_etc.gltbx_common_includes = [
+ env_etc.scitbx_include,
+ env_etc.boost_include,
+ ]
+-if (gl2ps_path is not None):
+- env_etc.gltbx_common_includes.append(gl2ps_path)
++if not env_etc.check_syslib('gl2ps', extra_libs='GL'):
++ if (gl2ps_path is not None):
++ env_etc.gltbx_common_includes.append(gl2ps_path)
+
+ if (not env_etc.no_boost_python):
+ Import("env_base", "env_no_includes_boost_python_ext")
+ trial_env = env_base.Clone()
+ env = env_no_includes_boost_python_ext.Clone()
+- env.Prepend(LIBS=["scitbx_boost_python"])
++ env.Prepend(LIBS=[env_etc.scitbx_boost_python])
+ if (env_etc.compiler == "win32_cl"):
+ for e in [trial_env, env]:
+ e.Append(LIBS=["glu32", "opengl32"])
+@@ -79,10 +80,15 @@ if (not env_etc.no_boost_python):
+ source=source)
+ env_util = env
+ source = ["util_ext.cpp"]
+- if (gl2ps_path is not None):
+- source.append("#gui_resources/gl2ps/gl2ps.c")
+- env_util = env.Clone()
+- env_util.Append(SHCXXFLAGS=["-DGLTBX_HAVE_GL2PS"])
++ if not env_etc.check_syslib('gl2ps', extra_libs='GL'):
++ if (gl2ps_path is not None):
++ source.append("#gui_resources/gl2ps/gl2ps.c")
++ env_util = env.Clone()
++ env_util.Append(SHCXXFLAGS=["-DGLTBX_HAVE_GL2PS"])
++ else:
++ env_util = env.Clone()
++ env_util.Append(SHCXXFLAGS=["-DGLTBX_HAVE_GL2PS"])
++ env_util.Append(LIBS=["gl2ps"])
+ env_util.SharedLibrary(
+ target="#lib/gltbx_util_ext",
+ source=source)
+diff --git a/cctbx_sources/iotbx/cif/boost_python/SConscript b/cctbx_sources/iotbx/cif/boost_python/SConscript
+index 49837af..2833ff1 100644
+--- a/cctbx_sources/iotbx/cif/boost_python/SConscript
++++ b/cctbx_sources/iotbx/cif/boost_python/SConscript
+@@ -34,15 +34,18 @@ antlr3_src_files = [
+ ]
+
+ prefix = "#ucif/antlr3/src"
+-source = [os.path.join(prefix, file_name) for file_name in antlr3_src_files]
++if not env_etc.check_syslib('antlr3c'):
++ source = [os.path.join(prefix, file_name) for file_name in antlr3_src_files]
++ env_etc.include_registry.append(
++ env=env,
++ paths=[antlr3_include, antlr3_dist])
++else:
++ source = []
++ env.Append(LIBS=['antlr3c'])
+ source.extend([
+ "cif_ext.cpp",
+ "#ucif/cifParser.cpp",
+ "#ucif/cifLexer.cpp",
+ ])
+
+-env_etc.include_registry.append(
+- env=env,
+- paths=[antlr3_include, antlr3_dist])
+-
+ env.SharedLibrary(target="#lib/iotbx_cif_ext", source=source)
+diff --git a/cctbx_sources/iotbx/mtz/SConscript b/cctbx_sources/iotbx/mtz/SConscript
+index c0a4bb0..cd539e6 100644
+--- a/cctbx_sources/iotbx/mtz/SConscript
++++ b/cctbx_sources/iotbx/mtz/SConscript
+@@ -22,7 +22,8 @@ if (not env_etc.no_boost_python):
+ env = env_iotbx_boost_python_ext.Clone()
+ env.Append(CXXFLAGS=env_etc.ccp4io_defines)
+ env.Append(SHCXXFLAGS=env_etc.ccp4io_defines)
+- env.Prepend(LIBS=["iotbx_mtz", "cctbx", ccp4io_lib, "scitbx_boost_python"])
++ env.Prepend(LIBS=["iotbx_mtz", "cctbx", ccp4io_lib,
++ env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/iotbx_mtz_ext",
+diff --git a/cctbx_sources/iotbx/pdb/SConscript b/cctbx_sources/iotbx/pdb/SConscript
+index 6af2664..9b89fe1 100644
+--- a/cctbx_sources/iotbx/pdb/SConscript
++++ b/cctbx_sources/iotbx/pdb/SConscript
+@@ -33,7 +33,7 @@ env.Program(target="hybrid_36_fem", source=["hybrid_36_fem.cpp"])
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["iotbx_pdb", "cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["iotbx_pdb", "cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/iotbx_pdb_ext",
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index debf569..429c44b 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -4,7 +4,7 @@ from libtbx import easy_run
+ from libtbx.utils import getenv_bool
+ from libtbx.str_utils import show_string
+ from libtbx.path import norm_join, full_command_path
+-import sys, os
++import sys, os, re
+ op = os.path
+
+ if (hasattr(Environment, "Clone")):
+@@ -1018,4 +1018,88 @@ def enable_cuda_if_possible():
+ enable_openmp_if_possible()
+ enable_cuda_if_possible()
+
++env_etc.use_system_libs = False
++def check_syslib(lib, extra_libs=None):
++ """ Check if a system library is available """
++ if not env_etc.use_system_libs:
++ return False
++ env_syslib = env_base.Clone(LIBS=extra_libs)
++ conf = env_syslib.Configure()
++ if not conf.CheckLib(library=lib):
++ print 'Could not find %s library!'%(lib)
++ conf.Finish()
++ return False
++ else:
++ conf.Finish()
++ return True
++env_etc.check_syslib = check_syslib
++
++env_etc.py_lib = 'python%s.%s'%(sys.version[0], sys.version[2])
++
++if (libtbx.env.build_options.use_system_libs):
++ env_etc.use_system_libs = True
++
++deb_py_str = '-py%s%s'%(sys.version[0], sys.version[2])
++gentoo_py_str = '-%s.%s'%(sys.version[0], sys.version[2])
++# This list can be extended by other distro's
++py_str_lst = [deb_py_str, gentoo_py_str]
++
++for py_str in py_str_lst:
++ if env_etc.check_syslib('boost_python%s'%py_str,
++ extra_libs=env_etc.py_lib):
++ env_etc.boost_python = 'boost_python%s'%py_str
++ env_etc.scitbx_boost_python = 'scitbx_boost_python%s'%py_str
++ break
++ else:
++ env_etc.boost_python = 'boost_python'
++ env_etc.scitbx_boost_python = 'scitbx_boost_python'
++
++env_etc.prefix = libtbx.env.build_options.install_prefix
++env_etc.destdir = libtbx.env.build_options.install_destdir
++env_etc.libdir = libtbx.env.build_options.libdir
++env_etc.install_path = os.path.abspath(env_etc.destdir + '/' + env_etc.prefix)
++env_etc.binpath = os.path.join(env_etc.install_path, 'bin')
++env_etc.libpath = os.path.abspath(env_etc.install_path + '/' + env_etc.libdir)
++env_etc.inclpath = os.path.join(env_etc.install_path, 'include')
++env_etc.rpath = os.path.join(env_etc.prefix, 'lib')
++
++def create_install_targets():
++ cwd = os.getcwd()
++ rp = libtbx.env.repository_paths
++ lib_dir = '%s%s'%(abs(libtbx.env.lib_path), env_etc.rpath)
++ exe_dev = libtbx.env.under_build("exe_dev")
++ include_path = libtbx.env.include_path
++ if not os.path.exists(lib_dir):
++ os.makedirs(lib_dir)
++ rp = list(rp)
++ rp.append(lib_dir)
++ rp.append(include_path)
++ for p in rp:
++ if isinstance(p, str):
++ src_dir = p
++ else:
++ src_dir = abs(p)
++ os.chdir(src_dir)
++ dest = None
++ for root, dirnames, filenames in os.walk('.'):
++ for filename in filenames:
++ if re.match('^lib.*\.(so.*|dylib.*|la|a)$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.libpath, root)
++ src = os.path.join(src_dir, root, filename)
++ env_base.Install(dest, src)
++ env_base.Alias("install-shlib", dest)
++ if re.match('^.*\.(h|hpp)$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.inclpath, root)
++ src = os.path.join(src_dir, root, filename)
++ env_base.Install(dest, src)
++ env_base.Alias("install-header", dest)
++ dest = env_etc.binpath
++ env_base.Install(dest, Glob('%s/*'%(exe_dev)))
++ env_base.Alias("install-bin", dest)
++ Alias('install', ['install-header', 'install-shlib', 'install-bin'])
++ os.chdir(cwd)
++
++if 'install' in COMMAND_LINE_TARGETS:
++ create_install_targets()
++
+ Export("env_base", "env_etc")
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index c3e1c7d..0885527 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -701,6 +701,10 @@ Wait for the command to finish, then try again.""" % vars())
+ precompile_headers=command_line.options.precompile_headers,
+ static_libraries=command_line.options.static_libraries,
+ static_exe=command_line.options.static_exe,
++ use_system_libs=command_line.options.use_system_libs,
++ install_prefix=command_line.options.install_prefix,
++ libdir=command_line.options.libdir,
++ install_destdir=command_line.options.install_destdir,
+ scan_boost=command_line.options.scan_boost,
+ write_full_flex_fwd_h=command_line.options.write_full_flex_fwd_h,
+ boost_python_no_py_signatures
+@@ -1759,6 +1763,10 @@ class build_options:
+ warning_level,
+ static_libraries,
+ static_exe,
++ use_system_libs,
++ install_prefix,
++ libdir,
++ install_destdir,
+ scan_boost,
+ write_full_flex_fwd_h=default_write_full_flex_fwd_h,
+ build_boost_python_extensions=default_build_boost_python_extensions,
+@@ -1822,6 +1830,10 @@ class build_options:
+ print >> f, "Boost threads enabled:", self.enable_boost_threads
+ print >> f, "Enable OpenMP if possible:", self.enable_openmp_if_possible
+ print >> f, "Enable CUDA:", self.enable_cuda
++ print >> f, "Use System Libraries:", self.use_system_libs
++ print >> f, "Install Prefix:", self.install_prefix
++ print >> f, "Libdir:", self.libdir
++ print >> f, "Install Destdir:", self.install_destdir
+ print >> f, "Use opt_resources if available:", self.opt_resources
+ print >> f, "Use environment flags:", self.use_environment_flags
+ if( self.use_environment_flags ):
+@@ -1940,6 +1952,28 @@ class pre_process_args:
+ action="store_true",
+ default=False,
+ help="link all executables statically (implies --static_libraries)")
++ parser.option(None, "--use_system_libs",
++ action="store_true",
++ default=False,
++ help="Use system Libraries to build.")
++ parser.option(None, "--install_destdir",
++ type="string",
++ action="store",
++ default="",
++ help="sets the destdir for the install targets.",
++ metavar="DIRECTORY")
++ parser.option(None, "--libdir",
++ type="string",
++ action="store",
++ default="lib",
++ help="sets the libdir relative to the PREFIX for the install targets. Default: lib",
++ metavar="DIRECTORY")
++ parser.option(None, "--install_prefix",
++ type="string",
++ action="store",
++ default="/usr/local",
++ help="sets the prefix for the install targets. Default: /usr/local",
++ metavar="DIRECTORY")
+ parser.option(None, "--scan_boost",
+ action="store_true",
+ default=False,
+diff --git a/cctbx_sources/mmtbx/den/SConscript b/cctbx_sources/mmtbx/den/SConscript
+index 2d3ce36..1a2b171 100644
+--- a/cctbx_sources/mmtbx/den/SConscript
++++ b/cctbx_sources/mmtbx/den/SConscript
+@@ -3,7 +3,7 @@ Import("env_etc")
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/mmtbx_den_restraints_ext",
+diff --git a/cctbx_sources/mmtbx/geometry_restraints/SConscript b/cctbx_sources/mmtbx/geometry_restraints/SConscript
+index 222d5f6..e11e5f9 100644
+--- a/cctbx_sources/mmtbx/geometry_restraints/SConscript
++++ b/cctbx_sources/mmtbx/geometry_restraints/SConscript
+@@ -3,7 +3,7 @@ Import("env_etc")
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/mmtbx_hbond_restraints_ext",
+diff --git a/cctbx_sources/mmtbx/secondary_structure/SConscript b/cctbx_sources/mmtbx/secondary_structure/SConscript
+index 7e82b43..5698af5 100644
+--- a/cctbx_sources/mmtbx/secondary_structure/SConscript
++++ b/cctbx_sources/mmtbx/secondary_structure/SConscript
+@@ -3,7 +3,7 @@ Import("env_etc")
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/mmtbx_secondary_structure_ext",
+diff --git a/cctbx_sources/rstbx/SConscript b/cctbx_sources/rstbx/SConscript
+index a1ab8e5..e2958a1 100644
+--- a/cctbx_sources/rstbx/SConscript
++++ b/cctbx_sources/rstbx/SConscript
+@@ -39,7 +39,7 @@ if (not env_etc.no_boost_python):
+ Import("env_boost_python_ext")
+ env_rstbx_boost_python_ext = env_boost_python_ext.Clone()
+ env_rstbx_boost_python_ext.Prepend(
+- LIBS=["rstbx", "cctbx", "scitbx_boost_python"])
++ LIBS=["rstbx", "cctbx", env_etc.scitbx_boost_python])
+ env_rstbx_boost_python_ext.SharedLibrary(
+ target="#lib/rstbx_ext", source="ext.cpp")
+ env_rstbx_boost_python_ext.SharedLibrary(
+diff --git a/cctbx_sources/scitbx/SConscript b/cctbx_sources/scitbx/SConscript
+index 9199ae0..6045fbc 100644
+--- a/cctbx_sources/scitbx/SConscript
++++ b/cctbx_sources/scitbx/SConscript
+@@ -28,7 +28,7 @@ SConscript("sparse/tests/SConscript")
+ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
+ env_scitbx_boost_python_ext = env_no_includes_boost_python_ext.Clone()
+- env_scitbx_boost_python_ext.Prepend(LIBS=["scitbx_boost_python"])
++ env_scitbx_boost_python_ext.Prepend(LIBS=[env_etc.scitbx_boost_python])
+ env_etc.include_registry.append(
+ env=env_scitbx_boost_python_ext,
+ paths=env_etc.scitbx_common_includes + [env_etc.python_include])
+diff --git a/cctbx_sources/scitbx/boost_python/SConscript b/cctbx_sources/scitbx/boost_python/SConscript
+index eda7b03..1f396e5 100644
+--- a/cctbx_sources/scitbx/boost_python/SConscript
++++ b/cctbx_sources/scitbx/boost_python/SConscript
+@@ -7,7 +7,7 @@ env_etc.enable_more_warnings(env=env)
+ env.Append(CXXFLAGS=env_etc.cxxflags_bpl_defines_base)
+ env.Append(SHCXXFLAGS=env_etc.cxxflags_bpl_defines_base)
+ env.Append(LIBPATH=env_etc.libpath_python)
+-env.Append(LIBS=["boost_python"] + env_etc.libs_python)
++env.Append(LIBS=[env_etc.boost_python] + env_etc.libs_python)
+ env_etc.include_registry.append(
+ env=env,
+ paths=env_etc.scitbx_common_includes + [env_etc.python_include])
+@@ -20,5 +20,5 @@ lib_scitbx_boost_python_sources = [
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+ builder(
+- target="#lib/scitbx_boost_python",
++ target="#lib/%s"%env_etc.scitbx_boost_python,
+ source=lib_scitbx_boost_python_sources)
+diff --git a/cctbx_sources/smtbx/refinement/boost_python/SConscript b/cctbx_sources/smtbx/refinement/boost_python/SConscript
+index 0387e1d..5144996 100644
+--- a/cctbx_sources/smtbx/refinement/boost_python/SConscript
++++ b/cctbx_sources/smtbx/refinement/boost_python/SConscript
+@@ -1,6 +1,6 @@
+-Import("env_smtbx_boost_python_ext")
++Import("env_smtbx_boost_python_ext", "env_etc")
+ env = env_smtbx_boost_python_ext.Clone()
+-env.Prepend(LIBS=["smtbx_refinement_constraints", "scitbx_boost_python"])
++env.Prepend(LIBS=["smtbx_refinement_constraints", env_etc.scitbx_boost_python])
+ env.SharedLibrary(target="#lib/smtbx_refinement_least_squares_ext", source=[
+ "least_squares_ext.cpp",
+ "weighting_schemes.cpp",
+diff --git a/cctbx_sources/smtbx/refinement/constraints/boost_python/SConscript b/cctbx_sources/smtbx/refinement/constraints/boost_python/SConscript
+index 009d288..1eb176b 100644
+--- a/cctbx_sources/smtbx/refinement/constraints/boost_python/SConscript
++++ b/cctbx_sources/smtbx/refinement/constraints/boost_python/SConscript
+@@ -1,5 +1,5 @@
+-Import("env_smtbx_boost_python_ext")
++Import("env_smtbx_boost_python_ext", "env_etc")
+ env = env_smtbx_boost_python_ext.Clone()
+-env.Prepend(LIBS=["smtbx_refinement_constraints", "scitbx_boost_python"])
++env.Prepend(LIBS=["smtbx_refinement_constraints", env_etc.scitbx_boost_python])
+ env.SharedLibrary(target="#lib/smtbx_refinement_constraints_ext",
+ source=Glob("*.cpp"))
+diff --git a/cctbx_sources/spotfinder/SConscript b/cctbx_sources/spotfinder/SConscript
+index 1d280d4..1d73677 100644
+--- a/cctbx_sources/spotfinder/SConscript
++++ b/cctbx_sources/spotfinder/SConscript
+@@ -54,7 +54,7 @@ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
+
+ env_spotfinder_boost_python_ext = env_no_includes_boost_python_ext.Clone()
+- env_spotfinder_boost_python_ext.Prepend(LIBS=[ "scitbx_boost_python"])
++ env_spotfinder_boost_python_ext.Prepend(LIBS=[ env_etc.scitbx_boost_python ])
+ env_etc.include_registry.append(
+ env=env_spotfinder_boost_python_ext,
+ paths=env_etc.spotfinder_common_includes + [env_etc.python_include])
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0007-adding-shlib-versioning.patch b/sci-libs/cctbx/files/2012.05.08.2305/0007-adding-shlib-versioning.patch
new file mode 100644
index 0000000..fd1888e
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0007-adding-shlib-versioning.patch
@@ -0,0 +1,208 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 23 Jul 2012 18:33:07 +0200
+Subject: adding-shlib-versioning
+
+---
+ cctbx_sources/boost_adaptbx/SConscript | 3 +
+ cctbx_sources/libtbx/SConscript | 115 +++++++++++++++++++++++++++++---
+ cctbx_sources/libtbx/env_config.py | 7 ++
+ 3 files changed, 116 insertions(+), 9 deletions(-)
+
+diff --git a/cctbx_sources/boost_adaptbx/SConscript b/cctbx_sources/boost_adaptbx/SConscript
+index 68cac89..dedbb05 100644
+--- a/cctbx_sources/boost_adaptbx/SConscript
++++ b/cctbx_sources/boost_adaptbx/SConscript
+@@ -58,6 +58,9 @@ if (not env_etc.no_boost_python):
+ SHLINKFLAGS=env_etc.shlinkflags_bpl,
+ SHLIBPREFIX="",
+ LIBS=[env_etc.boost_python] + env_etc.libs_python + env_etc.libm)
++ if (libtbx.env.build_options.libtoolize):
++ # Need to unset libtool since it does not support linking python-ext
++ env_etc.unset_libtool(env_no_includes_boost_python_ext)
+ env_no_includes_boost_python_ext.Append(
+ LIBPATH=env_etc.libpath_python)
+ env_no_includes_boost_python_ext.Append(
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 429c44b..58bdd30 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -1061,16 +1061,99 @@ env_etc.install_path = os.path.abspath(env_etc.destdir + '/' + env_etc.prefix)
+ env_etc.binpath = os.path.join(env_etc.install_path, 'bin')
+ env_etc.libpath = os.path.abspath(env_etc.install_path + '/' + env_etc.libdir)
+ env_etc.inclpath = os.path.join(env_etc.install_path, 'include')
+-env_etc.rpath = os.path.join(env_etc.prefix, 'lib')
++env_etc.rpath = os.path.abspath(env_etc.prefix + '/' + env_etc.libdir)
++
++def set_libtool(env):
++ # Versioning can be provided by appending "-version-info 3:12:1" to SHLINKFLAGS
++ # Please see:
++ # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
++ # for reference. Otherwise it will be set to 0:0:0
++ env_etc.shobjsuffix_save = env['SHOBJSUFFIX']
++ env_etc.SharedLibBuilder_save = env['BUILDERS']['SharedLibrary']
++ env.Replace(
++ SHLINKFLAGS='-rpath ' + env_etc.rpath,
++ SHOBJSUFFIX='.lo',
++ SHLIBSUFFIX='.la',
++ )
++ LIBTOOLCOM = 'libtool --mode=compile --tag='
++ LIBTOOLCCOM = LIBTOOLCOM + 'CC '
++ LIBTOOLCXXCOM = LIBTOOLCOM + 'CXX '
++ LIBTOOLLINK = 'libtool --mode=link --tag=CXX '
++ ShCAction = SCons.Action.Action(LIBTOOLCCOM + "$SHCCCOM", "$SHCCCOMSTR")
++ ShCXXAction = SCons.Action.Action(LIBTOOLCXXCOM + "$SHCXXCOM", "$SHCXXCOMSTR")
++ ShLinkAction = SCons.Action.Action(LIBTOOLLINK + "$SHLINKCOM", "$SHLINKCOMSTR")
++ libtool_install = 'libtool --mode=install install -D ${TARGET.abspath} %s%s/${TARGET.file}'%(abs(libtbx.env.lib_path), env_etc.rpath)
++
++ action_list = [ SCons.Defaults.SharedCheck,
++ ShLinkAction,
++ libtool_install,
++ ]
++ CSuffixes = SCons.Tool.cc.CSuffixes
++ # Can't import SCons.Tool.c++.CSuffixes because of that 'c++'
++ CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++', '.mm']
++ shared_obj = SCons.Builder.Builder(action = {},
++ emitter = {},
++ prefix = '$SHOBJPREFIX',
++ suffix = '$SHOBJSUFFIX',
++ src_builder = ['CFile', 'CXXFile'],
++ source_scanner = SourceFileScanner,
++ single_source = 1)
++ for suffix in CXXSuffixes:
++ shared_obj.add_action(suffix, ShCXXAction)
++ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
++ for suffix in CSuffixes:
++ shared_obj.add_action(suffix, ShCAction)
++ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
++
++ LibtoolBuilder = SCons.Builder.Builder(action = action_list,
++ emitter = "$SHLIBEMITTER",
++ prefix = '$SHLIBPREFIX',
++ suffix = '$SHLIBSUFFIX',
++ target_scanner = ProgramScanner,
++ src_suffix = '$SHOBJSUFFIX',
++ src_builder = shared_obj)
++
++ from SCons.Tool.install import add_targets_to_INSTALLED_FILES
++ LibtoolInstall = SCons.Builder.Builder(
++ action = 'libtool --mode=install install -D ${SOURCE.abspath} ${TARGET.abspath}',
++ target_factory = env.fs.Entry,
++ source_factory = env.fs.Entry,
++ multi = 1,
++ emitter = [ add_targets_to_INSTALLED_FILES, ],
++ name = 'LibtoolInstall')
++
++ env['BUILDERS']['LibtoolInstall'] = LibtoolInstall
++
++ lib_dir = '%s%s'%(abs(libtbx.env.lib_path), env_etc.rpath)
++ if not os.path.exists(lib_dir):
++ os.makedirs(lib_dir)
++ libtool_install_path = '#lib' + env_etc.rpath
++ env.Append(LIBPATH=libtool_install_path)
++ env['BUILDERS']['SharedLibrary'] = LibtoolBuilder
++env_etc.set_libtool = set_libtool
++
++def unset_libtool(env):
++ env['BUILDERS']['SharedLibrary'] = env_etc.SharedLibBuilder_save
++ env.Replace(
++ SHOBJSUFFIX=env_etc.shobjsuffix_save,
++ )
++env_etc.unset_libtool = unset_libtool
++
++if (libtbx.env.build_options.libtoolize):
++ env_etc.shlibsuffix = ".la"
++ env_base.Append(LIBSUFFIXES=[env_etc.shlibsuffix])
++ rpath_link = ['-rpath', env_etc.rpath]
++ env_etc.shlinkflags.extend(rpath_link)
++ if '-shared' in env_etc.shlinkflags:
++ env_etc.shlinkflags.remove('-shared')
++ env_etc.set_libtool(env_base)
+
+ def create_install_targets():
+ cwd = os.getcwd()
+ rp = libtbx.env.repository_paths
+- lib_dir = '%s%s'%(abs(libtbx.env.lib_path), env_etc.rpath)
++ lib_dir = abs(libtbx.env.lib_path)
+ exe_dev = libtbx.env.under_build("exe_dev")
+ include_path = libtbx.env.include_path
+- if not os.path.exists(lib_dir):
+- os.makedirs(lib_dir)
+ rp = list(rp)
+ rp.append(lib_dir)
+ rp.append(include_path)
+@@ -1082,17 +1165,31 @@ def create_install_targets():
+ os.chdir(src_dir)
+ dest = None
+ for root, dirnames, filenames in os.walk('.'):
++ # exclude .libs dir
++ if '.libs' in dirnames:
++ dirnames.remove('.libs')
+ for filename in filenames:
+- if re.match('^lib.*\.(so.*|dylib.*|la|a)$', filename, flags=re.IGNORECASE):
+- dest = os.path.join(env_etc.libpath, root)
+- src = os.path.join(src_dir, root, filename)
+- env_base.Install(dest, src)
+- env_base.Alias("install-shlib", dest)
++ if not (libtbx.env.build_options.libtoolize):
++ if re.match('^lib.*\.(so|dylib|a)$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.libpath, root)
++ src = os.path.join(src_dir, root, filename)
++ env_base.Install(dest, src)
++ env_base.Alias("install-shlib", dest)
++ else:
++ if re.match('^lib.*\.la$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.libpath, root, filename)
++ src = os.path.join(src_dir, root, filename)
++ env_base.LibtoolInstall(dest, src)
++ env_base.Alias("install-shlib", dest)
+ if re.match('^.*\.(h|hpp)$', filename, flags=re.IGNORECASE):
+ dest = os.path.join(env_etc.inclpath, root)
+ src = os.path.join(src_dir, root, filename)
+ env_base.Install(dest, src)
+ env_base.Alias("install-header", dest)
++ if src_dir == lib_dir:
++ break
++
++ env_base.Alias("install-shlib", dest)
+ dest = env_etc.binpath
+ env_base.Install(dest, Glob('%s/*'%(exe_dev)))
+ env_base.Alias("install-bin", dest)
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 0885527..3d9133e 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -705,6 +705,7 @@ Wait for the command to finish, then try again.""" % vars())
+ install_prefix=command_line.options.install_prefix,
+ libdir=command_line.options.libdir,
+ install_destdir=command_line.options.install_destdir,
++ libtoolize=command_line.options.libtoolize,
+ scan_boost=command_line.options.scan_boost,
+ write_full_flex_fwd_h=command_line.options.write_full_flex_fwd_h,
+ boost_python_no_py_signatures
+@@ -1767,6 +1768,7 @@ class build_options:
+ install_prefix,
+ libdir,
+ install_destdir,
++ libtoolize,
+ scan_boost,
+ write_full_flex_fwd_h=default_write_full_flex_fwd_h,
+ build_boost_python_extensions=default_build_boost_python_extensions,
+@@ -1830,6 +1832,7 @@ class build_options:
+ print >> f, "Boost threads enabled:", self.enable_boost_threads
+ print >> f, "Enable OpenMP if possible:", self.enable_openmp_if_possible
+ print >> f, "Enable CUDA:", self.enable_cuda
++ print >> f, "Libtoolize:", self.libtoolize
+ print >> f, "Use System Libraries:", self.use_system_libs
+ print >> f, "Install Prefix:", self.install_prefix
+ print >> f, "Libdir:", self.libdir
+@@ -1974,6 +1977,10 @@ class pre_process_args:
+ default="/usr/local",
+ help="sets the prefix for the install targets. Default: /usr/local",
+ metavar="DIRECTORY")
++ parser.option(None, "--libtoolize",
++ action="store_true",
++ default=False,
++ help="build all shared libraries with libtool.")
+ parser.option(None, "--scan_boost",
+ action="store_true",
+ default=False,
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0008-Fix-to-skip-pycbf-build.patch b/sci-libs/cctbx/files/2012.05.08.2305/0008-Fix-to-skip-pycbf-build.patch
new file mode 100644
index 0000000..7aa3a39
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0008-Fix-to-skip-pycbf-build.patch
@@ -0,0 +1,52 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Tue, 7 Aug 2012 18:08:30 +0200
+Subject: Fix to skip pycbf build
+
+---
+ cctbx_sources/cbflib_adaptbx/SConscript | 8 ++++----
+ cctbx_sources/cbflib_adaptbx/libtbx_refresh.py | 16 ++++++++--------
+ 2 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/cctbx_sources/cbflib_adaptbx/SConscript b/cctbx_sources/cbflib_adaptbx/SConscript
+index 334cfc2..42ab9c3 100644
+--- a/cctbx_sources/cbflib_adaptbx/SConscript
++++ b/cctbx_sources/cbflib_adaptbx/SConscript
+@@ -90,10 +90,10 @@ if (not env_etc.no_boost_python):
+ env=env_cbflib_boost_python_ext,
+ paths=env_etc.cbflib_common_includes + [env_etc.python_include])
+
+- env_cbflib_boost_python_ext.SharedLibrary(
+- target='#lib/_pycbf',
+- source=[prefix+"/pycbf/pycbf_wrap.c"],
+- LIBS=env_etc.cbf_lib+env_etc.libs_python+env_etc.libm)
++ #env_cbflib_boost_python_ext.SharedLibrary(
++ # target='#lib/_pycbf',
++ # source=[prefix+"/pycbf/pycbf_wrap.c"],
++ # LIBS=env_etc.cbf_lib+env_etc.libs_python+env_etc.libm)
+
+ Export("env_cbflib_boost_python_ext")
+
+diff --git a/cctbx_sources/cbflib_adaptbx/libtbx_refresh.py b/cctbx_sources/cbflib_adaptbx/libtbx_refresh.py
+index 51b3e42..dd1b8e9 100644
+--- a/cctbx_sources/cbflib_adaptbx/libtbx_refresh.py
++++ b/cctbx_sources/cbflib_adaptbx/libtbx_refresh.py
+@@ -1,11 +1,11 @@
+ from libtbx.str_utils import show_string
+ import os
+ op = os.path
+-pycbf_py = self.env.under_dist(module_name="cbflib", path="pycbf/pycbf.py")
+-if (not op.isfile(pycbf_py)):
+- raise RuntimeError("Missing file: %s" % show_string(pycbf_py))
+-target_dir = self.env.under_build(path="lib")
+-if (not op.isdir(target_dir)):
+- os.makedirs(target_dir)
+-print " Copying to lib: %s" % show_string(pycbf_py)
+-open(op.join(target_dir, "pycbf.py"), "w").write(open(pycbf_py).read())
++#pycbf_py = self.env.under_dist(module_name="cbflib", path="pycbf/pycbf.py")
++#if (not op.isfile(pycbf_py)):
++# raise RuntimeError("Missing file: %s" % show_string(pycbf_py))
++#target_dir = self.env.under_build(path="lib")
++#if (not op.isdir(target_dir)):
++# os.makedirs(target_dir)
++#print " Copying to lib: %s" % show_string(pycbf_py)
++#open(op.join(target_dir, "pycbf.py"), "w").write(open(pycbf_py).read())
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0009-build-libann-statically.patch b/sci-libs/cctbx/files/2012.05.08.2305/0009-build-libann-statically.patch
new file mode 100644
index 0000000..77ba2b2
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0009-build-libann-statically.patch
@@ -0,0 +1,27 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Thu, 19 Jul 2012 11:29:57 +0200
+Subject: build libann statically
+
+---
+ cctbx_sources/annlib_adaptbx/SConscript | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/cctbx_sources/annlib_adaptbx/SConscript b/cctbx_sources/annlib_adaptbx/SConscript
+index 31b4da6..f217b3f 100644
+--- a/cctbx_sources/annlib_adaptbx/SConscript
++++ b/cctbx_sources/annlib_adaptbx/SConscript
+@@ -29,9 +29,11 @@ if (libtbx.manual_date_stamp < 20090819):
+ env.Replace(CXXFLAGS=env_etc.cxxflags_base)
+ env.Replace(SHCXXFLAGS=env_etc.cxxflags_base)
+
+-if (env_etc.static_libraries): builder = env.StaticLibrary
+-else: builder = env.SharedLibrary
+-builder(target='#lib/ann',
++#if (env_etc.static_libraries): builder = env.StaticLibrary
++#else: builder = env.SharedLibrary
++# Create a static library since the changes are incompatiple
++# with debian's libann
++env.StaticLibrary(target='#lib/ann',
+ source = ["../annlib/src/ANN.cpp",
+ "../annlib/src/bd_fix_rad_search.cpp",
+ "../annlib/src/bd_pr_search.cpp",
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0010-adding-setup_py.patch b/sci-libs/cctbx/files/2012.05.08.2305/0010-adding-setup_py.patch
new file mode 100644
index 0000000..7599d82
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0010-adding-setup_py.patch
@@ -0,0 +1,662 @@
+From: Baptiste Carvello <devel@baptiste-carvello.net>
+Date: Tue, 21 Aug 2012 16:10:19 +0200
+Subject: adding-setup_py
+
+---
+ cctbx_sources/stdlib.py | 4 +
+ sconsutils.py | 485 +++++++++++++++++++++++++++++++++++++++++++++++
+ setup.py | 136 +++++++++++++
+ 3 files changed, 625 insertions(+)
+ create mode 100755 cctbx_sources/stdlib.py
+ create mode 100644 sconsutils.py
+ create mode 100755 setup.py
+
+diff --git a/cctbx_sources/stdlib.py b/cctbx_sources/stdlib.py
+new file mode 100755
+index 0000000..759f689
+--- /dev/null
++++ b/cctbx_sources/stdlib.py
+@@ -0,0 +1,4 @@
++from libtbx.forward_compatibility import stdlib_import
++
++math = stdlib_import("math")
++random = stdlib_import("random")
+diff --git a/sconsutils.py b/sconsutils.py
+new file mode 100644
+index 0000000..322585b
+--- /dev/null
++++ b/sconsutils.py
+@@ -0,0 +1,485 @@
++from distutils.sysconfig import get_python_lib, get_config_var
++from distutils.command.build_ext import build_ext as _build_ext
++from distutils.command.build_py import build_py as _build_py
++from distutils.command.install_lib import install_lib as _install_lib
++from distutils.command.install_data import install_data as _install_data
++from distutils.command.clean import clean as _clean
++from distutils.cmd import Command as _Command
++from distutils.dir_util import remove_tree
++from distutils.util import change_root, convert_path
++from distutils.errors import DistutilsExecError
++from distutils import log
++import sys, os
++import SCons.Script
++import libtbx
++import libtbx.env_config
++from libtbx.path import relocatable_path, absolute_path
++from libtbx.path import relpath # don't use relpath from os.path, introduced in 2.6
++from libtbx.utils import import_python_object
++import threading
++import pickle
++
++opj = os.path.join
++configure_list = []
++scons_buildargv = []
++scons_installargv = []
++SRCDIR=''
++
++class Command(_Command):
++ def run_scons(self, argv):
++ cwd = os.getcwd()
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build') # build_temp must be set by subclass
++ if not os.path.exists(builddir):
++ if not os.path.exists(os.path.abspath(self.build_temp)):
++ os.mkdir(os.path.abspath(self.build_temp))
++ os.mkdir(builddir)
++ elif not os.path.isdir(builddir):
++ raise RuntimeError(("Build directory '%s' cannot be created "
++ "because of existing file") % builddir)
++ os.chdir(builddir)
++ if '%PREFIX%' in configure_list:
++ idx=configure_list.index('%PREFIX%')
++ configure_list[idx] = self.prefix # prefix must be set by subclass
++ libtbx.env_config.cold_start(configure_list)
++ os.environ["LIBTBX_BUILD"] = builddir
++ os.environ['PYTHONPATH'] = ':'.join(sys.path)
++ self.spawn(argv)
++ os.chdir(cwd)
++
++class build_ext(_build_ext, Command):
++ user_options = _build_ext.user_options + [
++ ('prefix=', None, "installation prefix (default: python installation prefix")
++ ]
++ def initialize_options(self):
++ _build_ext.initialize_options(self)
++ self.prefix = None
++ def finalize_options(self):
++ _build_ext.finalize_options(self)
++ if not self.prefix:
++ self.prefix = get_config_var('prefix') # on Debian: 'usr'
++ def run(self):
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build') # build_temp set by _build_ext
++ self.run_scons(scons_buildargv)
++ for ext in self.extensions:
++ if len(ext.sources) != 1 or ext.sources[0] != '%SCONSLIB%':
++ log.warn("Don't know how to build extension '%s' -- skipping",
++ ext.name)
++ continue
++ dst = self.get_ext_fullpath(ext.name)
++ bld = opj(builddir, 'lib', os.path.basename(dst))
++ if os.path.isfile(bld):
++ self.copy_file(bld, dst)
++
++class build_py(_build_py):
++ def build_module (self, module, module_file, package):
++ if type(package) is str:
++ package = package.split('.')
++ elif type(package) not in (list, tuple):
++ raise TypeError, \
++ "'package' must be a string (dot-separated), list, or tuple"
++
++ # Now put the module source file into the "build" area -- this is
++ # easy, we just copy it somewhere under self.build_lib (the build
++ # directory for Python source).
++ outfile = self.get_module_outfile(self.build_lib, package, module)
++ dir = os.path.dirname(outfile)
++ self.mkpath(dir)
++ # If the module contains non-blank, non-comment/docstring lines, and doesn't have
++ # the __future__ import, add it before the first non-comment/docstring line
++ empty = True
++ found = False
++ docstring = None
++ file_obj = open(module_file)
++ for line in file_obj:
++ if docstring:
++ if (line.count(docstring) % 2) == 1:
++ # FIXME this logic will fail with lines such as """ + ''',
++ # but nobody with a sane mind would do that, would they ?
++ docstring = None
++ continue
++ if line == "from __future__ import division\n":
++ found = True
++ break
++ if line.isspace() or line.startswith('#'):
++ continue
++ if line.startswith('"""') and (line.count('"""') % 2) == 1:
++ docstring = '"""'
++ continue
++ if line.startswith('"'):
++ continue
++ if line.startswith("'''") and (line.count("'''") % 2) == 1:
++ docstring = "'''"
++ continue
++ if line.startswith("'"):
++ continue
++ empty = False
++ break
++ file_obj.close()
++ if empty or found:
++ return self.copy_file(module_file, outfile, preserve_mode=0)
++ elif self.dry_run:
++ if os.path.isdir(outfile):
++ outfile = opj(outfile, os.path.basename(module_file))
++ log.info("copying with modification %s -> %s", module_file, outfile)
++ return outfile, True
++ else:
++ if os.path.isdir(outfile):
++ outfile = opj(outfile, os.path.basename(module_file))
++ log.info("copying with modification %s -> %s", module_file, outfile)
++ file_obj = open(module_file)
++ outfile_obj = open(outfile, 'w')
++ written = False
++ docstring = None
++ for line in file_obj:
++ if not written:
++ if docstring:
++ if (line.count(docstring) % 2) == 1:
++ docstring = None
++ outfile_obj.write(line)
++ continue
++ if line.isspace() or line.startswith('#'):
++ outfile_obj.write(line)
++ continue
++ if line.startswith('"""') and (line.count('"""') % 2) == 1:
++ docstring = '"""'
++ outfile_obj.write(line)
++ continue
++ if line.startswith('"'):
++ outfile_obj.write(line)
++ continue
++ if line.startswith("'''") and (line.count("'''") % 2) == 1:
++ docstring = "'''"
++ outfile_obj.write(line)
++ continue
++ if line.startswith("'"):
++ outfile_obj.write(line)
++ continue
++ outfile_obj.write("from __future__ import division\n")
++ written = True
++ outfile_obj.write(line)
++ outfile_obj.close()
++ file_obj.close()
++ return outfile, True
++
++class test(_Command):
++ description = "runs the tests in the distutils build directory"
++ user_options = [
++ ('build-lib=', None,
++ "distutils build directory (default: 'build.build-lib')"),
++ ('build-temp=', 't',
++ "directory for temporary files (default: 'build.build-temp')")
++ ]
++ def initialize_options(self):
++ self.build_lib = None
++ self.build_temp = None
++ def finalize_options(self):
++ self.set_undefined_options('build',
++ ('build_lib', 'build_lib'),
++ ('build_temp', 'build_temp'))
++ def run(self):
++ libdir = os.path.abspath(os.path.abspath(self.build_lib))
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build')
++ testdir = opj(os.path.abspath(self.build_temp), 'cctbx-test')
++ self.setup_test_env(builddir, libdir, testdir)
++ os.environ["LIBTBX_BUILD"] = testdir
++ env = libtbx.env_config.unpickle()
++ os.environ['PYTHONPATH'] = ':'.join([libdir] + sys.path[5:])
++ llp = os.environ.get('LD_LIBRARY_PATH')
++ if llp is not None:
++ os.environ['LD_LIBRARY_PATH'] = ':'.join([opj(builddir, 'lib', '.libs'), llp])
++ else:
++ os.environ['LD_LIBRARY_PATH'] = opj(builddir, 'lib', '.libs')
++ os.chdir(testdir)
++ failed = []
++ for m in env.module_list:
++ for (module_name,dist_path) in m.name_and_dist_path_pairs():
++ try:
++# tst_list = import_python_object(
++# import_path="%s.run_tests.tst_list" % module_name, Does not work yet
++# error_prefix="",
++# target_must_be="",
++# where_str="").object
++ run_func = import_python_object(
++ import_path="%s.run_tests.run" % module_name,
++ error_prefix="",
++ target_must_be="",
++ where_str="").object
++ tst_mod = file(opj(abs(dist_path), "run_tests.py")) # Ugly, temporary
++ tst_lines = [l.strip() for l in tst_mod]
++ tst_mod.close()
++ tst_code = " ".join(["("] +
++ tst_lines[(tst_lines.index("tst_list = (")+1)
++ :(tst_lines.index(")")+1)]
++ )
++ tst_list = eval(tst_code)
++
++ except Exception:
++ continue
++ for tst in tst_list: # adapted from libtbx.test_utils.iter_tests_cmd
++ cmd_args = []
++ if (type(tst) == type([])):
++# cmd_args = tst[1:] FIXME why only in quick mode?
++ tst = tst[0]
++ if (tst.startswith("$B")):
++ tst_path = tst.replace("$B", builddir)
++ else:
++ tst_path = tst.replace("$D", abs(dist_path))
++ if "$" in tst_path or '"' in tst_path:
++ log.warn("Could not run test '%s':\n%s", tst, "Unexpected '$' in test path")
++ failed.append([module_name,tst,AssertionError("Unexpected '$' in test path")])
++ continue
++ if '"' in tst_path:
++ log.warn("Could not run test '%s':\n%s", tst, "Unexpected '\"' in test path")
++ failed.append([module_name,tst,AssertionError("Unexpected '\"' in test path")])
++ continue
++ tst_path = os.path.normpath(tst_path)
++ if (tst_path.endswith(".py")):
++ cmd = [sys.executable, tst_path] + cmd_args
++ else:
++ cmd = [tst_path] + cmd_args
++ try:
++ self.spawn(cmd)
++ except DistutilsExecError, e:
++ log.warn("Failure in test '%s':\n%s", tst, str(e))
++ failed.append([module_name,tst,e])
++ except Exception, e:
++ log.warn("Exception in test '%s':\n%s", tst, str(e))
++ failed.append([module_name,tst,e])
++ if failed:
++ log.warn("Some tests failed:")
++ for n,t,e in failed:
++ log.warn(" module %s, test %s" % (n,t))
++ raise RuntimeError("Test failures")
++
++ def setup_test_env(self, builddir, libdir, testdir):
++ """ Create the test directory and the temporary libtbx_env pickle object """
++ if not os.path.exists(testdir):
++ if not os.path.exists(os.path.abspath(self.build_temp)):
++ os.mkdir(os.path.abspath(self.build_temp))
++ os.mkdir(testdir)
++ elif not os.path.isdir(testdir):
++ raise RuntimeError(("Test directory '%s' cannot be created "
++ "because of existing file") % testdir)
++ os.environ["LIBTBX_BUILD"] = builddir
++ env = libtbx.env_config.unpickle()
++ module_dist_paths = {}
++ for key, value in env.module_dist_paths.items():
++ head, module = os.path.split(abs(value))
++ module_dist_paths[key] = relocatable_path(absolute_path(libdir), module)
++ env.module_dist_paths = module_dist_paths
++ for module in env.module_list:
++ paths = []
++ for path in module.dist_paths:
++ if path != None:
++ head, tail = os.path.split(abs(path))
++ rp = relocatable_path(absolute_path(libdir), tail)
++ paths.append(rp)
++ else:
++ paths.append(None)
++ module.dist_paths = paths
++ file_obj = open(opj(testdir,'libtbx_env'), 'wb')
++ pickle.dump(env, file_obj, 0)
++ file_obj.close()
++
++class install_lib(_install_lib, Command):
++ user_options = _install_lib.user_options + [
++ ('build-temp=', 't',
++ "directory for temporary files (default: 'build.build-temp')"),
++ ('prefix=', None, "installation prefix (default: 'install.prefix')"),
++ ('root=', None,
++ "install everything relative to this alternate root directory (default: 'install.root')")
++ ]
++ def initialize_options(self):
++ _install_lib.initialize_options(self)
++ self.build_temp = None
++ self.prefix = None
++ self.root = None
++ def finalize_options(self):
++ _install_lib.finalize_options(self)
++ self.set_undefined_options('build',
++ ('build_temp', 'build_temp'))
++ self.set_undefined_options('install',
++ ('prefix', 'prefix'),
++ ('root', 'root'))
++ def run(self):
++ _install_lib.run(self)
++ if self.root != None:
++ ip = '--install_destdir'
++ if ip not in configure_list:
++ configure_list.extend([ip, self.root])
++ self.run_scons(scons_installargv)
++
++class install_data(_install_data, Command):
++ user_options = _install_data.user_options + [
++ ('build-temp=', 't',
++ "directory for temporary files (default: 'build.build-temp')"),
++ ('prefix=', None, "installation prefix (default: 'install.prefix')")
++ ]
++ def initialize_options(self):
++ _install_data.initialize_options(self)
++ self.build_temp = None
++ self.prefix = None
++ def finalize_options(self):
++ _install_data.finalize_options(self)
++ self.set_undefined_options('build',
++ ('build_temp', 'build_temp'))
++ self.set_undefined_options('install',
++ ('prefix', 'prefix'))
++ def run(self):
++ # filter the list
++ newdf = []
++ libtbx_env_path = None
++ for f in self.data_files:
++ if type(f) is str:
++ newdf.append(f)
++ continue
++ if '%LIBTBXENV%' in f[1]:
++ f = (f[0], [p for p in f[1] if p != '%LIBTBXENV%'])
++ libtbx_env_path = opj(convert_path(f[0]), 'libtbx_env')
++ if not os.path.isabs(libtbx_env_path): # mimic the logic in install_data
++ libtbx_env_path = opj(self.install_dir, libtbx_env_path)
++ elif self.root:
++ libtbx_env_path = change_root(self.root, libtbx_env_path)
++ # we leave the directory in, so that distutils will create it
++ newdf.append(f)
++ self.data_files = newdf
++ _install_data.run(self)
++ if libtbx_env_path is not None:
++ self.install_libtbx_env(libtbx_env_path)
++ self.outfiles.append(libtbx_env_path)
++
++ def install_libtbx_env(self, libtbx_env_path):
++ """ Modify libtbx_env pickle object to set the correct paths. """
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build')
++ os.environ["LIBTBX_BUILD"] = builddir
++ env = libtbx.env_config.unpickle()
++ env.build_path = absolute_path(self.prefix)
++ build_path = env.build_path
++ python_lib = get_python_lib()
++ rel_path = opj(python_lib, 'cctbx')
++ env.bin_path = relocatable_path(build_path, 'bin')
++ env.lib_path = relocatable_path(build_path, 'lib')
++ env.include_path = relocatable_path(build_path, 'include')
++ env.repository_paths = relocatable_path(build_path, rel_path)
++ env.scons_dist_path = None
++ env.pythonpath = None
++ env.exe_path = env.bin_path
++ env.python_exe = relocatable_path(build_path, sys.executable)
++ env.path_utility = relocatable_path(build_path,
++ opj(rel_path, 'libtbx', 'command_line', 'path_utility.py'))
++ module_dist_paths = {}
++ for key, value in env.module_dist_paths.items():
++ head, module = os.path.split(abs(value))
++ module_dist_paths[key] = relocatable_path(build_path,
++ opj(rel_path, module))
++ env.module_dist_paths = module_dist_paths
++ for module in env.module_list:
++ paths = []
++ for path in module.dist_paths:
++ if path != None:
++ head, tail = os.path.split(abs(path))
++ rp = relocatable_path(build_path, opj(rel_path, tail))
++ paths.append(rp)
++ else:
++ paths.append(None)
++ module.dist_paths = paths
++ _dispatcher_registry={}
++ for key, value in env._dispatcher_registry.items():
++ new_key = relocatable_path(anchor=build_path,
++ relocatable=key.relocatable)
++ rel = relpath(abs(value), SRCDIR)
++ new_val = relocatable_path(anchor=absolute_path(rel_path),
++ relocatable=rel)
++ _dispatcher_registry[new_key] = new_val
++ env._dispatcher_registry = _dispatcher_registry
++ # install the environment file in the data dir
++ file_obj = open(libtbx_env_path, 'wb')
++ pickle.dump(env, file_obj, 0)
++ file_obj.close()
++
++class clean(_clean):
++ def run(self):
++ # remove the scons build dir
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build')
++ if os.path.exists(builddir):
++ remove_tree(builddir, dry_run=self.dry_run)
++ else:
++ log.debug("'%s' does not exist -- can't clean it",
++ builddir)
++ # remove the scons test dir
++ testdir = opj(os.path.abspath(self.build_temp), 'cctbx-test')
++ if os.path.exists(testdir):
++ remove_tree(testdir, dry_run=self.dry_run)
++ else:
++ log.debug("'%s' does not exist -- can't clean it",
++ testdir)
++ # call the base class to remove the distutils dirs
++ _clean.run(self)
++
++# adapted from setuptools
++# authors: Phillip J. Eby, Tarek Ziade and the distutils SIG
++# licence: PSF or ZPL
++
++from distutils.util import convert_path
++import re
++
++EXTPAT1 = re.compile(r"^from (\S+_ext) import")
++EXTPAT2 = re.compile(r"^import (\S+_ext)$")
++EXTPAT3 = re.compile(r"boost.python.import_ext\(['\"](\S+_ext)['\"]\)$")
++EXTPAT4 = re.compile(r"import_ext\(['\"](\S+_ext)['\"]\)$") # in module boost.python!
++
++def find_packages_and_extensions(where='.', exclude=()):
++ """Return a list all Python packages found within directory 'where'
++ and a list all extensions that need to be installed inside those packages
++
++ 'where' should be supplied as a "cross-platform" (i.e. URL-style) path; it
++ will be converted to the appropriate local path syntax. 'exclude' is a
++ sequence of package names to exclude; '*' can be used as a wildcard in the
++ names, such that 'foo.*' will exclude all subpackages of 'foo' (but not
++ 'foo' itself).
++ """
++ out = []
++ outext = set()
++ stack=[(convert_path(where), '')]
++
++ while stack:
++
++ where,prefix = stack.pop(0)
++ for name in os.listdir(where):
++
++ fn = opj(where,name)
++ if ('.' not in name and os.path.isdir(fn) and
++ os.path.isfile(opj(fn,'__init__.py'))
++ ):
++
++ out.append(prefix+name); stack.append((fn,prefix+name+'.'))
++
++ if name.endswith('.py'):
++
++ f = open(opj(where, name))
++ for l in f:
++
++ m = EXTPAT1.match(l)
++ if m is not None:
++ outext.add(m.group(1))
++
++ m = EXTPAT2.match(l)
++ if m is not None:
++ outext.add(m.group(1))
++
++ m = EXTPAT3.search(l)
++ if m is not None:
++ outext.add(m.group(1))
++
++ if name == 'python.py' and prefix.endswith('boost.'):
++ m = EXTPAT4.search(l)
++ if m is not None:
++ outext.add(m.group(1))
++
++ f.close()
++
++ for pat in list(exclude)+['ez_setup', 'distribute_setup']:
++ from fnmatch import fnmatchcase
++ out = [item for item in out if not fnmatchcase(item,pat)]
++
++ return out, list(outext)
+diff --git a/setup.py b/setup.py
+new file mode 100755
+index 0000000..033dc9e
+--- /dev/null
++++ b/setup.py
+@@ -0,0 +1,142 @@
++from distutils.core import setup, Extension
++import sys, os, shutil
++
++# General settings
++opj = os.path.join
++CURDIR = os.getcwd()
++SRCDIR = opj(CURDIR, 'cctbx_sources')
++py_vers = sys.version_info
++py_major = py_vers[0]
++py_minor = py_vers[1]
++py_str = 'python%s.%s'%(py_major, py_minor)
++clipper = opj('clipper_adaptbx','clipper')
++boost = opj('boost_adaptbx','boost')
++libtbx_pypath = opj('libtbx','pythonpath')
++scons_exe = '/usr/bin/scons' # FIXME platform dependent path
++scons_path = '/usr/lib/scons/'
++PATHLIST= [ SRCDIR,
++ opj(SRCDIR, libtbx_pypath),
++ opj(SRCDIR, clipper),
++ opj(SRCDIR, boost),
++ scons_path,
++ ]
++for p in PATHLIST:
++ if p not in sys.path:
++ # we need to insert at the front, in case cctbx is already installed
++ sys.path.insert(0,p)
++
++import sconsutils
++from sconsutils import find_packages_and_extensions, build_ext, build_py, test, install_lib, install_data, clean
++
++sconsutils.SRCDIR = SRCDIR
++
++# Debian Multiarch magic
++multiarch = os.environ.get('DEB_HOST_MULTIARCH')
++libdir = os.environ.get('MULTILIBDIR')
++if multiarch == None:
++ multiarch = ''
++else:
++ libdir = 'lib/' + multiarch
++
++if libdir == None:
++ libdir = 'lib'
++# Configure settings
++# We need this directory to get env_config.cold_start to run!
++# trailing slash is important
++init_dir = opj(SRCDIR, 'libtbx')+os.sep # the separator is needed for dirname to do the right thing
++build_opts = [ '--libtoolize',
++ '--use_system_libs',
++ '--use-environment-flags',
++ '--libdir', libdir,
++ '--install_prefix', '%PREFIX%', # prefix will be replaced at run time
++ ]
++conf_modules = [ 'annlib_adaptbx',
++ 'boost_adaptbx',
++ 'cbflib_adaptbx',
++ 'ccp4io_adaptbx',
++ 'cctbx',
++ 'chiltbx',
++ 'clipper_adaptbx',
++ 'crys3d',
++ 'fable',
++ 'fftw3tbx',
++ 'gltbx',
++ 'iotbx',
++ 'libtbx',
++ 'mmtbx',
++ 'omptbx',
++ 'rstbx',
++ 'scitbx',
++ 'smtbx',
++ 'spotfinder',
++ 'tbxx',
++ 'tntbx',
++ 'ucif',
++ 'wxtbx',
++ ]
++sconsutils.configure_list = [init_dir]
++sconsutils.configure_list.extend(build_opts)
++sconsutils.configure_list.extend(conf_modules)
++
++# Build settings
++sconsutils.scons_buildargv = [sys.executable, scons_exe]
++
++# Install settings
++sconsutils.scons_installargv = [sys.executable, scons_exe, 'install']
++
++# Setup settings
++
++NAME = 'cctbx'
++VERSION = '2012.05.08.2305'
++DESCRIPTION = 'cctbx'
++AUTHOR = 'cctbx'
++AUTHOR_EMAIL = 'cctbx@cci.lbl.gov'
++URL = 'http://cctbx.sourceforge.net/'
++LICENSE = 'CCTBX 2.0'
++KEYWORDS = 'crystallography'
++SCRIPTS = []
++PKG_DATA = {}
++EXTRA_PATH = 'cctbx'
++
++MODS = ['stdlib']
++
++PACKDIR = { 'boost' : 'cctbx_sources/boost_adaptbx/boost', # in setup, paths must stay in unix syntax
++ 'clipper' : 'cctbx_sources/clipper_adaptbx/clipper', # also, let's keep them relative
++ 'optik' : 'cctbx_sources/libtbx/pythonpath/optik', # FIXME installs incompatible fork to global path
++ 'tntbx' : 'cctbx_sources/tntbx/tntbx',
++ '' : 'cctbx_sources',
++ }
++
++PACKS = []
++EXT_MODULES = []
++for key, value in PACKDIR.items():
++ p, e = find_packages_and_extensions(value)
++ PACKS.extend(p)
++ EXT_MODULES.extend(e)
++ if key != '':
++ PACKS.append(key)
++
++EXT_MODULES = [ Extension(e, ['%SCONSLIB%']) for e in EXT_MODULES ] # special treatment from install_lib
++
++setup(name=NAME,
++ version = VERSION,
++ author = AUTHOR,
++ author_email = AUTHOR_EMAIL,
++ url = URL,
++ description = DESCRIPTION,
++ license = LICENSE,
++ keywords = KEYWORDS,
++ extra_path = EXTRA_PATH,
++ scripts = SCRIPTS,
++ py_modules = MODS,
++ package_dir = PACKDIR,
++ packages = PACKS,
++ ext_modules = EXT_MODULES,
++ data_files = [('share/cctbx/%s'%(py_str), ['%LIBTBXENV%'])], # special treatment from install_data
++ cmdclass = {'build_ext': build_ext,
++ 'build_py': build_py,
++ 'test': test,
++ 'install_lib': install_lib,
++ 'install_data': install_data,
++ 'clean': clean},
++ )
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0011-fix-missing-python-lib-during-linking.patch b/sci-libs/cctbx/files/2012.05.08.2305/0011-fix-missing-python-lib-during-linking.patch
new file mode 100644
index 0000000..6724c0c
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0011-fix-missing-python-lib-during-linking.patch
@@ -0,0 +1,47 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Thu, 19 Jul 2012 23:26:30 +0200
+Subject: fix missing python lib during linking
+
+---
+ cctbx_sources/libtbx/SConscript | 4 ++--
+ cctbx_sources/scitbx/boost_python/SConscript | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 58bdd30..53e1512 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -54,9 +54,11 @@ def set_python_include_and_libs(env_etc):
+ env_etc.python_include = libtbx.env_config.python_include_path()
+ if (sys.platform == "win32"):
+ env_etc.libs_python = ["python" + sys.version[0] + sys.version[2]]
++ env_etc.py_lib = 'python%s%s'%(sys.version[0], sys.version[2])
+ env_etc.libpath_python = [sys.prefix + r"\libs"]
+ else:
+ env_etc.libs_python = []
++ env_etc.py_lib = 'python%s.%s'%(sys.version[0], sys.version[2])
+ env_etc.libpath_python = []
+ if (env_etc.compiler.startswith("darwin_")):
+ env_etc.python_framework = "/".join(
+@@ -1034,8 +1036,6 @@ def check_syslib(lib, extra_libs=None):
+ return True
+ env_etc.check_syslib = check_syslib
+
+-env_etc.py_lib = 'python%s.%s'%(sys.version[0], sys.version[2])
+-
+ if (libtbx.env.build_options.use_system_libs):
+ env_etc.use_system_libs = True
+
+diff --git a/cctbx_sources/scitbx/boost_python/SConscript b/cctbx_sources/scitbx/boost_python/SConscript
+index 1f396e5..b906eb3 100644
+--- a/cctbx_sources/scitbx/boost_python/SConscript
++++ b/cctbx_sources/scitbx/boost_python/SConscript
+@@ -7,7 +7,7 @@ env_etc.enable_more_warnings(env=env)
+ env.Append(CXXFLAGS=env_etc.cxxflags_bpl_defines_base)
+ env.Append(SHCXXFLAGS=env_etc.cxxflags_bpl_defines_base)
+ env.Append(LIBPATH=env_etc.libpath_python)
+-env.Append(LIBS=[env_etc.boost_python] + env_etc.libs_python)
++env.Append(LIBS=[env_etc.boost_python] + [env_etc.py_lib,] + env_etc.libs_python)
+ env_etc.include_registry.append(
+ env=env,
+ paths=env_etc.scitbx_common_includes + [env_etc.python_include])
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0012-fix-to-remove-cctbx.python-interpreter.patch b/sci-libs/cctbx/files/2012.05.08.2305/0012-fix-to-remove-cctbx.python-interpreter.patch
new file mode 100644
index 0000000..ec9a216
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0012-fix-to-remove-cctbx.python-interpreter.patch
@@ -0,0 +1,29 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 23 Jul 2012 23:58:46 +0200
+Subject: fix to remove cctbx.python interpreter
+
+---
+ cctbx_sources/rstbx/bpcx/uc1_2.py | 2 +-
+ cctbx_sources/rstbx/bpcx/uc1_2_reeke.py | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/cctbx_sources/rstbx/bpcx/uc1_2.py b/cctbx_sources/rstbx/bpcx/uc1_2.py
+index 95ee9cd..1abf8e1 100644
+--- a/cctbx_sources/rstbx/bpcx/uc1_2.py
++++ b/cctbx_sources/rstbx/bpcx/uc1_2.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env cctbx.python
++#!/usr/bin/env python
+ #
+ # Biostruct-X Data Reduction Use Case 1.2:
+ #
+diff --git a/cctbx_sources/rstbx/bpcx/uc1_2_reeke.py b/cctbx_sources/rstbx/bpcx/uc1_2_reeke.py
+index c07c015..8eebd49 100644
+--- a/cctbx_sources/rstbx/bpcx/uc1_2_reeke.py
++++ b/cctbx_sources/rstbx/bpcx/uc1_2_reeke.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env cctbx.python
++#!/usr/bin/env python
+ #
+ # Biostruct-X Data Reduction Use Case 1.2:
+ #
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.patch b/sci-libs/cctbx/files/2012.05.08.2305/0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.patch
new file mode 100644
index 0000000..8243d93
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.patch
@@ -0,0 +1,90 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Tue, 24 Jul 2012 17:12:30 +0200
+Subject: fix to support LDFLAGS in use_enviroment_flags
+
+---
+ cctbx_sources/libtbx/SConscript | 11 ++++++++++-
+ cctbx_sources/libtbx/env_config.py | 7 ++++++-
+ 2 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 53e1512..7d51d4a 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -777,11 +777,15 @@ else:
+ # user options for any compiler from the environment variables
+ # at the time of configure
+ opts = libtbx.env.build_options
++ env_etc.ldflags_base = []
+ if( opts.use_environment_flags ):
+ print "libtbx.scons: using flags from initial environment: "
+ print " CXXFLAGS = ", opts.env_cxxflags
+ print " CFLAGS = ", opts.env_cflags
+ print " CPPFLAGS = ", opts.env_cppflags
++ print " LDFLAGS = ", opts.env_ldflags
++ flg = opts.env_ldflags.split(" ")
++ env_etc.ldflags_base = flg
+ flg = opts.env_cxxflags.split(" ")
+ if( hasattr(env_etc, "cxxflags_base") ):
+ env_etc.cxxflags_base.extend(flg)
+@@ -853,6 +857,9 @@ def env_base_sync_with_env_etc():
+ SHCFLAGS=env_etc.cflags_base,
+ SHCCFLAGS=env_etc.ccflags_base,
+ SHCXXFLAGS=env_etc.cxxflags_base)
++ env_base.Prepend(LINKFLAGS=env_etc.ldflags_base)
++ env_etc.shlinkflags.extend(env_etc.ldflags_base)
++ env_etc.shlinkflags_bpl.extend(env_etc.ldflags_base)
+ env_base_sync_with_env_etc()
+
+ if (static_exe):
+@@ -1070,8 +1077,10 @@ def set_libtool(env):
+ # for reference. Otherwise it will be set to 0:0:0
+ env_etc.shobjsuffix_save = env['SHOBJSUFFIX']
+ env_etc.SharedLibBuilder_save = env['BUILDERS']['SharedLibrary']
++ sh_flg = list(env_etc.ldflags_base)
++ sh_flg.extend(['-rpath', env_etc.rpath])
+ env.Replace(
+- SHLINKFLAGS='-rpath ' + env_etc.rpath,
++ SHLINKFLAGS=sh_flg,
+ SHOBJSUFFIX='.lo',
+ SHLIBSUFFIX='.la',
+ )
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 3d9133e..d8fb063 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -1803,6 +1803,7 @@ class build_options:
+ self.env_cxxflags = ""
+ self.env_cflags = ""
+ self.env_cppflags = ""
++ self.env_ldflags = ""
+ flg = os.environ.get("CXXFLAGS")
+ if flg is not None:
+ self.env_cxxflags = flg
+@@ -1812,6 +1813,9 @@ class build_options:
+ flg = os.environ.get("CPPFLAGS")
+ if flg is not None:
+ self.env_cppflags = flg
++ flg = os.environ.get("LDFLAGS")
++ if flg is not None:
++ self.env_ldflags = flg
+
+ def report(self, f=None):
+ if (f is None): f = sys.stdout
+@@ -1843,6 +1847,7 @@ class build_options:
+ print >>f, " CXXFLAGS = ", self.env_cxxflags
+ print >>f, " CFLAGS = ", self.env_cflags
+ print >>f, " CPPFLAGS = ", self.env_cppflags
++ print >>f, " LDFLAGS = ", self.env_ldflags
+
+ class include_registry:
+
+@@ -2000,7 +2005,7 @@ class pre_process_args:
+ action="store_true",
+ default=False,
+ help="add compiler flags from environment variables: CXXFLAGS, CFLAGS,"
+- " CPPFLAGS")
++ " CPPFLAGS, LDFLAGS")
+ parser.option(None, "--force_32bit",
+ action="store_true",
+ default=False,
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch b/sci-libs/cctbx/files/2012.05.08.2305/0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch
new file mode 100644
index 0000000..c3e357e
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch
@@ -0,0 +1,21 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Wed, 25 Jul 2012 01:44:36 +0200
+Subject: Fix to append CPPFLAGS to CXXFLAGS.
+
+---
+ cctbx_sources/libtbx/SConscript | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 7d51d4a..11a7810 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -798,6 +798,8 @@ else:
+ env_etc.ccflags_base = flg
+ flg = opts.env_cppflags.split(" ")
+ env_etc.ccflags_base.extend(flg)
++ # Need to append CPPFLAGS to cxxflags_base too!
++ env_etc.cxxflags_base.extend(flg)
+
+ """ ************************ Custom Builders and Emitters ********************************* """
+
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0016-autogenerate-pkgconfig-files.patch b/sci-libs/cctbx/files/2012.05.08.2305/0016-autogenerate-pkgconfig-files.patch
new file mode 100644
index 0000000..5646197
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0016-autogenerate-pkgconfig-files.patch
@@ -0,0 +1,305 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 6 Aug 2012 13:50:30 +0200
+Subject: autogenerate pkgconfig files
+
+---
+ cctbx_sources/cctbx/SConscript | 7 ++--
+ .../cctbx/sgtbx/direct_space_asu/proto/SConscript | 5 ++-
+ cctbx_sources/iotbx/mtz/SConscript | 6 +++-
+ cctbx_sources/iotbx/pdb/SConscript | 5 ++-
+ cctbx_sources/libtbx/SConscript | 37 +++++++++++++++++++-
+ cctbx_sources/mmtbx/masks/SConscript | 5 ++-
+ cctbx_sources/omptbx/SConscript | 5 ++-
+ cctbx_sources/rstbx/SConscript | 5 ++-
+ cctbx_sources/scitbx/boost_python/SConscript | 5 ++-
+ cctbx_sources/scitbx/minpack/SConscript | 5 ++-
+ cctbx_sources/scitbx/slatec/SConscript | 5 ++-
+ .../smtbx/refinement/constraints/SConscript | 5 ++-
+ cctbx_sources/spotfinder/SConscript | 5 ++-
+ 13 files changed, 86 insertions(+), 14 deletions(-)
+
+diff --git a/cctbx_sources/cctbx/SConscript b/cctbx_sources/cctbx/SConscript
+index 6ce770c..378cb36 100644
+--- a/cctbx_sources/cctbx/SConscript
++++ b/cctbx_sources/cctbx/SConscript
+@@ -96,9 +96,12 @@ lib_cctbx_sources = [
+ ]
+ if (env_etc.static_libraries): builder = envlm.StaticLibrary
+ else: builder = envlm.SharedLibrary
++name='cctbx'
+ builder(
+- target="#lib/cctbx",
+- source=lib_cctbx_sources)
++ target="#lib/"+name,
++ source=lib_cctbx_sources)
++desc='Library for general crystallographic applications'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ SConscript("examples/SConscript")
+
+diff --git a/cctbx_sources/cctbx/sgtbx/direct_space_asu/proto/SConscript b/cctbx_sources/cctbx/sgtbx/direct_space_asu/proto/SConscript
+index 5a5cfbd..4328794 100644
+--- a/cctbx_sources/cctbx/sgtbx/direct_space_asu/proto/SConscript
++++ b/cctbx_sources/cctbx/sgtbx/direct_space_asu/proto/SConscript
+@@ -16,9 +16,12 @@ lib_asu_sources = [
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+
++name='cctbx_sgtbx_asu'
+ builder(
+- target="#lib/cctbx_sgtbx_asu",
++ target="#lib/"+name,
+ source=lib_asu_sources)
++desc='Direct space asymmetric unit class library'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ env = env.Clone()
+ env.Prepend(LIBS=["cctbx_sgtbx_asu"])
+diff --git a/cctbx_sources/iotbx/mtz/SConscript b/cctbx_sources/iotbx/mtz/SConscript
+index cd539e6..f7d22b8 100644
+--- a/cctbx_sources/iotbx/mtz/SConscript
++++ b/cctbx_sources/iotbx/mtz/SConscript
+@@ -9,13 +9,17 @@ env.Append(SHCXXFLAGS=env_etc.ccp4io_defines)
+ env_etc.enable_more_warnings(env=env)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name='iotbx_mtz'
+ builder(
+- target="#lib/iotbx_mtz",
++ target="#lib/"+name,
+ source=[
+ "object.cpp",
+ "crystal.cpp",
+ "dataset.cpp",
+ "column.cpp"])
++desc='Wrapper Library to work with CCP4 MTZ files'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
++
+
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+diff --git a/cctbx_sources/iotbx/pdb/SConscript b/cctbx_sources/iotbx/pdb/SConscript
+index 9b89fe1..8a83058 100644
+--- a/cctbx_sources/iotbx/pdb/SConscript
++++ b/cctbx_sources/iotbx/pdb/SConscript
+@@ -9,8 +9,9 @@ env_etc.include_registry.append(
+ paths=env_etc.iotbx_common_includes)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name='iotbx_pdb'
+ builder(
+- target="#lib/iotbx_pdb",
++ target="#lib/"+name,
+ source=[
+ "hybrid_36_c.c",
+ "hybrid_36_cpp.cpp",
+@@ -25,6 +26,8 @@ builder(
+ "atom_selection.cpp",
+ "input.cpp",
+ "input_write.cpp"])
++desc='Fast comprehensive PDB handling library'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ env = env.Clone()
+ env_etc.include_registry.append(env=env, paths=[env_etc.fable_include])
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 11a7810..1e91202 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -1070,8 +1070,34 @@ env_etc.install_path = os.path.abspath(env_etc.destdir + '/' + env_etc.prefix)
+ env_etc.binpath = os.path.join(env_etc.install_path, 'bin')
+ env_etc.libpath = os.path.abspath(env_etc.install_path + '/' + env_etc.libdir)
+ env_etc.inclpath = os.path.join(env_etc.install_path, 'include')
++env_etc.pkgpath = os.path.join(env_etc.install_path, 'lib/pkgconfig')
+ env_etc.rpath = os.path.abspath(env_etc.prefix + '/' + env_etc.libdir)
+
++def create_pc_file(name, version, desc, requires=None, requires_private=None,
++ conflicts=None, libs_private=None):
++ """ Create pkg-config file. """
++ fpath = '%s/%s.pc'%(abs(libtbx.env.lib_path), name)
++ pc = open(fpath, 'w')
++ pc.write('prefix=%s\n'%env_etc.prefix)
++ pc.write('exec_prefix=${PREFIX}\n')
++ pc.write('libdir=${PREFIX}/%s\n'%env_etc.libdir)
++ pc.write('includedir=${PREFIX}/include\n\n')
++ pc.write('Name: %s\n'%name)
++ pc.write('Description: %s\n'%desc)
++ pc.write('Version: %s\n'%version)
++ if requires != None:
++ pc.write('Requires: %s\n'%requires)
++ if requires_private != None:
++ pc.write('Requires.private: %s\n'%requires_private)
++ if conflicts != None:
++ pc.write('Conflicts: %s\n'%conflicts)
++ pc.write('Libs: -L${libdir} -l%s\n'%name)
++ if libs_private != None:
++ pc.write('Libs.private: %s\n'%libs_private)
++ pc.write('Cflags: -I${includedir}')
++ pc.close()
++env_etc.create_pc_file = create_pc_file
++
+ def set_libtool(env):
+ # Versioning can be provided by appending "-version-info 3:12:1" to SHLINKFLAGS
+ # Please see:
+@@ -1197,6 +1223,11 @@ def create_install_targets():
+ src = os.path.join(src_dir, root, filename)
+ env_base.Install(dest, src)
+ env_base.Alias("install-header", dest)
++ if re.match('^.*\.pc$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.pkgpath, root)
++ src = os.path.join(src_dir, root, filename)
++ env_base.Install(dest, src)
++ env_base.Alias("install-pkgconfig", dest)
+ if src_dir == lib_dir:
+ break
+
+@@ -1204,7 +1235,11 @@ def create_install_targets():
+ dest = env_etc.binpath
+ env_base.Install(dest, Glob('%s/*'%(exe_dev)))
+ env_base.Alias("install-bin", dest)
+- Alias('install', ['install-header', 'install-shlib', 'install-bin'])
++ Alias('install', ['install-header',
++ 'install-shlib',
++ 'install-bin',
++ 'install-pkgconfig',
++ ])
+ os.chdir(cwd)
+
+ if 'install' in COMMAND_LINE_TARGETS:
+diff --git a/cctbx_sources/mmtbx/masks/SConscript b/cctbx_sources/mmtbx/masks/SConscript
+index ef93088..a6187cc 100644
+--- a/cctbx_sources/mmtbx/masks/SConscript
++++ b/cctbx_sources/mmtbx/masks/SConscript
+@@ -13,9 +13,12 @@ lib_sources = [
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+
++name='mmtbx_masks'
+ builder(
+- target="#lib/mmtbx_masks",
++ target="#lib/"+name,
+ source=lib_sources)
++desc='Masks for bulk solvent modelling'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ env = env.Clone()
+ env.Prepend(LIBS=["mmtbx_masks", "iotbx_pdb"])
+diff --git a/cctbx_sources/omptbx/SConscript b/cctbx_sources/omptbx/SConscript
+index 43aac91..76bb923 100644
+--- a/cctbx_sources/omptbx/SConscript
++++ b/cctbx_sources/omptbx/SConscript
+@@ -12,9 +12,12 @@ env_etc.include_registry.append(
+ paths=[env_etc.omptbx_include])
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name='omptbx'
+ builder(
+- target="#lib/omptbx",
++ target="#lib/"+name,
+ source=["stubs.cpp"])
++desc='OpenMP interface for CCTBX'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ if (not env_etc.no_boost_python):
+ Import("env_boost_python_ext")
+diff --git a/cctbx_sources/rstbx/SConscript b/cctbx_sources/rstbx/SConscript
+index e2958a1..6d66476 100644
+--- a/cctbx_sources/rstbx/SConscript
++++ b/cctbx_sources/rstbx/SConscript
+@@ -26,14 +26,17 @@ env_etc.include_registry.append(
+ paths=env_etc.rstbx_common_includes)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name='rstbx'
+ builder(
+- target="#lib/rstbx",
++ target="#lib/"+name,
+ source=["dps_core/dps_core.cpp",
+ "dps_core/directional_fft.cpp",
+ "dps_core/direction.cpp",
+ "diffraction/ewald_sphere.cpp",
+ "diffraction/partial_spot_position_partial_H.cpp"
+ ])
++desc='Library for calculations in reciprocal space'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ if (not env_etc.no_boost_python):
+ Import("env_boost_python_ext")
+diff --git a/cctbx_sources/scitbx/boost_python/SConscript b/cctbx_sources/scitbx/boost_python/SConscript
+index b906eb3..0b81d9a 100644
+--- a/cctbx_sources/scitbx/boost_python/SConscript
++++ b/cctbx_sources/scitbx/boost_python/SConscript
+@@ -19,6 +19,9 @@ lib_scitbx_boost_python_sources = [
+ ]
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name=env_etc.scitbx_boost_python
+ builder(
+- target="#lib/%s"%env_etc.scitbx_boost_python,
++ target="#lib/"+name,
+ source=lib_scitbx_boost_python_sources)
++desc='#TODO'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+diff --git a/cctbx_sources/scitbx/minpack/SConscript b/cctbx_sources/scitbx/minpack/SConscript
+index 7c325cb..ee7509e 100644
+--- a/cctbx_sources/scitbx/minpack/SConscript
++++ b/cctbx_sources/scitbx/minpack/SConscript
+@@ -9,7 +9,10 @@ env_etc.include_registry.append(
+ env.Append(LIBS=env_etc.libm)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+-builder(target='#lib/scitbx_minpack', source=["raw.cpp"])
++name='scitbx_minpack'
++builder(target='#lib/'+name, source=["raw.cpp"])
++desc='C++ port of files in MINPACK'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ if (not env_etc.no_boost_python):
+ Import("env_scitbx_boost_python_ext")
+diff --git a/cctbx_sources/scitbx/slatec/SConscript b/cctbx_sources/scitbx/slatec/SConscript
+index ca9b6da..39e38e1 100644
+--- a/cctbx_sources/scitbx/slatec/SConscript
++++ b/cctbx_sources/scitbx/slatec/SConscript
+@@ -6,4 +6,7 @@ env_etc.enable_more_warnings(env=env)
+ env.Append(LIBS=env_etc.libm)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+-builder(target='#lib/scitbx_slatec', source=["lib_c.c"])
++name='scitbx_slatec'
++builder(target='#lib/'+name, source=["lib_c.c"])
++desc='C port of files in SLATEC'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+diff --git a/cctbx_sources/smtbx/refinement/constraints/SConscript b/cctbx_sources/smtbx/refinement/constraints/SConscript
+index 67d99dc..306d1a4 100644
+--- a/cctbx_sources/smtbx/refinement/constraints/SConscript
++++ b/cctbx_sources/smtbx/refinement/constraints/SConscript
+@@ -4,7 +4,10 @@ env_etc.include_registry.append(env=env,
+ paths=["."] + env_etc.smtbx_common_includes)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+-builder(target="#lib/smtbx_refinement_constraints", source=Glob("*.cpp"))
++name='smtbx_refinement_constraints'
++builder(target="#lib/"+name, source=Glob("*.cpp"))
++desc='Library for small molecule crystallography constraints'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ env_program = env.Clone()
+ env_program.Prepend(LIBS=[ "cctbx", "smtbx_refinement_constraints" ])
+diff --git a/cctbx_sources/spotfinder/SConscript b/cctbx_sources/spotfinder/SConscript
+index 1d73677..a63c6d9 100644
+--- a/cctbx_sources/spotfinder/SConscript
++++ b/cctbx_sources/spotfinder/SConscript
+@@ -46,9 +46,12 @@ lib_spotfinder_sources = [
+
+ if (env_etc.static_libraries): builder = envlm.StaticLibrary
+ else: builder = envlm.SharedLibrary
++name='spotfinder'
+ builder(
+- target="#lib/spotfinder",
++ target="#lib/"+name,
+ source=lib_spotfinder_sources)
++desc='Library for locating Bragg-Spots on x-ray diffraction images'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0017-Fix-to-use-systems-include-path.patch b/sci-libs/cctbx/files/2012.05.08.2305/0017-Fix-to-use-systems-include-path.patch
new file mode 100644
index 0000000..4affc54
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0017-Fix-to-use-systems-include-path.patch
@@ -0,0 +1,128 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Tue, 7 Aug 2012 18:15:43 +0200
+Subject: Fix to use systems include path
+
+---
+ .../cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h | 4 ++--
+ .../cbflib_adaptbx/detectors/boost_python/general_cbf_write.h | 4 ++--
+ cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h | 4 ++--
+ .../cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp | 6 +++---
+ cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp | 4 ++--
+ cctbx_sources/ccp4io_adaptbx/ext.cpp | 2 +-
+ cctbx_sources/iotbx/mtz/ext.cpp | 2 +-
+ cctbx_sources/iotbx/mtz/object.h | 6 +++---
+ 8 files changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h
+index 66677bd..516b319 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h
++++ b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h
+@@ -3,8 +3,8 @@
+ #include <cbflib_adaptbx/detectors/cbf_adaptor.h>
+ #include <cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h>
+ #include <cbflib_adaptbx/detectors/buffer_based_service.h>
+-#include <include/cbf_binary.h>
+-#include <include/cbf_compress.h>
++#include <cbf/cbf_binary.h>
++#include <cbf/cbf_compress.h>
+
+ namespace iotbx {
+ namespace detectors {
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/general_cbf_write.h b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/general_cbf_write.h
+index c6c1afb..f45b4d1 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/general_cbf_write.h
++++ b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/general_cbf_write.h
+@@ -1,8 +1,8 @@
+ #ifndef GENERAL_CBF_WRITE_H
+ #define GENERAL_CBF_WRITE_H
+ #include <cbflib_adaptbx/detectors/cbf_adaptor.h>
+-#include "cbf_binary.h"
+-#include "cbf_compress.h"
++#include "cbf/cbf_binary.h"
++#include "cbf/cbf_compress.h"
+
+ namespace iotbx {
+ namespace detectors {
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h b/cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h
+index b5cc407..3787c7b 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h
++++ b/cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h
+@@ -8,8 +8,8 @@
+ #include <exception>
+ #include <scitbx/array_family/flex_types.h>
+ #include <scitbx/array_family/versa_matrix.h>
+-#include <include/cbf.h>
+-#include <include/cbf_simple.h>
++#include <cbf/cbf.h>
++#include <cbf/cbf_simple.h>
+ #include <cbflib_adaptbx/detectors/basic.h>
+
+ #undef cbf_failnez
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp b/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp
+index 2edbfb5..526556f 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp
++++ b/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp
+@@ -244,9 +244,9 @@ extern "C" {
+ #include <limits.h>
+ #include <ctype.h>
+
+-#include "cbf.h"
+-#include "cbf_file.h"
+-#include "cbf_byte_offset.h"
++#include "cbf/cbf.h"
++#include "cbf/cbf_file.h"
++#include "cbf/cbf_byte_offset.h"
+ #include <cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h>
+
+ /* Changes made in the byte-offset algorithm
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp b/cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp
+index 5f5d9b1..d121530 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp
++++ b/cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp
+@@ -1,5 +1,5 @@
+-#include <include/cbf.h>
+-#include <include/cbf_simple.h>
++#include <cbf/cbf.h>
++#include <cbf/cbf_simple.h>
+ #include <cstdio>
+ #include <string>
+ #include <exception>
+diff --git a/cctbx_sources/ccp4io_adaptbx/ext.cpp b/cctbx_sources/ccp4io_adaptbx/ext.cpp
+index ce21568..e507515 100644
+--- a/cctbx_sources/ccp4io_adaptbx/ext.cpp
++++ b/cctbx_sources/ccp4io_adaptbx/ext.cpp
+@@ -1,5 +1,5 @@
+ #include <boost/python.hpp>
+-#include <mmdb_manager.h>
++#include <mmdb/mmdb_manager.h>
+ #include <ssm_align.h>
+
+ namespace ccp4io_adaptbx { namespace boost_python {
+diff --git a/cctbx_sources/iotbx/mtz/ext.cpp b/cctbx_sources/iotbx/mtz/ext.cpp
+index b1a0db7..6aa416a 100644
+--- a/cctbx_sources/iotbx/mtz/ext.cpp
++++ b/cctbx_sources/iotbx/mtz/ext.cpp
+@@ -1,5 +1,5 @@
+ #include <boost/python/module.hpp>
+-#include <ccp4_errno.h>
++#include <ccp4/ccp4_errno.h>
+
+ namespace iotbx { namespace mtz { namespace boost_python {
+
+diff --git a/cctbx_sources/iotbx/mtz/object.h b/cctbx_sources/iotbx/mtz/object.h
+index da35fcf..b593534 100644
+--- a/cctbx_sources/iotbx/mtz/object.h
++++ b/cctbx_sources/iotbx/mtz/object.h
+@@ -6,9 +6,9 @@
+ # include <math.h>
+ #endif
+
+-#include <cmtzlib.h>
+-#include <ccp4_array.h>
+-#include <ccp4_errno.h>
++#include <ccp4/cmtzlib.h>
++#include <ccp4/ccp4_array.h>
++#include <ccp4/ccp4_errno.h>
+ #include <cctbx/sgtbx/space_group.h>
+ #include <cctbx/hendrickson_lattman.h>
+ #include <boost/shared_ptr.hpp>
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0018-Fix-to-skip-build-of-clipper-examples.patch b/sci-libs/cctbx/files/2012.05.08.2305/0018-Fix-to-skip-build-of-clipper-examples.patch
new file mode 100644
index 0000000..ffd4ebb
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0018-Fix-to-skip-build-of-clipper-examples.patch
@@ -0,0 +1,52 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Tue, 7 Aug 2012 18:19:02 +0200
+Subject: Fix to skip build of clipper examples
+
+---
+ cctbx_sources/clipper_adaptbx/SConscript | 33 +++++++++++++++---------------
+ 1 file changed, 17 insertions(+), 16 deletions(-)
+
+diff --git a/cctbx_sources/clipper_adaptbx/SConscript b/cctbx_sources/clipper_adaptbx/SConscript
+index c39047f..b0699ad 100644
+--- a/cctbx_sources/clipper_adaptbx/SConscript
++++ b/cctbx_sources/clipper_adaptbx/SConscript
+@@ -61,22 +61,23 @@ else:
+ env_exe = env.Clone()
+ env_exe.Prepend(LIBS=[env_etc.clipper_libs[0]])
+
+-exe = env_exe.Program(
+- target='#exe_dev/'+env["PROGPREFIX"]+'clipper.symtest'
+- +env["PROGSUFFIX"],
+- source = ["../clipper/examples/symtest.cpp",
+- ])
+-libtbx.env.write_dispatcher_in_bin(
+- source_file=exe[0].get_abspath(),
+- target_file="clipper.symtest")
+-exe = env_exe.Program(
+- target='#exe_dev/'+env["PROGPREFIX"]+'clipper.sanity_check'
+- +env["PROGSUFFIX"],
+- source = ["sanity_check.cpp",
+- ])
+-libtbx.env.write_dispatcher_in_bin(
+- source_file=exe[0].get_abspath(),
+- target_file="clipper.sanity_check")
++# Skip building clipper examples in Debian
++#exe = env_exe.Program(
++# target='#exe_dev/'+env["PROGPREFIX"]+'clipper.symtest'
++# +env["PROGSUFFIX"],
++# source = ["../clipper/examples/symtest.cpp",
++# ])
++#libtbx.env.write_dispatcher_in_bin(
++# source_file=exe[0].get_abspath(),
++# target_file="clipper.symtest")
++#exe = env_exe.Program(
++# target='#exe_dev/'+env["PROGPREFIX"]+'clipper.sanity_check'
++# +env["PROGSUFFIX"],
++# source = ["sanity_check.cpp",
++# ])
++#libtbx.env.write_dispatcher_in_bin(
++# source_file=exe[0].get_abspath(),
++# target_file="clipper.sanity_check")
+
+ if (hasattr(env_etc, "cctbx_include")):
+ if (not env_etc.no_boost_python):
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0101-system-cbf.patch b/sci-libs/cctbx/files/2012.05.08.2305/0101-system-cbf.patch
new file mode 100644
index 0000000..1688026
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0101-system-cbf.patch
@@ -0,0 +1,16 @@
+ cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h b/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h
+index 0089325..02234d1 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h
++++ b/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h
+@@ -5,7 +5,7 @@
+ extern "C" {
+ #endif
+ #include <stdio.h>
+-#include <include/cbf_file.h>
++#include <cbf/cbf_file.h>
+
+ /* Decompress an array with the byte-offset algorithm */
+
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0101-system-clipper.patch b/sci-libs/cctbx/files/2012.05.08.2305/0101-system-clipper.patch
new file mode 100644
index 0000000..6f50e5f
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0101-system-clipper.patch
@@ -0,0 +1,185 @@
+ cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h | 2 +-
+ cctbx_sources/clipper/clipper/contrib/Makefile.dep | 14 +++++++-------
+ cctbx_sources/clipper/clipper/contrib/edcalc.cpp | 2 +-
+ cctbx_sources/clipper/clipper/contrib/fffear.cpp | 2 +-
+ .../clipper/clipper/contrib/function_object_bases.h | 6 +++---
+ cctbx_sources/clipper/clipper/contrib/sfcalc.cpp | 2 +-
+ cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp | 4 ++--
+ cctbx_sources/clipper/clipper/contrib/sfweight.cpp | 4 ++--
+ cctbx_sources/clipper/clipper/contrib/skeleton.cpp | 2 +-
+ cctbx_sources/clipper_adaptbx/clipper/SConscript | 1 -
+ 10 files changed, 19 insertions(+), 20 deletions(-)
+
+diff --git a/cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h b/cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h
+index bd9f7d2..079958d 100644
+--- a/cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h
++++ b/cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h
+@@ -47,7 +47,7 @@
+ #define CLIPPER_CCTBX
+
+
+-#include "../core/hkl_datatypes.h"
++#include "clipper/core/hkl_datatypes.h"
+
+ #include <cctbx/sgtbx/space_group.h>
+ #include <cctbx/hendrickson_lattman.h>
+diff --git a/cctbx_sources/clipper/clipper/contrib/Makefile.dep b/cctbx_sources/clipper/clipper/contrib/Makefile.dep
+index 98251b1..0fe7bb3 100644
+--- a/cctbx_sources/clipper/clipper/contrib/Makefile.dep
++++ b/cctbx_sources/clipper/clipper/contrib/Makefile.dep
+@@ -1,27 +1,27 @@
+
+-function_object_bases.h: ../core/hkl_datatypes.h ../core/xmap.h ../core/nxmap_operator.h
++function_object_bases.h: clipper/core/hkl_datatypes.h clipper/core/xmap.h clipper/core/nxmap_operator.h
+
+ function_object_bases.o: function_object_bases.cpp function_object_bases.h
+
+ sfcalc.h: function_object_bases.h
+
+-sfcalc.o: sfcalc.cpp sfcalc.h ../core/atomsf.h
++sfcalc.o: sfcalc.cpp sfcalc.h clipper/core/atomsf.h
+
+ edcalc.h: function_object_bases.h
+
+-edcalc.o: edcalc.cpp edcalc.h ../core/atomsf.h
++edcalc.o: edcalc.cpp edcalc.h clipper/core/atomsf.h
+
+ sfcalc_obs.h: function_object_bases.h
+
+-sfcalc_obs.o: sfcalc_obs.cpp sfcalc_obs.h edcalc.h ../core/hkl_compute.h ../core/resol_targetfn.h
++sfcalc_obs.o: sfcalc_obs.cpp sfcalc_obs.h edcalc.h clipper/core/hkl_compute.h clipper/core/resol_targetfn.h
+
+ sfweight.h: function_object_bases.h
+
+-sfweight.o: sfweight.cpp sfweight.h ../core/hkl_operators.h ../core/resol_targetfn.h
++sfweight.o: sfweight.cpp sfweight.h clipper/core/hkl_operators.h clipper/core/resol_targetfn.h
+
+ fffear.h: function_object_bases.h
+
+-fffear.o: fffear.cpp fffear.h ../core/map_interp.h
++fffear.o: fffear.cpp fffear.h clipper/core/map_interp.h
+
+ mapfilter.h: function_object_bases.h
+
+@@ -29,7 +29,7 @@ mapfilter.o: mapfilter.cpp mapfilter.h
+
+ skeleton.h: function_object_bases.h
+
+-skeleton.o: skeleton.cpp skeleton.h ../core/map_utils.h
++skeleton.o: skeleton.cpp skeleton.h clipper/core/map_utils.h
+
+ originmatch.h: function_object_bases.h
+
+diff --git a/cctbx_sources/clipper/clipper/contrib/edcalc.cpp b/cctbx_sources/clipper/clipper/contrib/edcalc.cpp
+index f5df7b2..cc031bc 100644
+--- a/cctbx_sources/clipper/clipper/contrib/edcalc.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/edcalc.cpp
+@@ -43,7 +43,7 @@
+
+ #include "edcalc.h"
+
+-#include "../core/atomsf.h"
++#include "clipper/core/atomsf.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/fffear.cpp b/cctbx_sources/clipper/clipper/contrib/fffear.cpp
+index 9a728f7..189855a 100644
+--- a/cctbx_sources/clipper/clipper/contrib/fffear.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/fffear.cpp
+@@ -42,7 +42,7 @@
+
+ #include "fffear.h"
+
+-#include "../core/map_interp.h"
++#include "clipper/core/map_interp.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/function_object_bases.h b/cctbx_sources/clipper/clipper/contrib/function_object_bases.h
+index e6c98c7..4a40c73 100644
+--- a/cctbx_sources/clipper/clipper/contrib/function_object_bases.h
++++ b/cctbx_sources/clipper/clipper/contrib/function_object_bases.h
+@@ -48,9 +48,9 @@
+ #define CLIPPER_FUNCTION_OBJECT_BASES
+
+
+-#include "../core/hkl_datatypes.h"
+-#include "../core/xmap.h"
+-#include "../core/nxmap_operator.h"
++#include "clipper/core/hkl_datatypes.h"
++#include "clipper/core/xmap.h"
++#include "clipper/core/nxmap_operator.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/sfcalc.cpp b/cctbx_sources/clipper/clipper/contrib/sfcalc.cpp
+index 48c0d9c..a3c63f0 100644
+--- a/cctbx_sources/clipper/clipper/contrib/sfcalc.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/sfcalc.cpp
+@@ -43,7 +43,7 @@
+
+ #include "sfcalc.h"
+
+-#include "../core/atomsf.h"
++#include "clipper/core/atomsf.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp b/cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp
+old mode 100755
+new mode 100644
+index de47e09..0f67585
+--- a/cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp
+@@ -43,8 +43,8 @@
+
+ #include "sfcalc_obs.h"
+ #include "edcalc.h"
+-#include "../core/hkl_compute.h"
+-#include "../core/resol_targetfn.h"
++#include "clipper/core/hkl_compute.h"
++#include "clipper/core/resol_targetfn.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/sfweight.cpp b/cctbx_sources/clipper/clipper/contrib/sfweight.cpp
+old mode 100755
+new mode 100644
+index 1b2d4dc..6ec98c2
+--- a/cctbx_sources/clipper/clipper/contrib/sfweight.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/sfweight.cpp
+@@ -42,8 +42,8 @@
+
+
+ #include "sfweight.h"
+-#include "../core/hkl_operators.h"
+-#include "../core/resol_targetfn.h"
++#include "clipper/core/hkl_operators.h"
++#include "clipper/core/resol_targetfn.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/skeleton.cpp b/cctbx_sources/clipper/clipper/contrib/skeleton.cpp
+index bff1049..14ebf55 100644
+--- a/cctbx_sources/clipper/clipper/contrib/skeleton.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/skeleton.cpp
+@@ -42,7 +42,7 @@
+
+ #include "skeleton.h"
+
+-#include "../core/map_utils.h"
++#include "clipper/core/map_utils.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper_adaptbx/clipper/SConscript b/cctbx_sources/clipper_adaptbx/clipper/SConscript
+index 1911eb1..df03808 100644
+--- a/cctbx_sources/clipper_adaptbx/clipper/SConscript
++++ b/cctbx_sources/clipper_adaptbx/clipper/SConscript
+@@ -11,5 +11,4 @@ env.SharedLibrary(
+ "clipper_ext.cpp",
+ "hendrickson_lattman_bpl.cpp",
+ "sigmaa_bpl.cpp",
+- "../../clipper/clipper/contrib/sfweight.cpp",
+ "../../clipper/clipper/cctbx/clipper_cctbx.cpp"]+clipper_contrib_files)
diff --git a/sci-libs/cctbx/files/2012.05.08.2305/0102-dontstrip.patch b/sci-libs/cctbx/files/2012.05.08.2305/0102-dontstrip.patch
new file mode 100644
index 0000000..08118f4
--- /dev/null
+++ b/sci-libs/cctbx/files/2012.05.08.2305/0102-dontstrip.patch
@@ -0,0 +1,25 @@
+ cctbx_sources/libtbx/SConscript | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index debf569..46ab8d8 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -471,7 +471,7 @@ libtbx.scons: Warning: compiling with /MDd:
+ elif libtbx.env.build_options.debug_symbols:
+ lkfl = ["-rdynamic"]
+ else:
+- lkfl = ["-s"]
++ lkfl = []
+ env_etc.shlinkflags = ["-shared"]
+ if (libtbx.env.build_options.mode == "profile"):
+ env_base.Prepend(LINKFLAGS=["-pg"])
+@@ -589,7 +589,7 @@ else:
+ lkfl = ["-rdynamic"]
+
+ else:
+- lkfl = ["-s"]
++ lkfl = []
+ env_etc.shlinkflags = ["-shared"]
+ if (libtbx.env.build_options.mode == "profile"):
+ env_base.Prepend(LINKFLAGS=["-pg"])
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0001-remove-hardcoded-libtbx_build-env.patch b/sci-libs/cctbx/files/2013.02.27.0005/0001-remove-hardcoded-libtbx_build-env.patch
new file mode 100644
index 0000000..14d3f09
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0001-remove-hardcoded-libtbx_build-env.patch
@@ -0,0 +1,24 @@
+From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca@debian.org>
+Date: Sat, 30 Jun 2012 15:50:22 +0200
+Subject: remove-hardcoded-libtbx_build-env
+
+---
+ cctbx_sources/libtbx/env_config.py | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 9c01e0f..8a62446 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -2147,7 +2147,10 @@ def cold_start(args):
+ env.refresh()
+
+ def unpickle():
+- build_path = os.environ["LIBTBX_BUILD"]
++ if os.environ.has_key("LIBTBX_BUILD"):
++ build_path = os.environ["LIBTBX_BUILD"]
++ else:
++ build_path = "/usr/share/cctbx/python%d.%d"%(sys.version_info[:2])
+ set_preferred_sys_prefix_and_sys_executable(build_path=build_path)
+ libtbx_env = open(op.join(build_path, "libtbx_env"), "rb")
+ env = pickle.load(libtbx_env)
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0002-fix-opengl-header-missing-gltbx.patch b/sci-libs/cctbx/files/2013.02.27.0005/0002-fix-opengl-header-missing-gltbx.patch
new file mode 100644
index 0000000..d3684a5
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0002-fix-opengl-header-missing-gltbx.patch
@@ -0,0 +1,51 @@
+From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca@debian.org>
+Date: Sat, 30 Jun 2012 15:51:06 +0200
+Subject: fix-opengl-header-missing-gltbx
+
+---
+ cctbx_sources/gltbx/SConscript | 32 ++++++++++++++++----------------
+ 1 file changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/cctbx_sources/gltbx/SConscript b/cctbx_sources/gltbx/SConscript
+index d02e7a5..4b2213d 100644
+--- a/cctbx_sources/gltbx/SConscript
++++ b/cctbx_sources/gltbx/SConscript
+@@ -45,22 +45,22 @@ if (not env_etc.no_boost_python):
+ env=env,
+ paths=env_etc.gltbx_common_includes + [env_etc.python_include])
+ #
+- env_etc.gltbx_has_usable_opengl = False
+- conf = trial_env.Configure()
+- flag, output = conf.TryRun("""
+-#include <gltbx/include_opengl.h>
+-#include <iostream>
+-int main() { std::cout << GL_POINT << std::endl; return 0; }
+-""", extension=".cpp")
+- conf.Finish()
+- if (flag and len(output.strip()) != 0):
+- conf = env.Configure()
+- if (conf.TryCompile("""
+-#include <gltbx/include_opengl.h>
+-""", extension=".cpp")):
+- env_etc.gltbx_has_usable_opengl = True
+- conf.Finish()
+- #
++ env_etc.gltbx_has_usable_opengl = True
++# conf = trial_env.Configure()
++# flag, output = conf.TryRun("""
++##include <gltbx/include_opengl.h>
++##include <iostream>
++#int main() { std::cout << GL_POINT << std::endl; return 0; }
++#""", extension=".cpp")
++# conf.Finish()
++# if (flag and len(output.strip()) != 0):
++# conf = env.Configure()
++# if (conf.TryCompile("""
++##include <gltbx/include_opengl.h>
++#""", extension=".cpp")):
++# env_etc.gltbx_has_usable_opengl = True
++# conf.Finish()
++# #
+ if (not env_etc.gltbx_has_usable_opengl):
+ print "gltbx: OpenGL headers and/or libraries not available."
+ print "gltbx: Compilation skipped."
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0003-correct-paths-in-dispatcher-creation.patch b/sci-libs/cctbx/files/2013.02.27.0005/0003-correct-paths-in-dispatcher-creation.patch
new file mode 100644
index 0000000..8d3a3c2
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0003-correct-paths-in-dispatcher-creation.patch
@@ -0,0 +1,86 @@
+From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= <picca@debian.org>
+Date: Sat, 30 Jun 2012 16:01:20 +0200
+Subject: correct-paths-in-dispatcher-creation
+
+---
+ cctbx_sources/libtbx/env_config.py | 48 +++++++++++++++++++-------------------
+ 1 file changed, 24 insertions(+), 24 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 8a62446..c3e1c7d 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -932,27 +932,27 @@ Wait for the command to finish, then try again.""" % vars())
+ print >> f, '# command at the end.'
+ print >> f, '#'
+ write_do_not_edit(f=f)
+- print >> f, '# To customize this auto-generated script create'
++ #print >> f, '# To customize this auto-generated script create'
+ print >> f, '#'
+- print >> f, '# dispatcher_include*.sh'
++ #print >> f, '# dispatcher_include*.sh'
+ print >> f, '#'
+- print >> f, '# files in %s and run' % show_string(abs(self.build_path))
++ #print >> f, '# files in %s and run' % show_string(abs(self.build_path))
+ print >> f, '#'
+- print >> f, '# libtbx.refresh'
++ #print >> f, '# libtbx.refresh'
+ print >> f, '#'
+ print >> f, '# to re-generate the dispatchers (libtbx.refresh is a subset'
+ print >> f, '# of the functionality of the libtbx/configure.py command).'
+ print >> f, '#'
+- print >> f, '# See also:'
+- print >> f, '# %s' \
+- % show_string(self.under_build("dispatcher_include_template.sh"))
++ #print >> f, '# See also:'
++ #print >> f, '# %s' \
++ # % show_string(self.under_build("dispatcher_include_template.sh"))
+ print >> f, '#'
+ print >> f, _SHELLREALPATH_CODE
+ print >> f, 'unset PYTHONHOME'
+ print >> f, 'LC_ALL=C'
+ print >> f, 'export LC_ALL'
+- print >> f, 'LIBTBX_BUILD="$(shellrealpath "$0" && cd "$(dirname "$RESULT")/.." && pwd)"'
+- print >> f, 'export LIBTBX_BUILD'
++ #print >> f, 'LIBTBX_BUILD="$(shellrealpath "$0" && cd "$(dirname "$RESULT")/.." && pwd)"'
++ #print >> f, 'export LIBTBX_BUILD'
+ print >> f, 'LIBTBX_PYEXE_BASENAME="%s"' % self.python_exe.basename()
+ print >> f, 'export LIBTBX_PYEXE_BASENAME'
+ source_is_py = False
+@@ -969,21 +969,21 @@ Wait for the command to finish, then try again.""" % vars())
+ source_is_py = True
+ for line in self.dispatcher_include(where="at_start"):
+ print >> f, line
+- essentials = [("PYTHONPATH", self.pythonpath)]
+- essentials.append((
+- ld_library_path_var_name(),
+- self.ld_library_path_additions()))
+- essentials.append(("PATH", [self.bin_path]))
+- for n,v in essentials:
+- if (len(v) == 0): continue
+- v = ":".join([p.sh_value() for p in v])
+- print >> f, 'if [ -n "$%s" ]; then' % n
+- print >> f, ' %s="%s:$%s"' % (n, v, n)
+- print >> f, ' export %s' % n
+- print >> f, 'else'
+- print >> f, ' %s="%s"' % (n, v)
+- print >> f, ' export %s' % n
+- print >> f, 'fi'
++ # essentials = [("PYTHONPATH", self.pythonpath)]
++ # essentials.append((
++ # ld_library_path_var_name(),
++ # self.ld_library_path_additions()))
++ # essentials.append(("PATH", [self.bin_path]))
++ # for n,v in essentials:
++ # if (len(v) == 0): continue
++ # v = ":".join([p.sh_value() for p in v])
++ # print >> f, 'if [ -n "$%s" ]; then' % n
++ # print >> f, ' %s="%s:$%s"' % (n, v, n)
++ # print >> f, ' export %s' % n
++ # print >> f, 'else'
++ # print >> f, ' %s="%s"' % (n, v)
++ # print >> f, ' export %s' % n
++ # print >> f, 'fi'
+ precall_commands = self.dispatcher_precall_commands()
+ if (precall_commands is not None):
+ for line in precall_commands:
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0006-options-for-system-libs-installtarget-and-prefix.patch b/sci-libs/cctbx/files/2013.02.27.0005/0006-options-for-system-libs-installtarget-and-prefix.patch
new file mode 100644
index 0000000..861d6bc
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0006-options-for-system-libs-installtarget-and-prefix.patch
@@ -0,0 +1,1099 @@
+ cctbx_sources/boost_adaptbx/SConscript | 19 +-
+ cctbx_sources/cbflib_adaptbx/SConscript | 89 +++---
+ .../detectors/boost_python/SConscript | 4 +-
+ cctbx_sources/ccp4io_adaptbx/SConscript | 303 +++++++++++----------
+ cctbx_sources/cctbx/SConscript | 2 +-
+ cctbx_sources/clipper_adaptbx/SConscript | 94 ++++---
+ cctbx_sources/clipper_adaptbx/clipper/SConscript | 10 +-
+ cctbx_sources/gltbx/SConscript | 20 +-
+ cctbx_sources/iotbx/cif/boost_python/SConscript | 13 +-
+ cctbx_sources/iotbx/mtz/SConscript | 3 +-
+ cctbx_sources/iotbx/pdb/SConscript | 2 +-
+ cctbx_sources/libtbx/SConscript | 84 ++++++
+ cctbx_sources/libtbx/env_config.py | 34 +++
+ cctbx_sources/mmtbx/cablam/SConscript | 2 +-
+ cctbx_sources/mmtbx/den/SConscript | 2 +-
+ cctbx_sources/mmtbx/geometry_restraints/SConscript | 2 +-
+ cctbx_sources/mmtbx/secondary_structure/SConscript | 2 +-
+ cctbx_sources/rstbx/SConscript | 2 +-
+ cctbx_sources/scitbx/SConscript | 2 +-
+ cctbx_sources/scitbx/boost_python/SConscript | 4 +-
+ .../smtbx/refinement/boost_python/SConscript | 4 +-
+ .../refinement/constraints/boost_python/SConscript | 4 +-
+ cctbx_sources/spotfinder/SConscript | 2 +-
+ cctbx_sources/xfel/SConscript | 2 +-
+ 24 files changed, 443 insertions(+), 262 deletions(-)
+
+diff --git a/cctbx_sources/boost_adaptbx/SConscript b/cctbx_sources/boost_adaptbx/SConscript
+index e4d5994..7f96c04 100644
+--- a/cctbx_sources/boost_adaptbx/SConscript
++++ b/cctbx_sources/boost_adaptbx/SConscript
+@@ -9,7 +9,13 @@ import sys, os
+ op = os.path
+ Import("env_base", "env_etc")
+ env_etc.boost_dist = libtbx.env.dist_path("boost")
+-env_etc.boost_include = env_etc.boost_dist
++if not env_etc.check_syslib(env_etc.boost_python, extra_libs=env_etc.py_lib)\
++ or not env_etc.check_syslib('boost_thread'):
++ env_etc.boost_include = env_etc.boost_dist
++else:
++ # This way the compiler looks in the standard location for includes
++ # should work on all platforms.
++ env_etc.boost_include = ''
+ env_etc.boost_adaptbx_dist = libtbx.env.dist_path("boost_adaptbx")
+ env_etc.boost_adaptbx_include = os.path.dirname(env_etc.boost_adaptbx_dist)
+
+@@ -28,7 +34,7 @@ if (not env_etc.no_boost_python):
+ env_no_includes_boost_python_ext = env_base.Clone(
+ SHLINKFLAGS=env_etc.shlinkflags_bpl,
+ SHLIBPREFIX="",
+- LIBS=["boost_python"] + env_etc.libs_python + env_etc.libm)
++ LIBS=[env_etc.boost_python] + env_etc.libs_python + env_etc.libm)
+ env_no_includes_boost_python_ext.Append(
+ LIBPATH=env_etc.libpath_python)
+ env_no_includes_boost_python_ext.Append(
+@@ -215,10 +221,11 @@ object/function_doc_signature.cpp
+ bpl_dll_sources = [os.path.join(prefix, path) for path in bpl_dll_sources]
+ #
+ env.Repository(os.path.dirname(env_etc.boost_dist))
+- if (env_etc.static_bpl):
+- env.StaticLibrary(target="#lib/boost_python", source=bpl_dll_sources)
+- else:
+- env.SharedLibrary(target="#lib/boost_python", source=bpl_dll_sources)
++ if not env_etc.check_syslib(env_etc.boost_python, extra_libs=env_etc.py_lib):
++ if (env_etc.static_bpl):
++ env.StaticLibrary(target="#lib/boost_python", source=bpl_dll_sources)
++ else:
++ env.SharedLibrary(target="#lib/boost_python", source=bpl_dll_sources)
+ if (bool(int(ARGUMENTS.get("boost_python_tests", "0")))):
+ warn_if_unexpected_md5_hexdigest(
+ path=libtbx.env.under_dist("boost", "libs/python/test/Jamfile.v2"),
+diff --git a/cctbx_sources/cbflib_adaptbx/SConscript b/cctbx_sources/cbflib_adaptbx/SConscript
+index 4ac6717..334cfc2 100644
+--- a/cctbx_sources/cbflib_adaptbx/SConscript
++++ b/cctbx_sources/cbflib_adaptbx/SConscript
+@@ -3,9 +3,14 @@ import os
+ Import("env_base","env_etc")
+
+ env_etc.cbflib_dist = libtbx.env.dist_path("cbflib")
+-env_etc.cbflib_include = [env_etc.norm_join(env_etc.cbflib_dist,"examples"),
+- env_etc.norm_join(env_etc.cbflib_dist,"include"),
+- ]
++if not env_etc.check_syslib('cbf'):
++ env_etc.cbflib_include = [env_etc.norm_join(env_etc.cbflib_dist,"examples"),
++ env_etc.norm_join(env_etc.cbflib_dist,"include"),
++ ]
++else:
++ env_etc.cbflib_include = [env_etc.norm_join(env_etc.cbflib_dist,"examples"),
++ "",
++ ]
+ env_etc.cbflib_adaptbx_dist = libtbx.env.dist_path("cbflib_adaptbx")
+
+ env_etc.cbflib_common_includes = [
+@@ -34,39 +39,47 @@ cbflib_092_forward = []
+ if os.path.isfile( os.path.join(env_etc.cbflib_dist,"src","cbf_ws.c") ):
+ cbflib_092_forward.append("src/cbf_ws.c")
+
+-env.StaticLibrary(target='#lib/cbf',
+- source = [prefix+"/"+s for s in [
+- "examples/img.c",
+- "src/cbf.c",
+- "src/cbf_alloc.c",
+- "src/cbf_ascii.c",
+- "src/cbf_binary.c",
+- "src/cbf_byte_offset.c",
+- "src/cbf_canonical.c",
+- "src/cbf_codes.c",
+- "src/cbf_compress.c",
+- "src/cbf_context.c",
+- "src/cbf_file.c",
+- "src/cbf_lex.c",
+- "src/cbf_packed.c",
+- "src/cbf_predictor.c",
+- "src/cbf_read_binary.c",
+- "src/cbf_read_mime.c",
+- "src/cbf_simple.c",
+- "src/cbf_string.c",
+- "src/cbf_stx.c",
+- "src/cbf_tree.c",
+- "src/cbf_uncompressed.c",
+- "src/cbf_write.c",
+- "src/cbf_write_binary.c",
+- "src/md5c.c",
+- ] + cbflib_092_forward ] + [
+- "detectors/mar_adaptor.cpp",
+- "detectors/cbf_adaptor.cpp",
+- "detectors/cbf_byte_offset_optimized.cpp",
+- "detectors/buffer_based_service.cpp",
+- ],
+- CPPPATH=env_etc.cbflib_common_includes )
++cbflib_src = ["src/cbf.c",
++ "src/cbf_alloc.c",
++ "src/cbf_ascii.c",
++ "src/cbf_binary.c",
++ "src/cbf_byte_offset.c",
++ "src/cbf_canonical.c",
++ "src/cbf_codes.c",
++ "src/cbf_compress.c",
++ "src/cbf_context.c",
++ "src/cbf_file.c",
++ "src/cbf_lex.c",
++ "src/cbf_packed.c",
++ "src/cbf_predictor.c",
++ "src/cbf_read_binary.c",
++ "src/cbf_read_mime.c",
++ "src/cbf_simple.c",
++ "src/cbf_string.c",
++ "src/cbf_stx.c",
++ "src/cbf_tree.c",
++ "src/cbf_uncompressed.c",
++ "src/cbf_write.c",
++ "src/cbf_write_binary.c",
++ "src/md5c.c",
++ ]
++adaptor_src = ["detectors/mar_adaptor.cpp",
++ "detectors/cbf_adaptor.cpp",
++ "detectors/cbf_byte_offset_optimized.cpp",
++ "detectors/buffer_based_service.cpp",
++ ]
++if not env_etc.check_syslib('cbf'):
++ env.StaticLibrary(target='#lib/cbf',
++ source = [prefix+"/"+s for s in [
++ "examples/img.c"] + cbflib_src + cbflib_092_forward] + adaptor_src,
++ CPPPATH=env_etc.cbflib_common_includes )
++ env_etc.cbf_lib = ['cbf',]
++else:
++ env.StaticLibrary(target='#lib/cbf_adaptor',
++ source = [prefix+"/"+s for s in [
++ "examples/img.c"]] + adaptor_src,
++ CPPPATH=env_etc.cbflib_common_includes )
++ env_etc.cbf_lib = ['cbf','cbf_adaptor']
+
+ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
+@@ -80,7 +93,7 @@ if (not env_etc.no_boost_python):
+ env_cbflib_boost_python_ext.SharedLibrary(
+ target='#lib/_pycbf',
+ source=[prefix+"/pycbf/pycbf_wrap.c"],
+- LIBS=["cbf"]+env_etc.libs_python+env_etc.libm)
++ LIBS=env_etc.cbf_lib+env_etc.libs_python+env_etc.libm)
+
+ Export("env_cbflib_boost_python_ext")
+
+@@ -89,7 +102,7 @@ if (not env_etc.no_boost_python):
+ env_standalone = env.Clone(
+ LIBS = [env_etc.libm,],CPPPATH=env_etc.cbflib_common_includes
+ )
+-env_standalone.Prepend(LIBS=["cbf",])
++env_standalone.Prepend(LIBS=env_etc.cbf_lib)
+
+ for source in ["detectors/tst_memory",]:
+ target = "cbflib."+os.path.basename(source)
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/SConscript b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/SConscript
+index 2027439..8e987cc 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/SConscript
++++ b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/SConscript
+@@ -1,6 +1,6 @@
+-Import("env_cbflib_boost_python_ext")
++Import("env_cbflib_boost_python_ext", "env_etc")
+ env = env_cbflib_boost_python_ext.Clone()
+-env.Prepend(LIBS=["cbf",])
++env.Prepend(LIBS=env_etc.cbf_lib)
+ env.SharedLibrary(
+ target="#lib/cbflib_ext",
+ source=["cbflib_ext.cpp",])
+diff --git a/cctbx_sources/ccp4io_adaptbx/SConscript b/cctbx_sources/ccp4io_adaptbx/SConscript
+index 0356403..856115a 100644
+--- a/cctbx_sources/ccp4io_adaptbx/SConscript
++++ b/cctbx_sources/ccp4io_adaptbx/SConscript
+@@ -43,122 +43,167 @@ else:
+ # clean out after completely removing support for
+ # old CCP4 directory structure above
+
+-build_ccp4io_adaptbx = libtbx.env.under_build("ccp4io_adaptbx")
+-if (not op.isdir(build_ccp4io_adaptbx)):
+- os.mkdir(build_ccp4io_adaptbx)
+- assert op.isdir(build_ccp4io_adaptbx)
+-
+-def replace_printf(file_name):
+- full_path = op.join(path_lib_src, file_name)
+- if (not op.isfile(full_path)):
+- full_path = op.join(op.dirname(path_lib_src), "fortran", file_name)
+- result = ["#include <ccp4io_adaptbx/printf_wrappers.h>"]
+- for line in open(full_path).read().splitlines():
+- for key in ["printf", "fprintf"]:
+- matches = list(re.finditer(
+- pattern="[^A-Za-z0-9_]%s[^A-Za-z0-9_]" % key, string=line))
+- if (len(matches) != 0):
+- for m in reversed(matches):
+- s,e = m.start(), m.end()
+- line = line[:s] \
+- + line[s:e].replace(key, "ccp4io_%s" % key) \
+- + line[e:]
+- result.append(line)
+- return "\n".join(result)
+-
+-env = env_base.Clone(
+- SHLINKFLAGS=env_etc.shlinkflags)
+-env.Append(CCFLAGS=env_etc.ccp4io_defines)
+-env.Append(SHCCFLAGS=env_etc.ccp4io_defines)
+-env_etc.include_registry.append(
+- env=env,
+- paths=[
+- "#",
+- op.dirname(env_etc.ccp4io_include),
+- env_etc.ccp4io_include,
+- op.join(env_etc.ccp4io_dist, "lib", mmdb_src),
+- op.join(env_etc.ccp4io_dist, "lib", mmdb_src, "mmdb")])
+-env.Append(LIBS=env_etc.libm)
+-# XXX 2012-06-16: is this actually necessary here, or just in code that links to
+-# ccp4io.lib?
+-if (os.name == "nt") :
+- env.Prepend(LIBS=["Advapi32"])
+-if ( op.normcase(op.dirname(env_etc.ccp4io_dist))
+- != op.normcase("ccp4io")):
+- env.Repository(op.dirname(env_etc.ccp4io_dist))
+ source = []
+-
+ c_files = []
+-c_files.extend(["%s/%s" % (ccp4_src, bn ) for bn in """\
+-library_err.c
+-library_file.c
+-library_utils.c
+-ccp4_array.c
+-ccp4_parser.c
+-ccp4_unitcell.c
+-cvecmat.c
+-cmtzlib.c
+-""".splitlines()])
+-open(op.join(build_ccp4io_adaptbx, "csymlib.c"), "w").write(
+- open(op.join(path_lib_src, "csymlib.c")).read()
+- .replace(
+- "static int reported_syminfo = 0",
+- "static int reported_syminfo = 1"))
+-source.append(op.join("#ccp4io_adaptbx", "csymlib.c"))
++if not env_etc.check_syslib('ccp4c')\
++ or not env_etc.check_syslib('mmdb'):
++ build_ccp4io_adaptbx = libtbx.env.under_build("ccp4io_adaptbx")
++ if (not op.isdir(build_ccp4io_adaptbx)):
++ os.mkdir(build_ccp4io_adaptbx)
++ assert op.isdir(build_ccp4io_adaptbx)
++
++ def replace_printf(file_name):
++ full_path = op.join(path_lib_src, file_name)
++ if (not op.isfile(full_path)):
++ full_path = op.join(op.dirname(path_lib_src), "fortran", file_name)
++ result = ["#include <ccp4io_adaptbx/printf_wrappers.h>"]
++ for line in open(full_path).read().splitlines():
++ for key in ["printf", "fprintf"]:
++ matches = list(re.finditer(
++ pattern="[^A-Za-z0-9_]%s[^A-Za-z0-9_]" % key, string=line))
++ if (len(matches) != 0):
++ for m in reversed(matches):
++ s,e = m.start(), m.end()
++ line = line[:s] \
++ + line[s:e].replace(key, "ccp4io_%s" % key) \
++ + line[e:]
++ result.append(line)
++ return "\n".join(result)
++ env = env_base.Clone(
++ SHLINKFLAGS=env_etc.shlinkflags)
++ env.Append(CCFLAGS=env_etc.ccp4io_defines)
++ env.Append(SHCCFLAGS=env_etc.ccp4io_defines)
++ env_etc.include_registry.append(
++ env=env,
++ paths=[
++ "#",
++ op.dirname(env_etc.ccp4io_include),
++ env_etc.ccp4io_include,
++ op.join(env_etc.ccp4io_dist, "lib", mmdb_src),
++ op.join(env_etc.ccp4io_dist, "lib", mmdb_src, "mmdb")])
++
++ env.Append(LIBS=env_etc.libm)
++ # XXX 2012-06-16: is this actually necessary here, or just in code that links to
++ # ccp4io.lib?
++ if (os.name == "nt") :
++ env.Prepend(LIBS=["Advapi32"])
++ if ( op.normcase(op.dirname(env_etc.ccp4io_dist))
++ != op.normcase("ccp4io")):
++ env.Repository(op.dirname(env_etc.ccp4io_dist))
+
+-probe_file_name = op.join(path_lib_src, "cmaplib.h")
+-env_etc.ccp4io_has_cmaplib = op.isfile(probe_file_name)
+-if (env_etc.ccp4io_has_cmaplib):
+ c_files.extend(["%s/%s" % (ccp4_src, bn ) for bn in """\
+-cmap_accessor.c
+-cmap_close.c
+-cmap_data.c
+-cmap_header.c
+-cmap_labels.c
+-cmap_open.c
+-cmap_skew.c
+-cmap_stats.c
+-cmap_symop.c
+-""".splitlines()])
++ library_err.c
++ library_file.c
++ library_utils.c
++ ccp4_array.c
++ ccp4_parser.c
++ ccp4_unitcell.c
++ cvecmat.c
++ cmtzlib.c
++ """.splitlines()])
++ open(op.join(build_ccp4io_adaptbx, "csymlib.c"), "w").write(
++ open(op.join(path_lib_src, "csymlib.c")).read()
++ .replace(
++ "static int reported_syminfo = 0",
++ "static int reported_syminfo = 1"))
++ source.append(op.join("#ccp4io_adaptbx", "csymlib.c"))
+
+-c_files.extend(["%s/mmdb/%s.cpp" % ( mmdb_src, bn ) for bn in """\
+-bfgs_min
+-file_
+-hybrid_36
+-linalg_
+-machine_
+-math_
+-mattype_
+-mmdb_align
+-mmdb_atom
+-mmdb_bondmngr
+-mmdb_chain
+-mmdb_cifdefs
+-mmdb_coormngr
+-mmdb_cryst
+-mmdb_ficif
+-mmdb_file
+-mmdb_graph
+-mmdb_manager
+-mmdb_mask
+-mmdb_mmcif
+-mmdb_model
+-mmdb_rwbrook
+-mmdb_sbase
+-mmdb_sbase0
+-mmdb_selmngr
+-mmdb_symop
+-mmdb_tables
+-mmdb_title
+-mmdb_uddata
+-mmdb_utils
+-mmdb_xml
+-random_n
+-stream_
+-""".splitlines()])
+-prefix = "#"+op.join(op.basename(env_etc.ccp4io_dist), "lib")
+-for file_name in c_files:
+- source.append(op.join(prefix, file_name))
++ probe_file_name = op.join(path_lib_src, "cmaplib.h")
++ env_etc.ccp4io_has_cmaplib = op.isfile(probe_file_name)
++ if (env_etc.ccp4io_has_cmaplib):
++ c_files.extend(["%s/%s" % (ccp4_src, bn ) for bn in """\
++ cmap_accessor.c
++ cmap_close.c
++ cmap_data.c
++ cmap_header.c
++ cmap_labels.c
++ cmap_open.c
++ cmap_skew.c
++ cmap_stats.c
++ cmap_symop.c
++ """.splitlines()])
++
++ c_files.extend(["%s/mmdb/%s.cpp" % ( mmdb_src, bn ) for bn in """\
++ bfgs_min
++ file_
++ hybrid_36
++ linalg_
++ machine_
++ math_
++ mattype_
++ mmdb_align
++ mmdb_atom
++ mmdb_bondmngr
++ mmdb_chain
++ mmdb_cifdefs
++ mmdb_coormngr
++ mmdb_cryst
++ mmdb_ficif
++ mmdb_file
++ mmdb_graph
++ mmdb_manager
++ mmdb_mask
++ mmdb_mmcif
++ mmdb_model
++ mmdb_rwbrook
++ mmdb_sbase
++ mmdb_sbase0
++ mmdb_selmngr
++ mmdb_symop
++ mmdb_tables
++ mmdb_title
++ mmdb_uddata
++ mmdb_utils
++ mmdb_xml
++ random_n
++ stream_
++ """.splitlines()])
++ prefix = "#"+op.join(op.basename(env_etc.ccp4io_dist), "lib")
++ for file_name in c_files:
++ source.append(op.join(prefix, file_name))
++
++ ssm_prefix = "#"+op.join(op.basename(env_etc.ccp4io_dist), "lib", "ssm")
++ ssm_sources = """\
++ ss_csia.cpp
++ ss_graph.cpp
++ ss_vxedge.cpp
++ ssm_align.cpp
++ ssm_superpose.cpp
++ """.splitlines()
++ source.extend( [ op.join( ssm_prefix, f ) for f in ssm_sources ] )
++
++ need_f_c = (
++ libtbx.env.has_module("solve_resolve")
++ or libtbx.env.find_in_repositories(relative_path="mosflm_fable"))
++ if (need_f_c or os.name != "nt"):
++ source.append(op.join("#ccp4io_adaptbx", "fortran_call_stubs.c"))
++ for file_name in """\
++ ccp4_diskio_f.c
++ ccp4_general.c
++ ccp4_general_f.c
++ ccp4_parser_f.c
++ ccp4_program.c
++ ccp4_unitcell_f.c
++ cmaplib_f.c
++ cmtzlib_f.c
++ csymlib_f.c
++ library_f.c
++ """.splitlines():
++ open(op.join(build_ccp4io_adaptbx, file_name), "w").write(
++ replace_printf(file_name=file_name))
++ source.append(op.join("#ccp4io_adaptbx", file_name))
++ source.append(op.join("#ccp4io_adaptbx", "printf_wrappers.c"))
++ env_etc.ccp4io_lib = "ccp4io"
++ mmdb_path= [ os.path.join( env_etc.ccp4io_dist, "lib", mmdb_src ),
++ os.path.join( env_etc.ccp4io_dist, "lib", mmdb_src, "mmdb" ),
++ ]
++else:
++ env = env_base.Clone(
++ SHLINKFLAGS=env_etc.shlinkflags)
++ env.Append(CCFLAGS=env_etc.ccp4io_defines)
++ env.Append(SHCCFLAGS=env_etc.ccp4io_defines)
++ env_etc.ccp4io_lib = ["ccp4io", "mmdb", "ccp4c"]
++ mmdb_path= []
+
+ ssm_prefix = "#"+op.join(op.basename(env_etc.ccp4io_dist), "lib", "ssm")
+ ssm_sources = """\
+@@ -170,46 +215,20 @@ ssm_superpose.cpp
+ """.splitlines()
+ source.extend( [ op.join( ssm_prefix, f ) for f in ssm_sources ] )
+
+-need_f_c = (
+- libtbx.env.has_module("solve_resolve")
+- or libtbx.env.find_in_repositories(relative_path="mosflm_fable"))
+-if (need_f_c or os.name != "nt"):
+- source.append(op.join("#ccp4io_adaptbx", "fortran_call_stubs.c"))
+- for file_name in """\
+-ccp4_diskio_f.c
+-ccp4_general.c
+-ccp4_general_f.c
+-ccp4_parser_f.c
+-ccp4_program.c
+-ccp4_unitcell_f.c
+-cmaplib_f.c
+-cmtzlib_f.c
+-csymlib_f.c
+-library_f.c
+-""".splitlines():
+- open(op.join(build_ccp4io_adaptbx, file_name), "w").write(
+- replace_printf(file_name=file_name))
+- source.append(op.join("#ccp4io_adaptbx", file_name))
+- source.append(op.join("#ccp4io_adaptbx", "printf_wrappers.c"))
+-
+ # static library for solve_resolve
+ env.StaticLibrary(target='#lib/ccp4io', source=source)
+-env_etc.ccp4io_lib = "ccp4io"
+
+ if ( libtbx.env.has_module("boost")
+ and not env_etc.no_boost_python):
+ Import( "env_no_includes_boost_python_ext" )
+ sources = [ "#ccp4io_adaptbx/ext.cpp" ]
+ env_ext = env_no_includes_boost_python_ext.Clone()
+- env_ext.Prepend( LIBS = "ccp4io" )
++ env_ext.Prepend( LIBS = env_etc.ccp4io_lib )
+ env_etc.include_registry.append(
+ env = env_ext,
+- paths = [
+- os.path.join( env_etc.ccp4io_dist, "lib", mmdb_src ),
+- os.path.join( env_etc.ccp4io_dist, "lib", mmdb_src, "mmdb" ),
+- os.path.join( env_etc.ccp4io_dist, "lib", "ssm"),
+- env_etc.boost_include,
+- env_etc.python_include,
+- ]
++ paths = mmdb_path + [ os.path.join( env_etc.ccp4io_dist, "lib", "ssm"),
++ env_etc.boost_include,
++ env_etc.python_include,
++ ]
+ )
+ env_ext.SharedLibrary( target = "#lib/ccp4io_adaptbx_ext", source = sources )
+diff --git a/cctbx_sources/cctbx/SConscript b/cctbx_sources/cctbx/SConscript
+index 162f019..1321069 100644
+--- a/cctbx_sources/cctbx/SConscript
++++ b/cctbx_sources/cctbx/SConscript
+@@ -108,7 +108,7 @@ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
+
+ env_cctbx_boost_python_ext = env_no_includes_boost_python_ext.Clone()
+- env_cctbx_boost_python_ext.Prepend(LIBS=["scitbx_boost_python"])
++ env_cctbx_boost_python_ext.Prepend(LIBS=[env_etc.scitbx_boost_python])
+ env_etc.include_registry.append(
+ env=env_cctbx_boost_python_ext,
+ paths=env_etc.cctbx_common_includes + [env_etc.python_include])
+diff --git a/cctbx_sources/clipper_adaptbx/SConscript b/cctbx_sources/clipper_adaptbx/SConscript
+index 9cce49e..c39047f 100644
+--- a/cctbx_sources/clipper_adaptbx/SConscript
++++ b/cctbx_sources/clipper_adaptbx/SConscript
+@@ -3,54 +3,63 @@ Import("env_base", "env_etc")
+
+ env_etc.clipper_dist = libtbx.env.dist_path("clipper")
+ env_etc.clipper_include = env_etc.clipper_dist
++# This way the compiler looks in the standard location for includes
++# should work on all platforms
++env_etc.clipper_sysinclude = ''
+
+ env = env_base.Clone(
+ SHLINKFLAGS=env_etc.shlinkflags,
+ LIBS=env_etc.libm)
+-env.Prepend(CPPPATH=[env_etc.clipper_include])
+-
+-if (env_etc.static_libraries): builder = env.StaticLibrary
+-else: builder = env.SharedLibrary
+-builder(target='#lib/clipper',
+- source = ["../clipper/clipper/core/"+file_name for file_name in """
+- atomsf.cpp
+- cell.cpp
+- clipper_memory.cpp
+- clipper_message.cpp
+- clipper_stats.cpp
+- clipper_types.cpp
+- clipper_util.cpp
+- container.cpp
+- container_hkl.cpp
+- container_map.cpp
+- container_types.cpp
+- coords.cpp
+- derivs.cpp
+- hkl_compute.cpp
+- hkl_data.cpp
+- hkl_datatypes.cpp
+- hkl_info.cpp
+- hkl_lookup.cpp
+- hkl_operators.cpp
+- map_interp.cpp
+- map_utils.cpp
+- nxmap.cpp
+- nxmap_operator.cpp
+- ramachandran.cpp
+- resol_basisfn.cpp
+- resol_fn.cpp
+- resol_targetfn.cpp
+- rotation.cpp
+- spacegroup.cpp
+- spacegroup_data.cpp
+- symop.cpp
+- xmap.cpp
+-""".split()])
+-# fftmap_sparse.cpp
+-# fftmap.cpp
++if env_etc.check_syslib('clipper-core') and \
++ env_etc.check_syslib('clipper-contrib'):
++ env.Prepend(CPPPATH=[env_etc.clipper_sysinclude])
++ env_etc.clipper_libs=['clipper-core', 'clipper-contrib']
++ env_etc.has_clipper_contrib = True
++else:
++ env.Prepend(CPPPATH=[env_etc.clipper_include])
++ env_etc.clipper_libs=['clipper',]
++ if (env_etc.static_libraries): builder = env.StaticLibrary
++ else: builder = env.SharedLibrary
++ builder(target='#lib/'+env_etc.clipper_libs[0],
++ source = ["../clipper/clipper/core/"+file_name for file_name in """
++ atomsf.cpp
++ cell.cpp
++ clipper_memory.cpp
++ clipper_message.cpp
++ clipper_stats.cpp
++ clipper_types.cpp
++ clipper_util.cpp
++ container.cpp
++ container_hkl.cpp
++ container_map.cpp
++ container_types.cpp
++ coords.cpp
++ derivs.cpp
++ hkl_compute.cpp
++ hkl_data.cpp
++ hkl_datatypes.cpp
++ hkl_info.cpp
++ hkl_lookup.cpp
++ hkl_operators.cpp
++ map_interp.cpp
++ map_utils.cpp
++ nxmap.cpp
++ nxmap_operator.cpp
++ ramachandran.cpp
++ resol_basisfn.cpp
++ resol_fn.cpp
++ resol_targetfn.cpp
++ rotation.cpp
++ spacegroup.cpp
++ spacegroup_data.cpp
++ symop.cpp
++ xmap.cpp
++ """.split()])
++ # fftmap_sparse.cpp
++ # fftmap.cpp
+
+ env_exe = env.Clone()
+-env_exe.Prepend(LIBS=["clipper"])
++env_exe.Prepend(LIBS=[env_etc.clipper_libs[0]])
+
+ exe = env_exe.Program(
+ target='#exe_dev/'+env["PROGPREFIX"]+'clipper.symtest'
+@@ -77,6 +86,7 @@ if (hasattr(env_etc, "cctbx_include")):
+ env=env_clipper_boost_python_ext,
+ paths=[
+ env_etc.clipper_include,
++ env_etc.clipper_sysinclude,
+ env_etc.libtbx_include,
+ env_etc.cctbx_include,
+ env_etc.scitbx_include,
+diff --git a/cctbx_sources/clipper_adaptbx/clipper/SConscript b/cctbx_sources/clipper_adaptbx/clipper/SConscript
+index 9f79f83..1911eb1 100644
+--- a/cctbx_sources/clipper_adaptbx/clipper/SConscript
++++ b/cctbx_sources/clipper_adaptbx/clipper/SConscript
+@@ -1,6 +1,10 @@
+-Import("env_clipper_boost_python_ext")
++Import("env_clipper_boost_python_ext", "env_etc")
+ env = env_clipper_boost_python_ext.Clone()
+-env.Prepend(LIBS=["clipper", "cctbx"])
++env.Prepend(LIBS=env_etc.clipper_libs+["cctbx"])
++if (env_etc.has_clipper_contrib):
++ clipper_contrib_files = []
++else:
++ clipper_contrib_files = ["../../clipper/clipper/contrib/sfweight.cpp",]
+ env.SharedLibrary(
+ target="#lib/clipper_ext",
+ source=[
+@@ -8,4 +12,4 @@ env.SharedLibrary(
+ "hendrickson_lattman_bpl.cpp",
+ "sigmaa_bpl.cpp",
+ "../../clipper/clipper/contrib/sfweight.cpp",
+- "../../clipper/clipper/cctbx/clipper_cctbx.cpp"])
++ "../../clipper/clipper/cctbx/clipper_cctbx.cpp"]+clipper_contrib_files)
+diff --git a/cctbx_sources/gltbx/SConscript b/cctbx_sources/gltbx/SConscript
+index d02e7a5..e90f6c3 100644
+--- a/cctbx_sources/gltbx/SConscript
++++ b/cctbx_sources/gltbx/SConscript
+@@ -12,14 +12,15 @@ env_etc.gltbx_common_includes = [
+ env_etc.scitbx_include,
+ env_etc.boost_include,
+ ]
+-if (gl2ps_path is not None):
+- env_etc.gltbx_common_includes.append(gl2ps_path)
++if not env_etc.check_syslib('gl2ps', extra_libs='GL'):
++ if (gl2ps_path is not None):
++ env_etc.gltbx_common_includes.append(gl2ps_path)
+
+ if (not env_etc.no_boost_python):
+ Import("env_base", "env_no_includes_boost_python_ext")
+ trial_env = env_base.Clone()
+ env = env_no_includes_boost_python_ext.Clone()
+- env.Prepend(LIBS=["scitbx_boost_python"])
++ env.Prepend(LIBS=[env_etc.scitbx_boost_python])
+ if (env_etc.compiler == "win32_cl"):
+ for e in [trial_env, env]:
+ e.Append(LIBS=["glu32", "opengl32"])
+@@ -79,10 +80,15 @@ int main() { std::cout << GL_POINT << std::endl; return 0; }
+ source=source)
+ env_util = env
+ source = ["util_ext.cpp"]
+- if (gl2ps_path is not None):
+- source.append("#gui_resources/gl2ps/gl2ps.c")
+- env_util = env.Clone()
+- env_util.Append(SHCXXFLAGS=["-DGLTBX_HAVE_GL2PS"])
++ if not env_etc.check_syslib('gl2ps', extra_libs='GL'):
++ if (gl2ps_path is not None):
++ source.append("#gui_resources/gl2ps/gl2ps.c")
++ env_util = env.Clone()
++ env_util.Append(SHCXXFLAGS=["-DGLTBX_HAVE_GL2PS"])
++ else:
++ env_util = env.Clone()
++ env_util.Append(SHCXXFLAGS=["-DGLTBX_HAVE_GL2PS"])
++ env_util.Append(LIBS=["gl2ps"])
+ env_util.SharedLibrary(
+ target="#lib/gltbx_util_ext",
+ source=source)
+diff --git a/cctbx_sources/iotbx/cif/boost_python/SConscript b/cctbx_sources/iotbx/cif/boost_python/SConscript
+index 49837af..2833ff1 100644
+--- a/cctbx_sources/iotbx/cif/boost_python/SConscript
++++ b/cctbx_sources/iotbx/cif/boost_python/SConscript
+@@ -34,15 +34,18 @@ antlr3_src_files = [
+ ]
+
+ prefix = "#ucif/antlr3/src"
+-source = [os.path.join(prefix, file_name) for file_name in antlr3_src_files]
++if not env_etc.check_syslib('antlr3c'):
++ source = [os.path.join(prefix, file_name) for file_name in antlr3_src_files]
++ env_etc.include_registry.append(
++ env=env,
++ paths=[antlr3_include, antlr3_dist])
++else:
++ source = []
++ env.Append(LIBS=['antlr3c'])
+ source.extend([
+ "cif_ext.cpp",
+ "#ucif/cifParser.cpp",
+ "#ucif/cifLexer.cpp",
+ ])
+
+-env_etc.include_registry.append(
+- env=env,
+- paths=[antlr3_include, antlr3_dist])
+-
+ env.SharedLibrary(target="#lib/iotbx_cif_ext", source=source)
+diff --git a/cctbx_sources/iotbx/mtz/SConscript b/cctbx_sources/iotbx/mtz/SConscript
+index 76fb87c..4019731 100644
+--- a/cctbx_sources/iotbx/mtz/SConscript
++++ b/cctbx_sources/iotbx/mtz/SConscript
+@@ -23,7 +23,8 @@ if (not env_etc.no_boost_python):
+ env = env_iotbx_boost_python_ext.Clone()
+ env.Append(CXXFLAGS=env_etc.ccp4io_defines)
+ env.Append(SHCXXFLAGS=env_etc.ccp4io_defines)
+- env.Prepend(LIBS=["iotbx_mtz", "cctbx", ccp4io_lib, "scitbx_boost_python"])
++ env.Prepend(LIBS=["iotbx_mtz", "cctbx", ccp4io_lib,
++ env_etc.scitbx_boost_python])
+ if (os.name == "nt") :
+ env.Prepend(LIBS=["Advapi32"])
+ env_etc.enable_more_warnings(env=env)
+diff --git a/cctbx_sources/iotbx/pdb/SConscript b/cctbx_sources/iotbx/pdb/SConscript
+index 6af2664..9b89fe1 100644
+--- a/cctbx_sources/iotbx/pdb/SConscript
++++ b/cctbx_sources/iotbx/pdb/SConscript
+@@ -33,7 +33,7 @@ env.Program(target="hybrid_36_fem", source=["hybrid_36_fem.cpp"])
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["iotbx_pdb", "cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["iotbx_pdb", "cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/iotbx_pdb_ext",
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index c273536..5aced44 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -1071,4 +1071,88 @@ def enable_cuda_if_possible():
+ enable_openmp_if_possible()
+ enable_cuda_if_possible()
+
++env_etc.use_system_libs = False
++def check_syslib(lib, extra_libs=None):
++ """ Check if a system library is available """
++ if not env_etc.use_system_libs:
++ return False
++ env_syslib = env_base.Clone(LIBS=extra_libs)
++ conf = env_syslib.Configure()
++ if not conf.CheckLib(library=lib):
++ print 'Could not find %s library!'%(lib)
++ conf.Finish()
++ return False
++ else:
++ conf.Finish()
++ return True
++env_etc.check_syslib = check_syslib
++
++env_etc.py_lib = 'python%s.%s'%(sys.version[0], sys.version[2])
++
++if (libtbx.env.build_options.use_system_libs):
++ env_etc.use_system_libs = True
++
++deb_py_str = '-py%s%s'%(sys.version[0], sys.version[2])
++gentoo_py_str = '-%s.%s'%(sys.version[0], sys.version[2])
++# This list can be extended by other distro's
++py_str_lst = [deb_py_str, gentoo_py_str]
++
++for py_str in py_str_lst:
++ if env_etc.check_syslib('boost_python%s'%py_str,
++ extra_libs=env_etc.py_lib):
++ env_etc.boost_python = 'boost_python%s'%py_str
++ env_etc.scitbx_boost_python = 'scitbx_boost_python%s'%py_str
++ break
++ else:
++ env_etc.boost_python = 'boost_python'
++ env_etc.scitbx_boost_python = 'scitbx_boost_python'
++
++env_etc.prefix = libtbx.env.build_options.install_prefix
++env_etc.destdir = libtbx.env.build_options.install_destdir
++env_etc.libdir = libtbx.env.build_options.libdir
++env_etc.install_path = os.path.abspath(env_etc.destdir + '/' + env_etc.prefix)
++env_etc.binpath = os.path.join(env_etc.install_path, 'bin')
++env_etc.libpath = os.path.abspath(env_etc.install_path + '/' + env_etc.libdir)
++env_etc.inclpath = os.path.join(env_etc.install_path, 'include')
++env_etc.rpath = os.path.join(env_etc.prefix, 'lib')
++
++def create_install_targets():
++ cwd = os.getcwd()
++ rp = libtbx.env.repository_paths
++ lib_dir = '%s%s'%(abs(libtbx.env.lib_path), env_etc.rpath)
++ exe_dev = libtbx.env.under_build("exe_dev")
++ include_path = libtbx.env.include_path
++ if not os.path.exists(lib_dir):
++ os.makedirs(lib_dir)
++ rp = list(rp)
++ rp.append(lib_dir)
++ rp.append(include_path)
++ for p in rp:
++ if isinstance(p, str):
++ src_dir = p
++ else:
++ src_dir = abs(p)
++ os.chdir(src_dir)
++ dest = None
++ for root, dirnames, filenames in os.walk('.'):
++ for filename in filenames:
++ if re.match('^lib.*\.(so.*|dylib.*|la|a)$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.libpath, root)
++ src = os.path.join(src_dir, root, filename)
++ env_base.Install(dest, src)
++ env_base.Alias("install-shlib", dest)
++ if re.match('^.*\.(h|hpp)$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.inclpath, root)
++ src = os.path.join(src_dir, root, filename)
++ env_base.Install(dest, src)
++ env_base.Alias("install-header", dest)
++ dest = env_etc.binpath
++ env_base.Install(dest, Glob('%s/*'%(exe_dev)))
++ env_base.Alias("install-bin", dest)
++ Alias('install', ['install-header', 'install-shlib', 'install-bin'])
++ os.chdir(cwd)
++
++if 'install' in COMMAND_LINE_TARGETS:
++ create_install_targets()
++
+ Export("env_base", "env_etc")
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 41b6f91..ddf2848 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -740,6 +740,10 @@ Wait for the command to finish, then try again.""" % vars())
+ precompile_headers=command_line.options.precompile_headers,
+ static_libraries=command_line.options.static_libraries,
+ static_exe=command_line.options.static_exe,
++ use_system_libs=command_line.options.use_system_libs,
++ install_prefix=command_line.options.install_prefix,
++ libdir=command_line.options.libdir,
++ install_destdir=command_line.options.install_destdir,
+ scan_boost=command_line.options.scan_boost,
+ write_full_flex_fwd_h=command_line.options.write_full_flex_fwd_h,
+ boost_python_no_py_signatures
+@@ -1799,6 +1803,10 @@ class build_options:
+ warning_level,
+ static_libraries,
+ static_exe,
++ use_system_libs,
++ install_prefix,
++ libdir,
++ install_destdir,
+ scan_boost,
+ write_full_flex_fwd_h=default_write_full_flex_fwd_h,
+ build_boost_python_extensions=default_build_boost_python_extensions,
+@@ -1860,6 +1868,10 @@ class build_options:
+ self.boost_python_bool_int_strict
+ print >> f, "Enable OpenMP if possible:", self.enable_openmp_if_possible
+ print >> f, "Enable CUDA:", self.enable_cuda
++ print >> f, "Use System Libraries:", self.use_system_libs
++ print >> f, "Install Prefix:", self.install_prefix
++ print >> f, "Libdir:", self.libdir
++ print >> f, "Install Destdir:", self.install_destdir
+ print >> f, "Use opt_resources if available:", self.opt_resources
+ print >> f, "Use environment flags:", self.use_environment_flags
+ if( self.use_environment_flags ):
+@@ -1983,6 +1995,28 @@ class pre_process_args:
+ action="store_true",
+ default=False,
+ help="link all executables statically (implies --static_libraries)")
++ parser.option(None, "--use_system_libs",
++ action="store_true",
++ default=False,
++ help="Use system Libraries to build.")
++ parser.option(None, "--install_destdir",
++ type="string",
++ action="store",
++ default="",
++ help="sets the destdir for the install targets.",
++ metavar="DIRECTORY")
++ parser.option(None, "--libdir",
++ type="string",
++ action="store",
++ default="lib",
++ help="sets the libdir relative to the PREFIX for the install targets. Default: lib",
++ metavar="DIRECTORY")
++ parser.option(None, "--install_prefix",
++ type="string",
++ action="store",
++ default="/usr/local",
++ help="sets the prefix for the install targets. Default: /usr/local",
++ metavar="DIRECTORY")
+ parser.option(None, "--scan_boost",
+ action="store_true",
+ default=False,
+diff --git a/cctbx_sources/mmtbx/cablam/SConscript b/cctbx_sources/mmtbx/cablam/SConscript
+index 67b1edb..36a11bc 100644
+--- a/cctbx_sources/mmtbx/cablam/SConscript
++++ b/cctbx_sources/mmtbx/cablam/SConscript
+@@ -3,7 +3,7 @@ Import("env_etc")
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/mmtbx_cablam_align_utils_ext",
+diff --git a/cctbx_sources/mmtbx/den/SConscript b/cctbx_sources/mmtbx/den/SConscript
+index 2d3ce36..1a2b171 100644
+--- a/cctbx_sources/mmtbx/den/SConscript
++++ b/cctbx_sources/mmtbx/den/SConscript
+@@ -3,7 +3,7 @@ Import("env_etc")
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/mmtbx_den_restraints_ext",
+diff --git a/cctbx_sources/mmtbx/geometry_restraints/SConscript b/cctbx_sources/mmtbx/geometry_restraints/SConscript
+index b9ee02c..72af551 100644
+--- a/cctbx_sources/mmtbx/geometry_restraints/SConscript
++++ b/cctbx_sources/mmtbx/geometry_restraints/SConscript
+@@ -3,7 +3,7 @@ Import("env_etc")
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/mmtbx_hbond_restraints_ext",
+diff --git a/cctbx_sources/mmtbx/secondary_structure/SConscript b/cctbx_sources/mmtbx/secondary_structure/SConscript
+index 7e82b43..5698af5 100644
+--- a/cctbx_sources/mmtbx/secondary_structure/SConscript
++++ b/cctbx_sources/mmtbx/secondary_structure/SConscript
+@@ -3,7 +3,7 @@ Import("env_etc")
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+ env = env_iotbx_boost_python_ext.Clone()
+- env.Prepend(LIBS=["cctbx", "scitbx_boost_python"])
++ env.Prepend(LIBS=["cctbx", env_etc.scitbx_boost_python])
+ env_etc.enable_more_warnings(env=env)
+ env.SharedLibrary(
+ target="#lib/mmtbx_secondary_structure_ext",
+diff --git a/cctbx_sources/rstbx/SConscript b/cctbx_sources/rstbx/SConscript
+index d79b762..a049b88 100644
+--- a/cctbx_sources/rstbx/SConscript
++++ b/cctbx_sources/rstbx/SConscript
+@@ -39,7 +39,7 @@ if (not env_etc.no_boost_python):
+ Import("env_boost_python_ext")
+ env_rstbx_boost_python_ext = env_boost_python_ext.Clone()
+ env_rstbx_boost_python_ext.Prepend(
+- LIBS=["rstbx", "cctbx", "scitbx_boost_python"])
++ LIBS=["rstbx", "cctbx", env_etc.scitbx_boost_python])
+ env_rstbx_boost_python_ext.SharedLibrary(
+ target="#lib/rstbx_ext", source="ext.cpp")
+ env_rstbx_boost_python_ext.SharedLibrary(
+diff --git a/cctbx_sources/scitbx/SConscript b/cctbx_sources/scitbx/SConscript
+index 9199ae0..6045fbc 100644
+--- a/cctbx_sources/scitbx/SConscript
++++ b/cctbx_sources/scitbx/SConscript
+@@ -28,7 +28,7 @@ SConscript("sparse/tests/SConscript")
+ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
+ env_scitbx_boost_python_ext = env_no_includes_boost_python_ext.Clone()
+- env_scitbx_boost_python_ext.Prepend(LIBS=["scitbx_boost_python"])
++ env_scitbx_boost_python_ext.Prepend(LIBS=[env_etc.scitbx_boost_python])
+ env_etc.include_registry.append(
+ env=env_scitbx_boost_python_ext,
+ paths=env_etc.scitbx_common_includes + [env_etc.python_include])
+diff --git a/cctbx_sources/scitbx/boost_python/SConscript b/cctbx_sources/scitbx/boost_python/SConscript
+index eda7b03..1f396e5 100644
+--- a/cctbx_sources/scitbx/boost_python/SConscript
++++ b/cctbx_sources/scitbx/boost_python/SConscript
+@@ -7,7 +7,7 @@ env_etc.enable_more_warnings(env=env)
+ env.Append(CXXFLAGS=env_etc.cxxflags_bpl_defines_base)
+ env.Append(SHCXXFLAGS=env_etc.cxxflags_bpl_defines_base)
+ env.Append(LIBPATH=env_etc.libpath_python)
+-env.Append(LIBS=["boost_python"] + env_etc.libs_python)
++env.Append(LIBS=[env_etc.boost_python] + env_etc.libs_python)
+ env_etc.include_registry.append(
+ env=env,
+ paths=env_etc.scitbx_common_includes + [env_etc.python_include])
+@@ -20,5 +20,5 @@ lib_scitbx_boost_python_sources = [
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+ builder(
+- target="#lib/scitbx_boost_python",
++ target="#lib/%s"%env_etc.scitbx_boost_python,
+ source=lib_scitbx_boost_python_sources)
+diff --git a/cctbx_sources/smtbx/refinement/boost_python/SConscript b/cctbx_sources/smtbx/refinement/boost_python/SConscript
+index 0387e1d..5144996 100644
+--- a/cctbx_sources/smtbx/refinement/boost_python/SConscript
++++ b/cctbx_sources/smtbx/refinement/boost_python/SConscript
+@@ -1,6 +1,6 @@
+-Import("env_smtbx_boost_python_ext")
++Import("env_smtbx_boost_python_ext", "env_etc")
+ env = env_smtbx_boost_python_ext.Clone()
+-env.Prepend(LIBS=["smtbx_refinement_constraints", "scitbx_boost_python"])
++env.Prepend(LIBS=["smtbx_refinement_constraints", env_etc.scitbx_boost_python])
+ env.SharedLibrary(target="#lib/smtbx_refinement_least_squares_ext", source=[
+ "least_squares_ext.cpp",
+ "weighting_schemes.cpp",
+diff --git a/cctbx_sources/smtbx/refinement/constraints/boost_python/SConscript b/cctbx_sources/smtbx/refinement/constraints/boost_python/SConscript
+index 009d288..1eb176b 100644
+--- a/cctbx_sources/smtbx/refinement/constraints/boost_python/SConscript
++++ b/cctbx_sources/smtbx/refinement/constraints/boost_python/SConscript
+@@ -1,5 +1,5 @@
+-Import("env_smtbx_boost_python_ext")
++Import("env_smtbx_boost_python_ext", "env_etc")
+ env = env_smtbx_boost_python_ext.Clone()
+-env.Prepend(LIBS=["smtbx_refinement_constraints", "scitbx_boost_python"])
++env.Prepend(LIBS=["smtbx_refinement_constraints", env_etc.scitbx_boost_python])
+ env.SharedLibrary(target="#lib/smtbx_refinement_constraints_ext",
+ source=Glob("*.cpp"))
+diff --git a/cctbx_sources/spotfinder/SConscript b/cctbx_sources/spotfinder/SConscript
+index 1d280d4..1d73677 100644
+--- a/cctbx_sources/spotfinder/SConscript
++++ b/cctbx_sources/spotfinder/SConscript
+@@ -54,7 +54,7 @@ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
+
+ env_spotfinder_boost_python_ext = env_no_includes_boost_python_ext.Clone()
+- env_spotfinder_boost_python_ext.Prepend(LIBS=[ "scitbx_boost_python"])
++ env_spotfinder_boost_python_ext.Prepend(LIBS=[ env_etc.scitbx_boost_python ])
+ env_etc.include_registry.append(
+ env=env_spotfinder_boost_python_ext,
+ paths=env_etc.spotfinder_common_includes + [env_etc.python_include])
+diff --git a/cctbx_sources/xfel/SConscript b/cctbx_sources/xfel/SConscript
+index e680f73..3397762 100644
+--- a/cctbx_sources/xfel/SConscript
++++ b/cctbx_sources/xfel/SConscript
+@@ -31,7 +31,7 @@ if (not env_etc.no_boost_python):
+ Import("env_boost_python_ext")
+ env_xfel_boost_python_ext = env_boost_python_ext.Clone()
+ env_xfel_boost_python_ext.Prepend(
+- LIBS=["cctbx", "scitbx_boost_python"])
++ LIBS=["cctbx", env_etc.scitbx_boost_python])
+ env_xfel_boost_python_ext.SharedLibrary(
+ target="#lib/xfel_ext", source="ext.cpp")
+ env_xfel_boost_python_ext.SharedLibrary(
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0007-adding-shlib-versioning.patch b/sci-libs/cctbx/files/2013.02.27.0005/0007-adding-shlib-versioning.patch
new file mode 100644
index 0000000..fd1888e
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0007-adding-shlib-versioning.patch
@@ -0,0 +1,208 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 23 Jul 2012 18:33:07 +0200
+Subject: adding-shlib-versioning
+
+---
+ cctbx_sources/boost_adaptbx/SConscript | 3 +
+ cctbx_sources/libtbx/SConscript | 115 +++++++++++++++++++++++++++++---
+ cctbx_sources/libtbx/env_config.py | 7 ++
+ 3 files changed, 116 insertions(+), 9 deletions(-)
+
+diff --git a/cctbx_sources/boost_adaptbx/SConscript b/cctbx_sources/boost_adaptbx/SConscript
+index 68cac89..dedbb05 100644
+--- a/cctbx_sources/boost_adaptbx/SConscript
++++ b/cctbx_sources/boost_adaptbx/SConscript
+@@ -58,6 +58,9 @@ if (not env_etc.no_boost_python):
+ SHLINKFLAGS=env_etc.shlinkflags_bpl,
+ SHLIBPREFIX="",
+ LIBS=[env_etc.boost_python] + env_etc.libs_python + env_etc.libm)
++ if (libtbx.env.build_options.libtoolize):
++ # Need to unset libtool since it does not support linking python-ext
++ env_etc.unset_libtool(env_no_includes_boost_python_ext)
+ env_no_includes_boost_python_ext.Append(
+ LIBPATH=env_etc.libpath_python)
+ env_no_includes_boost_python_ext.Append(
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 429c44b..58bdd30 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -1061,16 +1061,99 @@ env_etc.install_path = os.path.abspath(env_etc.destdir + '/' + env_etc.prefix)
+ env_etc.binpath = os.path.join(env_etc.install_path, 'bin')
+ env_etc.libpath = os.path.abspath(env_etc.install_path + '/' + env_etc.libdir)
+ env_etc.inclpath = os.path.join(env_etc.install_path, 'include')
+-env_etc.rpath = os.path.join(env_etc.prefix, 'lib')
++env_etc.rpath = os.path.abspath(env_etc.prefix + '/' + env_etc.libdir)
++
++def set_libtool(env):
++ # Versioning can be provided by appending "-version-info 3:12:1" to SHLINKFLAGS
++ # Please see:
++ # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
++ # for reference. Otherwise it will be set to 0:0:0
++ env_etc.shobjsuffix_save = env['SHOBJSUFFIX']
++ env_etc.SharedLibBuilder_save = env['BUILDERS']['SharedLibrary']
++ env.Replace(
++ SHLINKFLAGS='-rpath ' + env_etc.rpath,
++ SHOBJSUFFIX='.lo',
++ SHLIBSUFFIX='.la',
++ )
++ LIBTOOLCOM = 'libtool --mode=compile --tag='
++ LIBTOOLCCOM = LIBTOOLCOM + 'CC '
++ LIBTOOLCXXCOM = LIBTOOLCOM + 'CXX '
++ LIBTOOLLINK = 'libtool --mode=link --tag=CXX '
++ ShCAction = SCons.Action.Action(LIBTOOLCCOM + "$SHCCCOM", "$SHCCCOMSTR")
++ ShCXXAction = SCons.Action.Action(LIBTOOLCXXCOM + "$SHCXXCOM", "$SHCXXCOMSTR")
++ ShLinkAction = SCons.Action.Action(LIBTOOLLINK + "$SHLINKCOM", "$SHLINKCOMSTR")
++ libtool_install = 'libtool --mode=install install -D ${TARGET.abspath} %s%s/${TARGET.file}'%(abs(libtbx.env.lib_path), env_etc.rpath)
++
++ action_list = [ SCons.Defaults.SharedCheck,
++ ShLinkAction,
++ libtool_install,
++ ]
++ CSuffixes = SCons.Tool.cc.CSuffixes
++ # Can't import SCons.Tool.c++.CSuffixes because of that 'c++'
++ CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++', '.mm']
++ shared_obj = SCons.Builder.Builder(action = {},
++ emitter = {},
++ prefix = '$SHOBJPREFIX',
++ suffix = '$SHOBJSUFFIX',
++ src_builder = ['CFile', 'CXXFile'],
++ source_scanner = SourceFileScanner,
++ single_source = 1)
++ for suffix in CXXSuffixes:
++ shared_obj.add_action(suffix, ShCXXAction)
++ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
++ for suffix in CSuffixes:
++ shared_obj.add_action(suffix, ShCAction)
++ shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
++
++ LibtoolBuilder = SCons.Builder.Builder(action = action_list,
++ emitter = "$SHLIBEMITTER",
++ prefix = '$SHLIBPREFIX',
++ suffix = '$SHLIBSUFFIX',
++ target_scanner = ProgramScanner,
++ src_suffix = '$SHOBJSUFFIX',
++ src_builder = shared_obj)
++
++ from SCons.Tool.install import add_targets_to_INSTALLED_FILES
++ LibtoolInstall = SCons.Builder.Builder(
++ action = 'libtool --mode=install install -D ${SOURCE.abspath} ${TARGET.abspath}',
++ target_factory = env.fs.Entry,
++ source_factory = env.fs.Entry,
++ multi = 1,
++ emitter = [ add_targets_to_INSTALLED_FILES, ],
++ name = 'LibtoolInstall')
++
++ env['BUILDERS']['LibtoolInstall'] = LibtoolInstall
++
++ lib_dir = '%s%s'%(abs(libtbx.env.lib_path), env_etc.rpath)
++ if not os.path.exists(lib_dir):
++ os.makedirs(lib_dir)
++ libtool_install_path = '#lib' + env_etc.rpath
++ env.Append(LIBPATH=libtool_install_path)
++ env['BUILDERS']['SharedLibrary'] = LibtoolBuilder
++env_etc.set_libtool = set_libtool
++
++def unset_libtool(env):
++ env['BUILDERS']['SharedLibrary'] = env_etc.SharedLibBuilder_save
++ env.Replace(
++ SHOBJSUFFIX=env_etc.shobjsuffix_save,
++ )
++env_etc.unset_libtool = unset_libtool
++
++if (libtbx.env.build_options.libtoolize):
++ env_etc.shlibsuffix = ".la"
++ env_base.Append(LIBSUFFIXES=[env_etc.shlibsuffix])
++ rpath_link = ['-rpath', env_etc.rpath]
++ env_etc.shlinkflags.extend(rpath_link)
++ if '-shared' in env_etc.shlinkflags:
++ env_etc.shlinkflags.remove('-shared')
++ env_etc.set_libtool(env_base)
+
+ def create_install_targets():
+ cwd = os.getcwd()
+ rp = libtbx.env.repository_paths
+- lib_dir = '%s%s'%(abs(libtbx.env.lib_path), env_etc.rpath)
++ lib_dir = abs(libtbx.env.lib_path)
+ exe_dev = libtbx.env.under_build("exe_dev")
+ include_path = libtbx.env.include_path
+- if not os.path.exists(lib_dir):
+- os.makedirs(lib_dir)
+ rp = list(rp)
+ rp.append(lib_dir)
+ rp.append(include_path)
+@@ -1082,17 +1165,31 @@ def create_install_targets():
+ os.chdir(src_dir)
+ dest = None
+ for root, dirnames, filenames in os.walk('.'):
++ # exclude .libs dir
++ if '.libs' in dirnames:
++ dirnames.remove('.libs')
+ for filename in filenames:
+- if re.match('^lib.*\.(so.*|dylib.*|la|a)$', filename, flags=re.IGNORECASE):
+- dest = os.path.join(env_etc.libpath, root)
+- src = os.path.join(src_dir, root, filename)
+- env_base.Install(dest, src)
+- env_base.Alias("install-shlib", dest)
++ if not (libtbx.env.build_options.libtoolize):
++ if re.match('^lib.*\.(so|dylib|a)$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.libpath, root)
++ src = os.path.join(src_dir, root, filename)
++ env_base.Install(dest, src)
++ env_base.Alias("install-shlib", dest)
++ else:
++ if re.match('^lib.*\.la$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.libpath, root, filename)
++ src = os.path.join(src_dir, root, filename)
++ env_base.LibtoolInstall(dest, src)
++ env_base.Alias("install-shlib", dest)
+ if re.match('^.*\.(h|hpp)$', filename, flags=re.IGNORECASE):
+ dest = os.path.join(env_etc.inclpath, root)
+ src = os.path.join(src_dir, root, filename)
+ env_base.Install(dest, src)
+ env_base.Alias("install-header", dest)
++ if src_dir == lib_dir:
++ break
++
++ env_base.Alias("install-shlib", dest)
+ dest = env_etc.binpath
+ env_base.Install(dest, Glob('%s/*'%(exe_dev)))
+ env_base.Alias("install-bin", dest)
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 0885527..3d9133e 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -705,6 +705,7 @@ Wait for the command to finish, then try again.""" % vars())
+ install_prefix=command_line.options.install_prefix,
+ libdir=command_line.options.libdir,
+ install_destdir=command_line.options.install_destdir,
++ libtoolize=command_line.options.libtoolize,
+ scan_boost=command_line.options.scan_boost,
+ write_full_flex_fwd_h=command_line.options.write_full_flex_fwd_h,
+ boost_python_no_py_signatures
+@@ -1767,6 +1768,7 @@ class build_options:
+ install_prefix,
+ libdir,
+ install_destdir,
++ libtoolize,
+ scan_boost,
+ write_full_flex_fwd_h=default_write_full_flex_fwd_h,
+ build_boost_python_extensions=default_build_boost_python_extensions,
+@@ -1830,6 +1832,7 @@ class build_options:
+ print >> f, "Boost threads enabled:", self.enable_boost_threads
+ print >> f, "Enable OpenMP if possible:", self.enable_openmp_if_possible
+ print >> f, "Enable CUDA:", self.enable_cuda
++ print >> f, "Libtoolize:", self.libtoolize
+ print >> f, "Use System Libraries:", self.use_system_libs
+ print >> f, "Install Prefix:", self.install_prefix
+ print >> f, "Libdir:", self.libdir
+@@ -1974,6 +1977,10 @@ class pre_process_args:
+ default="/usr/local",
+ help="sets the prefix for the install targets. Default: /usr/local",
+ metavar="DIRECTORY")
++ parser.option(None, "--libtoolize",
++ action="store_true",
++ default=False,
++ help="build all shared libraries with libtool.")
+ parser.option(None, "--scan_boost",
+ action="store_true",
+ default=False,
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0008-Fix-to-skip-pycbf-build.patch b/sci-libs/cctbx/files/2013.02.27.0005/0008-Fix-to-skip-pycbf-build.patch
new file mode 100644
index 0000000..7aa3a39
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0008-Fix-to-skip-pycbf-build.patch
@@ -0,0 +1,52 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Tue, 7 Aug 2012 18:08:30 +0200
+Subject: Fix to skip pycbf build
+
+---
+ cctbx_sources/cbflib_adaptbx/SConscript | 8 ++++----
+ cctbx_sources/cbflib_adaptbx/libtbx_refresh.py | 16 ++++++++--------
+ 2 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/cctbx_sources/cbflib_adaptbx/SConscript b/cctbx_sources/cbflib_adaptbx/SConscript
+index 334cfc2..42ab9c3 100644
+--- a/cctbx_sources/cbflib_adaptbx/SConscript
++++ b/cctbx_sources/cbflib_adaptbx/SConscript
+@@ -90,10 +90,10 @@ if (not env_etc.no_boost_python):
+ env=env_cbflib_boost_python_ext,
+ paths=env_etc.cbflib_common_includes + [env_etc.python_include])
+
+- env_cbflib_boost_python_ext.SharedLibrary(
+- target='#lib/_pycbf',
+- source=[prefix+"/pycbf/pycbf_wrap.c"],
+- LIBS=env_etc.cbf_lib+env_etc.libs_python+env_etc.libm)
++ #env_cbflib_boost_python_ext.SharedLibrary(
++ # target='#lib/_pycbf',
++ # source=[prefix+"/pycbf/pycbf_wrap.c"],
++ # LIBS=env_etc.cbf_lib+env_etc.libs_python+env_etc.libm)
+
+ Export("env_cbflib_boost_python_ext")
+
+diff --git a/cctbx_sources/cbflib_adaptbx/libtbx_refresh.py b/cctbx_sources/cbflib_adaptbx/libtbx_refresh.py
+index 51b3e42..dd1b8e9 100644
+--- a/cctbx_sources/cbflib_adaptbx/libtbx_refresh.py
++++ b/cctbx_sources/cbflib_adaptbx/libtbx_refresh.py
+@@ -1,11 +1,11 @@
+ from libtbx.str_utils import show_string
+ import os
+ op = os.path
+-pycbf_py = self.env.under_dist(module_name="cbflib", path="pycbf/pycbf.py")
+-if (not op.isfile(pycbf_py)):
+- raise RuntimeError("Missing file: %s" % show_string(pycbf_py))
+-target_dir = self.env.under_build(path="lib")
+-if (not op.isdir(target_dir)):
+- os.makedirs(target_dir)
+-print " Copying to lib: %s" % show_string(pycbf_py)
+-open(op.join(target_dir, "pycbf.py"), "w").write(open(pycbf_py).read())
++#pycbf_py = self.env.under_dist(module_name="cbflib", path="pycbf/pycbf.py")
++#if (not op.isfile(pycbf_py)):
++# raise RuntimeError("Missing file: %s" % show_string(pycbf_py))
++#target_dir = self.env.under_build(path="lib")
++#if (not op.isdir(target_dir)):
++# os.makedirs(target_dir)
++#print " Copying to lib: %s" % show_string(pycbf_py)
++#open(op.join(target_dir, "pycbf.py"), "w").write(open(pycbf_py).read())
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0009-build-libann-statically.patch b/sci-libs/cctbx/files/2013.02.27.0005/0009-build-libann-statically.patch
new file mode 100644
index 0000000..77ba2b2
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0009-build-libann-statically.patch
@@ -0,0 +1,27 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Thu, 19 Jul 2012 11:29:57 +0200
+Subject: build libann statically
+
+---
+ cctbx_sources/annlib_adaptbx/SConscript | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/cctbx_sources/annlib_adaptbx/SConscript b/cctbx_sources/annlib_adaptbx/SConscript
+index 31b4da6..f217b3f 100644
+--- a/cctbx_sources/annlib_adaptbx/SConscript
++++ b/cctbx_sources/annlib_adaptbx/SConscript
+@@ -29,9 +29,11 @@ if (libtbx.manual_date_stamp < 20090819):
+ env.Replace(CXXFLAGS=env_etc.cxxflags_base)
+ env.Replace(SHCXXFLAGS=env_etc.cxxflags_base)
+
+-if (env_etc.static_libraries): builder = env.StaticLibrary
+-else: builder = env.SharedLibrary
+-builder(target='#lib/ann',
++#if (env_etc.static_libraries): builder = env.StaticLibrary
++#else: builder = env.SharedLibrary
++# Create a static library since the changes are incompatiple
++# with debian's libann
++env.StaticLibrary(target='#lib/ann',
+ source = ["../annlib/src/ANN.cpp",
+ "../annlib/src/bd_fix_rad_search.cpp",
+ "../annlib/src/bd_pr_search.cpp",
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0010-adding-setup_py.patch b/sci-libs/cctbx/files/2013.02.27.0005/0010-adding-setup_py.patch
new file mode 100644
index 0000000..7599d82
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0010-adding-setup_py.patch
@@ -0,0 +1,662 @@
+From: Baptiste Carvello <devel@baptiste-carvello.net>
+Date: Tue, 21 Aug 2012 16:10:19 +0200
+Subject: adding-setup_py
+
+---
+ cctbx_sources/stdlib.py | 4 +
+ sconsutils.py | 485 +++++++++++++++++++++++++++++++++++++++++++++++
+ setup.py | 136 +++++++++++++
+ 3 files changed, 625 insertions(+)
+ create mode 100755 cctbx_sources/stdlib.py
+ create mode 100644 sconsutils.py
+ create mode 100755 setup.py
+
+diff --git a/cctbx_sources/stdlib.py b/cctbx_sources/stdlib.py
+new file mode 100755
+index 0000000..759f689
+--- /dev/null
++++ b/cctbx_sources/stdlib.py
+@@ -0,0 +1,4 @@
++from libtbx.forward_compatibility import stdlib_import
++
++math = stdlib_import("math")
++random = stdlib_import("random")
+diff --git a/sconsutils.py b/sconsutils.py
+new file mode 100644
+index 0000000..322585b
+--- /dev/null
++++ b/sconsutils.py
+@@ -0,0 +1,485 @@
++from distutils.sysconfig import get_python_lib, get_config_var
++from distutils.command.build_ext import build_ext as _build_ext
++from distutils.command.build_py import build_py as _build_py
++from distutils.command.install_lib import install_lib as _install_lib
++from distutils.command.install_data import install_data as _install_data
++from distutils.command.clean import clean as _clean
++from distutils.cmd import Command as _Command
++from distutils.dir_util import remove_tree
++from distutils.util import change_root, convert_path
++from distutils.errors import DistutilsExecError
++from distutils import log
++import sys, os
++import SCons.Script
++import libtbx
++import libtbx.env_config
++from libtbx.path import relocatable_path, absolute_path
++from libtbx.path import relpath # don't use relpath from os.path, introduced in 2.6
++from libtbx.utils import import_python_object
++import threading
++import pickle
++
++opj = os.path.join
++configure_list = []
++scons_buildargv = []
++scons_installargv = []
++SRCDIR=''
++
++class Command(_Command):
++ def run_scons(self, argv):
++ cwd = os.getcwd()
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build') # build_temp must be set by subclass
++ if not os.path.exists(builddir):
++ if not os.path.exists(os.path.abspath(self.build_temp)):
++ os.mkdir(os.path.abspath(self.build_temp))
++ os.mkdir(builddir)
++ elif not os.path.isdir(builddir):
++ raise RuntimeError(("Build directory '%s' cannot be created "
++ "because of existing file") % builddir)
++ os.chdir(builddir)
++ if '%PREFIX%' in configure_list:
++ idx=configure_list.index('%PREFIX%')
++ configure_list[idx] = self.prefix # prefix must be set by subclass
++ libtbx.env_config.cold_start(configure_list)
++ os.environ["LIBTBX_BUILD"] = builddir
++ os.environ['PYTHONPATH'] = ':'.join(sys.path)
++ self.spawn(argv)
++ os.chdir(cwd)
++
++class build_ext(_build_ext, Command):
++ user_options = _build_ext.user_options + [
++ ('prefix=', None, "installation prefix (default: python installation prefix")
++ ]
++ def initialize_options(self):
++ _build_ext.initialize_options(self)
++ self.prefix = None
++ def finalize_options(self):
++ _build_ext.finalize_options(self)
++ if not self.prefix:
++ self.prefix = get_config_var('prefix') # on Debian: 'usr'
++ def run(self):
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build') # build_temp set by _build_ext
++ self.run_scons(scons_buildargv)
++ for ext in self.extensions:
++ if len(ext.sources) != 1 or ext.sources[0] != '%SCONSLIB%':
++ log.warn("Don't know how to build extension '%s' -- skipping",
++ ext.name)
++ continue
++ dst = self.get_ext_fullpath(ext.name)
++ bld = opj(builddir, 'lib', os.path.basename(dst))
++ if os.path.isfile(bld):
++ self.copy_file(bld, dst)
++
++class build_py(_build_py):
++ def build_module (self, module, module_file, package):
++ if type(package) is str:
++ package = package.split('.')
++ elif type(package) not in (list, tuple):
++ raise TypeError, \
++ "'package' must be a string (dot-separated), list, or tuple"
++
++ # Now put the module source file into the "build" area -- this is
++ # easy, we just copy it somewhere under self.build_lib (the build
++ # directory for Python source).
++ outfile = self.get_module_outfile(self.build_lib, package, module)
++ dir = os.path.dirname(outfile)
++ self.mkpath(dir)
++ # If the module contains non-blank, non-comment/docstring lines, and doesn't have
++ # the __future__ import, add it before the first non-comment/docstring line
++ empty = True
++ found = False
++ docstring = None
++ file_obj = open(module_file)
++ for line in file_obj:
++ if docstring:
++ if (line.count(docstring) % 2) == 1:
++ # FIXME this logic will fail with lines such as """ + ''',
++ # but nobody with a sane mind would do that, would they ?
++ docstring = None
++ continue
++ if line == "from __future__ import division\n":
++ found = True
++ break
++ if line.isspace() or line.startswith('#'):
++ continue
++ if line.startswith('"""') and (line.count('"""') % 2) == 1:
++ docstring = '"""'
++ continue
++ if line.startswith('"'):
++ continue
++ if line.startswith("'''") and (line.count("'''") % 2) == 1:
++ docstring = "'''"
++ continue
++ if line.startswith("'"):
++ continue
++ empty = False
++ break
++ file_obj.close()
++ if empty or found:
++ return self.copy_file(module_file, outfile, preserve_mode=0)
++ elif self.dry_run:
++ if os.path.isdir(outfile):
++ outfile = opj(outfile, os.path.basename(module_file))
++ log.info("copying with modification %s -> %s", module_file, outfile)
++ return outfile, True
++ else:
++ if os.path.isdir(outfile):
++ outfile = opj(outfile, os.path.basename(module_file))
++ log.info("copying with modification %s -> %s", module_file, outfile)
++ file_obj = open(module_file)
++ outfile_obj = open(outfile, 'w')
++ written = False
++ docstring = None
++ for line in file_obj:
++ if not written:
++ if docstring:
++ if (line.count(docstring) % 2) == 1:
++ docstring = None
++ outfile_obj.write(line)
++ continue
++ if line.isspace() or line.startswith('#'):
++ outfile_obj.write(line)
++ continue
++ if line.startswith('"""') and (line.count('"""') % 2) == 1:
++ docstring = '"""'
++ outfile_obj.write(line)
++ continue
++ if line.startswith('"'):
++ outfile_obj.write(line)
++ continue
++ if line.startswith("'''") and (line.count("'''") % 2) == 1:
++ docstring = "'''"
++ outfile_obj.write(line)
++ continue
++ if line.startswith("'"):
++ outfile_obj.write(line)
++ continue
++ outfile_obj.write("from __future__ import division\n")
++ written = True
++ outfile_obj.write(line)
++ outfile_obj.close()
++ file_obj.close()
++ return outfile, True
++
++class test(_Command):
++ description = "runs the tests in the distutils build directory"
++ user_options = [
++ ('build-lib=', None,
++ "distutils build directory (default: 'build.build-lib')"),
++ ('build-temp=', 't',
++ "directory for temporary files (default: 'build.build-temp')")
++ ]
++ def initialize_options(self):
++ self.build_lib = None
++ self.build_temp = None
++ def finalize_options(self):
++ self.set_undefined_options('build',
++ ('build_lib', 'build_lib'),
++ ('build_temp', 'build_temp'))
++ def run(self):
++ libdir = os.path.abspath(os.path.abspath(self.build_lib))
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build')
++ testdir = opj(os.path.abspath(self.build_temp), 'cctbx-test')
++ self.setup_test_env(builddir, libdir, testdir)
++ os.environ["LIBTBX_BUILD"] = testdir
++ env = libtbx.env_config.unpickle()
++ os.environ['PYTHONPATH'] = ':'.join([libdir] + sys.path[5:])
++ llp = os.environ.get('LD_LIBRARY_PATH')
++ if llp is not None:
++ os.environ['LD_LIBRARY_PATH'] = ':'.join([opj(builddir, 'lib', '.libs'), llp])
++ else:
++ os.environ['LD_LIBRARY_PATH'] = opj(builddir, 'lib', '.libs')
++ os.chdir(testdir)
++ failed = []
++ for m in env.module_list:
++ for (module_name,dist_path) in m.name_and_dist_path_pairs():
++ try:
++# tst_list = import_python_object(
++# import_path="%s.run_tests.tst_list" % module_name, Does not work yet
++# error_prefix="",
++# target_must_be="",
++# where_str="").object
++ run_func = import_python_object(
++ import_path="%s.run_tests.run" % module_name,
++ error_prefix="",
++ target_must_be="",
++ where_str="").object
++ tst_mod = file(opj(abs(dist_path), "run_tests.py")) # Ugly, temporary
++ tst_lines = [l.strip() for l in tst_mod]
++ tst_mod.close()
++ tst_code = " ".join(["("] +
++ tst_lines[(tst_lines.index("tst_list = (")+1)
++ :(tst_lines.index(")")+1)]
++ )
++ tst_list = eval(tst_code)
++
++ except Exception:
++ continue
++ for tst in tst_list: # adapted from libtbx.test_utils.iter_tests_cmd
++ cmd_args = []
++ if (type(tst) == type([])):
++# cmd_args = tst[1:] FIXME why only in quick mode?
++ tst = tst[0]
++ if (tst.startswith("$B")):
++ tst_path = tst.replace("$B", builddir)
++ else:
++ tst_path = tst.replace("$D", abs(dist_path))
++ if "$" in tst_path or '"' in tst_path:
++ log.warn("Could not run test '%s':\n%s", tst, "Unexpected '$' in test path")
++ failed.append([module_name,tst,AssertionError("Unexpected '$' in test path")])
++ continue
++ if '"' in tst_path:
++ log.warn("Could not run test '%s':\n%s", tst, "Unexpected '\"' in test path")
++ failed.append([module_name,tst,AssertionError("Unexpected '\"' in test path")])
++ continue
++ tst_path = os.path.normpath(tst_path)
++ if (tst_path.endswith(".py")):
++ cmd = [sys.executable, tst_path] + cmd_args
++ else:
++ cmd = [tst_path] + cmd_args
++ try:
++ self.spawn(cmd)
++ except DistutilsExecError, e:
++ log.warn("Failure in test '%s':\n%s", tst, str(e))
++ failed.append([module_name,tst,e])
++ except Exception, e:
++ log.warn("Exception in test '%s':\n%s", tst, str(e))
++ failed.append([module_name,tst,e])
++ if failed:
++ log.warn("Some tests failed:")
++ for n,t,e in failed:
++ log.warn(" module %s, test %s" % (n,t))
++ raise RuntimeError("Test failures")
++
++ def setup_test_env(self, builddir, libdir, testdir):
++ """ Create the test directory and the temporary libtbx_env pickle object """
++ if not os.path.exists(testdir):
++ if not os.path.exists(os.path.abspath(self.build_temp)):
++ os.mkdir(os.path.abspath(self.build_temp))
++ os.mkdir(testdir)
++ elif not os.path.isdir(testdir):
++ raise RuntimeError(("Test directory '%s' cannot be created "
++ "because of existing file") % testdir)
++ os.environ["LIBTBX_BUILD"] = builddir
++ env = libtbx.env_config.unpickle()
++ module_dist_paths = {}
++ for key, value in env.module_dist_paths.items():
++ head, module = os.path.split(abs(value))
++ module_dist_paths[key] = relocatable_path(absolute_path(libdir), module)
++ env.module_dist_paths = module_dist_paths
++ for module in env.module_list:
++ paths = []
++ for path in module.dist_paths:
++ if path != None:
++ head, tail = os.path.split(abs(path))
++ rp = relocatable_path(absolute_path(libdir), tail)
++ paths.append(rp)
++ else:
++ paths.append(None)
++ module.dist_paths = paths
++ file_obj = open(opj(testdir,'libtbx_env'), 'wb')
++ pickle.dump(env, file_obj, 0)
++ file_obj.close()
++
++class install_lib(_install_lib, Command):
++ user_options = _install_lib.user_options + [
++ ('build-temp=', 't',
++ "directory for temporary files (default: 'build.build-temp')"),
++ ('prefix=', None, "installation prefix (default: 'install.prefix')"),
++ ('root=', None,
++ "install everything relative to this alternate root directory (default: 'install.root')")
++ ]
++ def initialize_options(self):
++ _install_lib.initialize_options(self)
++ self.build_temp = None
++ self.prefix = None
++ self.root = None
++ def finalize_options(self):
++ _install_lib.finalize_options(self)
++ self.set_undefined_options('build',
++ ('build_temp', 'build_temp'))
++ self.set_undefined_options('install',
++ ('prefix', 'prefix'),
++ ('root', 'root'))
++ def run(self):
++ _install_lib.run(self)
++ if self.root != None:
++ ip = '--install_destdir'
++ if ip not in configure_list:
++ configure_list.extend([ip, self.root])
++ self.run_scons(scons_installargv)
++
++class install_data(_install_data, Command):
++ user_options = _install_data.user_options + [
++ ('build-temp=', 't',
++ "directory for temporary files (default: 'build.build-temp')"),
++ ('prefix=', None, "installation prefix (default: 'install.prefix')")
++ ]
++ def initialize_options(self):
++ _install_data.initialize_options(self)
++ self.build_temp = None
++ self.prefix = None
++ def finalize_options(self):
++ _install_data.finalize_options(self)
++ self.set_undefined_options('build',
++ ('build_temp', 'build_temp'))
++ self.set_undefined_options('install',
++ ('prefix', 'prefix'))
++ def run(self):
++ # filter the list
++ newdf = []
++ libtbx_env_path = None
++ for f in self.data_files:
++ if type(f) is str:
++ newdf.append(f)
++ continue
++ if '%LIBTBXENV%' in f[1]:
++ f = (f[0], [p for p in f[1] if p != '%LIBTBXENV%'])
++ libtbx_env_path = opj(convert_path(f[0]), 'libtbx_env')
++ if not os.path.isabs(libtbx_env_path): # mimic the logic in install_data
++ libtbx_env_path = opj(self.install_dir, libtbx_env_path)
++ elif self.root:
++ libtbx_env_path = change_root(self.root, libtbx_env_path)
++ # we leave the directory in, so that distutils will create it
++ newdf.append(f)
++ self.data_files = newdf
++ _install_data.run(self)
++ if libtbx_env_path is not None:
++ self.install_libtbx_env(libtbx_env_path)
++ self.outfiles.append(libtbx_env_path)
++
++ def install_libtbx_env(self, libtbx_env_path):
++ """ Modify libtbx_env pickle object to set the correct paths. """
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build')
++ os.environ["LIBTBX_BUILD"] = builddir
++ env = libtbx.env_config.unpickle()
++ env.build_path = absolute_path(self.prefix)
++ build_path = env.build_path
++ python_lib = get_python_lib()
++ rel_path = opj(python_lib, 'cctbx')
++ env.bin_path = relocatable_path(build_path, 'bin')
++ env.lib_path = relocatable_path(build_path, 'lib')
++ env.include_path = relocatable_path(build_path, 'include')
++ env.repository_paths = relocatable_path(build_path, rel_path)
++ env.scons_dist_path = None
++ env.pythonpath = None
++ env.exe_path = env.bin_path
++ env.python_exe = relocatable_path(build_path, sys.executable)
++ env.path_utility = relocatable_path(build_path,
++ opj(rel_path, 'libtbx', 'command_line', 'path_utility.py'))
++ module_dist_paths = {}
++ for key, value in env.module_dist_paths.items():
++ head, module = os.path.split(abs(value))
++ module_dist_paths[key] = relocatable_path(build_path,
++ opj(rel_path, module))
++ env.module_dist_paths = module_dist_paths
++ for module in env.module_list:
++ paths = []
++ for path in module.dist_paths:
++ if path != None:
++ head, tail = os.path.split(abs(path))
++ rp = relocatable_path(build_path, opj(rel_path, tail))
++ paths.append(rp)
++ else:
++ paths.append(None)
++ module.dist_paths = paths
++ _dispatcher_registry={}
++ for key, value in env._dispatcher_registry.items():
++ new_key = relocatable_path(anchor=build_path,
++ relocatable=key.relocatable)
++ rel = relpath(abs(value), SRCDIR)
++ new_val = relocatable_path(anchor=absolute_path(rel_path),
++ relocatable=rel)
++ _dispatcher_registry[new_key] = new_val
++ env._dispatcher_registry = _dispatcher_registry
++ # install the environment file in the data dir
++ file_obj = open(libtbx_env_path, 'wb')
++ pickle.dump(env, file_obj, 0)
++ file_obj.close()
++
++class clean(_clean):
++ def run(self):
++ # remove the scons build dir
++ builddir = opj(os.path.abspath(self.build_temp), 'cctbx-build')
++ if os.path.exists(builddir):
++ remove_tree(builddir, dry_run=self.dry_run)
++ else:
++ log.debug("'%s' does not exist -- can't clean it",
++ builddir)
++ # remove the scons test dir
++ testdir = opj(os.path.abspath(self.build_temp), 'cctbx-test')
++ if os.path.exists(testdir):
++ remove_tree(testdir, dry_run=self.dry_run)
++ else:
++ log.debug("'%s' does not exist -- can't clean it",
++ testdir)
++ # call the base class to remove the distutils dirs
++ _clean.run(self)
++
++# adapted from setuptools
++# authors: Phillip J. Eby, Tarek Ziade and the distutils SIG
++# licence: PSF or ZPL
++
++from distutils.util import convert_path
++import re
++
++EXTPAT1 = re.compile(r"^from (\S+_ext) import")
++EXTPAT2 = re.compile(r"^import (\S+_ext)$")
++EXTPAT3 = re.compile(r"boost.python.import_ext\(['\"](\S+_ext)['\"]\)$")
++EXTPAT4 = re.compile(r"import_ext\(['\"](\S+_ext)['\"]\)$") # in module boost.python!
++
++def find_packages_and_extensions(where='.', exclude=()):
++ """Return a list all Python packages found within directory 'where'
++ and a list all extensions that need to be installed inside those packages
++
++ 'where' should be supplied as a "cross-platform" (i.e. URL-style) path; it
++ will be converted to the appropriate local path syntax. 'exclude' is a
++ sequence of package names to exclude; '*' can be used as a wildcard in the
++ names, such that 'foo.*' will exclude all subpackages of 'foo' (but not
++ 'foo' itself).
++ """
++ out = []
++ outext = set()
++ stack=[(convert_path(where), '')]
++
++ while stack:
++
++ where,prefix = stack.pop(0)
++ for name in os.listdir(where):
++
++ fn = opj(where,name)
++ if ('.' not in name and os.path.isdir(fn) and
++ os.path.isfile(opj(fn,'__init__.py'))
++ ):
++
++ out.append(prefix+name); stack.append((fn,prefix+name+'.'))
++
++ if name.endswith('.py'):
++
++ f = open(opj(where, name))
++ for l in f:
++
++ m = EXTPAT1.match(l)
++ if m is not None:
++ outext.add(m.group(1))
++
++ m = EXTPAT2.match(l)
++ if m is not None:
++ outext.add(m.group(1))
++
++ m = EXTPAT3.search(l)
++ if m is not None:
++ outext.add(m.group(1))
++
++ if name == 'python.py' and prefix.endswith('boost.'):
++ m = EXTPAT4.search(l)
++ if m is not None:
++ outext.add(m.group(1))
++
++ f.close()
++
++ for pat in list(exclude)+['ez_setup', 'distribute_setup']:
++ from fnmatch import fnmatchcase
++ out = [item for item in out if not fnmatchcase(item,pat)]
++
++ return out, list(outext)
+diff --git a/setup.py b/setup.py
+new file mode 100755
+index 0000000..033dc9e
+--- /dev/null
++++ b/setup.py
+@@ -0,0 +1,142 @@
++from distutils.core import setup, Extension
++import sys, os, shutil
++
++# General settings
++opj = os.path.join
++CURDIR = os.getcwd()
++SRCDIR = opj(CURDIR, 'cctbx_sources')
++py_vers = sys.version_info
++py_major = py_vers[0]
++py_minor = py_vers[1]
++py_str = 'python%s.%s'%(py_major, py_minor)
++clipper = opj('clipper_adaptbx','clipper')
++boost = opj('boost_adaptbx','boost')
++libtbx_pypath = opj('libtbx','pythonpath')
++scons_exe = '/usr/bin/scons' # FIXME platform dependent path
++scons_path = '/usr/lib/scons/'
++PATHLIST= [ SRCDIR,
++ opj(SRCDIR, libtbx_pypath),
++ opj(SRCDIR, clipper),
++ opj(SRCDIR, boost),
++ scons_path,
++ ]
++for p in PATHLIST:
++ if p not in sys.path:
++ # we need to insert at the front, in case cctbx is already installed
++ sys.path.insert(0,p)
++
++import sconsutils
++from sconsutils import find_packages_and_extensions, build_ext, build_py, test, install_lib, install_data, clean
++
++sconsutils.SRCDIR = SRCDIR
++
++# Debian Multiarch magic
++multiarch = os.environ.get('DEB_HOST_MULTIARCH')
++libdir = os.environ.get('MULTILIBDIR')
++if multiarch == None:
++ multiarch = ''
++else:
++ libdir = 'lib/' + multiarch
++
++if libdir == None:
++ libdir = 'lib'
++# Configure settings
++# We need this directory to get env_config.cold_start to run!
++# trailing slash is important
++init_dir = opj(SRCDIR, 'libtbx')+os.sep # the separator is needed for dirname to do the right thing
++build_opts = [ '--libtoolize',
++ '--use_system_libs',
++ '--use-environment-flags',
++ '--libdir', libdir,
++ '--install_prefix', '%PREFIX%', # prefix will be replaced at run time
++ ]
++conf_modules = [ 'annlib_adaptbx',
++ 'boost_adaptbx',
++ 'cbflib_adaptbx',
++ 'ccp4io_adaptbx',
++ 'cctbx',
++ 'chiltbx',
++ 'clipper_adaptbx',
++ 'crys3d',
++ 'fable',
++ 'fftw3tbx',
++ 'gltbx',
++ 'iotbx',
++ 'libtbx',
++ 'mmtbx',
++ 'omptbx',
++ 'rstbx',
++ 'scitbx',
++ 'smtbx',
++ 'spotfinder',
++ 'tbxx',
++ 'tntbx',
++ 'ucif',
++ 'wxtbx',
++ ]
++sconsutils.configure_list = [init_dir]
++sconsutils.configure_list.extend(build_opts)
++sconsutils.configure_list.extend(conf_modules)
++
++# Build settings
++sconsutils.scons_buildargv = [sys.executable, scons_exe]
++
++# Install settings
++sconsutils.scons_installargv = [sys.executable, scons_exe, 'install']
++
++# Setup settings
++
++NAME = 'cctbx'
++VERSION = '2012.05.08.2305'
++DESCRIPTION = 'cctbx'
++AUTHOR = 'cctbx'
++AUTHOR_EMAIL = 'cctbx@cci.lbl.gov'
++URL = 'http://cctbx.sourceforge.net/'
++LICENSE = 'CCTBX 2.0'
++KEYWORDS = 'crystallography'
++SCRIPTS = []
++PKG_DATA = {}
++EXTRA_PATH = 'cctbx'
++
++MODS = ['stdlib']
++
++PACKDIR = { 'boost' : 'cctbx_sources/boost_adaptbx/boost', # in setup, paths must stay in unix syntax
++ 'clipper' : 'cctbx_sources/clipper_adaptbx/clipper', # also, let's keep them relative
++ 'optik' : 'cctbx_sources/libtbx/pythonpath/optik', # FIXME installs incompatible fork to global path
++ 'tntbx' : 'cctbx_sources/tntbx/tntbx',
++ '' : 'cctbx_sources',
++ }
++
++PACKS = []
++EXT_MODULES = []
++for key, value in PACKDIR.items():
++ p, e = find_packages_and_extensions(value)
++ PACKS.extend(p)
++ EXT_MODULES.extend(e)
++ if key != '':
++ PACKS.append(key)
++
++EXT_MODULES = [ Extension(e, ['%SCONSLIB%']) for e in EXT_MODULES ] # special treatment from install_lib
++
++setup(name=NAME,
++ version = VERSION,
++ author = AUTHOR,
++ author_email = AUTHOR_EMAIL,
++ url = URL,
++ description = DESCRIPTION,
++ license = LICENSE,
++ keywords = KEYWORDS,
++ extra_path = EXTRA_PATH,
++ scripts = SCRIPTS,
++ py_modules = MODS,
++ package_dir = PACKDIR,
++ packages = PACKS,
++ ext_modules = EXT_MODULES,
++ data_files = [('share/cctbx/%s'%(py_str), ['%LIBTBXENV%'])], # special treatment from install_data
++ cmdclass = {'build_ext': build_ext,
++ 'build_py': build_py,
++ 'test': test,
++ 'install_lib': install_lib,
++ 'install_data': install_data,
++ 'clean': clean},
++ )
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0011-fix-missing-python-lib-during-linking.patch b/sci-libs/cctbx/files/2013.02.27.0005/0011-fix-missing-python-lib-during-linking.patch
new file mode 100644
index 0000000..6724c0c
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0011-fix-missing-python-lib-during-linking.patch
@@ -0,0 +1,47 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Thu, 19 Jul 2012 23:26:30 +0200
+Subject: fix missing python lib during linking
+
+---
+ cctbx_sources/libtbx/SConscript | 4 ++--
+ cctbx_sources/scitbx/boost_python/SConscript | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 58bdd30..53e1512 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -54,9 +54,11 @@ def set_python_include_and_libs(env_etc):
+ env_etc.python_include = libtbx.env_config.python_include_path()
+ if (sys.platform == "win32"):
+ env_etc.libs_python = ["python" + sys.version[0] + sys.version[2]]
++ env_etc.py_lib = 'python%s%s'%(sys.version[0], sys.version[2])
+ env_etc.libpath_python = [sys.prefix + r"\libs"]
+ else:
+ env_etc.libs_python = []
++ env_etc.py_lib = 'python%s.%s'%(sys.version[0], sys.version[2])
+ env_etc.libpath_python = []
+ if (env_etc.compiler.startswith("darwin_")):
+ env_etc.python_framework = "/".join(
+@@ -1034,8 +1036,6 @@ def check_syslib(lib, extra_libs=None):
+ return True
+ env_etc.check_syslib = check_syslib
+
+-env_etc.py_lib = 'python%s.%s'%(sys.version[0], sys.version[2])
+-
+ if (libtbx.env.build_options.use_system_libs):
+ env_etc.use_system_libs = True
+
+diff --git a/cctbx_sources/scitbx/boost_python/SConscript b/cctbx_sources/scitbx/boost_python/SConscript
+index 1f396e5..b906eb3 100644
+--- a/cctbx_sources/scitbx/boost_python/SConscript
++++ b/cctbx_sources/scitbx/boost_python/SConscript
+@@ -7,7 +7,7 @@ env_etc.enable_more_warnings(env=env)
+ env.Append(CXXFLAGS=env_etc.cxxflags_bpl_defines_base)
+ env.Append(SHCXXFLAGS=env_etc.cxxflags_bpl_defines_base)
+ env.Append(LIBPATH=env_etc.libpath_python)
+-env.Append(LIBS=[env_etc.boost_python] + env_etc.libs_python)
++env.Append(LIBS=[env_etc.boost_python] + [env_etc.py_lib,] + env_etc.libs_python)
+ env_etc.include_registry.append(
+ env=env,
+ paths=env_etc.scitbx_common_includes + [env_etc.python_include])
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0012-fix-to-remove-cctbx.python-interpreter.patch b/sci-libs/cctbx/files/2013.02.27.0005/0012-fix-to-remove-cctbx.python-interpreter.patch
new file mode 100644
index 0000000..6fad24f
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0012-fix-to-remove-cctbx.python-interpreter.patch
@@ -0,0 +1,20 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 23 Jul 2012 23:58:46 +0200
+Subject: fix to remove cctbx.python interpreter
+
+---
+ cctbx_sources/rstbx/bpcx/uc1_2.py | 2 +-
+ cctbx_sources/rstbx/bpcx/uc1_2_reeke.py | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/cctbx_sources/rstbx/bpcx/uc1_2.py b/cctbx_sources/rstbx/bpcx/uc1_2.py
+index 95ee9cd..1abf8e1 100644
+--- a/cctbx_sources/rstbx/bpcx/uc1_2.py
++++ b/cctbx_sources/rstbx/bpcx/uc1_2.py
+@@ -1,5 +1,5 @@
+ from __future__ import division
+-#!/usr/bin/env cctbx.python
++#!/usr/bin/env python
+ #
+ # Biostruct-X Data Reduction Use Case 1.2:
+ #
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.patch b/sci-libs/cctbx/files/2013.02.27.0005/0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.patch
new file mode 100644
index 0000000..8243d93
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0013-fix-to-support-LDFLAGS-in-use_enviroment_flags.patch
@@ -0,0 +1,90 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Tue, 24 Jul 2012 17:12:30 +0200
+Subject: fix to support LDFLAGS in use_enviroment_flags
+
+---
+ cctbx_sources/libtbx/SConscript | 11 ++++++++++-
+ cctbx_sources/libtbx/env_config.py | 7 ++++++-
+ 2 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 53e1512..7d51d4a 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -777,11 +777,15 @@ else:
+ # user options for any compiler from the environment variables
+ # at the time of configure
+ opts = libtbx.env.build_options
++ env_etc.ldflags_base = []
+ if( opts.use_environment_flags ):
+ print "libtbx.scons: using flags from initial environment: "
+ print " CXXFLAGS = ", opts.env_cxxflags
+ print " CFLAGS = ", opts.env_cflags
+ print " CPPFLAGS = ", opts.env_cppflags
++ print " LDFLAGS = ", opts.env_ldflags
++ flg = opts.env_ldflags.split(" ")
++ env_etc.ldflags_base = flg
+ flg = opts.env_cxxflags.split(" ")
+ if( hasattr(env_etc, "cxxflags_base") ):
+ env_etc.cxxflags_base.extend(flg)
+@@ -853,6 +857,9 @@ def env_base_sync_with_env_etc():
+ SHCFLAGS=env_etc.cflags_base,
+ SHCCFLAGS=env_etc.ccflags_base,
+ SHCXXFLAGS=env_etc.cxxflags_base)
++ env_base.Prepend(LINKFLAGS=env_etc.ldflags_base)
++ env_etc.shlinkflags.extend(env_etc.ldflags_base)
++ env_etc.shlinkflags_bpl.extend(env_etc.ldflags_base)
+ env_base_sync_with_env_etc()
+
+ if (static_exe):
+@@ -1070,8 +1077,10 @@ def set_libtool(env):
+ # for reference. Otherwise it will be set to 0:0:0
+ env_etc.shobjsuffix_save = env['SHOBJSUFFIX']
+ env_etc.SharedLibBuilder_save = env['BUILDERS']['SharedLibrary']
++ sh_flg = list(env_etc.ldflags_base)
++ sh_flg.extend(['-rpath', env_etc.rpath])
+ env.Replace(
+- SHLINKFLAGS='-rpath ' + env_etc.rpath,
++ SHLINKFLAGS=sh_flg,
+ SHOBJSUFFIX='.lo',
+ SHLIBSUFFIX='.la',
+ )
+diff --git a/cctbx_sources/libtbx/env_config.py b/cctbx_sources/libtbx/env_config.py
+index 3d9133e..d8fb063 100644
+--- a/cctbx_sources/libtbx/env_config.py
++++ b/cctbx_sources/libtbx/env_config.py
+@@ -1803,6 +1803,7 @@ class build_options:
+ self.env_cxxflags = ""
+ self.env_cflags = ""
+ self.env_cppflags = ""
++ self.env_ldflags = ""
+ flg = os.environ.get("CXXFLAGS")
+ if flg is not None:
+ self.env_cxxflags = flg
+@@ -1812,6 +1813,9 @@ class build_options:
+ flg = os.environ.get("CPPFLAGS")
+ if flg is not None:
+ self.env_cppflags = flg
++ flg = os.environ.get("LDFLAGS")
++ if flg is not None:
++ self.env_ldflags = flg
+
+ def report(self, f=None):
+ if (f is None): f = sys.stdout
+@@ -1843,6 +1847,7 @@ class build_options:
+ print >>f, " CXXFLAGS = ", self.env_cxxflags
+ print >>f, " CFLAGS = ", self.env_cflags
+ print >>f, " CPPFLAGS = ", self.env_cppflags
++ print >>f, " LDFLAGS = ", self.env_ldflags
+
+ class include_registry:
+
+@@ -2000,7 +2005,7 @@ class pre_process_args:
+ action="store_true",
+ default=False,
+ help="add compiler flags from environment variables: CXXFLAGS, CFLAGS,"
+- " CPPFLAGS")
++ " CPPFLAGS, LDFLAGS")
+ parser.option(None, "--force_32bit",
+ action="store_true",
+ default=False,
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch b/sci-libs/cctbx/files/2013.02.27.0005/0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch
new file mode 100644
index 0000000..c3e357e
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0014-Fix-to-append-CPPFLAGS-to-CXXFLAGS.patch
@@ -0,0 +1,21 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Wed, 25 Jul 2012 01:44:36 +0200
+Subject: Fix to append CPPFLAGS to CXXFLAGS.
+
+---
+ cctbx_sources/libtbx/SConscript | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 7d51d4a..11a7810 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -798,6 +798,8 @@ else:
+ env_etc.ccflags_base = flg
+ flg = opts.env_cppflags.split(" ")
+ env_etc.ccflags_base.extend(flg)
++ # Need to append CPPFLAGS to cxxflags_base too!
++ env_etc.cxxflags_base.extend(flg)
+
+ """ ************************ Custom Builders and Emitters ********************************* """
+
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0016-autogenerate-pkgconfig-files.patch b/sci-libs/cctbx/files/2013.02.27.0005/0016-autogenerate-pkgconfig-files.patch
new file mode 100644
index 0000000..e3ba655
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0016-autogenerate-pkgconfig-files.patch
@@ -0,0 +1,305 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Mon, 6 Aug 2012 13:50:30 +0200
+Subject: autogenerate pkgconfig files
+
+---
+ cctbx_sources/cctbx/SConscript | 7 ++--
+ .../cctbx/sgtbx/direct_space_asu/proto/SConscript | 5 ++-
+ cctbx_sources/iotbx/mtz/SConscript | 6 +++-
+ cctbx_sources/iotbx/pdb/SConscript | 5 ++-
+ cctbx_sources/libtbx/SConscript | 37 +++++++++++++++++++-
+ cctbx_sources/mmtbx/masks/SConscript | 5 ++-
+ cctbx_sources/omptbx/SConscript | 5 ++-
+ cctbx_sources/rstbx/SConscript | 5 ++-
+ cctbx_sources/scitbx/boost_python/SConscript | 5 ++-
+ cctbx_sources/scitbx/minpack/SConscript | 5 ++-
+ cctbx_sources/scitbx/slatec/SConscript | 5 ++-
+ .../smtbx/refinement/constraints/SConscript | 5 ++-
+ cctbx_sources/spotfinder/SConscript | 5 ++-
+ 13 files changed, 86 insertions(+), 14 deletions(-)
+
+diff --git a/cctbx_sources/cctbx/SConscript b/cctbx_sources/cctbx/SConscript
+index 6ce770c..378cb36 100644
+--- a/cctbx_sources/cctbx/SConscript
++++ b/cctbx_sources/cctbx/SConscript
+@@ -96,9 +96,12 @@ lib_cctbx_sources = [
+ ]
+ if (env_etc.static_libraries): builder = envlm.StaticLibrary
+ else: builder = envlm.SharedLibrary
++name='cctbx'
+ builder(
+- target="#lib/cctbx",
+- source=lib_cctbx_sources)
++ target="#lib/"+name,
++ source=lib_cctbx_sources)
++desc='Library for general crystallographic applications'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ SConscript("examples/SConscript")
+
+diff --git a/cctbx_sources/cctbx/sgtbx/direct_space_asu/proto/SConscript b/cctbx_sources/cctbx/sgtbx/direct_space_asu/proto/SConscript
+index 5a5cfbd..4328794 100644
+--- a/cctbx_sources/cctbx/sgtbx/direct_space_asu/proto/SConscript
++++ b/cctbx_sources/cctbx/sgtbx/direct_space_asu/proto/SConscript
+@@ -16,9 +16,12 @@ lib_asu_sources = [
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+
++name='cctbx_sgtbx_asu'
+ builder(
+- target="#lib/cctbx_sgtbx_asu",
++ target="#lib/"+name,
+ source=lib_asu_sources)
++desc='Direct space asymmetric unit class library'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ env = env.Clone()
+ env.Prepend(LIBS=["cctbx_sgtbx_asu"])
+diff --git a/cctbx_sources/iotbx/mtz/SConscript b/cctbx_sources/iotbx/mtz/SConscript
+index cd539e6..f7d22b8 100644
+--- a/cctbx_sources/iotbx/mtz/SConscript
++++ b/cctbx_sources/iotbx/mtz/SConscript
+@@ -9,13 +9,17 @@ env.Append(SHCXXFLAGS=env_etc.ccp4io_defines)
+ env_etc.enable_more_warnings(env=env)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name='iotbx_mtz'
+ builder(
+- target="#lib/iotbx_mtz",
++ target="#lib/"+name,
+ source=[
+ "object.cpp",
+ "crystal.cpp",
+ "dataset.cpp",
+ "column.cpp"])
++desc='Wrapper Library to work with CCP4 MTZ files'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
++
+
+ if (not env_etc.no_boost_python):
+ Import("env_iotbx_boost_python_ext")
+diff --git a/cctbx_sources/iotbx/pdb/SConscript b/cctbx_sources/iotbx/pdb/SConscript
+index 9b89fe1..8a83058 100644
+--- a/cctbx_sources/iotbx/pdb/SConscript
++++ b/cctbx_sources/iotbx/pdb/SConscript
+@@ -9,8 +9,9 @@ env_etc.include_registry.append(
+ paths=env_etc.iotbx_common_includes)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name='iotbx_pdb'
+ builder(
+- target="#lib/iotbx_pdb",
++ target="#lib/"+name,
+ source=[
+ "hybrid_36_c.c",
+ "hybrid_36_cpp.cpp",
+@@ -25,6 +26,8 @@ builder(
+ "atom_selection.cpp",
+ "input.cpp",
+ "input_write.cpp"])
++desc='Fast comprehensive PDB handling library'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ env = env.Clone()
+ env_etc.include_registry.append(env=env, paths=[env_etc.fable_include])
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index 11a7810..1e91202 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -1070,8 +1070,34 @@ env_etc.install_path = os.path.abspath(env_etc.destdir + '/' + env_etc.prefix)
+ env_etc.binpath = os.path.join(env_etc.install_path, 'bin')
+ env_etc.libpath = os.path.abspath(env_etc.install_path + '/' + env_etc.libdir)
+ env_etc.inclpath = os.path.join(env_etc.install_path, 'include')
++env_etc.pkgpath = os.path.join(env_etc.install_path, 'lib/pkgconfig')
+ env_etc.rpath = os.path.abspath(env_etc.prefix + '/' + env_etc.libdir)
+
++def create_pc_file(name, version, desc, requires=None, requires_private=None,
++ conflicts=None, libs_private=None):
++ """ Create pkg-config file. """
++ fpath = '%s/%s.pc'%(abs(libtbx.env.lib_path), name)
++ pc = open(fpath, 'w')
++ pc.write('prefix=%s\n'%env_etc.prefix)
++ pc.write('exec_prefix=${prefix}\n')
++ pc.write('libdir=${prefix}/%s\n'%env_etc.libdir)
++ pc.write('includedir=${prefix}/include\n\n')
++ pc.write('Name: %s\n'%name)
++ pc.write('Description: %s\n'%desc)
++ pc.write('Version: %s\n'%version)
++ if requires != None:
++ pc.write('Requires: %s\n'%requires)
++ if requires_private != None:
++ pc.write('Requires.private: %s\n'%requires_private)
++ if conflicts != None:
++ pc.write('Conflicts: %s\n'%conflicts)
++ pc.write('Libs: -L${libdir} -l%s\n'%name)
++ if libs_private != None:
++ pc.write('Libs.private: %s\n'%libs_private)
++ pc.write('Cflags: -I${includedir}')
++ pc.close()
++env_etc.create_pc_file = create_pc_file
++
+ def set_libtool(env):
+ # Versioning can be provided by appending "-version-info 3:12:1" to SHLINKFLAGS
+ # Please see:
+@@ -1197,6 +1223,11 @@ def create_install_targets():
+ src = os.path.join(src_dir, root, filename)
+ env_base.Install(dest, src)
+ env_base.Alias("install-header", dest)
++ if re.match('^.*\.pc$', filename, flags=re.IGNORECASE):
++ dest = os.path.join(env_etc.pkgpath, root)
++ src = os.path.join(src_dir, root, filename)
++ env_base.Install(dest, src)
++ env_base.Alias("install-pkgconfig", dest)
+ if src_dir == lib_dir:
+ break
+
+@@ -1204,7 +1235,11 @@ def create_install_targets():
+ dest = env_etc.binpath
+ env_base.Install(dest, Glob('%s/*'%(exe_dev)))
+ env_base.Alias("install-bin", dest)
+- Alias('install', ['install-header', 'install-shlib', 'install-bin'])
++ Alias('install', ['install-header',
++ 'install-shlib',
++ 'install-bin',
++ 'install-pkgconfig',
++ ])
+ os.chdir(cwd)
+
+ if 'install' in COMMAND_LINE_TARGETS:
+diff --git a/cctbx_sources/mmtbx/masks/SConscript b/cctbx_sources/mmtbx/masks/SConscript
+index ef93088..a6187cc 100644
+--- a/cctbx_sources/mmtbx/masks/SConscript
++++ b/cctbx_sources/mmtbx/masks/SConscript
+@@ -13,9 +13,12 @@ lib_sources = [
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+
++name='mmtbx_masks'
+ builder(
+- target="#lib/mmtbx_masks",
++ target="#lib/"+name,
+ source=lib_sources)
++desc='Masks for bulk solvent modelling'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ env = env.Clone()
+ env.Prepend(LIBS=["mmtbx_masks", "iotbx_pdb"])
+diff --git a/cctbx_sources/omptbx/SConscript b/cctbx_sources/omptbx/SConscript
+index 43aac91..76bb923 100644
+--- a/cctbx_sources/omptbx/SConscript
++++ b/cctbx_sources/omptbx/SConscript
+@@ -12,9 +12,12 @@ env_etc.include_registry.append(
+ paths=[env_etc.omptbx_include])
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name='omptbx'
+ builder(
+- target="#lib/omptbx",
++ target="#lib/"+name,
+ source=["stubs.cpp"])
++desc='OpenMP interface for CCTBX'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ if (not env_etc.no_boost_python):
+ Import("env_boost_python_ext")
+diff --git a/cctbx_sources/rstbx/SConscript b/cctbx_sources/rstbx/SConscript
+index e2958a1..6d66476 100644
+--- a/cctbx_sources/rstbx/SConscript
++++ b/cctbx_sources/rstbx/SConscript
+@@ -26,14 +26,17 @@ env_etc.include_registry.append(
+ paths=env_etc.rstbx_common_includes)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name='rstbx'
+ builder(
+- target="#lib/rstbx",
++ target="#lib/"+name,
+ source=["dps_core/dps_core.cpp",
+ "dps_core/directional_fft.cpp",
+ "dps_core/direction.cpp",
+ "diffraction/ewald_sphere.cpp",
+ "diffraction/partial_spot_position_partial_H.cpp"
+ ])
++desc='Library for calculations in reciprocal space'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ if (not env_etc.no_boost_python):
+ Import("env_boost_python_ext")
+diff --git a/cctbx_sources/scitbx/boost_python/SConscript b/cctbx_sources/scitbx/boost_python/SConscript
+index b906eb3..0b81d9a 100644
+--- a/cctbx_sources/scitbx/boost_python/SConscript
++++ b/cctbx_sources/scitbx/boost_python/SConscript
+@@ -19,6 +19,9 @@ lib_scitbx_boost_python_sources = [
+ ]
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
++name=env_etc.scitbx_boost_python
+ builder(
+- target="#lib/%s"%env_etc.scitbx_boost_python,
++ target="#lib/"+name,
+ source=lib_scitbx_boost_python_sources)
++desc='#TODO'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+diff --git a/cctbx_sources/scitbx/minpack/SConscript b/cctbx_sources/scitbx/minpack/SConscript
+index 7c325cb..ee7509e 100644
+--- a/cctbx_sources/scitbx/minpack/SConscript
++++ b/cctbx_sources/scitbx/minpack/SConscript
+@@ -9,7 +9,10 @@ env_etc.include_registry.append(
+ env.Append(LIBS=env_etc.libm)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+-builder(target='#lib/scitbx_minpack', source=["raw.cpp"])
++name='scitbx_minpack'
++builder(target='#lib/'+name, source=["raw.cpp"])
++desc='C++ port of files in MINPACK'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ if (not env_etc.no_boost_python):
+ Import("env_scitbx_boost_python_ext")
+diff --git a/cctbx_sources/scitbx/slatec/SConscript b/cctbx_sources/scitbx/slatec/SConscript
+index ca9b6da..39e38e1 100644
+--- a/cctbx_sources/scitbx/slatec/SConscript
++++ b/cctbx_sources/scitbx/slatec/SConscript
+@@ -6,4 +6,7 @@ env_etc.enable_more_warnings(env=env)
+ env.Append(LIBS=env_etc.libm)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+-builder(target='#lib/scitbx_slatec', source=["lib_c.c"])
++name='scitbx_slatec'
++builder(target='#lib/'+name, source=["lib_c.c"])
++desc='C port of files in SLATEC'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+diff --git a/cctbx_sources/smtbx/refinement/constraints/SConscript b/cctbx_sources/smtbx/refinement/constraints/SConscript
+index 67d99dc..306d1a4 100644
+--- a/cctbx_sources/smtbx/refinement/constraints/SConscript
++++ b/cctbx_sources/smtbx/refinement/constraints/SConscript
+@@ -4,7 +4,10 @@ env_etc.include_registry.append(env=env,
+ paths=["."] + env_etc.smtbx_common_includes)
+ if (env_etc.static_libraries): builder = env.StaticLibrary
+ else: builder = env.SharedLibrary
+-builder(target="#lib/smtbx_refinement_constraints", source=Glob("*.cpp"))
++name='smtbx_refinement_constraints'
++builder(target="#lib/"+name, source=Glob("*.cpp"))
++desc='Library for small molecule crystallography constraints'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ env_program = env.Clone()
+ env_program.Prepend(LIBS=[ "cctbx", "smtbx_refinement_constraints" ])
+diff --git a/cctbx_sources/spotfinder/SConscript b/cctbx_sources/spotfinder/SConscript
+index 1d73677..a63c6d9 100644
+--- a/cctbx_sources/spotfinder/SConscript
++++ b/cctbx_sources/spotfinder/SConscript
+@@ -46,9 +46,12 @@ lib_spotfinder_sources = [
+
+ if (env_etc.static_libraries): builder = envlm.StaticLibrary
+ else: builder = envlm.SharedLibrary
++name='spotfinder'
+ builder(
+- target="#lib/spotfinder",
++ target="#lib/"+name,
+ source=lib_spotfinder_sources)
++desc='Library for locating Bragg-Spots on x-ray diffraction images'
++env_etc.create_pc_file(name=name, version='0.0.0', desc=desc)
+
+ if (not env_etc.no_boost_python):
+ Import("env_no_includes_boost_python_ext")
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0017-Fix-to-use-systems-include-path.patch b/sci-libs/cctbx/files/2013.02.27.0005/0017-Fix-to-use-systems-include-path.patch
new file mode 100644
index 0000000..4affc54
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0017-Fix-to-use-systems-include-path.patch
@@ -0,0 +1,128 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Tue, 7 Aug 2012 18:15:43 +0200
+Subject: Fix to use systems include path
+
+---
+ .../cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h | 4 ++--
+ .../cbflib_adaptbx/detectors/boost_python/general_cbf_write.h | 4 ++--
+ cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h | 4 ++--
+ .../cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp | 6 +++---
+ cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp | 4 ++--
+ cctbx_sources/ccp4io_adaptbx/ext.cpp | 2 +-
+ cctbx_sources/iotbx/mtz/ext.cpp | 2 +-
+ cctbx_sources/iotbx/mtz/object.h | 6 +++---
+ 8 files changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h
+index 66677bd..516b319 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h
++++ b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/cbf_binary_adaptor.h
+@@ -3,8 +3,8 @@
+ #include <cbflib_adaptbx/detectors/cbf_adaptor.h>
+ #include <cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h>
+ #include <cbflib_adaptbx/detectors/buffer_based_service.h>
+-#include <include/cbf_binary.h>
+-#include <include/cbf_compress.h>
++#include <cbf/cbf_binary.h>
++#include <cbf/cbf_compress.h>
+
+ namespace iotbx {
+ namespace detectors {
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/general_cbf_write.h b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/general_cbf_write.h
+index c6c1afb..f45b4d1 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/boost_python/general_cbf_write.h
++++ b/cctbx_sources/cbflib_adaptbx/detectors/boost_python/general_cbf_write.h
+@@ -1,8 +1,8 @@
+ #ifndef GENERAL_CBF_WRITE_H
+ #define GENERAL_CBF_WRITE_H
+ #include <cbflib_adaptbx/detectors/cbf_adaptor.h>
+-#include "cbf_binary.h"
+-#include "cbf_compress.h"
++#include "cbf/cbf_binary.h"
++#include "cbf/cbf_compress.h"
+
+ namespace iotbx {
+ namespace detectors {
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h b/cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h
+index b5cc407..3787c7b 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h
++++ b/cctbx_sources/cbflib_adaptbx/detectors/cbf_adaptor.h
+@@ -8,8 +8,8 @@
+ #include <exception>
+ #include <scitbx/array_family/flex_types.h>
+ #include <scitbx/array_family/versa_matrix.h>
+-#include <include/cbf.h>
+-#include <include/cbf_simple.h>
++#include <cbf/cbf.h>
++#include <cbf/cbf_simple.h>
+ #include <cbflib_adaptbx/detectors/basic.h>
+
+ #undef cbf_failnez
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp b/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp
+index 2edbfb5..526556f 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp
++++ b/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.cpp
+@@ -244,9 +244,9 @@ extern "C" {
+ #include <limits.h>
+ #include <ctype.h>
+
+-#include "cbf.h"
+-#include "cbf_file.h"
+-#include "cbf_byte_offset.h"
++#include "cbf/cbf.h"
++#include "cbf/cbf_file.h"
++#include "cbf/cbf_byte_offset.h"
+ #include <cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h>
+
+ /* Changes made in the byte-offset algorithm
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp b/cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp
+index 5f5d9b1..d121530 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp
++++ b/cctbx_sources/cbflib_adaptbx/detectors/tst_memory.cpp
+@@ -1,5 +1,5 @@
+-#include <include/cbf.h>
+-#include <include/cbf_simple.h>
++#include <cbf/cbf.h>
++#include <cbf/cbf_simple.h>
+ #include <cstdio>
+ #include <string>
+ #include <exception>
+diff --git a/cctbx_sources/ccp4io_adaptbx/ext.cpp b/cctbx_sources/ccp4io_adaptbx/ext.cpp
+index ce21568..e507515 100644
+--- a/cctbx_sources/ccp4io_adaptbx/ext.cpp
++++ b/cctbx_sources/ccp4io_adaptbx/ext.cpp
+@@ -1,5 +1,5 @@
+ #include <boost/python.hpp>
+-#include <mmdb_manager.h>
++#include <mmdb/mmdb_manager.h>
+ #include <ssm_align.h>
+
+ namespace ccp4io_adaptbx { namespace boost_python {
+diff --git a/cctbx_sources/iotbx/mtz/ext.cpp b/cctbx_sources/iotbx/mtz/ext.cpp
+index b1a0db7..6aa416a 100644
+--- a/cctbx_sources/iotbx/mtz/ext.cpp
++++ b/cctbx_sources/iotbx/mtz/ext.cpp
+@@ -1,5 +1,5 @@
+ #include <boost/python/module.hpp>
+-#include <ccp4_errno.h>
++#include <ccp4/ccp4_errno.h>
+
+ namespace iotbx { namespace mtz { namespace boost_python {
+
+diff --git a/cctbx_sources/iotbx/mtz/object.h b/cctbx_sources/iotbx/mtz/object.h
+index da35fcf..b593534 100644
+--- a/cctbx_sources/iotbx/mtz/object.h
++++ b/cctbx_sources/iotbx/mtz/object.h
+@@ -6,9 +6,9 @@
+ # include <math.h>
+ #endif
+
+-#include <cmtzlib.h>
+-#include <ccp4_array.h>
+-#include <ccp4_errno.h>
++#include <ccp4/cmtzlib.h>
++#include <ccp4/ccp4_array.h>
++#include <ccp4/ccp4_errno.h>
+ #include <cctbx/sgtbx/space_group.h>
+ #include <cctbx/hendrickson_lattman.h>
+ #include <boost/shared_ptr.hpp>
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0018-Fix-to-skip-build-of-clipper-examples.patch b/sci-libs/cctbx/files/2013.02.27.0005/0018-Fix-to-skip-build-of-clipper-examples.patch
new file mode 100644
index 0000000..ffd4ebb
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0018-Fix-to-skip-build-of-clipper-examples.patch
@@ -0,0 +1,52 @@
+From: Radostan Riedel <raybuntu@googlemail.com>
+Date: Tue, 7 Aug 2012 18:19:02 +0200
+Subject: Fix to skip build of clipper examples
+
+---
+ cctbx_sources/clipper_adaptbx/SConscript | 33 +++++++++++++++---------------
+ 1 file changed, 17 insertions(+), 16 deletions(-)
+
+diff --git a/cctbx_sources/clipper_adaptbx/SConscript b/cctbx_sources/clipper_adaptbx/SConscript
+index c39047f..b0699ad 100644
+--- a/cctbx_sources/clipper_adaptbx/SConscript
++++ b/cctbx_sources/clipper_adaptbx/SConscript
+@@ -61,22 +61,23 @@ else:
+ env_exe = env.Clone()
+ env_exe.Prepend(LIBS=[env_etc.clipper_libs[0]])
+
+-exe = env_exe.Program(
+- target='#exe_dev/'+env["PROGPREFIX"]+'clipper.symtest'
+- +env["PROGSUFFIX"],
+- source = ["../clipper/examples/symtest.cpp",
+- ])
+-libtbx.env.write_dispatcher_in_bin(
+- source_file=exe[0].get_abspath(),
+- target_file="clipper.symtest")
+-exe = env_exe.Program(
+- target='#exe_dev/'+env["PROGPREFIX"]+'clipper.sanity_check'
+- +env["PROGSUFFIX"],
+- source = ["sanity_check.cpp",
+- ])
+-libtbx.env.write_dispatcher_in_bin(
+- source_file=exe[0].get_abspath(),
+- target_file="clipper.sanity_check")
++# Skip building clipper examples in Debian
++#exe = env_exe.Program(
++# target='#exe_dev/'+env["PROGPREFIX"]+'clipper.symtest'
++# +env["PROGSUFFIX"],
++# source = ["../clipper/examples/symtest.cpp",
++# ])
++#libtbx.env.write_dispatcher_in_bin(
++# source_file=exe[0].get_abspath(),
++# target_file="clipper.symtest")
++#exe = env_exe.Program(
++# target='#exe_dev/'+env["PROGPREFIX"]+'clipper.sanity_check'
++# +env["PROGSUFFIX"],
++# source = ["sanity_check.cpp",
++# ])
++#libtbx.env.write_dispatcher_in_bin(
++# source_file=exe[0].get_abspath(),
++# target_file="clipper.sanity_check")
+
+ if (hasattr(env_etc, "cctbx_include")):
+ if (not env_etc.no_boost_python):
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0101-system-cbf.patch b/sci-libs/cctbx/files/2013.02.27.0005/0101-system-cbf.patch
new file mode 100644
index 0000000..1688026
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0101-system-cbf.patch
@@ -0,0 +1,16 @@
+ cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h b/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h
+index 0089325..02234d1 100644
+--- a/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h
++++ b/cctbx_sources/cbflib_adaptbx/detectors/cbf_byte_offset_optimized.h
+@@ -5,7 +5,7 @@
+ extern "C" {
+ #endif
+ #include <stdio.h>
+-#include <include/cbf_file.h>
++#include <cbf/cbf_file.h>
+
+ /* Decompress an array with the byte-offset algorithm */
+
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0101-system-clipper.patch b/sci-libs/cctbx/files/2013.02.27.0005/0101-system-clipper.patch
new file mode 100644
index 0000000..6f50e5f
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0101-system-clipper.patch
@@ -0,0 +1,185 @@
+ cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h | 2 +-
+ cctbx_sources/clipper/clipper/contrib/Makefile.dep | 14 +++++++-------
+ cctbx_sources/clipper/clipper/contrib/edcalc.cpp | 2 +-
+ cctbx_sources/clipper/clipper/contrib/fffear.cpp | 2 +-
+ .../clipper/clipper/contrib/function_object_bases.h | 6 +++---
+ cctbx_sources/clipper/clipper/contrib/sfcalc.cpp | 2 +-
+ cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp | 4 ++--
+ cctbx_sources/clipper/clipper/contrib/sfweight.cpp | 4 ++--
+ cctbx_sources/clipper/clipper/contrib/skeleton.cpp | 2 +-
+ cctbx_sources/clipper_adaptbx/clipper/SConscript | 1 -
+ 10 files changed, 19 insertions(+), 20 deletions(-)
+
+diff --git a/cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h b/cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h
+index bd9f7d2..079958d 100644
+--- a/cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h
++++ b/cctbx_sources/clipper/clipper/cctbx/clipper_cctbx.h
+@@ -47,7 +47,7 @@
+ #define CLIPPER_CCTBX
+
+
+-#include "../core/hkl_datatypes.h"
++#include "clipper/core/hkl_datatypes.h"
+
+ #include <cctbx/sgtbx/space_group.h>
+ #include <cctbx/hendrickson_lattman.h>
+diff --git a/cctbx_sources/clipper/clipper/contrib/Makefile.dep b/cctbx_sources/clipper/clipper/contrib/Makefile.dep
+index 98251b1..0fe7bb3 100644
+--- a/cctbx_sources/clipper/clipper/contrib/Makefile.dep
++++ b/cctbx_sources/clipper/clipper/contrib/Makefile.dep
+@@ -1,27 +1,27 @@
+
+-function_object_bases.h: ../core/hkl_datatypes.h ../core/xmap.h ../core/nxmap_operator.h
++function_object_bases.h: clipper/core/hkl_datatypes.h clipper/core/xmap.h clipper/core/nxmap_operator.h
+
+ function_object_bases.o: function_object_bases.cpp function_object_bases.h
+
+ sfcalc.h: function_object_bases.h
+
+-sfcalc.o: sfcalc.cpp sfcalc.h ../core/atomsf.h
++sfcalc.o: sfcalc.cpp sfcalc.h clipper/core/atomsf.h
+
+ edcalc.h: function_object_bases.h
+
+-edcalc.o: edcalc.cpp edcalc.h ../core/atomsf.h
++edcalc.o: edcalc.cpp edcalc.h clipper/core/atomsf.h
+
+ sfcalc_obs.h: function_object_bases.h
+
+-sfcalc_obs.o: sfcalc_obs.cpp sfcalc_obs.h edcalc.h ../core/hkl_compute.h ../core/resol_targetfn.h
++sfcalc_obs.o: sfcalc_obs.cpp sfcalc_obs.h edcalc.h clipper/core/hkl_compute.h clipper/core/resol_targetfn.h
+
+ sfweight.h: function_object_bases.h
+
+-sfweight.o: sfweight.cpp sfweight.h ../core/hkl_operators.h ../core/resol_targetfn.h
++sfweight.o: sfweight.cpp sfweight.h clipper/core/hkl_operators.h clipper/core/resol_targetfn.h
+
+ fffear.h: function_object_bases.h
+
+-fffear.o: fffear.cpp fffear.h ../core/map_interp.h
++fffear.o: fffear.cpp fffear.h clipper/core/map_interp.h
+
+ mapfilter.h: function_object_bases.h
+
+@@ -29,7 +29,7 @@ mapfilter.o: mapfilter.cpp mapfilter.h
+
+ skeleton.h: function_object_bases.h
+
+-skeleton.o: skeleton.cpp skeleton.h ../core/map_utils.h
++skeleton.o: skeleton.cpp skeleton.h clipper/core/map_utils.h
+
+ originmatch.h: function_object_bases.h
+
+diff --git a/cctbx_sources/clipper/clipper/contrib/edcalc.cpp b/cctbx_sources/clipper/clipper/contrib/edcalc.cpp
+index f5df7b2..cc031bc 100644
+--- a/cctbx_sources/clipper/clipper/contrib/edcalc.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/edcalc.cpp
+@@ -43,7 +43,7 @@
+
+ #include "edcalc.h"
+
+-#include "../core/atomsf.h"
++#include "clipper/core/atomsf.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/fffear.cpp b/cctbx_sources/clipper/clipper/contrib/fffear.cpp
+index 9a728f7..189855a 100644
+--- a/cctbx_sources/clipper/clipper/contrib/fffear.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/fffear.cpp
+@@ -42,7 +42,7 @@
+
+ #include "fffear.h"
+
+-#include "../core/map_interp.h"
++#include "clipper/core/map_interp.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/function_object_bases.h b/cctbx_sources/clipper/clipper/contrib/function_object_bases.h
+index e6c98c7..4a40c73 100644
+--- a/cctbx_sources/clipper/clipper/contrib/function_object_bases.h
++++ b/cctbx_sources/clipper/clipper/contrib/function_object_bases.h
+@@ -48,9 +48,9 @@
+ #define CLIPPER_FUNCTION_OBJECT_BASES
+
+
+-#include "../core/hkl_datatypes.h"
+-#include "../core/xmap.h"
+-#include "../core/nxmap_operator.h"
++#include "clipper/core/hkl_datatypes.h"
++#include "clipper/core/xmap.h"
++#include "clipper/core/nxmap_operator.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/sfcalc.cpp b/cctbx_sources/clipper/clipper/contrib/sfcalc.cpp
+index 48c0d9c..a3c63f0 100644
+--- a/cctbx_sources/clipper/clipper/contrib/sfcalc.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/sfcalc.cpp
+@@ -43,7 +43,7 @@
+
+ #include "sfcalc.h"
+
+-#include "../core/atomsf.h"
++#include "clipper/core/atomsf.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp b/cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp
+old mode 100755
+new mode 100644
+index de47e09..0f67585
+--- a/cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/sfcalc_obs.cpp
+@@ -43,8 +43,8 @@
+
+ #include "sfcalc_obs.h"
+ #include "edcalc.h"
+-#include "../core/hkl_compute.h"
+-#include "../core/resol_targetfn.h"
++#include "clipper/core/hkl_compute.h"
++#include "clipper/core/resol_targetfn.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/sfweight.cpp b/cctbx_sources/clipper/clipper/contrib/sfweight.cpp
+old mode 100755
+new mode 100644
+index 1b2d4dc..6ec98c2
+--- a/cctbx_sources/clipper/clipper/contrib/sfweight.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/sfweight.cpp
+@@ -42,8 +42,8 @@
+
+
+ #include "sfweight.h"
+-#include "../core/hkl_operators.h"
+-#include "../core/resol_targetfn.h"
++#include "clipper/core/hkl_operators.h"
++#include "clipper/core/resol_targetfn.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper/clipper/contrib/skeleton.cpp b/cctbx_sources/clipper/clipper/contrib/skeleton.cpp
+index bff1049..14ebf55 100644
+--- a/cctbx_sources/clipper/clipper/contrib/skeleton.cpp
++++ b/cctbx_sources/clipper/clipper/contrib/skeleton.cpp
+@@ -42,7 +42,7 @@
+
+ #include "skeleton.h"
+
+-#include "../core/map_utils.h"
++#include "clipper/core/map_utils.h"
+
+
+ namespace clipper {
+diff --git a/cctbx_sources/clipper_adaptbx/clipper/SConscript b/cctbx_sources/clipper_adaptbx/clipper/SConscript
+index 1911eb1..df03808 100644
+--- a/cctbx_sources/clipper_adaptbx/clipper/SConscript
++++ b/cctbx_sources/clipper_adaptbx/clipper/SConscript
+@@ -11,5 +11,4 @@ env.SharedLibrary(
+ "clipper_ext.cpp",
+ "hendrickson_lattman_bpl.cpp",
+ "sigmaa_bpl.cpp",
+- "../../clipper/clipper/contrib/sfweight.cpp",
+ "../../clipper/clipper/cctbx/clipper_cctbx.cpp"]+clipper_contrib_files)
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0101-system-libccp4.patch b/sci-libs/cctbx/files/2013.02.27.0005/0101-system-libccp4.patch
new file mode 100644
index 0000000..16d088d
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0101-system-libccp4.patch
@@ -0,0 +1,15 @@
+ cctbx_sources/iotbx/mtz/object.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/cctbx_sources/iotbx/mtz/object.cpp b/cctbx_sources/iotbx/mtz/object.cpp
+index c6ce383..1975a44 100644
+--- a/cctbx_sources/iotbx/mtz/object.cpp
++++ b/cctbx_sources/iotbx/mtz/object.cpp
+@@ -1,5 +1,5 @@
+-#include <cvecmat.h>
+-#include <ccp4_spg.h>
++#include <ccp4/cvecmat.h>
++#include <ccp4/ccp4_spg.h>
+ #include <scitbx/math/utils.h>
+ #include <iotbx/mtz/batch.h>
+ #include <iotbx/mtz/column.h>
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0102-dontstrip.patch b/sci-libs/cctbx/files/2013.02.27.0005/0102-dontstrip.patch
new file mode 100644
index 0000000..08118f4
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0102-dontstrip.patch
@@ -0,0 +1,25 @@
+ cctbx_sources/libtbx/SConscript | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index debf569..46ab8d8 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -471,7 +471,7 @@ libtbx.scons: Warning: compiling with /MDd:
+ elif libtbx.env.build_options.debug_symbols:
+ lkfl = ["-rdynamic"]
+ else:
+- lkfl = ["-s"]
++ lkfl = []
+ env_etc.shlinkflags = ["-shared"]
+ if (libtbx.env.build_options.mode == "profile"):
+ env_base.Prepend(LINKFLAGS=["-pg"])
+@@ -589,7 +589,7 @@ else:
+ lkfl = ["-rdynamic"]
+
+ else:
+- lkfl = ["-s"]
++ lkfl = []
+ env_etc.shlinkflags = ["-shared"]
+ if (libtbx.env.build_options.mode == "profile"):
+ env_base.Prepend(LINKFLAGS=["-pg"])
diff --git a/sci-libs/cctbx/files/2013.02.27.0005/0103-respect-cflags.patch b/sci-libs/cctbx/files/2013.02.27.0005/0103-respect-cflags.patch
new file mode 100644
index 0000000..60a3c5b
--- /dev/null
+++ b/sci-libs/cctbx/files/2013.02.27.0005/0103-respect-cflags.patch
@@ -0,0 +1,60 @@
+ cctbx_sources/libtbx/SConscript | 17 ++++++-----------
+ 1 file changed, 6 insertions(+), 11 deletions(-)
+
+diff --git a/cctbx_sources/libtbx/SConscript b/cctbx_sources/libtbx/SConscript
+index c273536..a70dae8 100644
+--- a/cctbx_sources/libtbx/SConscript
++++ b/cctbx_sources/libtbx/SConscript
+@@ -120,7 +120,7 @@ def patch_scons_env_for_ad_hoc_debug(env, O123_replacement=["-O0", "-g"]):
+ for f in env[kw]:
+ if (f in ["-O1", "-O2", "-O3"]):
+ dbg_ccflags.extend(O123_replacement)
+- elif (f not in ["-ffast-math", "-funroll-loops"]):
++ elif (f not in []):
+ dbg_ccflags.append(f)
+ env.Replace(**{kw: dbg_ccflags})
+ env_etc.patch_scons_env_for_ad_hoc_debug = patch_scons_env_for_ad_hoc_debug
+@@ -453,9 +453,9 @@ libtbx.scons: Warning: compiling with /MDd:
+ warn_options = gcc_common_warn_options() + ["-Werror"]
+ env_etc.ccflags_base.extend(warn_options)
+ if (libtbx.env.build_options.optimization):
+- opts = ["-DNDEBUG", "-O3", "-ffast-math"]
++ opts = ["-DNDEBUG"]
+ if (env_etc.gcc_version >= 40100 and is_64bit_architecture):
+- opts.insert(2, "-funroll-loops")
++ opts.insert(2, )
+ else:
+ opts = ["-O0", "-fno-inline"]
+ if (libtbx.env.build_options.mode == "profile"):
+@@ -565,9 +565,7 @@ else:
+ warn_options = gcc_common_warn_options() + ["-Werror"]
+ env_etc.ccflags_base.extend(warn_options)
+ if (libtbx.env.build_options.optimization):
+- opts = ["-DNDEBUG", "-O3", "-ffast-math"]
+- if (env_etc.gcc_version >= 40100 and is_64bit_architecture):
+- opts.insert(2, "-funroll-loops")
++ opts = ["-DNDEBUG"]
+ else:
+ opts = ["-O0", "-fno-inline"]
+ if (libtbx.env.build_options.mode == "profile"):
+@@ -633,10 +631,7 @@ int main() {
+ env_etc.cxxflags_base = []
+ setup_clang_warning(env_etc, libtbx.env.build_options.warning_level)
+ if (libtbx.env.build_options.optimization):
+- opts = [
+- "-DNDEBUG",
+- "-O3",
+- "-ffast-math"]
++ opts = ["-DNDEBUG"]
+ else:
+ opts = ["-O0", "-fno-inline"]
+ if (libtbx.env.build_options.debug_symbols):
+@@ -782,7 +777,7 @@ int main() {
+ env_etc.cxxflags_base.append("-fcoalesce-templates")
+ env_etc.cxxflags_base.append("-DBOOST_ALL_NO_LIB")
+ if (libtbx.env.build_options.optimization):
+- opts = ["-DNDEBUG", "-O3", "-ffast-math"]
++ opts = ["-DNDEBUG"]
+ if (cxx == "c++" and env_etc.gcc_version
+ and env_etc.gcc_version == 40000):
+ opts[1] = "-O2" # Apple's optimizer is broken
diff --git a/sci-libs/cctbx/metadata.xml b/sci-libs/cctbx/metadata.xml
new file mode 100644
index 0000000..a259ded
--- /dev/null
+++ b/sci-libs/cctbx/metadata.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>sci-chemistry</herd>
+ <maintainer>
+ <email>jlec@gentoo.org</email>
+ <name>Justin Lecher (jlec)</name>
+ </maintainer>
+ <longdescription>
+ The Computational Crystallography Toolbox (cctbx) is being developed
+ as the open source component of the PHENIX system. The goal of
+ the PHENIX project is to advance automation of macromolecular structure
+ determination. PHENIX depends on the cctbx, but not vice versa. This
+ hierarchical approach enforces a clean design as a reusable library.
+ The cctbx is therefore also useful for small-molecule crystallography
+ and even general scientific applications.
+ </longdescription>
+</pkgmetadata>
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-06-01 17:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-01 17:24 [gentoo-commits] proj/sci:ccp4 commit in: sci-libs/cctbx/files/2013.02.27.0005/, sci-libs/cctbx/files/2012.05.08.2305/, Justin Lecher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox