commit:     e094f6f984fe57e55a2850f60ba11be9dfaf23a6
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Sun Jul  9 21:02:26 2017 +0000
Commit:     David Seifert <soap <AT> gentoo <DOT> org>
CommitDate: Sun Jul  9 21:02:53 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e094f6f9

sci-libs/plplot: Re-enable OCaml support

* Convert absolute -L paths to relative ones in
  order to prevent ocamlmklib's braindead behaviour
  of randomly inserting RPATHs into libraries.

Package-Manager: Portage-2.3.6, Repoman-2.3.2

 .../files/plplot-5.12.0-ocaml-remove-rpath.patch   | 34 ++++++++++++++++++++++
 sci-libs/plplot/plplot-5.12.0-r1.ebuild            | 20 ++++++++-----
 2 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/sci-libs/plplot/files/plplot-5.12.0-ocaml-remove-rpath.patch 
b/sci-libs/plplot/files/plplot-5.12.0-ocaml-remove-rpath.patch
new file mode 100644
index 00000000000..2d18c79736f
--- /dev/null
+++ b/sci-libs/plplot/files/plplot-5.12.0-ocaml-remove-rpath.patch
@@ -0,0 +1,34 @@
+Fix OCaml's asinine RPATH inserting behaviour.
+
+--- a/bindings/ocaml/CMakeLists.txt
++++ b/bindings/ocaml/CMakeLists.txt
+@@ -97,6 +97,20 @@
+ 
+   # ocamlc -c compiles *.c into *.o.
+   # ocamlmklib links *.o into *.so and *.a
++
++  # ocamlmklib implicits inserts RPATHs if it is provided with an absolute 
path to -L,
++  # which is absolutely unacceptable and presents a massive security hazard. 
The
++  # following statements convert the absolute paths to relative ones to fix 
this.
++  # See also:
++  #   https://caml.inria.fr/mantis/view.php?id=5943
++  if(CMAKE_SKIP_RPATH)
++    file(RELATIVE_PATH CAMLIDL_LINK_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR} 
${CAMLIDL_LIB_DIR})
++    file(RELATIVE_PATH CMAKE_LINK_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} 
${CMAKE_BINARY_DIR})
++  else(CMAKE_SKIP_RPATH)
++    set(CAMLIDL_LINK_LIB_DIR ${CAMLIDL_LIB_DIR})
++    set(CMAKE_LINK_BINARY_DIR ${CMAKE_BINARY_DIR})
++  endif(CMAKE_SKIP_RPATH)
++
+   add_custom_command(
+     OUTPUT
+     ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.o
+@@ -105,7 +119,7 @@
+     ${CMAKE_CURRENT_BINARY_DIR}/libplplot_stubs.a
+     COMMAND ${OCAMLC} -ccopt -I${CAMLIDL_LIB_DIR} -c 
${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.c
+     COMMAND ${OCAMLC} -ccopt -I${CMAKE_SOURCE_DIR}/include -ccopt 
-I${CMAKE_BINARY_DIR}/include -ccopt -I${CMAKE_SOURCE_DIR}/lib/qsastime -ccopt 
-I${CMAKE_BINARY_DIR} -ccopt -I${CAMLIDL_LIB_DIR} -ccopt -DPLPLOT_HAVE_CONFIG_H 
-c ${CMAKE_CURRENT_SOURCE_DIR}/plplot_impl.c
+-    COMMAND ${OCAMLMKLIB} -o plplot_stubs -L${CAMLIDL_LIB_DIR} -lcamlidl 
-L${CMAKE_BINARY_DIR}/src -lplplot 
${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.o 
${CMAKE_CURRENT_BINARY_DIR}/plplot_impl.o ${ocaml_STATIC_FLAGS}
++    COMMAND ${OCAMLMKLIB} -o plplot_stubs -L${CAMLIDL_LINK_LIB_DIR} -lcamlidl 
-L${CMAKE_LINK_BINARY_DIR}/src -lplplot 
${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.o 
${CMAKE_CURRENT_BINARY_DIR}/plplot_impl.o ${ocaml_STATIC_FLAGS}
+     DEPENDS
+     ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.c
+     ${CMAKE_CURRENT_SOURCE_DIR}/plplot_impl.c

diff --git a/sci-libs/plplot/plplot-5.12.0-r1.ebuild 
b/sci-libs/plplot/plplot-5.12.0-r1.ebuild
index c8be469a4e5..a8582c6ed65 100644
--- a/sci-libs/plplot/plplot-5.12.0-r1.ebuild
+++ b/sci-libs/plplot/plplot-5.12.0-r1.ebuild
@@ -17,7 +17,7 @@ SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
 LICENSE="LGPL-2"
 SLOT="0/14" # SONAME of libplplot.so
 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
-IUSE="cairo cxx doc +dynamic examples fortran gd java jpeg latex lua octave pdf
+IUSE="cairo cxx doc +dynamic examples fortran gd java jpeg latex lua ocaml 
octave pdf
        pdl png python qhull qt5 shapefile svg tcl test threads tk truetype 
wxwidgets X"
 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} ) qt5? ( dynamic ) test? ( 
latex ) tk? ( tcl )"
 RESTRICT="octave? ( test )"
@@ -31,6 +31,11 @@ RDEPEND="
                virtual/latex-base
        )
        lua? ( dev-lang/lua:0= )
+       ocaml? (
+               dev-lang/ocaml
+               dev-ml/camlidl
+               cairo? ( dev-ml/cairo-ocaml[gtk] )
+       )
        octave? ( sci-mathematics/octave:0= )
        pdf? ( media-libs/libharu:0= )
        pdl? (
@@ -78,6 +83,7 @@ DEPEND="${RDEPEND}
                >=virtual/jdk-1.5
                dev-lang/swig
        )
+       ocaml? ( dev-ml/findlib )
        octave? ( >=dev-lang/swig-3.0.12 )
        python? ( dev-lang/swig )
        test? (
@@ -90,6 +96,7 @@ PATCHES=(
        "${FILESDIR}"/${PN}-5.11.0-octave.patch
        "${FILESDIR}"/${PN}-5.12.0-multiarch.patch
        "${FILESDIR}"/${PN}-5.12.0-java-install-path.patch
+       "${FILESDIR}"/${PN}-5.12.0-ocaml-remove-rpath.patch
 )
 
 pkg_setup() {
@@ -131,9 +138,6 @@ src_configure() {
        # - Bindings:
        #   * Ada is a mess in Gentoo, don't use
        #   * D has been removed from Gentoo, don't use
-       #   * OCaml is a general disaster and randomly inserts RPATH
-       #     on the basis of absolute -L linker paths:
-       #       https://caml.inria.fr/mantis/view.php?id=5943
        #   * Qt4 has been disabled, as it is deprecated and unsupported 
upstream
        # - DPLD_* drivers need to use ON/OFF instead of the usex defaults 
yes/no, as
        #   the testsuite performs a string comparison to determine which tests 
to run
@@ -149,8 +153,7 @@ src_configure() {
                ## Features
                -DBUILD_DOC=OFF
                -DBUILD_DOX_DOC=OFF
-               -DUSE_RPATH=OFF
-               -DCMAKE_SKIP_INSTALL_RPATH=ON
+               -DCMAKE_SKIP_RPATH=ON
                -DPREBUILT_DOC=$(usex doc)
                -DHAVE_SHAPELIB=$(usex shapefile)
                -DWITH_FREETYPE=$(usex truetype)
@@ -165,7 +168,7 @@ src_configure() {
                ## Bindings
                -DENABLE_ada=OFF
                -DENABLE_d=OFF
-               -DENABLE_ocaml=OFF
+               -DENABLE_ocaml=$(usex ocaml)
                -DENABLE_pyqt4=OFF
                -DENABLE_cxx=$(usex cxx)
                -DENABLE_DYNDRIVERS=$(usex dynamic)
@@ -242,6 +245,9 @@ src_configure() {
        use shapefile && mycmakeargs+=(
                -DSHAPELIB_INCLUDE_DIR="${EPREFIX}"/usr/include/libshp
        )
+       use ocaml && mycmakeargs+=(
+               -DOCAML_INSTALL_DIR="$(ocamlc -where)"
+       )
        use python && mycmakeargs+=(
                -DENABLE_pyqt5=$(usex qt5)
        )

Reply via email to