File casacore.spec of Package casacore

# spec file
# Copyright (c) 2022 SUSE LLC
# 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

# ninja too old on openSUSE Leap 15.1
%if 0%{?suse_version} == 1500 && 0%{?sle_version} == 150100
%bcond_with ninja
%global __builder ninja
%bcond_without ninja

%global flavor @BUILD_FLAVOR@%{nil}

%define sover 7
%global shlib lib%{name}%{sover}
%define srcname casacore

%if "%{flavor}" == "openmpi1"
%global mpi_flavor openmpi
 %if 0%{?suse_version} >= 1550
 %define mpi_vers 1
 %define mpi_vers %{nil}

%if "%{flavor}" == "openmpi2"
%global mpi_flavor openmpi
%define mpi_vers 2

%if "%{flavor}" == "openmpi3"
%global mpi_flavor openmpi
%define mpi_vers 3

%if "%{flavor}" == "openmpi4"
%global mpi_flavor openmpi
%define mpi_vers 4

%{?mpi_flavor:%{bcond_without mpi}}%{!?mpi_flavor:%{bcond_with mpi}}
%{?with_mpi:%{!?mpi_flavor:error "No MPI family specified!"}}

%if %{with mpi}
%define my_prefix  %{_libdir}/mpi/gcc/%{mpi_flavor}%{?mpi_vers}
%define my_bindir  %{my_prefix}/bin
%define my_libdir  %{my_prefix}/%{_lib}
%define my_incdir  %{my_prefix}/include
%define my_datadir %{my_prefix}/share
%define my_suffix  -%{mpi_flavor}%{?mpi_vers}
%define my_prefix  %{_prefix}
%define my_bindir  %{_bindir}
%define my_libdir  %{_libdir}
%define my_incdir  %{_includedir}
%define my_datadir %{_datadir}

%define pname %{srcname}%{?my_suffix}
%define shlib lib%{srcname}%{sover}%{?my_suffix}

Name:           %{pname}
Version:        3.5.0
Release:        0
Summary:        A suite of C++ libraries for radio astronomy data processing
License:        LGPL-2.0-or-later
Source99:       casacore-rpmlintrc
# PATCH-FIX-UPSTREAM casacore-fitsio-header.patch -- Fix location of cfitsio headers used in sources
Patch1:         casacore-fitsio-header.patch
BuildRequires:  bison
BuildRequires:  blas-devel
BuildRequires:  cmake
BuildRequires:  fftw3-threads-devel
BuildRequires:  flex
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  hdf5%{?my_suffix}-devel
BuildRequires:  lapack-devel
BuildRequires:  libboost_headers-devel
BuildRequires:  libboost_python3-devel
BuildRequires:  pkgconfig
BuildRequires:  python3-devel
BuildRequires:  python3-numpy-devel
BuildRequires:  readline-devel
BuildRequires:  pkgconfig(cfitsio)
BuildRequires:  pkgconfig(fftw3)
BuildRequires:  pkgconfig(gsl)
BuildRequires:  pkgconfig(ncurses)
BuildRequires:  pkgconfig(wcslib)
BuildRequires:  pkgconfig(zlib)
%if %{with mpi}
BuildRequires:  %{mpi_flavor}%{?mpi_vers}-config
BuildRequires:  %{mpi_flavor}%{?mpi_vers}-devel
BuildRequires:  fftw3-openmp-devel
%if %{with ninja}
BuildRequires:  ninja

Casacore provides a suite of C++ libraries for radio astronomy data processing.

%package -n %{shlib}
Summary:        Shared libraries for casacore, a suite of radio astronomy data

%description -n %{shlib}
Casacore provides a suite of C++ libraries for radio astronomy data processing.

This package provides the shared libraries for casacore.

%package devel
Summary:        Headers and sources for developing with casacore
Requires:       %{shlib} = %{version}
Requires:       gsl-devel
Requires:       hdf5-devel
Requires:       lapack-devel
Requires:       libboost_python3-devel
Requires:       readline-devel
Requires:       pkgconfig(cfitsio)
Requires:       pkgconfig(fftw3)
Requires:       pkgconfig(ncurses)
Requires:       pkgconfig(wcslib)

%description devel
Casacore provides a suite of C++ libraries for radio astronomy data processing.

This package provides the headers and sources for developing software with casacore.

%autosetup -p1 -n %{srcname}-%{version}

%if %{with mpi}
source %{my_bindir}/
export CC=mpicc
export CXX=mpicxx
export CC=gcc
export CXX=g++

export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
%cmake \
  -DDATA_DIR:PATH=%{my_datadir}/casacore/data \
  -DUSE_MPI:BOOL=%{?with_mpi:ON}%{!?with_mpi:OFF} \



# Move pkgconfig file to arch-specific libdir
if [ "%{_lib}" != "lib" ]
mkdir -p %{buildroot}%{my_libdir}/pkgconfig/
mv %{buildroot}%{my_prefix}/lib/pkgconfig/*.pc %{buildroot}%{my_libdir}/pkgconfig/

%post -n %{shlib} -p /sbin/ldconfig
%postun -n %{shlib} -p /sbin/ldconfig


%files -n %{shlib}

%files devel
%license COPYING

openSUSE Build Service is sponsored by