%global commit0  5a07df503a6f01280f493cbcc2aace462b9dee57
%define upstream_version 2.4_1

%define major		1
%define libname		%mklibname qt5lockedfile %major
%define develname	%mklibname qt5lockedfile -d

%define libnameqt6	%mklibname qt6lockedfile %major
%define develnameqt6	%mklibname qt6lockedfile -d

%define soname %(echo %{upstream_version} | cut -d '_' -f1)

Summary:	QFile extension with advisory locking functions
Name:		qtlockedfile
Version:	%(echo %{upstream_version} | sed 's,_,.,')
Release:	%mkrel 22
Group:		Development/KDE and Qt
License:	GPLv3 or LGPLv2 with exceptions
URL:		https://docs.huihoo.com/qt/solutions/4/qtlockedfile/qtlockedfile.html
Source0:	https://github.com/qtproject/qt-solutions/archive/%{commit0}.tar.gz#/%{name}-%{commit0}.tar.gz
Source1:	qtlockedfile.prf
Source2:	LICENSE.LGPL
Source3:	LGPL_EXCEPTION
Source4:	LICENSE.GPL3

Patch0:		qtlockedfile-use-current-version.patch
Patch1:		qtlockedfile-dont-build-example.patch

BuildRequires:	pkgconfig(Qt5Core)
BuildRequires:	pkgconfig(Qt6Core)

%description
This class extends the QFile class with inter-process file locking capabilities.
If an application requires that several processes should access the same file,
QtLockedFile can be used to easily ensure that only one process at a time is
writing to the file, and that no process is writing to it while others are
reading it.

#--------------------------------------------------------------------

%package	-n %libname
Summary:	QFile extension with advisory locking functions for Qt5
Group:		Development/KDE and Qt

Obsoletes:	%{_lib}qt4lockedfile1 < 2.4.1-22

%description	-n %libname
This class extends the QFile class with inter-process file locking capabilities.
If an application requires that several processes should access the same file,
QtLockedFile can be used to easily ensure that only one process at a time is
writing to the file, and that no process is writing to it while others are
reading it.

This is the Qt5 library package for %{name}.

%files -n %libname
%{_qt5_libdir}/libQt5Solutions_LockedFile*.so.%{major}{,.*}

#--------------------------------------------------------------------

%package        -n %libnameqt6
Summary:        QFile extension with advisory locking functions for Qt6
Group:          Development/KDE and Qt

%description    -n %libnameqt6
This class extends the QFile class with inter-process file locking capabilities.
If an application requires that several processes should access the same file,
QtLockedFile can be used to easily ensure that only one process at a time is
writing to the file, and that no process is writing to it while others are
reading it.

This is the Qt6 library package for %{name}.

%files -n %libnameqt6
%{_qt6_libdir}/libQt6Solutions_LockedFile*.so.%{major}{,.*}

#--------------------------------------------------------------------

%package	-n %develname
Summary:	Development files for Qt5 %{name}
Group:		Development/KDE and Qt
Requires:	%{libname} = %{version}-%{release}
Provides:	%{name}-devel = %{version}
Provides:       %{name}5-devel = %{version}
Provides:       qt5lockedfile-devel = %{version}

Obsoletes:	%{_lib}qt4lockedfile-devel < 2.4.1-22

%description	-n %develname
This package contains libraries and header files for developing applications
that use Qt5 QtLockedFile.

%files -n %develname
%doc doc example
%{_qt5_libdir}/libQt5Solutions_LockedFile*.so
%{_qt5_includedir}/QtSolutions/
%{_qt5_archdatadir}/mkspecs/features/%{name}.prf

#--------------------------------------------------------------------

%package        -n %develnameqt6
Summary:        Development files for Qt6 %{name}
Group:          Development/KDE and Qt
Requires:       %{libnameqt6} = %{version}-%{release}
Provides:       qt6lockedfile-devel = %{version}

%description    -n %develnameqt6
This package contains libraries and header files for developing applications
that use Qt6 QtLockedFile.

%files -n %develnameqt6
%doc doc example
%{_qt6_libdir}/libQt6Solutions_LockedFile*.so
%{_qt6_includedir}/QtSolutions/
%{_qt6_archdatadir}/mkspecs/features/%{name}.prf

#--------------------------------------------------------------------

%prep
%setup -qn qt-solutions-%{commit0}/%{name}
# use versioned soname
sed -i s,head,%soname, common.pri
mkdir licenses
cp %{SOURCE2} %{SOURCE3} %{SOURCE4} licenses

%build
touch .licenseAccepted
# Does not use GNU configure
./configure -library
mkdir qt5
pushd qt5
	%qmake_qt5 ..
	%make_build
popd

mkdir qt6
pushd qt6
        %qmake_qt6 ..
        %make_build
popd


