## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## 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

%global forgeurl https://gitlab.com/Teuniz/EDFlib
%global version0 1.27
%global tag0 v%{version0}
%forgemeta

Name:           edflib
Version:        %{forgeversion}
%global so_version 2
Release:        %autorelease
Summary:        C/C++ library to read/write EDF+ and BDF+ files

# The entire source is BSD-3-Clause, except:
#   - The executable sources sine_generator.c, sweep_generator.c,
#     test_edflib.c, and test_generator.c are all BSD-2-Clause, but the
#     binaries built from these sources are not installed; therefore these
#     sources do not contribute to the license of the binary RPMs.
#   - The contents of unittest/ are GPL-3.0-or-later, but the binaries that
#     link these sources are for testing only and are not installed; therefore
#     these sources do not contribute to the license of the binary RPMs.
License:        BSD-3-Clause
SourceLicense:  %{license} AND BSD-2-Clause AND GPL-3.0-or-later
URL:            https://www.teuniz.net/edflib
# As of 1.26, we have switched to packaging from the automatic GitLab source
# archive instead; for 1.26, the release archive at:
#   %%global tar_version %%(echo '%%{version}' | tr -d .)
#   Source:         https://www.teuniz.net/edflib/edflib_%%{tar_version}.tar.gz
# lacked the lib/ subdirectory containing the Makefile, and had some other cruft
# in a tmp/ directory, indicating an error-prone manual release process.
Source:         %{forgesource}

# Library makefile: make more amenable to distribution packaging
# https://gitlab.com/Teuniz/EDFlib/-/merge_requests/7
# This PR seems to have languished upstream, and the project appears to have
# disabled merge requests at some point, so the link above is broken.
#
# - 1.27 broke ABI by changing EDFLIB_MAXSIGNALS, which affects the structure
#   edflib_hdr_t in the public API, this patch now sets an SONAME
Patch:          edflib-1.27-makefile.patch

# Big-endian support was proposed upstream, but a patch was declined, and
# beginning with version 1.23, “non-support” of big-endian architectures is
# explicitly documented and enforced at runtime. See the linked issue:
#
# edflib does not support big-endian architectures
# https://bugzilla.redhat.com/show_bug.cgi?id=2135034
#
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch:    s390x %{ix86}

BuildRequires:  make
BuildRequires:  gcc

%global common_description %{expand:
EDFlib is a programming library for C/C++ for reading and writing EDF+ and BDF+
files. It also reads “old style” EDF and BDF files. EDF means European Data
Format. BDF is the 24-bits version of EDF.

Documentation is available at https://www.teuniz.net/edflib/index.html.}

%description %common_description

Documentation is available at https://www.teuniz.net/edflib/index.html.


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

%description devel %common_description

The edflib-devel package contains libraries and header files for developing
applications that use edflib.


%prep
%autosetup %{forgesetupargs} -p1
# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_compiler_flags
sed -r -i 's/-O[23]//' lib/makefile


%build
%make_build -C lib CC="${CC-gcc}" LDCONFIG='/bin/true' MYUID='0' \
    EXTRA_CFLAGS="${CFLAGS}" LDLIBS="${LDFLAGS-}"
%make_build -C unittest CC="${CC-gcc}" \
    CFLAGS="${CFLAGS-} -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE ${LDFLAGS-}"


%install
%make_install -C lib PREFIX='%{_prefix}' MYUID=0 LDCONFIG=/bin/true


%check
./unittest/edflib_test


%files
%license LICENSE
%doc README.md
%{_libdir}/libedf.so.%{so_version}


%files devel
%{_includedir}/edflib.h
%{_libdir}/libedf.so


%changelog
## START: Generated by rpmautospec
* Thu Dec 12 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.27-2
- Add a SourceLicense field

* Thu Oct 10 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.27-1
- Update to 1.27 (close RHBZ#2317823)

* Wed Jul 17 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.26-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Mon Jun 10 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.26-1
- Update to 1.26 (close RHBZ#2291007)

* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.25-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.25-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Tue Jan 02 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.25-1
- Update to 1.25 (close RHBZ#2256463)

* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.24-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Sat Jun 03 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.24-3
- Remove explicit %%set_build_flags, not needed since F36 > >
  https://www.fedoraproject.org/wiki/Changes/SetBuildFlagsBuildCheck

* Sun Apr 23 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.24-1
- Update to 1.24 (close RHBZ#2188776)

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

* Tue Dec 20 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.23-2
- Leaf package: remove i686 support

* Sat Oct 15 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.23-1
- Update to 1.23 (close RHBZ#2135023)
- Drop downstream patch for s390x support

* Wed Aug 03 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.22-2
- Update License to SPDX

* Sat Jul 23 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.22-1
- Update to 1.22 (close RHBZ#2107790)
- Downstream .so version is bumped from 0.1 to 0.2.

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.21-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Fri Jul 08 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.21-2
- Fix extra newline in description

* Fri Feb 04 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.21-1
- Update to 1.21 (close RHBZ#2050649)
- Fixed a bug where EDFplus patient and recording subfields were not read
  correctly if they started with an “X”.

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.20-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Sat Nov 20 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.20-2
- Do not patch for endianness  except on s390x

* Tue Nov 16 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.20-1
- Initial package
## END: Generated by rpmautospec