commit:     5e3a68ac72fd7e3da395fc9a055295e18c091fea
Author:     Marek Szuba <marecki <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 28 13:23:24 2017 +0000
Commit:     Marek Szuba <marecki <AT> gentoo <DOT> org>
CommitDate: Thu Dec 28 13:26:18 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5e3a68ac

sci-electronics/ngspice: support building shared libs and the Tcl module

Also a few dependency fixes + restrict tests again.

Submitted-by: Fabio Rossi <rossi.f <AT> inwind.it>
Closes: https://bugs.gentoo.org/632140
Package-Manager: Portage-2.3.13, Repoman-2.3.3

 .../files/ngspice-27-blt_linkage_workaround.patch  |  12 ++
 .../ngspice-27-fix_parsing_tcl_commands.patch      |  16 ++
 sci-electronics/ngspice/metadata.xml               |   3 +
 sci-electronics/ngspice/ngspice-27-r1.ebuild       | 189 +++++++++++++++++++++
 4 files changed, 220 insertions(+)

diff --git 
a/sci-electronics/ngspice/files/ngspice-27-blt_linkage_workaround.patch 
b/sci-electronics/ngspice/files/ngspice-27-blt_linkage_workaround.patch
new file mode 100644
index 00000000000..53415c748d6
--- /dev/null
+++ b/sci-electronics/ngspice/files/ngspice-27-blt_linkage_workaround.patch
@@ -0,0 +1,12 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -461,6 +461,9 @@
+         AC_MSG_ERROR([Couldn't find BLT])
+     fi
+     rm -f conftest.tcl
++
++    AC_SEARCH_LIBS([Blt_GetVector], [BLT BLT24 BLT25],,
++        [AC_MSG_ERROR([Couldnt find BLT library.])])
+     
+     AC_CHECK_LIB([pthread], [pthread_create])
+     

diff --git 
a/sci-electronics/ngspice/files/ngspice-27-fix_parsing_tcl_commands.patch 
b/sci-electronics/ngspice/files/ngspice-27-fix_parsing_tcl_commands.patch
new file mode 100644
index 00000000000..bad336590df
--- /dev/null
+++ b/sci-electronics/ngspice/files/ngspice-27-fix_parsing_tcl_commands.patch
@@ -0,0 +1,16 @@
+--- a/src/tclspice.c
++++ b/src/tclspice.c
+@@ -828,10 +828,9 @@
+     int i;
+     NG_IGNORE(clientData);
+     save_interp();
+-    /* Looks backwards through the first command and strips the :: part */
+-    for (i = strlen(argv[0])-1; i > 0; i--)
+-        if (argv[0][i] == *":")
+-            argv[0] += i + 1;
++    char *prefix = strstr(argv[0], "spice::");
++    if (prefix)
++        argv[0] = prefix + 7;
+     return _run(argc, (char **)argv);
+ }
+ 

diff --git a/sci-electronics/ngspice/metadata.xml 
b/sci-electronics/ngspice/metadata.xml
index 54267123c56..ed47ec5f170 100644
--- a/sci-electronics/ngspice/metadata.xml
+++ b/sci-electronics/ngspice/metadata.xml
@@ -9,6 +9,9 @@
                Ngspice is a mixed-level/mixed-signal circuit simulator. Its 
code is based on
                three open source software packages: Spice3f5, Cider1b1 and 
Xspice.
        </longdescription>
+       <use>
+               <flag name="shared">Build ngspice as a shared library</flag>
+       </use>
        <upstream>
                <remote-id type="sourceforge">ngspice</remote-id>
        </upstream>

diff --git a/sci-electronics/ngspice/ngspice-27-r1.ebuild 
b/sci-electronics/ngspice/ngspice-27-r1.ebuild
new file mode 100644
index 00000000000..372ba4f94d7
--- /dev/null
+++ b/sci-electronics/ngspice/ngspice-27-r1.ebuild
@@ -0,0 +1,189 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit autotools multibuild toolchain-funcs
+
+DESCRIPTION="The Next Generation Spice (Electronic Circuit Simulator)"
+SRC_URI="mirror://sourceforge/ngspice/${P}.tar.gz
+       doc? ( mirror://sourceforge/ngspice/${P}-manual.pdf )"
+HOMEPAGE="http://ngspice.sourceforge.net";
+LICENSE="BSD GPL-2"
+
+SLOT="0"
+IUSE="X debug doc examples fftw openmp readline shared tcl"
+KEYWORDS="~amd64 ~ppc ~sparc ~x86 ~x64-macos"
+
+# See bug #642460
+RESTRICT="test"
+
+DEPEND="sys-libs/ncurses:0=
+       X? ( x11-libs/libXaw
+               x11-libs/libXt
+               x11-libs/libX11 )
+       fftw? ( sci-libs/fftw:3.0 )
+       readline? ( sys-libs/readline:0= )
+       tcl? ( dev-lang/tcl:0
+               dev-tcltk/blt )"
+RDEPEND="${DEPEND}
+       X? ( sci-visualization/xgraph )"
+
+DOCS=(
+       ANALYSES
+       AUTHORS
+       BUGS
+       ChangeLog
+       DEVICES
+       NEWS
+       README
+       Stuarts_Poly_Notes
+)
+
+PATCHES=(
+       "${FILESDIR}"/${P}-autoconf_fftw3.patch
+       "${FILESDIR}"/${P}-blt_linkage_workaround.patch
+       "${FILESDIR}"/${P}-fix_parsing_tcl_commands.patch
+       "${FILESDIR}"/${P}-split_terminfo.patch
+)
+
+pkg_setup() {
+       MULTIBUILD_VARIANTS=( "binaries" )
+       use shared && MULTIBUILD_VARIANTS+=( "shared" )
+       use tcl && MULTIBUILD_VARIANTS+=( "tcl" )
+       use openmp && tc-check-openmp
+}
+
+src_prepare() {
+       default
+
+       if use tcl; then
+               if use examples; then
+                       find examples/tclspice -type f -iname \*tcl |
+                       while read s
+                       do
+                               sed -i -e 
's@../../../src/.libs/libspice...@libspice.so@g' \
+                                       -e 's@package require BLT@package 
require Tk\npackage require BLT@g' \
+                                       -e "s@spice::codemodel 
\(.*\)/\(.*\).cm@spice::codemodel /usr/$(get_libdir)/ngspice/\2.cm@g" \
+                                       "${s}" || die "sed failed"
+                       done
+               fi
+       fi
+
+       eautoreconf
+}
+
+src_configure() {
+       multibuild_copy_sources
+       multibuild_foreach_variant ngspice_configure
+}
+
+ngspice_configure() {
+       pushd "${BUILD_DIR}"
+
+       local myconf
+       if use debug; then
+               myconf="--enable-debug \
+                       --enable-ftedebug \
+                       --enable-cpdebug \
+                       --enable-sensdebug \
+                       --enable-asdebug \
+                       --enable-stepdebug \
+                       --enable-pzdebug"
+       else
+               myconf="--disable-debug \
+                       --disable-ftedebug \
+                       --disable-cpdebug \
+                       --disable-sensdebug \
+                       --disable-asdebug \
+                       --disable-stepdebug \
+                       --disable-pzdebug"
+       fi
+       # As of December 2017, these do not compile
+       myconf="${myconf} \
+               --disable-blktmsdebug \
+               --disable-smltmsdebug"
+
+       myconf="${myconf} \
+               --enable-xspice \
+               --enable-cider \
+               --enable-ndev \
+               --disable-xgraph \
+               --disable-dependency-tracking \
+               --disable-rpath \
+               $(use_enable openmp) \
+               $(use_with fftw fftw3) \
+               $(use_with readline)"
+
+       if [ "${MULTIBUILD_VARIANT}" == "shared" ]; then
+               myconf="${myconf} \
+                       --with-ngshared"
+       elif [ "${MULTIBUILD_VARIANT}" == "tcl" ]; then
+               myconf="${myconf} \
+                       --with-tcl"
+       else
+               myconf="${myconf} \
+                       $(use_with X x)"
+       fi
+
+       econf ${myconf}
+}
+
+src_compile() {
+       multibuild_foreach_variant ngspice_compile
+}
+
+ngspice_compile() {
+       pushd "${BUILD_DIR}"
+       default
+}
+
+src_install() {
+       multibuild_foreach_variant ngspice_install
+
+       # merge the installations of all variants
+       for v in "${MULTIBUILD_VARIANTS[@]}" ; do
+               cp -a "${D}_${v}"/* "${D}" || die "Failed to combine multibuild 
installations"
+               rm -rf "${D}_${v}"
+       done
+
+       use tcl && DOCS+=( README.tcl )
+       use doc && DOCS+=( "${DISTDIR}"/${P}-manual.pdf )
+
+       default
+
+       # We don't need ngmakeidx to be installed
+       rm -f "${D}"/usr/bin/ngmakeidx
+       rm -f "${D}"/usr/share/man/man1/ngmakeidx.1
+
+       if use examples; then
+               use tcl || rm -rf examples/tclspice
+
+               insinto /usr/share/${PN}
+               doins -r examples
+       fi
+}
+
+ngspice_install() {
+       pushd "${BUILD_DIR}"
+
+       emake DESTDIR="${D}_${MULTIBUILD_VARIANT}" install
+
+       # Strip shared-library and Tcl-module builds to the bare minimum;
+       # all the support files will have been handled by the 'binaries' build.
+       if [ "${MULTIBUILD_VARIANT}" != "binaries" ]; then
+               rm -rf "${D}_${MULTIBUILD_VARIANT}"/usr/bin{,.debug}
+               rm -rf "${D}_${MULTIBUILD_VARIANT}"/usr/share
+               rm -rf "${D}_${MULTIBUILD_VARIANT}"/usr/$(get_libdir)/*.la
+               rm -rf 
"${D}_${MULTIBUILD_VARIANT}"/usr/$(get_libdir)/ngspice/*.cm{,.debug}
+       fi
+}
+
+src_test() {
+       multibuild_foreach_variant ngspice_test
+}
+
+ngspice_test() {
+       pushd "${BUILD_DIR}"
+       default
+}

Reply via email to