From 3ea8c0c317486674c8130598b9ed958fabf1cef3 Mon Sep 17 00:00:00 2001
From: Kevin Mihelich <kevin@archlinuxarm.org>
Date: Thu, 11 Apr 2013 14:08:05 +0000
Subject: [PATCH] extra/qt5 to 5.0.2-1, enabled gles2 for #443

---
 extra/qt5/PKGBUILD          | 81 +++++++++++++++++++++++++++++++++----
 extra/qt5/gcc48.patch       | 63 +++++++++++++++++++++++++++++
 extra/qt5/use-python2.patch | 11 +++++
 3 files changed, 147 insertions(+), 8 deletions(-)
 create mode 100644 extra/qt5/gcc48.patch

diff --git a/extra/qt5/PKGBUILD b/extra/qt5/PKGBUILD
index ee6cd0171..a6187d3d0 100644
--- a/extra/qt5/PKGBUILD
+++ b/extra/qt5/PKGBUILD
@@ -5,6 +5,7 @@
 #  - removed libfbclient, ibase
 #  - no x86/neon optimizations
 #  - disabled distcc, restricted makeflags to -j2
+#  - enabled opengl es2, mesa makedepend for headers
 
 highmem=1
 
@@ -22,8 +23,8 @@ pkgname=('qt5-base'
          'qt5-translations'
          'qt5-webkit'
          'qt5-xmlpatterns')
-pkgver=5.0.1
-pkgrel=10.1
+pkgver=5.0.2
+pkgrel=1
 arch=('i686' 'x86_64')
 url='http://qt-project.org/'
 license=('GPL3' 'LGPL')
