# not tagged or released
%global srcver 2.16.1
%global commit 18a9ed25c7ff79a7f4f4bf850c345c72179b8998
%global gitdate 20200316
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global githubproject l-smash/l-smash

%global builddir build

Name:           l-smash
Version:        %{srcver}
Release:        0.%{gitdate}.git%{shortcommit}%{?dist}.2sunshine
Summary:        A set of isom/mov analysis and manipulation tools

License:        ISC
URL:            http://l-smash.github.io/l-smash/
Source0:        https://github.com/%{githubproject}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz
Source1:        http://%{name}.github.io/%{name}/restrictions.html
Patch0:         l-smash-2.16.1-optflags.02.patch
Patch1:         l-smash-2.16.1-preserve.patch
BuildRequires:  gcc

%description
L_SMASH provides a set of tools to analyze and manipulate isom/mov files,
notably of the mp4, mov, 3gp, 3g2, m4a, m4v formats.

%package        devel
Summary:        Development files for %{name}
Group:          Development/Libraries

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

%package        lib
Summary:        The %{name} library
Group:          Development/Libraries

%description    lib
The %{name}-lib package contains the libraries for applications
that use %{name}.

%prep
%setup -q -n %{name}-%{commit}
# obey our build flags
%patch -P 0 -p1 -b .optflags
%patch -P 1 -p1 -b .preserve

%build
# this package doesn't understand our %%configure
LDFLAGS="%{build_ldflags}" \
    ./configure \
    --extra-cflags="%{optflags}" \
    --prefix=%{_prefix} \
    --exec-prefix=%{_exec_prefix} \
    --bindir=%{_bindir} \
    --includedir=%{_includedir} \
    --libdir=%{_libdir} \
    --enable-shared \
    --disable-static \
    --enable-debug # in order not to strip

make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot} INSTALL="install -p"

%ldconfig_scriptlets

%files
%license LICENSE
%{_bindir}/*

%files lib
%license LICENSE
%{_libdir}/*.so.*

%files devel
%license LICENSE
%{_includedir}/*.h
%{_libdir}/*.so
%{_libdir}/pkgconfig/liblsmash.pc

%changelog
* Sat Nov 09 2024 Moritz Barsnick <moritz+rpm@barsnick.net> 2.16.1-0.20200316.git18a9ed2.1sunshine
- use non-deprecated %%patch macro syntax

* Tue Apr 21 2020 Moritz Barsnick <moritz+rpm@barsnick.net> 2.16.1-0.20200316.git18a9ed2.1sunshine
- initial RPM