Blob Blame Raw
# This is a serial build of NEURON
%global _description %{expand:
NEURON is a simulation environment for modeling individual neurons and networks
of neurons. It provides tools for conveniently building, managing, and using
models in a way that is numerically sound and computationally efficient. It is
particularly well-suited to problems that are closely linked to experimental
data, especially those that involve cells with complex anatomical and
biophysical properties.

This package is currently built without GUI (iv) support.
It does not include MPI support.

Please install the %{name}-devel package to compile nmodl files and so on.

%global tarname nrn

# fails somehow, disabled by default
%bcond_with metis

# Music support
%bcond_with music

Name:       neuron
Version:    7.7.1
Release:    13%{?dist}
Summary:    A flexible and powerful simulator of neurons and networks

License:    GPLv3+

Patch0:     0001-Unbundle-Random123.patch
# libstdc++ bundled is from 1988: seems heavily modified. Headers from there
# are not present in the current version
# Upstream changes the soname etc., so this will not conflict with the packaged
# version
# Unbundle readline
Patch1:     0002-Unbundle-readline.patch
Patch2:     0003-Remove-duplicate-file-installation.patch
Patch3:     0004-Build-python-bits-in-the-source-tree.patch

# Random123 does not build on these, so neither can NEURON
ExcludeArch:    %{arm} mips64r2 mips32r2 s390 s390x

BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  bison-devel
BuildRequires:  flex
BuildRequires:  flex-devel
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  git-core
BuildRequires:  iv-devel
BuildRequires:  libX11-devel
BuildRequires:  libtool
%if %{with metis}
BuildRequires:  metis-devel
BuildRequires:  ncurses-devel
BuildRequires:  readline-devel
BuildRequires:  Random123-devel

# Bundles sundials. WIP
# BuildRequires:  sundials-devel
Provides: bundled(sundials) = 2.0.1

%description %_description

%package devel
Summary:    Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}

%description devel
Headers and development shared libraries for the %{name} package

%package doc
Summary:    Documentation for %{name}
BuildArch:  noarch

%description doc
Documentation for %{name}

%package -n python3-%{name}
Summary:   Python3 interface to %{name}
Requires:  %{name}%{?_isa} = %{version}-%{release}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  python3-Cython

%description -n python3-%{name} %_description

%autosetup -n %{tarname}-%{version} -S git

# Remove executable perms from source files
find src -type f -executable ! -name "*.sh" | xargs chmod -x

# Remove bundled Random123
rm -rf src/Random123
rm -rf src/readline

# Stop build file from generating version header
sed -i '/ d'

# Create version file ourselves
export TIMESTAMP=$(date +%Y-%m-%d)
export COMMIT=%{shortcommit}
cat > src/nrnoc/nrnversion.h << EOF
#define GIT_BRANCH "master"
#define GIT_DESCRIBE "Neuron built for Fedora"

# Use system libtool instead of a local copy that neuron tries to install
pushd bin
    for f in *
        sed -i 's|\(LIBTOOL.*=.*\)$(pkgdatadir)\(.*\)|\1$(bindir)\2|' $f

# Not yet to be used

%if %{with metis}
%global metis_flags --with-metis
%global metis_flags " "

# --disable-pytsetup simply prevents the post-exec hook where it wants to run
# python We do that ourselves in our two sections
%configure %{metis_flags} \
--with-gnu-ld --disable-pysetup \
--with-nrnpython=%{__python3} \
--disable-rpm-rules --without-paranrn

sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool && \
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

# For cythonisation
%make_build -C share/lib/python

# MUSIC support
%if %{with music}
%make_build -C src/neuronmusic
pushd src/neuronmusic


# Music support
%if %{with music}
pushd src/neuronmusic

# Bits from the post install hook
# It requires the libraries before to be installed, not just built, so it must
# be done here. The only alternative is a different package that requires this,
# but this is simpler

# It can't find these somehow.
RPM_LD_FLAGS="%{?__global_ldflags} -L$RPM_BUILD_ROOT/%{_libdir}"
pushd src/nrnpython/

# Remove installed libtool copy
rm -fv $RPM_BUILD_ROOT/%{_datadir}/%{tarname}/libtool

# Move to includedir
mv $RPM_BUILD_ROOT/%{_libdir}/nrnconf.h $RPM_BUILD_ROOT/%{_includedir}/%{tarname}/nrnconf.h

# Post install clean up
# Remove stray object files
# Probably worth a PR
# Must be done at end, otherwise it deletes object files required for other builds
find . $RPM_BUILD_ROOT/%{_libdir}/ -name "*.o" -exec rm -f '{}' \;
# Remove libtool archives
find . $RPM_BUILD_ROOT/%{_libdir}/ -name "*.la" -exec rm -f '{}' \;
# Remove duplicate files. These are installed in the correct python locations already
rm -rf $RPM_BUILD_ROOT/%{_datadir}/%{tarname}/lib/python/%{name}

# Rename oc to hoc to prevent conflicts with origin-client binary oc
# rhbz: 1696118
mv $RPM_BUILD_ROOT/%{_bindir}/oc $RPM_BUILD_ROOT/%{_bindir}/hoc

# Still needed on F28?

# The makefiles do not have shebangs
%license Copyright
# Binaries, scripts and makefiles
# Libs
# Bundles
# other hoc files and data
%dir %{_datadir}/%{tarname}

# Python bits
%files -n python3-%{name}
# A data file resides here
# The libraries are here
# Egg info

%files devel
%license Copyright
# Bundles

%files doc
%license Copyright

* Wed Jan 29 2020 Fedora Release Engineering <> - 7.7.1-13
- Rebuilt for

* Wed Nov 20 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-12
- Build with iv support

* Thu Oct 03 2019 Miro Hrončok <> - 7.7.1-11
- Rebuilt for Python 3.8.0rc1 (#1748018)

* Mon Aug 19 2019 Miro Hrončok <> - 7.7.1-10
- Rebuilt for Python 3.8

* Thu Jul 25 2019 Fedora Release Engineering <> - 7.7.1-9
- Rebuilt for

* Mon Jul 15 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-8
- Enable Python build also

* Sat Jul 13 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-7
- Test a fixed python setup

* Sun Jun 23 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-6
- Add another patch

* Sun Jun 23 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-5
- Improve patch to install all headers

* Sun Jun 23 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-4
- Install all header files

* Wed Jun 19 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-3
- Replace patch to inclde required headers

* Wed Jun 19 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-2
- Remove iv header from nrnconfig file

* Wed Jun 19 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.7.1-1
- Revert to using release tar
- Use bundled sundials

* Fri May 17 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.5-7.20181214git
- Fix file list

* Fri May 17 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.5-6.20181214git
- Rename oc to hoc to prevent conflict with origin-client binary
- rhbz 1696118

* Sat Mar 02 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.5-5.20181214git5687519
- Bump and rebuild

* Thu Jan 31 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.5-4.20181214git5687519
- Remove libtool archives
- Remove stray comment
- Improve previous changelog

* Sun Jan 27 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.5-3.20181214git5687519
- Unbundle readline
- Remove readme: only speaks about installation
- Move header to includedir
- Update license
- Remove exec permissions from source files

* Sun Jan 06 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.5-2.20181214git5687519
- Put each BR on different line
- Remove unneeded comment
- Re-do random123 patch to only modify autotools files
- Remove random123 in prep

* Fri Dec 28 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 7.5-1.20181214git5687519
- Update to latest git snapshot that uses current sundials
- Build without MPI