Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 632140 - sci-electronics/ngspice-27: add support to create a shared library
Summary: sci-electronics/ngspice-27: add support to create a shared library
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: The Soldering-Iron Brotherhood
URL:
Whiteboard:
Keywords: EBUILD, PATCH
Depends on:
Blocks:
 
Reported: 2017-09-27 13:21 UTC by Fabio Rossi
Modified: 2017-12-29 15:35 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
ngspice-26.ebuild (ngspice-26.ebuild,4.71 KB, text/plain)
2017-10-06 09:14 UTC, Fabio Rossi
Details
ngspice-26-blt-linkage-workaround.patch (ngspice-26-blt-linkage-workaround.patch,3.00 KB, patch)
2017-10-06 09:15 UTC, Fabio Rossi
Details | Diff
ngspice-26.ebuild (ngspice-26.ebuild,4.73 KB, text/plain)
2017-10-13 16:42 UTC, Fabio Rossi
Details
ngspice-26.ebuild (ngspice-26.ebuild,4.94 KB, text/plain)
2017-10-19 08:33 UTC, Fabio Rossi
Details
ngspice-26-blt-linkage-workaround.patch (ngspice-26-blt-linkage-workaround.patch,377 bytes, patch)
2017-10-19 08:36 UTC, Fabio Rossi
Details | Diff
ngspice-26-fix-parsing-tcl-commands.patch (ngspice-26-fix-parsing-tcl-commands.patch,928 bytes, patch)
2017-10-19 08:36 UTC, Fabio Rossi
Details | Diff
ngspice-27-r1.ebuild (ngspice-27-r1.ebuild,4.84 KB, text/plain)
2017-12-27 23:52 UTC, Fabio Rossi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fabio Rossi 2017-09-27 13:21:03 UTC
ngspice can be build as a shared library (libngspice.so), this feature is used by future Kicad releases to add spice simulation capabilities. There is the option --with-ngshared to be enabled at configure time to produce the shared library instead of classic ngspice binaries. 

The problem is that the build system of ngspice doesn't support binaries and shared library options at the same time:

https://sourceforge.net/p/ngspice/mailman/message/32846117/

So I guess it is needed to run twice the compilation to have both binaries and shared library installed at the same time. IMHO it would be better to have both options installed to be able to run spice via the binary tool or using through the shared library.

What do you think?
Comment 1 Fabio Rossi 2017-10-06 09:13:39 UTC
After getting suggestions from upstream (see https://sourceforge.net/p/ngspice/mailman/message/36057429/ for details), I have modified the current ngspice-26 version in portage to build also the shared libraries. Due to limits in the upstream build system, I chose to use multibuild feature and merge the outputs of different compilations. There are three options:

1) build only ngspice binaries
2) build a classic .so shared lib
3) build a shared lib for TCL

In principle the three options are mutually exclusive but I decided to build the package always with option (1) leaving the other two optionals. I introduced two USE flags (shared and tcl) to build the libraries.

Besides that, comparing to the original ebuild, here is a list of changes:
* upgrade to EAPI 6
* added installation of examples
* added support to openmp
* added doc USE flag
* removed a few configure options as suggested in https://sourceforge.net/p/ngspice/mailman/message/36057868/ (I left only --enable-ndev but they suggest to remove it because obsolete).

The TCL implementation seems to work, I had to patch upstream as described https://sourceforge.net/p/ngspice/discussion/120973/thread/45ef6946/#051e but there is still a problem running one of the examples as indicated in https://sourceforge.net/p/ngspice/support-requests/25/

I am attaching here the new ebuild and the patch required for TCL.
Comment 2 Fabio Rossi 2017-10-06 09:14:16 UTC
Created attachment 497826 [details]
ngspice-26.ebuild
Comment 3 Fabio Rossi 2017-10-06 09:15:32 UTC
Created attachment 497828 [details, diff]
ngspice-26-blt-linkage-workaround.patch

