sci-libs/plplot: Re-enable OCaml support
authorDavid Seifert <soap@gentoo.org>
Sun, 9 Jul 2017 21:02:26 +0000 (14:02 -0700)
committerDavid Seifert <soap@gentoo.org>
Sun, 9 Jul 2017 21:02:53 +0000 (14:02 -0700)
* 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

sci-libs/plplot/files/plplot-5.12.0-ocaml-remove-rpath.patch [new file with mode: 0644]
sci-libs/plplot/plplot-5.12.0-r1.ebuild

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 (file)
index 0000000..2d18c79
--- /dev/null
@@ -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
index c8be469a4e5458754748fafe3f4fe7849dbfa514..a8582c6ed65802a58e4ace289693a5032f460ddc 100644 (file)
@@ -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)
        )