# this spec file can be used for multiple RPM-based distributions including Fedora, RHEL, *SUSE, and others

%{?_datarootdir: %global mydatarootdir %_datarootdir}
%{!?_datarootdir: %global mydatarootdir %{buildroot}/usr/share}

%global module_dir %{_libdir}/qore-modules
%global user_module_dir %{mydatarootdir}/qore-modules/

%if 0%{?sles_version}
%global dist .sles%{?sles_version}
%else
%if 0%{?suse_version}
# get *suse release major version
%global os_maj %(echo %suse_version|rev|cut -b3-|rev)
# get *suse release minor version without trailing zeros
%global os_min %(echo %suse_version|rev|cut -b-2|rev|sed s/0*$//)
%if %suse_version > 1010
%global dist .opensuse%{os_maj}_%{os_min}
%else
%global dist .suse%{os_maj}_%{os_min}
%endif
%endif
%endif

# see if we can determine the distribution type
%if 0%{!?dist:1}
%if 0%{?rhel}
%global dist .el%{rhel}
%endif
%endif

Summary: Multithreaded Programming Language
Name: qore
Version: 1.19.2
Release: 1%{dist}
%if 0%{?suse_version}
License: LGPL-2.0+ or GPL-2.0+ or MIT
%else
License: LGPLv2+ or GPLv2+ or MIT
%endif
Group: Development/Languages
URL: http://qore.org
Source0: https://github.com/qorelanguage/qore/releases/download/release-%{version}/%{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires: /usr/bin/env
BuildRequires: flex >= 2.5.31
BuildRequires: bison
BuildRequires: openssl-devel
BuildRequires: pcre-devel
BuildRequires: zlib-devel
BuildRequires: gmp-devel
BuildRequires: mpfr-devel
BuildRequires: doxygen
BuildRequires: gcc-c++
%if 0%{?suse_version}
BuildRequires: pkg-config
BuildRequires: fdupes
%if 0%{?sles_version} && %{?sles_version} <= 10
BuildRequires: bzip2
%else
BuildRequires: libbz2-devel
%endif
%else
BuildRequires: pkgconfig
BuildRequires: bzip2-devel
%if 0%{?redhat} >= 8 || 0%{?centos} >= 8
BuildRequires: gdb-headless
%endif
%endif
%if 0%{?sles_version}
BuildArch: %{_target_cpu}
%endif

%description
Qore is a scripting language supporting threading and embedded logic, designed
for applying a flexible scripting-based approach to enterprise interface
development but is also useful as a general purpose language.

%if 0%{?suse_version}
%debug_package
%endif

%if 0%{?fedora}
%global libname libqore
%else
%if 0%{?rhel}
%global libname libqore
%else
%global libname libqore12
%endif
%endif

%package -n %{libname}
Summary: The libraries for the qore runtime and qore clients
Group: System Environment/Libraries
Provides: qore-module(abi)%{?_isa} = 1.4
Provides: qore-module(abi)%{?_isa} = 1.3
%if "%{libname}" == "libqore"
Provides: libqore12 = %{version}
Obsoletes: libqore12 < %{version}
%endif
%if 0%{?sles_version}
BuildArch: %{_target_cpu}
%endif

%description -n %{libname}
Qore is a scripting language supporting threading and embedded logic, designed
for applying a flexible scripting-based approach to enterprise interface
development but is also useful as a general purpose language.

This package provides the qore library required for all clients using qore
functionality.

%files -n %{libname}
%defattr(-,root,root,-)
%{_libdir}/libqore.so.12.4.1
%{_libdir}/libqore.so.12
%doc COPYING.LGPL COPYING.GPL COPYING.MIT README.md README-LICENSE README-MODULES RELEASE-NOTES AUTHORS ABOUT

%post -n %{libname}
ldconfig %{_libdir}

%postun -n %{libname}
ldconfig %{_libdir}

%package stdlib
Summary: Standard library modules
Group: System Environment/Libraries
Requires: %{libname} = %{version}-%{release}
%if ! 0%{?el7}
Recommends: %{name} = %{version}
%endif

%description stdlib
Qore is a scripting language supporting threading and embedded logic, designed
for applying a flexible scripting-based approach to enterprise interface
development but is also useful as a general purpose language.

This package provides the Qore language standard library user and binary
modules.

%files stdlib
%defattr(-,root,root,-)
%{user_module_dir}
%{module_dir}
%doc COPYING.MIT README-LICENSE

%package doc
Summary: API documentation, programming language reference, and Qore example programs
Group: Documentation
BuildArch: noarch

%description doc
Qore is a scripting language supporting threading and embedded logic, designed
for applying a flexible scripting-based approach to enterprise interface
development but is also useful as a general purpose language.

This package provides the HTML documentation for the Qore programming language
and also for user modules delivered with Qore and also example programs.

%files doc
%defattr(-,root,root,-)
%doc docs/lang docs/modules/* examples/ COPYING.LGPL COPYING.GPL COPYING.MIT README-LICENSE

%package devel
Summary: The header files needed to compile programs using the qore library
Group: Development/Libraries
Requires: %{libname}%{?_isa} = %{version}-%{release}
%if 0%{?sles_version}
BuildArch: %{_target_cpu}
%endif

%description devel
Qore is a scripting language supporting threading and embedded logic, designed
for applying a flexible scripting-based approach to enterprise interface
development but is also useful as a general purpose language.

This package provides header files needed to compile client programs using the
Qore library.

%files devel
%defattr(-,root,root,-)
/usr/bin/qpp
/usr/bin/qdx
/usr/bin/qjar
%{_libdir}/libqore.so
%{_libdir}/pkgconfig/qore.pc
%dir %{_libdir}/cmake
%{_libdir}/cmake/Qore
%{_prefix}/include/*
%{mydatarootdir}/qore
%{mydatarootdir}/qore/*

%package devel-doc
Summary: C++ API documentation for the qore library
Group: Documentation
BuildArch: noarch

%description devel-doc
Qore is a scripting language supporting threading and embedded logic, designed
for applying a flexible scripting-based approach to enterprise interface
development but is also useful as a general purpose language.

This package provides HTML documentation for the C++ API for the Qore library.

%files devel-doc
%defattr(-,root,root,-)
%doc docs/library/html/*

%package misc-tools
Summary: Miscellaneous user tools writen in Qore Programming Language
License: LGPL-2.0+ or GPL-2.0+ or MIT
Group: Development/Tools/Other
Requires: qore = %{version}-%{release}
BuildArch: noarch

%description misc-tools
This package contains tool for working with:
 - REST APIs
 - SQL Databases

%files misc-tools
%defattr(-,root,root,-)
%{_bindir}/qdp
%{_bindir}/qget
%{_bindir}/rest
%{_bindir}/sfrest
%{_bindir}/saprest
%{_bindir}/sqlutil
%{_bindir}/schema-reverse

%prep
%setup -q
# silence the executable warning for examples
find examples -type f -exec chmod -x {} \;

%build
export CXXFLAGS="%{?optflags}"
%configure --disable-debug --disable-dependency-tracking
%{__make} %{?_smp_mflags}

%install
make install prefix=%{_prefix} DESTDIR=$RPM_BUILD_ROOT
rm $RPM_BUILD_ROOT/%{_libdir}/libqore.la
mkdir -p $RPM_BUILD_ROOT/%{module_dir}
%if 0%{?suse_version}
%fdupes -s docs/library/html
%endif

%check
export QORE_MODULE_DIR=qlib
./qore examples/test/qore/threads/background.qtest
./qore examples/test/qore/threads/deadlock.qtest
./qore examples/test/qore/threads/max-threads-count.qtest
./qore examples/test/qore/threads/set_thread_init.qtest
./qore examples/test/qore/threads/thread-object.qtest
./qore examples/test/qore/threads/thread-resources.qtest
./qore examples/test/qore/threads/tld.qtest

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
/usr/bin/qore
/usr/bin/qdbg
/usr/bin/qdbg-server
/usr/bin/qdbg-remote
/usr/bin/qdbg-vsc-adapter
%if 0%{?_mandir:1}
%{_mandir}/man1/qore.1.*
%else
%if 0%{?rh_dist}
%if %{?rh_dist} <= 5
/usr/man/man1/qore.1.*
%else
/usr/share/man/man1/qore.1.*
%endif
%else
%if 0%{?mdkversion}
/usr/share/man/man1/qore.1.*
%endif
%endif
%endif

%changelog
* Tue Sep 26 2023 David Nichols <david@qore.org> 1.19.2
- updated version to 1.19.2

* Sat Sep 23 2023 David Nichols <david@qore.org> 1.19.1
- updated version to 1.19.1

* Sat Aug 19 2023 David Nichols <david@qore.org> 1.19.0
- updated version to 1.19.0
- updated libqore version to 12.4.1

* Tue Aug 15 2023 David Nichols <david@qore.org> 1.18.1
- updated version to 1.18.1

* Fri Aug 4 2023 David Nichols <david@qore.org> 1.18.0
- updated version to 1.18.0

* Fri Jul 7 2023 David Nichols <david@qore.org> 1.17.0
- updated version to 1.17.0
- updated libqore version to 12.4.0

* Thu Jun 15 2023 David Nichols <david@qore.org> 1.16.1
- updated version to 1.16.1

* Tue Apr 4 2023 David Nichols <david@qore.org> 1.16.0
- updated version to 1.16.0

* Sun Mar 19 2023 David Nichols <david@qore.org> 1.15.0
- updated version to 1.15.0
- updated libqore version to 12.3.1

* Sat Mar 11 2023 David Nichols <david@qore.org> 1.14.2
- updated version to 1.14.2

* Mon Feb 20 2023 David Nichols <david@qore.org> 1.14.1
- updated version to 1.14.1

* Mon Jan 23 2023 David Nichols <david@qore.org> 1.14.0
- updated version to 1.14.0
- updated libqore version to 12.3.0
- added support for module-abi 1.4

* Mon Jan 2 2023 David Nichols <david@qore.org> 1.13.0
- updated version to 1.13.0
- updated libqore version to 12.2.0

* Mon Dec 12 2022 David Nichols <david@qore.org> 1.12.4
- updated version to 1.12.4

* Mon Nov 14 2022 David Nichols <david@qore.org> 1.12.3
- updated version to 1.12.3

* Tue Nov 1 2022 David Nichols <david@qore.org> 1.12.2
- updated version to 1.12.2

* Mon Sep 19 2022 David Nichols <david@qore.org> 1.12.1
- updated version to 1.12.1
- updated libqore version to 12.1.1

* Tue Sep 13 2022 David Nichols <david@qore.org> 1.12.0
- updated version to 1.12.0
- updated libqore version to 12.1.0

* Fri Sep 2 2022 David Nichols <david@qore.org> 1.11.0
- updated version to 1.11.0

* Sat Jul 16 2022 David Nichols <david@qore.org> 1.10.0
- updated version to 1.10.0
- updated libqore version to 12.0.3

* Tue Jul 5 2022 David Nichols <david@qore.org> 1.9.1
- updated version to 1.9.1
- updated libqore version to 12.0.2

* Mon Jun 20 2022 David Nichols <david@qore.org> 1.9.0
- updated version to 1.9.0

* Sun Jun 5 2022 David Nichols <david@qore.org> 1.8.1
- updated version to 1.8.1

* Fri May 6 2022 David Nichols <david@qore.org> 1.8.0
- updated version to 1.8.0

* Mon May 2 2022 David Nichols <david@qore.org> 1.7.2
- updated version to 1.7.2

* Mon Apr 18 2022 David Nichols <david@qore.org> 1.7.1
- updated version to 1.7.1

* Mon Mar 28 2022 David Nichols <david@qore.org> 1.7.0
- updated version to 1.7.0

* Fri Mar 18 2022 David Nichols <david@qore.org> 1.6.0
- updated version to 1.6.0

* Wed Mar 9 2022 David Nichols <david@qore.org> 1.5.1
- updated version to 1.5.1

* Sun Feb 20 2022 David Nichols <david@qore.org> 1.5.0
- updated version to 1.5.0

* Wed Feb 9 2022 David Nichols <david@qore.org> 1.4.0
- updated version to 1.4.0
- updated libqore version to 12.0.0
- added support for module-abi 1.3, dropped support for all previous versions

* Fri Jan 28 2022 David Nichols <david@qore.org> 1.3.0
- updated version to 1.3.0
- updated libqore version to 7.4.2

* Fri Jan 21 2022 David Nichols <david@qore.org> 1.2.0
- updated version to 1.2.0
- updated libqore version to 7.4.1

* Sun Jan 9 2022 David Nichols <david@qore.org> 1.1.0
- updated version to 1.1.0
- updated libqore version to 7.4.0

* Wed Dec 15 2021 David Nichols <david@qore.org> 1.0.13
- updated version to 1.0.13
- updated libqore version to 7.3.0

* Thu Nov 25 2021 David Nichols <david@qore.org> 1.0.12
- updated version to 1.0.12
- updated libqore version to 7.2.3

* Sat Nov 20 2021 David Nichols <david@qore.org> 1.0.11
- updated version to 1.0.11

* Wed Oct 13 2021 David Nichols <david@qore.org> 1.0.10
- updated version to 1.0.10
- updated libqore version to 7.2.2

* Wed Oct 6 2021 David Nichols <david@qore.org> 1.0.9
- updated version to 1.0.9
- updated libqore version to 7.2.1

* Sun Oct 3 2021 David Nichols <david@qore.org> 1.0.8
- updated version to 1.0.8
- updated libqore version to 7.2.0

* Thu Sep 23 2021 David Nichols <david@qore.org> 1.0.7
- updated version to 1.0.7
- updated libqore version to 7.1.1

* Mon Sep 20 2021 David Nichols <david@qore.org> 1.0.6
- updated version to 1.0.6

* Thu Sep 16 2021 David Nichols <david@qore.org> 1.0.5
- updated version to 1.0.5

* Tue Sep 7 2021 David Nichols <david@qore.org> 1.0.4
- updated version to 1.0.4

* Mon Aug 16 2021 David Nichols <david@qore.org> 1.0.3
- updated version to 1.0.3
- updated libqore version to 7.1.0
- added module api 1.1

* Sat Jul 17 2021 David Nichols <david@qore.org> 1.0.2
- updated version to 1.0.2

* Thu Jul 1 2021 David Nichols <david@qore.org> 1.0.1
- updated version to 1.0.1
- updated libqore version to 7.0.1

* Thu Dec 31 2020 David Nichols <david@qore.org> 1.0
- updated version to 1.0
- updated libqore version to 7.0.0
- updated ABI version to 1.0; removed all others

* Mon Dec 21 2020 David Nichols <david@qore.org> 0.9.11
- updated version to 0.9.11

* Sun Nov 29 2020 David Nichols <david@qore.org> 0.9.10
- updated version to 0.9.10

* Mon Nov 16 2020 David Nichols <david@qore.org> 0.9.9
- updated version to 0.9.9

* Tue Nov 10 2020 David Nichols <david@qore.org> 0.9.8
- updated version to 0.9.8

* Fri Nov 6 2020 David Nichols <david@qore.org> 0.9.7
- updated version to 0.9.7

* Thu Oct 22 2020 David Nichols <david@qore.org> 0.9.6
- updated version to 0.9.6

* Wed May 20 2020 David Nichols <david@qore.org> 0.9.5
- updated version to 0.9.5

* Sun May 10 2020 David Nichols <david@qore.org> 0.9.4.4
- updated version to 0.9.4.4

* Sat Mar 28 2020 David Nichols <david@qore.org> 0.9.4.3
- updated version to 0.9.4.3

* Mon Mar 2 2020 David Nichols <david@qore.org> 0.9.4.2
- updated version to 0.9.4.2

* Wed Feb 12 2020 David Nichols <david@qore.org> 0.9.4.1
- updated version to 0.9.4.1

* Sat Sep 7 2019 David Nichols <david@qore.org> 0.9.4
- updated version to 0.9.4

* Tue Mar 26 2019 David Nichols <david@qore.org> 0.9.3
- updated version to 0.9.3

* Mon Mar 11 2019 David Nichols <david@qore.org> 0.9.2
- updated version to 0.9.2

* Fri Feb 15 2019 David Nichols <david@qore.org> 0.9.1
- updated version to 0.9.1

* Fri Nov 16 2018 David Nichols <david@qore.org> 0.9
- updated version to 0.9

* Wed Nov 14 2018 David Nichols <david@qore.org> 0.8.13.9
- updated version to 0.8.13.9

* Thu Oct 25 2018 David Nichols <david@qore.org> 0.8.13.8
- updated version to 0.8.13.8

* Tue Sep 11 2018 David Nichols <david@qore.org> 0.8.13.7
- updated version to 0.8.13.7

* Fri Jun 22 2018 David Nichols <david@qore.org> 0.8.13.6
- updated version to 0.8.13.6

* Tue May 15 2018 David Nichols <david@qore.org> 0.8.13.5
- updated version to 0.8.13.5

* Fri Apr 13 2018 David Nichols <david@qore.org> 0.8.13.4
- updated version to 0.8.13.4

* Thu Mar 22 2018 David Nichols <david@qore.org> 0.8.13.3
- updated version to 0.8.13.3

* Sat Dec 30 2017 David Nichols <david@qore.org> 0.8.13.2
- updated version to 0.8.13.2

* Fri Sep 29 2017 David Nichols <david@qore.org> 0.8.13.1
- updated version to 0.8.13.1

* Fri Aug 4 2017 David Nichols <david@qore.org> 0.8.13
- updated version to 0.8.13

* Thu Aug 3 2017 David Nichols <david@qore.org> 0.8.12.12
- updated to 0.8.12.12

* Thu Jun 15 2017 David Nichols <david@qore.org> 0.8.12.11
- updated to 0.8.12.11

* Thu Apr 13 2017 David Nichols <david@qore.org> 0.8.12.10
- updated to 0.8.12.10

* Thu Mar 16 2017 David Nichols <david@qore.org> 0.8.12.9
- updated to 0.8.12.9

* Tue Feb 21 2017 David Nichols <david@qore.org> 0.8.12.8
- updated to 0.8.12.8

* Sun Feb 12 2017 David Nichols <david@qore.org> 0.8.12.7
- updated to 0.8.12.7

* Wed Feb 1 2017 David Nichols <david@qore.org> 0.8.12.6
- updated to 0.8.12.6

* Wed Nov 23 2016 David Nichols <david@qore.org> 0.8.12.5
- updated to 0.8.12.5

* Fri Oct 21 2016 David Nichols <david@qore.org> 0.8.12.4
- updated to 0.8.12.4

* Tue Sep 27 2016 David Nichols <david@qore.org> 0.8.12.3
- updated to 0.8.12.3

* Sat Sep 10 2016 David Nichols <david@qore.org> 0.8.12.2
- updated to 0.8.12.2

* Wed Aug 17 2016 David Nichols <david@qore.org> 0.8.12.1
- updated to 0.8.12.1

* Sun Oct 19 2014 David Nichols <david@qore.org> 0.8.12
- updated to 0.8.12

* Mon Jun 23 2014 David Nichols <david@qore.org> 0.8.11.1
- updated to 0.8.11.1

* Sat May 31 2014 David Nichols <david@qore.org> 0.8.11
- updated to 0.8.11

* Wed Mar 12 2014 David Nichols <david@qore.org> 0.8.10
- updated to 0.8.10

* Fri Oct 04 2013 David Nichols <david@qore.org> 0.8.9
- updated to 0.8.9

* Sun Feb 24 2013 David Nichols <david@qore.org> 0.8.8
- updated to 0.8.8

* Wed Nov 21 2012 David Nichols <david@qore.org> 0.8.7
- updated to 0.8.7

* Fri Nov 9 2012 David Nichols <david@qore.org> 0.8.6.2
- updated to 0.8.6.2

* Sat Oct 27 2012 David Nichols <david@qore.org> 0.8.6.1
- updated to 0.8.6.1

* Sun Sep 2 2012 David Nichols <david@qore.org> 0.8.6
- updated to 0.8.6

* Wed May 23 2012 David Nichols <david@qore.org> 0.8.5
- updated to 0.8.5

* Tue May 22 2012 David Nichols <david@qore.org> 0.8.4
- updated for new doxygen-based documentation, added devel-doc pkg for API docs
- updated package descriptions

* Thu Oct 20 2011 David Nichols <david@qore.org> 0.8.4
- updated to 0.8.4

* Fri Oct 07 2011 Petr Vanek <petr.vanek@qoretechnologies.com> 0.8.3
- pkg-config

* Sun Mar 6 2011 David Nichols <david@qore.org>
- updated to 0.8.3

* Sun Dec 26 2010 David Nichols <david@qore.org>
- updated to 0.8.2

* Tue Jun 15 2010 David Nichols <david@qore.org>
- updated to 0.8.1

* Wed Nov 18 2009 David Nichols <david_nichols@users.sourceforge.net>
- updated to 0.8.0

* Fri Nov 6 2009 David Nichols <david_nichols@users.sourceforge.net>
- updated to 0.7.7

* Mon Jul 13 2009 David Nichols <david_nichols@users.sourceforge.net>
- updated to 0.7.6

* Mon Jun 22 2009 David Nichols <david_nichols@users.sourceforge.net>
- updated to 0.7.5

* Wed Mar 4 2009 David Nichols <david_nichols@users.sourceforge.net>
- updated to 0.7.4

* Wed Dec 3 2008 David Nichols <david_nichols@users.sourceforge.net>
- updated to 0.7.3

* Wed Nov 26 2008 David Nichols <david_nichols@users.sourceforge.net>
- made libqore* the default name for lib package, removed la file

* Sun Nov 23 2008 David Nichols <david_nichols@users.sourceforge.net>
- updated to 0.7.2

* Tue Oct 7 2008 David Nichols <david_nichols@users.sourceforge.net>
- released 0.7.0

* Thu Sep 4 2008 David Nichols <david_nichols@users.sourceforge.net>
- removed all modules as they are now independent projects

* Tue Sep 2 2008 David Nichols <david_nichols@users.sourceforge.net>
- fixed dist tag for suse distributions
- updated for new module directory, added qore-module-api-* capability

* Thu Jun 12 2008 David Nichols <david_nichols@users.sourceforge.net>
- added new modules

* Mon Oct 22 2007 David Nichols <david_nichols@users.sourceforge.net>
- updated spec file with corrections from suse open build service

* Tue Jul 17 2007 David Nichols <david_nichols@users.sourceforge.net>
- updated library version to 3.1.0

* Sat Jul 14 2007 David Nichols <david_nichols@users.sourceforge.net>
- copied improvements from opensuse rpm and updated based on rpmlint output
- updated version to 0.7.0

* Thu Jun 14 2007 David Nichols <david_nichols@users.sourceforge.net>
- fixed spec file to support more architectures

* Wed Jun 13 2007 David Nichols <david_nichols@users.sourceforge.net>
- removed tibae module from spec file due to compiler requiremenets (g++-32)
- added pgsql module

* Tue Feb 20 2007 David Nichols <david_nichols@users.sourceforge.net>
- updated to libqore.so.3.0.0

* Sun Feb 11 2007 David Nichols <david_nichols@users.sourceforge.net>
- updated to 0.6.2 and libqore 1.1

* Tue Jan 30 2007 David Nichols <david_nichols@users.sourceforge.net>
- added tuxedo module

* Fri Jan 5 2007 David Nichols <david_nichols@users.sourceforge.net>
- updated libqore so version to 1.0.0

* Sat Nov 18 2006 David Nichols <david_nichols@users.sourceforge.net>
- updated descriptions
- changes to make spec file more release-agnostic (use of the dist tag in release)

* Wed Dec 7 2005 David Nichols <david_nichols@users.sourceforge.net>
- Initial rpm build
