File mingw64-libnova.spec of Package mingw64-libnova

#
# spec file for package mingw libnova
#
# Copyright (c) 2023 SUSE LINUX Products 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 http://bugs.opensuse.org/
#

%define so_ver 0-16-0
%define _pkg_name libnova
Name:           mingw64-%{_pkg_name}
Version:        0.16.0
Release:        0
Summary:        Celestial Mechanics, Astrometry and Astrodynamics Library
License:        LGPL-2.0-or-later
Group:          System/Libraries
Url:            https://libnova.sourceforge.net/
# NB Double escape to avoid macros being expanded in comments - which seems totally broken rpmbuild behaviour
# see at least https://bugzilla.redhat.com/show_bug.cgi?id=1224660
#Source0:        https://downloads.sourceforge.net/%%{_pkg_name}/%%{_pkg_name}-%%{version}.tar.gz
# Fake pretend released was a file called mingw64-pkg.tar.gz
Source0:        https://downloads.sourceforge.net/%{pkg_name}/%{name}-%{version}.tar.gz
#
# Last file release was v0.15 but there is a later version; so use that one
# For unknown reasons v0.16 was tagged in git but no release file .tar.gz (or any other format) was made
# So this was used to create the .tar.gz file:
#
#Source1:        https://sourceforge.net/p/libnova/libnova/ci/v0.16/tree/
# git clone --depth 1 --branch v0.16 https://git.code.sf.net/p/libnova/libnova libnova-0.16.0
# popd libnova-0.16.0; ./autogen.sh; pushd
# tar --exclude-vcs -zcf mingw64-libnova-0.16.0.tar.gz libnova-0.16.0
#
# Further note that the tagged release failed to set/update/report the library version,
#  so see the patch below to fix that.
#
Patch0:         0001-Fix-64bit-cross-build-v0.16.patch
Patch1:         0002-Fix-reported-version-v0.16.patch
BuildRequires:  mingw64-cross-gcc
BuildRequires:  libtool
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
libnova is a general purpose, double precision, Celestial Mechanics,
Astrometry and Astrodynamics library. The intended audience of libnova
is C & C++ programmers, astronomers and anyone else interested in
calculating positions of astronomical objects or celestial mechanics.

%package devel
Summary:        Development files for libnova
Group:          Development/Libraries/C and C++
Requires:       glibc-devel
Requires:       %{name} = %{version}

%description devel
This package contains development files for libnova.

%prep
%setup -q -n %{_pkg_name}-%{version}
%patch -P 0
%patch -P 1

%build
%{_mingw64_configure} --with-pic
# NB Configure seems to do the build so the following is unnecessary
#%%{_mingw64_make} %%{?_smp_mflags}

%install
%make_install
# Remove not needed libtool config file
#  otherwise causes issues with post osc build checks
#  where-ever it is, not managed to found out!
find %{buildroot} -name "libnova.la" -exec rm {} \;

%files devel
%defattr(-,root,root,-)
%{_mingw64_includedir}/libnova/

%files
%defattr(-,root,root,-)
%{_mingw64_bindir}/libnova-%{so_ver}.dll
%{_mingw64_bindir}/libnovaconfig.exe
%{_mingw64_libdir}/libnova.a
%{_mingw64_libdir}/libnova.dll.a

%changelog
openSUSE Build Service is sponsored by