Summary: JasPer library for images manipulation - MinGW32 cross version
Summary(pl.UTF-8): Biblioteka JasPer do obróbki obrazów - wersja skrośna dla MinGW32
Name: crossmingw32-jasper
-Version: 2.0.33
+Version: 3.0.6
Release: 1
-License: BSD-like
+License: JasPer v2.0 (BSD-like)
Group: Development/Libraries
-# versions up to 2.0.14: http://www.ece.uvic.ca/~frodo/jasper/#download
#Source0Download: https://github.com/jasper-software/jasper/releases
Source0: https://github.com/jasper-software/jasper/releases/download/version-%{version}/jasper-%{version}.tar.gz
-# Source0-md5: 8761ef749b696e3cace330801e27b486
+# Source0-md5: f9388d52a6220303141a42d4c2c81e62
+Patch0: jasper-mingw32.patch
URL: https://www.ece.uvic.ca/~frodo/jasper/
BuildRequires: cmake >= 2.8.11
BuildRequires: crossmingw32-gcc
%prep
%setup -q -n jasper-%{version}
+%patch0 -p1
%build
# there is upstream directory named "build", use different name
-DJAS_ENABLE_AUTOMATIC_DEPENDENCIES=OFF \
-DJAS_ENABLE_DOC=OFF \
-DJAS_ENABLE_OPENGL=OFF \
+ -DJAS_STDC_VERSION="$(i386-mingw32-cpp -x c -dM < /dev/null | grep __STDC_VERSION__| cut -d' ' -f3)" \
-DJPEG_INCLUDE_DIR:PATH=%{_includedir} \
-DJPEG_LIBRARY=%{_libdir}/libjpeg.dll.a
%files
%defattr(644,root,root,755)
-%doc LICENSE README doc/jasper.pdf doc/jpeg2000.pdf
+%doc ChangeLog LICENSE.txt NEWS.txt README.md doc/jpeg2000.pdf
%{_libdir}/libjasper.dll.a
%{_includedir}/jasper
%{_pkgconfigdir}/jasper.pc
--- /dev/null
+Current mingw32 doesn't provide <sysinfoapi.h>, so use older API.
+--- jasper-3.0.6/src/libjasper/base/jas_malloc.c.orig 2023-03-13 13:16:49.488682893 +0100
++++ jasper-3.0.6/src/libjasper/base/jas_malloc.c 2023-03-13 18:13:28.802255734 +0100
+@@ -94,7 +94,6 @@
+ # include <unistd.h>
+ #elif defined(_WIN32)
+ # include <windows.h>
+-# include <sysinfoapi.h>
+ #endif
+
+ /******************************************************************************\
+@@ -649,15 +648,14 @@ size_t jas_get_total_mem_size()
+ long page_size = sysconf(_SC_PAGE_SIZE);
+ return pages * page_size;
+ #elif defined(_WIN32)
+- /*
+- Reference:
+- https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getphysicallyinstalledsystemmemory
+- */
+- ULONGLONG size;
+- if (!GetPhysicallyInstalledSystemMemory(&size)) {
++ MEMORYSTATUSEX memStatusEx = {0};
++ memStatusEx.dwLength = sizeof(MEMORYSTATUSEX);
++ BOOL bRet = GlobalMemoryStatusEx(&memStatusEx);
++ return memStatusEx.ullTotalPhys;
++ if (!GlobalMemoryStatusEx(&memStatusEx)) {
+ return 0;
+ }
+- return 1024 * size;
++ return memStatusEx.ullTotalPhys;
+ #else
+ return 0;
+ #endif