%install
# libraries
mkdir -p %{buildroot}%{_qt5_libdir}
cp -ap lib/* %{buildroot}%{_qt5_libdir}


# headers
mkdir -p %{buildroot}%{_qt5_includedir}/QtSolutions
cp -a \
    src/qtlockedfile.h \
    src/QtLockedFile \
    %{buildroot}%{_qt5_includedir}/QtSolutions

mkdir -p %{buildroot}%{_qt5_archdatadir}/mkspecs/features
cp -a %{SOURCE1} %{buildroot}%{_qt5_archdatadir}/mkspecs/features/

mkdir -p %{buildroot}%{_qt6_includedir}/QtSolutions
cp -a \
    src/qtlockedfile.h \
    src/QtLockedFile \
    %{buildroot}%{_qt6_includedir}/QtSolutions

mkdir -p %{buildroot}%{_qt6_archdatadir}/mkspecs/features
cp -a %{SOURCE1} %{buildroot}%{_qt6_archdatadir}/mkspecs/features/



%changelog
* Tue Sep 05 2023 daviddavid <daviddavid> 2.4.1-22.mga10
+ Revision: 1984544
- time to remove Qt4 support and add now Qt6 support

* Sun Apr 03 2022 umeabot <umeabot> 2.4.1-21.mga9
+ Revision: 1842191
- Mageia 9 Mass Rebuild

* Thu Dec 17 2020 umeabot <umeabot> 2.4.1-20.mga8
+ Revision: 1659634
- Rebuild for new Qt5

* Sun Feb 16 2020 umeabot <umeabot> 2.4.1-19.mga8
+ Revision: 1536353
- Mageia 8 Mass Rebuild

* Thu Oct 17 2019 daviddavid <daviddavid> 2.4.1-18.mga8
+ Revision: 1454214
- update URL and Source URL
- update summaries and descriptions

* Fri Jul 26 2019 daviddavid <daviddavid> 2.4.1-17.mga8
+ Revision: 1424454
- rebuild for new Qt5 headers path and new mkspecs macros

* Mon Apr 01 2019 umeabot <umeabot> 2.4.1-16.mga7
+ Revision: 1384462
- Qt5 Rebuild

* Sun Sep 23 2018 umeabot <umeabot> 2.4.1-15.mga7
+ Revision: 1300710
- Mageia 7 Mass Rebuild
+ kekepower <kekepower>
- Use make_build

* Mon Dec 28 2015 pterjan <pterjan> 2.4.1-14.mga6
+ Revision: 916629
- Fix qt4 devel to require qt4 lib instead of qt5 lib

* Sun Aug 02 2015 neoclust <neoclust> 2.4.1-13.mga6
+ Revision: 860800
- Fix Soname

* Sun Aug 02 2015 neoclust <neoclust> 2.4.1-12.mga6
+ Revision: 860794
- Add more provides

* Sun Aug 02 2015 neoclust <neoclust> 2.4.1-11.mga6
+ Revision: 860785
- Add Qt4 lib too

* Sun Aug 02 2015 neoclust <neoclust> 2.4.1-10.mga6
+ Revision: 860778
- New snapshot ( qt5)

* Wed Oct 15 2014 umeabot <umeabot> 2.4.1-9.mga5
+ Revision: 738993
- Second Mageia 5 Mass Rebuild

* Tue Sep 16 2014 umeabot <umeabot> 2.4.1-8.mga5
+ Revision: 688550
- Mageia 5 Mass Rebuild

* Fri Oct 18 2013 umeabot <umeabot> 2.4.1-7.mga4
+ Revision: 517905
- Mageia 4 Mass Rebuild

* Sun Jan 13 2013 umeabot <umeabot> 2.4.1-6.mga3
+ Revision: 380003
- Mass Rebuild - https://wiki.mageia.org/en/Feature:Mageia3MassRebuild

* Wed Jan 25 2012 mikala <mikala> 2.4.1-5.mga2
+ Revision: 200682
- Rebuild for Qt4.8

* Tue Dec 27 2011 dmorgan <dmorgan> 2.4.1-4.mga2
+ Revision: 187998
- Use new qt4 macros

* Mon Dec 26 2011 dmorgan <dmorgan> 2.4.1-3.mga2
+ Revision: 187964
- Rebuild against new qt4 and new include path

* Mon Jun 20 2011 ahmad <ahmad> 2.4.1-2.mga2
+ Revision: 110219
- Use the lib %%major in the file list

* Mon Jun 20 2011 ahmad <ahmad> 2.4.1-1.mga2
+ Revision: 110213
- Adapt the spec to the Mageia packaging policies
- imported package qtlockedfile


* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Fri Apr 16 2010 Orcan Ogetbil <oget[dot]fedora[at]gmail[dot]com> 2.4-2
- Remove unnecessary linkage to libQtGui

* Thu Apr 15 2010 Orcan Ogetbil <oget[dot]fedora[at]gmail[dot]com> 2.4-1
- Initial Fedora package.