@@ -32,18 +33,19 @@ makedepends=('libxcb' 'xcb-proto' 'xcb-util' 'xcb-util-image' 'xcb-util-wm' 'xcb
             'libjpeg-turbo' 'cups' 'libpulse' 'hicolor-icon-theme' 'desktop-file-utils'
             'postgresql-libs' 'libmariadbclient' 'sqlite' 'unixodbc'
             'python2' 'ruby' 'gperf' 'libxslt' 'libxcomposite' 'fontconfig'
-            'libmng' 'openal' 'gtk2')
+            'libmng' 'openal' 'gtk2' 'mesa')
 groups=('qt' 'qt5')
 options=('!libtool' '!distcc')
 _pkgfqn="qt-everywhere-opensource-src-${pkgver}"
 source=("http://releases.qt-project.org/${pkgbase}/${pkgver}/single/${_pkgfqn}.tar.xz"
         'assistant.desktop' 'designer.desktop' 'linguist.desktop'
-        'use-python2.patch')
+        'use-python2.patch' 'gcc48.patch')
 md5sums=('00a577bd88e682d1b4d01d41d1d699cf'
          'f1837a03fd0ebbd2da58975845f278e3'
          '480fea1ed076992b688373c8db274be0'
          '5595c24d5bb942c21e3a4d299e6d0bf1'
-         'ec3133b093550f16a21bb91e5f0f2943')
+         'd6ab43fb371be494e3bfd9b210c40bf1'
+         '7927028e2374321c78a76df858e723d6')
 
 build() {
   cd ${_pkgfqn}
@@ -63,10 +65,16 @@ build() {
     -e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2|" \
     $(find . -name '*.py')
 
+  # GCC 4.8 fixes
+  cd qtbase
+  patch -p1 -i "${srcdir}"/gcc48.patch
+  cd ../
+
   ./configure -confirm-license -opensource \
     -prefix /usr \
+    -bindir /usr/lib/qt/bin \
     -docdir /usr/share/doc/qt \
-    -headerdir /usr/include/qt5 \
+    -headerdir /usr/include/qt \
     -archdatadir /usr/lib/qt \
     -datadir /usr/share/qt \
     -sysconfdir /etc/xdg \
@@ -88,16 +96,29 @@ build() {
     -no-sse4.2 \
     -no-avx \
     -no-avx2 \
-    -no-neon
+    -no-neon \
+    -opengl es2
 
   make
+
+  # build docs
+  make docs
+
+  # build examples
+  for m in qtbase qtdeclarative qtmultimedia qtquick1 qtscript qtsvg qttools \
+    qtwebkit-examples-and-demos qtxmlpatterns; do
+    cd ${m}/examples
+    ${QTDIR}/qmake
+    make
+  cd ../../
+  done
 }
 
 package_qt5-base() {
   pkgdesc='A cross-platform application and UI framework'
   depends=('libjpeg-turbo' 'xcb-util-keysyms' 'libgl' 'dbus' 'fontconfig' 'systemd'
            'xcb-util-wm' 'libxrender' 'libxi' 'sqlite' 'libpng' 'xcb-util-image'
-           'hicolor-icon-theme' 'xdg-utils' 'icu')
+           'hicolor-icon-theme' 'xdg-utils' 'icu' 'qtchooser')
   optdepends=('postgresql-libs: PostgreSQL driver'
               'libmariadbclient: MariaDB driver'
               'unixodbc: ODBC driver')
@@ -118,6 +139,12 @@ package_qt5-base() {
   # Fix wrong qmake path in pri file
   sed -i "s|${srcdir}/${_pkgfqn}/qtbase|/usr|" \
     "${pkgdir}"/usr/lib/qt/mkspecs/modules/qt_lib_bootstrap.pri
+
+  # Useful symlinks
+  install -d "${pkgdir}"/usr/bin
+  for b in "${pkgdir}"/usr/lib/qt/bin/*; do
+    ln -s /usr/lib/qt/bin/$(basename $b) "${pkgdir}"/usr/bin/$(basename $b)-qt5
+  done
 }
 
 package_qt5-declarative() {
@@ -131,6 +158,32 @@ package_qt5-declarative() {
   # Fix wrong path in prl files
   find "${pkgdir}/usr/lib" -type f -name '*.prl' \
     -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d;s/\(QMAKE_PRL_LIBS =\).*/\1/' {} \;
+
+  # Useful symlinks
+  install -d "${pkgdir}"/usr/bin
+  for b in "${pkgdir}"/usr/lib/qt/bin/*; do
+    ln -s /usr/lib/qt/bin/$(basename $b) "${pkgdir}"/usr/bin/$(basename $b)-qt5
+  done
+}
+
+package_qt5-doc() {
+  pkgdesc='A cross-platform application and UI framework (Documentation and Examples)'
+  depends=('qt5-base')
+  conflicts=('qt-doc')
+  replaces=('qt-doc')
+  provides=('qt-doc')
+  options=('docs')
+  groups=()
+
+  cd ${_pkgfqn}
+  make INSTALL_ROOT="${pkgdir}" install_docs
+
+  for m in qtbase qtdeclarative qtmultimedia qtquick1 qtscript qtsvg qttools \
+    qtwebkit-examples-and-demos qtxmlpatterns; do
+    cd ${m}/examples
+    make INSTALL_ROOT="${pkgdir}" install
+    cd ../../
+  done
 }
 
 package_qt5-jsbackend() {
@@ -143,6 +196,12 @@ package_qt5-jsbackend() {
   # Fix wrong path in prl files
   find "${pkgdir}/usr/lib" -type f -name '*.prl' \
     -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d;s/\(QMAKE_PRL_LIBS =\).*/\1/' {} \;
+
+  # Useful symlinks
+  install -d "${pkgdir}"/usr/bin
+  for b in "${pkgdir}"/usr/lib/qt/bin/*; do
+    ln -s /usr/lib/qt/bin/$(basename $b) "${pkgdir}"/usr/bin/$(basename $b)-qt5
+  done
 }
 
 package_qt5-xmlpatterns() {
@@ -165,6 +224,12 @@ package_qt5-translations() {
 
   cd ${_pkgfqn}/qttranslations
   make INSTALL_ROOT="${pkgdir}" install
+
+  # Useful symlinks
+  install -d "${pkgdir}"/usr/bin
+  for b in "${pkgdir}"/usr/lib/qt/bin/*; do
+    ln -s /usr/lib/qt/bin/$(basename $b) "${pkgdir}"/usr/bin/$(basename $b)-qt5
+  done 
 }
 
 package_qt5-multimedia() {
diff --git a/extra/qt5/gcc48.patch b/extra/qt5/gcc48.patch
new file mode 100644
index 000000000..03b205b68
--- /dev/null
+++ b/extra/qt5/gcc48.patch
@@ -0,0 +1,63 @@
+# Author:     David E. Narváez <david.narvaez@computer.org>
+# AuthorDate: 2013-02-23 23:14:50 -0500
+# Commit:     David E. Narváez <david.narvaez@computer.org>
+# CommitDate: 2013-02-23 23:14:50 -0500
+#
+# Rename qAbs Function for timeval
+#
+# This decouples it from qAbs which is declared as a constexpr under
+# certain compilation flags and enables for qtbase to be compiled with
+# GCC 4.8
+#
+# Change-Id: I78e02256ffc8b460ca74ae5241e77dfac4e09ba9
+diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp
+index 0eee425..7a29247 100644
+--- a/src/corelib/kernel/qtimerinfo_unix.cpp
++++ b/src/corelib/kernel/qtimerinfo_unix.cpp
+@@ -87,22 +87,21 @@
+     firstTimerInfo = 0;
+ }
+ 
+ timeval QTimerInfoList::updateCurrentTime()
+ {
+     return (currentTime = qt_gettime());
+ }
+ 
+ #if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC) && !defined(Q_OS_INTEGRITY)) || defined(QT_BOOTSTRAPPED)
+ 
+-template <>
+-timeval qAbs(const timeval &t)
++timeval qAbsTimeval(const timeval &t)
+ {
+     timeval tmp = t;
+     if (tmp.tv_sec < 0) {
+         tmp.tv_sec = -tmp.tv_sec - 1;
+         tmp.tv_usec -= 1000000;
+     }
+     if (tmp.tv_sec == 0 && tmp.tv_usec < 0) {
+         tmp.tv_usec = -tmp.tv_usec;
+     }
+     return normalizedTimeval(tmp);
+@@ -137,21 +136,21 @@
+     *delta = elapsedTime - elapsedTimeTicks;
+ 
+     previousTicks = currentTicks;
+     previousTime = currentTime;
+ 
+     // If tick drift is more than 10% off compared to realtime, we assume that the clock has
+     // been set. Of course, we have to allow for the tick granularity as well.
+     timeval tickGranularity;
+     tickGranularity.tv_sec = 0;
+     tickGranularity.tv_usec = msPerTick * 1000;
+-    return elapsedTimeTicks < ((qAbs(*delta) - tickGranularity) * 10);
++    return elapsedTimeTicks < ((qAbsTimeval(*delta) - tickGranularity) * 10);
+ }
+ 
+ /*
+   repair broken timer
+ */
+ void QTimerInfoList::timerRepair(const timeval &diff)
+ {
+     // repair all timers
+     for (int i = 0; i < size(); ++i) {
+         register QTimerInfo *t = at(i);
diff --git a/extra/qt5/use-python2.patch b/extra/qt5/use-python2.patch
index 8a7075a97..eb53b10f6 100644
--- a/extra/qt5/use-python2.patch
+++ b/extra/qt5/use-python2.patch
@@ -94,3 +94,14 @@
  message_receiver_generator.input = MESSAGE_RECEIVERS
  message_receiver_generator.depends = $$SCRIPTS
  message_receiver_generator.output_function = message_receiver_generator_output
+--- qt-everywhere-opensource-src-5.0.2/qtwebkit/Tools/qmake/mkspecs/features/configure.prf~	2013-04-11 08:05:15.149214600 +0000
++++ qt-everywhere-opensource-src-5.0.2/qtwebkit/Tools/qmake/mkspecs/features/configure.prf	2013-04-11 08:05:28.829105110 +0000
+@@ -116,7 +116,7 @@
+     production_build:blackberry {
+         addReasonForSkippingBuild("Build not supported on BB10 yet.")
+     }
+-    requiredPrograms = gperf python perl bison ruby flex
++    requiredPrograms = gperf python2 perl bison ruby flex
+     for(program, requiredPrograms): \
+         !programExistsInPath($$program): \
+             addReasonForSkippingBuild("Missing $$program from PATH")