commit:     9acc8d665d245b46d3c8c7e864337c2ee0f41351
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  5 08:15:01 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Oct  5 08:15:24 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9acc8d66

sci-libs/cgnslib: fix modern C issues

Closes: https://bugs.gentoo.org/934122
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sci-libs/cgnslib/cgnslib-4.4.0-r2.ebuild       | 106 +++++++++++++++++++++++++
 sci-libs/cgnslib/files/cgnslib-4.4.0-c99.patch |  55 +++++++++++++
 2 files changed, 161 insertions(+)

diff --git a/sci-libs/cgnslib/cgnslib-4.4.0-r2.ebuild 
b/sci-libs/cgnslib/cgnslib-4.4.0-r2.ebuild
new file mode 100644
index 000000000000..53eb0c7c01ac
--- /dev/null
+++ b/sci-libs/cgnslib/cgnslib-4.4.0-r2.ebuild
@@ -0,0 +1,106 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+FORTRAN_NEEDED="fortran"
+FORTRAN_STANDARD="90 2003"
+
+inherit cmake flag-o-matic fortran-2
+
+DESCRIPTION="CFD General Notation System standard library"
+HOMEPAGE="
+       https://cgns.github.io/
+       https://github.com/CGNS/CGNS
+"
+SRC_URI="https://github.com/CGNS/CGNS/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+S="${WORKDIR}/CGNS-${PV}"
+
+LICENSE="ZLIB"
+SLOT="0/$(ver_cut 1-2)"
+KEYWORDS="~amd64 ~arm ~arm64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="base-scope debug examples fortran hdf5 legacy mpi scoping szip test 
tools"
+
+RDEPEND="
+       hdf5? ( sci-libs/hdf5:=[mpi=,szip=] )
+       tools? (
+               dev-lang/tcl:=
+               dev-lang/tk:=
+               x11-libs/libXmu:=
+               virtual/glu
+               virtual/opengl
+       )
+"
+DEPEND="${RDEPEND}"
+
+RESTRICT="
+       fortran? ( test )
+       !test? ( test )
+"
+REQUIRED_USE="
+       mpi? ( hdf5 )
+       szip? ( hdf5 )
+"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-4.4.0-c99.patch
+)
+
+pkg_setup() {
+       use fortran && fortran-2_pkg_setup
+}
+
+src_prepare() {
+       # gentoo libdir
+       sed \
+               -e 's|/lib|/'$(get_libdir)'|' \
+               -e '/DESTINATION/s|lib|'$(get_libdir)'|g' \
+               -i src/CMakeLists.txt || die
+       cmake_src_prepare
+}
+
+src_configure() {
+       # -Werror=lto-type-mismatch
+       # https://bugs.gentoo.org/862684
+       # https://github.com/CGNS/CGNS/issues/758
+       filter-lto
+
+       # Needed for 4.4.0-c99.patch as it uses an internal header (bug #934122)
+       local tk_ver=$(best_version dev-lang/tk)
+       tk_ver=${tk_ver#dev-lang/tk-}
+       tk_ver=$(ver_cut 1-2 ${tk_ver})
+       append-cppflags 
-I"${ESYSROOT}/usr/$(get_libdir)/tk${tk_ver}/include/generic"
+
+       local mycmakeargs=(
+               -DCGNS_BUILD_SHARED=ON
+               -DCGNS_USE_SHARED=ON
+
+               -DCGNS_BUILD_CGNSTOOLS="$(usex tools)"
+               -DCGNS_ENABLE_BASE_SCOPE="$(usex base-scope)"
+               -DCGNS_ENABLE_FORTRAN="$(usex fortran)"
+               -DCGNS_ENABLE_HDF5="$(usex hdf5)"
+               -DCGNS_ENABLE_LEGACY="$(usex legacy)"
+               -DCGNS_ENABLE_SCOPING="$(usex scoping)"
+               -DCGNS_ENABLE_MEM_DEBUG="$(usex debug)"
+               -DCGNS_ENABLE_TESTS="$(usex test)"
+       )
+
+       if use mpi; then
+               mycmakeargs+=(
+                       -DHDF5_NEED_MPI="$(usex mpi)"
+                       -DHDF5_NEED_SZIP="$(usex szip)"
+                       -DHDF5_NEED_ZLIB="$(usex szip)"
+               )
+       fi
+
+       cmake_src_configure
+}
+
+src_install() {
+       cmake_src_install
+       dodoc README.md release_docs/{HISTORY,RELEASE,changes_from_2.5}.txt
+       rm "${ED}/usr/$(get_libdir)/libcgns.a" || die
+       dodoc release_docs/*.pdf
+       docompress -x /usr/share/doc/${PF}/examples
+       use examples && dodoc -r src/examples
+}

diff --git a/sci-libs/cgnslib/files/cgnslib-4.4.0-c99.patch 
b/sci-libs/cgnslib/files/cgnslib-4.4.0-c99.patch
new file mode 100644
index 000000000000..f0caba2045a6
--- /dev/null
+++ b/sci-libs/cgnslib/files/cgnslib-4.4.0-c99.patch
@@ -0,0 +1,55 @@
+https://github.com/CGNS/CGNS/pull/757
+https://github.com/CGNS/CGNS/pull/757
+
+From 4d791bccf1f2341de9091eb22d2ce225ec9139f7 Mon Sep 17 00:00:00 2001
+From: Mickael Philit <[email protected]>
+Date: Sun, 3 Mar 2024 20:54:39 +0100
+Subject: [PATCH] backport gcc14 fedora patch
+
+---
+ src/cgnstools/tkogl/gencyl.c | 4 ++--
+ src/cgnstools/tkogl/tkogl.c  | 8 +++++++-
+ 2 files changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/src/cgnstools/tkogl/gencyl.c b/src/cgnstools/tkogl/gencyl.c
+index cc36c4ba6..b64d777f4 100644
+--- a/src/cgnstools/tkogl/gencyl.c
++++ b/src/cgnstools/tkogl/gencyl.c
+@@ -682,8 +682,8 @@ RenderModel (Model* model)
+       Vector normal;
+       GLdouble v [3];
+       obj = gluNewTess();
+-      gluTessCallback(obj, GLU_BEGIN, glBegin);
+-      gluTessCallback(obj, GLU_VERTEX, glVertex3fv);
++      gluTessCallback(obj, GLU_BEGIN, (_GLUfuncptr)glBegin);
++      gluTessCallback(obj, GLU_VERTEX, (_GLUfuncptr)glVertex3fv);
+       gluTessCallback(obj, GLU_END, glEnd);
+       if (flags&CLOSE_FIRST) {
+          CrossSection *a = model->cross [0];
+diff --git a/src/cgnstools/tkogl/tkogl.c b/src/cgnstools/tkogl/tkogl.c
+index e697e735e..506599d54 100644
+--- a/src/cgnstools/tkogl/tkogl.c
++++ b/src/cgnstools/tkogl/tkogl.c
+@@ -22,6 +22,12 @@
+ #include "printstr.h"
+ #include "feedback.h"
+ 
++#if ! defined(__WIN32__) && ! defined(_WIN32)
++/* For TkWmAddToColormapWindows. */
++#define _TKPORT /* Typical installations cannot find tkPort.h. */
++#include <tkInt.h>
++#endif
++
+ #ifndef CONST
+ # define CONST
+ #endif
+@@ -599,7 +605,7 @@ OGLwinCmd(clientData, interp, argc, argv)
+ 
+     if ((Tk_Parent(tkwin) != NULL) &&
+       (Tk_Colormap(tkwin) != Tk_Colormap (Tk_Parent(tkwin)))) {
+-       TkWmAddToColormapWindows(tkwin);
++       TkWmAddToColormapWindows((TkWindow *)tkwin);
+     }
+ 
+     /* See if this window will share display lists with another */
+

Reply via email to