File ngspice.spec of Package ngspice

#
# spec file for package ngspice
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%bcond_without oldapps

%global flavor @BUILD_FLAVOR@%{nil}

%if "%flavor" == "shlibs"
%define build_shared 1
%endif
%define pname   ngspice

Name:           %pname%{?build_shared:-shared}
%define so_ver 0
Version:        30
Release:        0
Summary:        Mixed-level, Mixed-signal Circuit Simulator Based on spice3f5
License:        BSD-2-Clause
Group:          Productivity/Scientific/Electronics
Url:            http://ngspice.sourceforge.net
Source0:        http://downloads.sourceforge.net/%{pname}/%{pname}-%{version}.tar.gz
Source1:        http://downloads.sourceforge.net/%{pname}/%{pname}-%{version}-manual.pdf
Patch1:         ngspice-Use-gnuplot-terminal-auto-detection.patch
BuildRequires:  bison
BuildRequires:  fftw3-devel
BuildRequires:  flex
BuildRequires:  gcc-fortran
BuildRequires:  ncurses-devel
BuildRequires:  readline-devel
BuildRequires:  xorg-x11-devel
Requires:       %{pname}-scripts = %{version}
Requires:       %{pname}-xspice-cm = %{version}
Requires:       lib%{pname}%{so_ver} = %{version}
Recommends:     %{pname}-doc = %{version}
Provides:       ng-spice-rework = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Ngspice is a mixed-level/mixed-signal circuit simulator. Its code
is based on three open source software packages: Spice3f5, Cider1b1
and Xspice.

%package doc
Summary:        Documentation for ngspice
Group:          Documentation/Other
Requires:       %{pname} = %{version}

%description doc
Ngspice is a mixed-level/mixed-signal circuit simulator. Its code
is based on three open source software packages: Spice3f5, Cider1b1
and Xspice.

%package xspice-cm
Summary:        Xspice code model Plugins
Group:          Productivity/Scientific/Electronics

%description xspice-cm
Ngspice is a mixed-level/mixed-signal circuit simulator. Its code
is based on three open source software packages: Spice3f5, Cider1b1
and Xspice. This package contains the Xspice code model plugins.

%package scripts
Summary:        Ngspice init scripts
Group:          Productivity/Scientific/Electronics

%description scripts
Ngspice is a mixed-level/mixed-signal circuit simulator. Its code
is based on three open source software packages: Spice3f5, Cider1b1
and Xspice. This package contains the ngspice init scripts shared
between ngspice and libngspice.


%package xspice-cm-devel
Summary:        Development files for Xspice code model plugins
Group:          Development/Libraries/Other
Requires:       %{pname}-xspice-cm = %{version}

%description xspice-cm-devel
Ngspice is a mixed-level/mixed-signal circuit simulator. Its code
is based on three open source software packages: Spice3f5, Cider1b1
and Xspice. This package contains the development files for Xspice
code model plugins.

%package -n lib%{pname}%{so_ver}
Summary:        Shared libraries for ngspice
Group:          System/Libraries
Requires:       %{pname}-scripts
Requires:       %{pname}-xspice-cm

%description -n lib%{pname}%{so_ver}
Ngspice is a mixed-level/mixed-signal circuit simulator. Its code
is based on three open source software packages: Spice3f5, Cider1b1
and Xspice. This package contains the shared libraries.

%package -n lib%{pname}-devel
Summary:        Development files for ngspice
Group:          Development/Libraries/Other
Requires:       lib%{pname}%{so_ver} = %{version}

%description -n lib%{pname}-devel
Ngspice is a mixed-level/mixed-signal circuit simulator. Its code
is based on three open source software packages: Spice3f5, Cider1b1
and Xspice. This package contains the development files.

%prep
%setup -q -n ngspice-%{version}
cp %{S:1} .
%patch1 -p1

%build
export CFLAGS="%{optflags} -fPIE"
export LDFLAGS="-pie"
%configure \
    --disable-debug \
%if 0%{!?build_shared:1}
    --with-x \
%else
    --with-ngshared \
%endif
    %{?with_oldapps:--enable-oldapps} \
    --with-readline=yes \
    --enable-xspice \
    --enable-cider \
    --enable-openmp

make V=1 %{?_smp_mflags}

%install
%makeinstall
find %{buildroot} -type f -name "*.la" -delete -print
%if 0%{!?build_shared:1}
rm %{buildroot}%{_includedir}/%{pname}/sharedspice.h
%else
rm -rf %{buildroot}%{_bindir}/cmpp %{buildroot}/%{_mandir} \
       %{buildroot}%{_libdir}/%{pname} \
       %{buildroot}%{_datadir}/%{pname}/dlmain.c \
       %{buildroot}%{_datadir}/%{pname}/scripts \
       %{buildroot}%{_includedir}/%{pname}/[^s]*.h \
       %{buildroot}%{_includedir}/%{pname}/s[^h]*.h
%endif

%post -n lib%{pname}%{so_ver} -p /sbin/ldconfig
%postun -n lib%{pname}%{so_ver} -p /sbin/ldconfig

%if 0%{!?build_shared:1}
%files
%license COPYING
%doc ANALYSES AUTHORS BUGS DEVICES FAQ NEWS README
%{_bindir}/ngspice
%{_mandir}/man1/ngspice.1%{?ext_man}
%dir %{_datadir}/ngspice
%if 0%{?with_oldapps}
%{_bindir}/ngmakeidx
%{_bindir}/ngmultidec
%{_bindir}/ngnutmeg
%{_bindir}/ngproc2mod
%{_bindir}/ngsconvert
%{_mandir}/man1/ngmultidec.1%{?ext_man}
%{_mandir}/man1/ngnutmeg.1%{?ext_man}
%{_mandir}/man1/ngsconvert.1%{?ext_man}
%{_mandir}/man1/ngmakeidx.1%{?ext_man}
%{_mandir}/man1/ngproc2mod.1%{?ext_man}
%{_datadir}/ngspice/helpdir
%endif

%files scripts
%{_datadir}/ngspice/scripts

%files doc
%doc ngspice-%{version}-manual.pdf

%files xspice-cm
%{_bindir}/cmpp
%{_mandir}/man1/cmpp.1%{?ext_man}
%{_libdir}/%{pname}

%files xspice-cm-devel
%doc Stuarts_Poly_Notes src/xspice/icm/README
%{_includedir}/%{pname}
%{_datadir}/%{pname}/dlmain.c

%else
%files -n lib%{pname}%{so_ver}
%{_libdir}/lib%{pname}.so.*

%files -n lib%{pname}-devel
%dir %{_includedir}/%{pname}
%{_includedir}/%{pname}/sharedspice.h
%{_libdir}/lib%{pname}.so
%{_libdir}/pkgconfig/%{pname}.pc
%endif

%changelog
openSUSE Build Service is sponsored by