patch taken from RedHat https://bugzilla.redhat.com/show_bug.cgi?id=1047056
Comment 4 Fabio Rossi 2017-10-06 09:16:43 UTC
everything works also for latest ngspice-27, just rename the patch
Comment 5 Fabio Rossi 2017-10-13 16:42:03 UTC
Created attachment 498548 [details]
ngspice-26.ebuild
Comment 6 Fabio Rossi 2017-10-19 08:33:42 UTC
Created attachment 499262 [details]
ngspice-26.ebuild

Added a new patch to fix a bug in the TCL command parser (backporting an upstream fix which will be merged in the next release, probably ngspice-28)
Comment 7 Fabio Rossi 2017-10-19 08:36:05 UTC
Created attachment 499264 [details, diff]
ngspice-26-blt-linkage-workaround.patch

Replaced the previous patch from RedHat with the upstream fix. The ligspicelite.so is not built anymore because upstream idea is to link against BLT with full support to graphics.
Comment 8 Fabio Rossi 2017-10-19 08:36:45 UTC
Created attachment 499266 [details, diff]
ngspice-26-fix-parsing-tcl-commands.patch
Comment 9 Marek Szuba archtester gentoo-dev 2017-12-27 12:36:25 UTC
Thank you very much for having put all of this together, Fabio! Would you be so kind and sync your patches with the ngspice-27 ebuild now in the tree?
Comment 10 Fabio Rossi 2017-12-27 23:52:30 UTC
Created attachment 511784 [details]
ngspice-27-r1.ebuild

I have updated the ebuild for ngspice-27 aligning it to the portage version, here is a list of the changes.

Comparing to the old ngspice-26 proposal here attached (now obsoleted):

- now src_test() function supports the three parallel builds
- added RESTRICT=test until the test can be run successfully
- added the fftw useflag and dep
- moved xgraph in RDEPEND
- changed the src_prepare() by removing sed patching and adding the external patches
- sensdebug is now enabled/disabled with the USE=debug logic
- I don't use anymore use_with in src_configure() when MULTIBUILD_VARIANT is shared|tcl (check already done in pkg_setup())
- now I support the DOCS array

Comparing to portage version:

- added the multibuild logic to get the shared libs
- the readline conditional deps was missing
- added the ncurses dep
- the openmp useflag requires a check in pkg_setup()
- fixed the X11 deps (objdump -x /usr/bin/ngspice | grep NEEDED| grep libX)
- removed from the TODO list a few compile flags as suggested by upstream (https://sourceforge.net/p/ngspice/mailman/message/36057868/)
Comment 11 Larry the Git Cow gentoo-dev 2017-12-28 13:26:37 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5e3a68ac72fd7e3da395fc9a055295e18c091fea

commit 5e3a68ac72fd7e3da395fc9a055295e18c091fea
Author:     Marek Szuba <marecki@gentoo.org>
AuthorDate: 2017-12-28 13:23:24 +0000
Commit:     Marek Szuba <marecki@gentoo.org>
CommitDate: 2017-12-28 13:26:18 +0000

    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@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(+)
Comment 12 Marek Szuba archtester gentoo-dev 2017-12-29 15:35:26 UTC
Just a quick summary of changes between Fabio's submission and what I have pushed to the tree.

1. No need to inherit eutils.

2. Test failures observed for ngspice-27 were not the same as those in bug #108405, and besides a workaround has just been put in place so the restriction is no longer necessary.

3. sys-libs/readline and sys-libs/ncurses did not have slots specified

4. While technically epatch has not been deprecated yet, it is now preferred to use eapply instead - and it is definitely recommended to stick with one way of applying patches (PATCHES *could* be extended with Tcl-related patches only after "if use tcl" check, they are now applied unconditionally merely for simplicity).

5. doc/Makefile.am seems to have serious issues with recent versions of Automake so after a few attempts to bring it up to date, I excluded it again. Incidentally, unlike the Tcl-script bit with its large number of affected file, this could have been done using a simple patch.

6. 27 ebuild used dodoc to install the PDF manual, Fabio's 27-r1 went back to the insinto+doins combo from 26 (even though README.Tcl *was* installed using dodoc).  The final 27-r1 has in the end switched to expanding the DOCS array for both.

7. Re-added removal of the ngmakeidx man page/

8. No need for a die guard after emake in ngspice_install(), it will die by itself if need be.