## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 2;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%bcond_without check
%bcond_without doc

%global srcname the_Foundation

Name:           the_foundation
Version:        1.6.1
Release:        %autorelease
Summary:        Opinionated C11 library for low-level functionality

License:        BSD-2-Clause
URL:            https://codeberg.org/skyjake/the_Foundation
Source:         %{url}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# https://codeberg.org/skyjake/the_Foundation/issues/13
# Patch:          %%{name}-soname_major_ver_only.diff

BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  libunistring-devel
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(libpcre2-posix)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(zlib)
%if %{with doc}
BuildRequires:  doxygen
%endif

%global soname_version %%(echo %%{version}} | cut -d. -f1)

%global _description %{expand:
An object-oriented C library whose API is designed for a particular coding
style, taking cues from C++ STL and Qt.}

%description    %{_description}


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

%description    devel %{_description}

The %{name}-devel package contains libraries and header files for
developing applications that use %{srcname}.


%if %{with doc}
%package        doc
Summary:        Documentation for %{srcname}
BuildArch:      noarch

%description    doc %{_description}

The %{name}-doc package contains the documentation for %{srcname}.
%endif


%prep
%autosetup -n %{name} -p1


%build
%cmake
%cmake_build
%if %{with doc}
doxygen %{srcname}.doxygen
%endif


%install
%cmake_install


%if %{with check}
%check
# math has non-zero retval
# network and threading both segfault
for t in \
  archive \
  string \
  test \
  udptest \
; do
  %{__cmake_builddir}/${t}_Foundation
done
%endif


%files
%license LICENSE
%doc CHANGES.md README.md
%{_libdir}/*.so.%{soname_version}
%{_libdir}/*.so.%{version}

%files devel
%{_includedir}/*
%{_libdir}/*.so
%{_libdir}/cmake/%{srcname}
%{_libdir}/pkgconfig/%{srcname}.pc

%if %{with doc}
%files doc
%license LICENSE
%doc doc/html/*
%endif


%changelog
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Fri Mar 10 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.6.1-1
- Update to 1.6.1
- This uses major version only as SONAME version

* Thu Feb 09 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.6.0-2
- Switch to using SPDX license identifier

* Thu Feb 09 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.6.0-1
- Update to 1.6.0

* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Wed Jan 11 2023 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.5.0-1
- Update to 1.5.0
- switch from pcre to pcre2

* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Thu May 05 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.4.0-1
- Update to 1.4.0

* Fri Apr 08 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.3.0-1
- Update to 1.3.0

* Mon Mar 07 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.2.0-3
- Commit SOVERSION patch

* Mon Mar 07 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.2.0-2
- Use minor version in SOVERSION

* Sun Mar 06 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.2.0-1
- Update to 1.2.0 (resolves: rhbz#2061037)

* Thu Feb 10 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.1.0-2
- Bump to resolve fc36-in-f37 issue during f36 branching

* Tue Feb 08 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 1.1.0-1
- Initial Fedora package