## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 35;
    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

# Doxygen HTML help is not suitable for packaging due to a minified JavaScript
# bundle inserted by Doxygen itself. See discussion at
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555.
#
# We can enable the Doxygen PDF documentation as a substitute.
%bcond doc 1

Name:           cpp-hocon
Version:        0.3.0
# Makes sure an SONAME bump does not catch us by surprise. Currently, there is
# no ABI stability even across patch releases, and the SONAME comes from the
# complete version number.
%global so_version 0.3.0
Release:        %autorelease
Summary:        C++ support for the HOCON configuration file format

# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch:    %{ix86}

License:        Apache-2.0
URL:            https://github.com/puppetlabs/cpp-hocon
Source:         %{url}/archive/%{version}/cpp-hocon-%{version}.tar.gz

BuildRequires:  cmake
BuildRequires:  gcc-c++
# Our choice; the make backend would work fine too
BuildRequires:  ninja-build

BuildRequires:  boost-devel
BuildRequires:  cmake(leatherman)
BuildRequires:  gettext

# Tests
BuildRequires:  catch1-devel

# Documentation
BuildRequires:  doxygen
%if %{with doc}
BuildRequires:  doxygen-latex
BuildRequires:  make
%endif

# See facter, which has the same workaround.
# autoreq is not picking this one up so be specific
Requires:       leatherman%{?_isa}

%description
This is a port of the TypesafeConfig library to C++.

The library provides C++ support for the HOCON configuration file format.


%package devel
Summary:        Development files for the cpp-hocon library
Requires:       cpp-hocon%{?_isa} = %{version}-%{release}
Requires:       boost-devel%{?_isa}
Requires:       leatherman-devel%{?_isa}

%description devel
Libraries and headers to link against cpp-hocon.


%if %{with doc}
%package doc
Summary:        Documentation for the cpp-hocon library

BuildArch:      noarch

%description doc
Documentation for the cpp-hocon library.
%endif


%prep
%autosetup

# Do not use the obsolete vendored copy of the Catch unit testing library
# included with leatherman.
sed -r -i 's/(LEATHERMAN_COMPONENTS)(\b.+)?(\bcatch\b)/\1\2/' CMakeLists.txt
sed -r -i 's|\$\{LEATHERMAN_CATCH_INCLUDE\}|"%{_includedir}/catch"|' \
    lib/tests/CMakeLists.txt

%if %{with doc}
# We enable the Doxygen PDF documentation as a substitute. We must enable
# GENERATE_LATEX and LATEX_BATCHMODE; the rest are precautionary and should
# already be set as we like them. We also disable GENERATE_HTML, since we will
# not use it.
sed -r -i \
    -e "s/^([[:blank:]]*(GENERATE_LATEX|LATEX_BATCHMODE|USE_PDFLATEX|\
PDF_HYPERLINKS)[[:blank:]]*=[[:blank:]]*)NO[[:blank:]]*/\1YES/" \
    -e "s/^([[:blank:]]*(LATEX_TIMESTAMP|GENERATE_HTML)\
[[:blank:]]*=[[:blank:]]*)YES[[:blank:]]*/\1NO/" \
    lib/Doxyfile.in
%endif


%build
%cmake \
    -DLeatherman_DIR=%{_libdir}/cmake/leatherman \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -GNinja
%cmake_build

%if %{with doc}
pushd lib
doxygen Doxyfile
%make_build -C latex
mv latex/refman.pdf latex/cpp-hocon.pdf
popd
%endif


%install
%cmake_install


%check
%ctest


%files
%license LICENSE
%if %{without doc}
%doc README.md
%endif
%{_libdir}/libcpp-hocon.so.%{so_version}


%files devel
%{_libdir}/libcpp-hocon.so
%{_includedir}/hocon/


%if %{with doc}
%files doc
%license LICENSE
%doc lib/latex/cpp-hocon.pdf
%endif


%changelog
* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-35
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Tue Jul 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-34
- When PDF docs are disabled, omit the -doc subpackage

* Tue Jul 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-33
- Do not package CONTRIBUTING.md

* Sat Jun 17 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-32
- Use new (rpm 4.17.1+) bcond style

* Sat Jun 03 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-31
- Remove explicit %%set_build_flags, not needed since F36

* Sat Jun 03 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-30
- Eschew versioned dependencies

