# Depends on: git xorg-proto xorg-libxkbfile xorg-xtrans xorg-libx11 xorg-libxext xorg-libfs xorg-libice xorg-libsm xcb-proto libxcb xcb-util-keysyms xcb-util-renderutil xcb-util xcb-util-image xcb-util-wm xcb-util-cursor glib dbus xorg-fontconfig xorg-libsm xorg-libxrandr xorg-libxv xorg-libxi unixodbc libjpeg-turbo alsa-lib xdg-utils hicolor-icon-theme desktop-file-utils mesa xorg-libxcursor xorg-libxrender libpng mariadb icu libglade xorg-libxfixes xorg-libxinerama libxkbcommon libinput harfbuzz mtdev postgresql cups python gperf ruby pulseaudio bluez libtiff libmng openal libxslt xorg-libxcomposite gstreamer gstreamer-plugins-base gstreamer-plugins-good gstreamer-plugins-bad gstreamer1 gstreamer1-plugins-base gstreamer1-plugins-good gstreamer1-plugins-bad pulseaudio hunspell wayland ca-certificates openssl pcre gtk2 gtk3 libxkbcommon nss pciutils freetype

description="A cross-platform application and UI framework"
url="http://qt-project.org/"
packager="pierre at nutyx dot org"
name=qt-base
release=1
_name="${name/-/}-opensource-src"

build() {

QT5PREFIX=/usr
QT5BINDIR=$QT5PREFIX/bin/qt

cd ${_name}-${version}

unset QTDIR
export PATH="$PWD/qtbase/bin:$PWD/qtrepotools/bin:$PATH"

./configure -prefix         /usr                        \
            -sysconfdir     /etc/xdg                    \
            -bindir         /usr/bin/qt                 \
            -plugindir      /usr/lib/qt/plugins         \
            -importdir      /usr/lib/qt/imports         \
            -headerdir      /usr/include/qt             \
            -datadir        /usr/share/qt               \
            -docdir         /usr/share/doc/qt           \
            -translationdir /usr/share/qt/translations  \
            -examplesdir    /usr/share/doc/qt/examples  \
            -plugin-sql-{psql,mysql,sqlite,odbc}        \
            -confirm-license    \
            -opensource         \
            -openssl-linked     \
            -nomake tests       \
            -nomake examples    \
            -optimized-qmake    \
            -reduce-relocations \
            -dbus-linked        \
            -feature-menu       \
            -feature-textdate   \
            -feature-ftp        \
            -system-zlib        \
            -system-libjpeg     \
            -system-libpng      \
            -system-xcb         \
            -system-xkbcommon   \
            -system-pcre        \
            -system-harfbuzz    \
            -system-sqlite      \
            -system-freetype    \
	    -no-rpath

make
make INSTALL_ROOT=$PKG install

mkdir -p $PKG/etc/profile.d
cat > $PKG/etc/profile.d/qt.sh << EOf
# Begin /etc/profile.d/qt.sh
QT5PREFIX=$QT5PREFIX
QT5DIR=$QT5PREFIX
QT5BINDIR=$QT5PREFIX/bin/qt
export QT5PREFIX QT5BINDIR QT5DIR
pathappend $QT5BINDIR
# End /etc/profile.d/qt.sh
EOf

mkdir -p $PKG/usr/bin
for i in $PKG/usr/bin/qt/*; do 
    ln -sv /usr/bin/qt/$(basename $i) $PKG/usr/bin/$(basename $i)
done
}