* Sat Jun 03 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-29
- Tidy up macros in the spec file a bit

* Mon Feb 20 2023 Jonathan Wakely <jwakely@redhat.com> - 0.3.0-27
- Rebuilt for Boost 1.81

* Mon Jan 23 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-26
- Revert "Work around missing dependency on texlive-wasy"

* Thu Jan 19 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-25
- Work around missing dependency on texlive-wasy

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-24
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Mon Dec 19 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-23
- Leaf package: remove i686 support

* Mon Dec 19 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-22
- Indicate dirs. in files list with trailing slashes

* Sun Jul 31 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-21
- Update License field to SPDX

* Wed Jul 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-20
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed May 04 2022 Thomas Rodgers <trodgers@redhat.com> - 0.3.0-19
- Rebuilt for Boost 1.78

* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Thu Dec 09 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-17
- Fix Doxygen PDF missing from -doc due to typo

* Sat Nov 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-16
- Tweak a spec file comment

* Mon Sep 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-15
- Rename PDF documentation file

* Mon Sep 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-14
- Drop explicit License on -doc; same as main

* Mon Sep 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-13
- Package PDF documentation in lieu of HTML.

* Sun Sep 26 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-12
- Improve documentation packaging

* Sun Sep 26 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-11
- Reduce macro indirection in the spec file

* Fri Sep 24 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-10
- BR cmake(leatherman) instead of leatherman-devel

* Fri Sep 24 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-9
- Use ninja backend for CMake

* Tue Aug 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-8
- Rebuild for Boost 1.76 (fix RHBZ#1991863)

* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue Mar 09 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-4
- Trivial simplification in the %%build section
- BR catch1-devel, and patch the build system to use it instead of the vendored
  copy in leatherman-devel; this fixes FTBFS due to SIGSTKSZ no longer being a
  preprocessor macro constant in glibc 2.34

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Fri Jan 22 2021 Jonathan Wakely <jwakely@redhat.com> - 0.3.0-2
- Rebuilt for Boost 1.75

* Sat Jan  9 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.3.0-1
- Update to 0.3.0 (SONAME bump)
- Drop EPEL7 conditionals in Fedora spec file
- Drop missing header patch, now upstreamed
  (https://github.com/puppetlabs/cpp-hocon/pull/124)

* Sat Jan  9 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.2.2-1
- Update to 0.2.2 (SONAME bump)
- Drop patch for upstream commit caab275509826dc5fe5ab2632582abb8f83ea2b3, now
  released

* Sat Jan  9 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.2.1-7
- Drop downstream pkg-config support (no .pc file)

* Fri Jan  8 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 0.2.1-6
- Use %%{name} macro in several places
- Use %%cmake_* macros consistently
- Add a %%check section to run the tests
- Build HTML documentation with Doxygen, and add a new -doc subpackage
- Add top-level documentation files (README.md etc.)
- Try to add necessary libs to the .pc file, and remove unnecessary -I

* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Wed Jun 03 2020 Jonathan Wakely <jwakely@redhat.com> - 0.2.1-4
- Rebuilt for leatherman-1.12.0
- Link tests to libboost_filesystem

* Wed Jun 03 2020 Jonathan Wakely <jwakely@redhat.com> - 0.2.1-3
- Rebuild for Boost 1.73.0

* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Wed Jul 24 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.2.1-1
- Update to 0.2.1

* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.6-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.6-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.6-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Fri Feb 23 2018 Peter Robinson <pbrobinson@fedoraproject.org> 0.1.6-7
- Disable tests (fails on x86)

* Thu Feb 15 2018 Filipe Rosset <rosset.filipe@gmail.com> - 0.1.6-6
- fix FTBFS

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.1.6-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Tue Jan 23 2018 Jonathan Wakely <jwakely@redhat.com> - 0.1.6-4
- Rebuilt for Boost 1.66

* Wed Oct 25 2017 James Hogarth <james.hogarth@gmail.com> - 0.1.6-3
- Point to correct location on epel7 for leatherman cmake3 files

* Thu Oct 19 2017 James Hogarth <james.hogarth@gmail.com> - 0.1.6-2
- rebuilt

* Wed Oct 04 2017 James Hogarth <james.hogarth@gmail.com> - 0.1.6-1
- Initial packaging