]> git.friedersdorff.com Git - max/slackbuilds.git/blob - libraries/qt5/qt5.SlackBuild
Add build scripts for qt5-5.9.4
[max/slackbuilds.git] / libraries / qt5 / qt5.SlackBuild
1 #!/bin/sh
2
3 # Slackware build script for qt5
4
5 # Copyright 2013-2017 Larry Hajali <larryhaja[at]gmail[dot]com>
6 # Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013  Patrick J. Volkerding, Sebeka, MN, USA
7 # All rights reserved.
8 #
9 # Redistribution and use of this script, with or without modification, is
10 # permitted provided that the following conditions are met:
11 #
12 # 1. Redistributions of this script must retain the above copyright
13 #    notice, this list of conditions and the following disclaimer.
14 #
15 #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
18 #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 # Merged some ideas from Alex Sarmardzic's script for qt4 at SlackBuilds.org
27 # ^^ Modified by Robby Workman <rworkman@slackware.com> for QT4 & KDE4
28
29 # We're using qt-copy instead of a released qt version, as this git release
30 # has at least one bugfix strongly recommended by the kde developers.
31
32 # Obtained from:
33 # git clone git://gitorious.org/+kde-developers/qt/kde-qt.git
34 # git checkout origin/4.5.3-patched
35 # git checkout origin/4.6.0-stable-patched
36 # git checkout origin/4.6.1-patched
37 # git checkout origin/4.7.0-patched
38 #
39 # Alternate method (we don't use this):
40 # wget http://qt.gitorious.org/qt/kde-qt/archive-tarball/4.6.2-patched
41 #
42 # Modifications 2010, 2011, 2012  Eric Hameleers, Eindhoven, NL
43 # qt 4.7.3, 4.7.4, 4.8.0, 4.8.1, 4.8.2, 4.8.4 are built from original nokia sources.
44
45 # This is the highly modified version qt.SlackBuild found in Slackware
46 # tailored to Qt 5. Modified by Larry Hajali.
47
48 PRGNAM=qt5
49 VERSION=${VERSION:-5.9.3}
50 BUILD=${BUILD:-1}
51 TAG=${TAG:-_SBo}
52
53 if [ -z "$ARCH" ]; then
54   case "$( uname -m )" in
55     i?86) ARCH=i586 ;;
56     arm*) ARCH=arm ;;
57        *) ARCH=$( uname -m ) ;;
58   esac
59 fi
60
61 CWD=$(pwd)
62 TMP=${TMP:-/tmp/SBo}
63 PKG=$TMP/package-$PRGNAM
64 OUTPUT=${OUTPUT:-/tmp}
65
66 if [ "$ARCH" = "i586" ]; then
67   SLKCFLAGS="-O2 -march=i586 -mtune=i686"
68   LIBDIRSUFFIX=""
69 elif [ "$ARCH" = "i686" ]; then
70   SLKCFLAGS="-O2 -march=i686 -mtune=i686"
71   LIBDIRSUFFIX=""
72 elif [ "$ARCH" = "x86_64" ]; then
73   SLKCFLAGS="-O2 -fPIC"
74   LIBDIRSUFFIX="64"
75 elif [ "$ARCH" = "armv7hl" ]; then
76   # To prevent "qatomic_armv6.h error: output number 2 not directly addressable"
77   # More permanent solution is to patch gcc:
78   # http://bazaar.launchpad.net/~linaro-toolchain-dev/gcc-linaro/4.6/revision/106731
79   SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16 -fno-strict-volatile-bitfields"
80   LIBDIRSUFFIX=""
81 else
82   SLKCFLAGS="-O2"
83   LIBDIRSUFFIX=""
84 fi
85
86 # http://doc.qt.io/qt-5/qtwebengine-platform-notes.html#audio-and-video-codec-support
87 PRCOD=""
88 [ "$PROPRIETARY_CODECS" = "yes" ] && PRCOD="WEBENGINE_CONFIG += use_proprietary_codecs"
89
90 set -e
91
92 rm -rf $PKG
93 mkdir -p $TMP $PKG $OUTPUT
94 cd $TMP
95 rm -rf ${PRGNAM/5/}-everywhere-opensource-src-$VERSION
96 tar xvf $CWD/${PRGNAM/5/}-everywhere-opensource-src-$VERSION.tar.xz
97 cd ${PRGNAM/5/}-everywhere-opensource-src-$VERSION
98 chown -R root:root .
99 find -L . \
100  \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
101   -o -perm 511 \) -exec chmod 755 {} \; -o \
102  \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
103   -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
104
105 # Slackware patch to build against MySQL/MariaDB.
106 #patch -p1 < $CWD/patches/qt5.mysql.h.diff
107
108 # Patch for the newer mozilla-nss
109 # patch -p1 < $CWD/patches/nss-update-sslv3-nonce.patch
110
111 # Limit -reduce-relocations to ix86 and x86_64.
112 # https://bugreports.qt-project.org/browse/QTBUG-36129
113 if echo $ARCH | grep -q '\(i.86\|x86_64\)' 2>/dev/null; then
114   RELOCATIONS="-reduce-relocations"
115 else
116   RELOCATIONS=""
117 fi
118
119 sed -i "s|-O2|$SLKCFLAGS|" qtbase/mkspecs/common/gcc-base.conf
120
121 # Build examples. Default is no.
122 if [ "${EXAMPLES:-no}" == "yes" ]; then
123   BUILD_EXAMPLES=""
124 else
125   BUILD_EXAMPLES="-nomake examples"
126 fi
127
128 echo "$PRCOD" >> qtwebengine/.qmake.conf
129
130 export CFLAGS="$SLKCFLAGS"
131 export CXXFLAGS="$SLKCFLAGS"
132 ./configure -v \
133   -confirm-license \
134   -opensource \
135   -prefix "/usr/lib${LIBDIRSUFFIX}/$PRGNAM" \
136   -sysconfdir "/etc/xdg" \
137   -headerdir "/usr/include/$PRGNAM" \
138   -libdir "/usr/lib${LIBDIRSUFFIX}" \
139   -docdir "/usr/doc/$PRGNAM-$VERSION" \
140   -system-libpng \
141   -system-libjpeg \
142   -system-zlib \
143   -system-sqlite \
144   -system-pcre \
145   -plugin-sql-sqlite \
146   -icu \
147   -openssl \
148   -verbose \
149   -optimized-qmake \
150   -dbus-linked \
151   -qpa xcb \
152   -xcb \
153   -glib \
154   -accessibility \
155   -no-separate-debug-info \
156   -no-pch \
157   -no-rpath \
158   -no-strip \
159   -release \
160   -no-use-gold-linker \
161   -pulseaudio \
162   $RELOCATIONS \
163   $BUILD_EXAMPLES
164
165 make -j8
166 make install INSTALL_ROOT=$PKG
167
168 # Install documentation. Default is not to install documentation.
169 if [ "${DOCS:-no}" == "yes" ]; then
170   # Recreate Makefiles in order to use the just compiled qdoc.
171   for doc in $(find . -name "Makefile*" | xargs egrep "^\s/usr/lib${LIBDIRSUFFIX}/qt5/bin/" \
172     | cut -d':' -f1 | uniq)
173   do
174     rm -fv $doc
175   done
176   make docs -j8
177   make install_docs INSTALL_ROOT=$PKG
178 fi
179
180 find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
181   | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
182
183 ln -s $PRGNAM $PKG/usr/lib${LIBDIRSUFFIX}/qt-$VERSION
184
185 mkdir -p $PKG/usr/bin
186 for BIN in $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM/bin/*; do
187   TMP_FILE=$(echo $BIN | sed -e "s|$PKG||")
188   case $(basename $BIN) in
189     syncqt.pl|fixqt4headers.pl)
190       ln -s $TMP_FILE $PKG/usr/bin/$(basename $BIN)
191       ;;
192     *)
193       ln -s $TMP_FILE $PKG/usr/bin/$(basename $BIN)-$PRGNAM
194       ;;
195   esac
196 done
197
198 # Create Environment variables
199 mkdir -p $PKG/etc/profile.d
200 sed -e "s|@LIBDIRSUFFIX@|${LIBDIRSUFFIX}|g" $CWD/profile.d/$PRGNAM.sh \
201   > $PKG/etc/profile.d/$PRGNAM.sh
202 sed -e "s|@LIBDIRSUFFIX@|${LIBDIRSUFFIX}|g" $CWD/profile.d/$PRGNAM.csh \
203   > $PKG/etc/profile.d/$PRGNAM.csh
204 chmod 0755 $PKG/etc/profile.d/*
205
206 cat > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/Qt5.pc << EOF
207 prefix=/usr/lib${LIBDIRSUFFIX}/$PRGNAM
208 bindir=\${prefix}/bin
209 datadir=\${prefix}
210 docdir=/usr/doc/$PRGNAM-$VERSION
211 archdatadir=\${prefix}
212 examplesdir=\${prefix}/examples
213 headerdir=/usr/include/$PRGNAM
214 importdir=\${prefix}/imports
215 qmldir=\${prefix}/qml
216 libdir=/usr/lib${LIBDIRSUFFIX}
217 libexec=\${prefix}/libexec
218 moc=\${bindir}/moc
219 plugindir=\${prefix}/plugins
220 qmake=\${bindir}/qmake
221 sysconfdir=/etc/xdg
222 translationdir=\${prefix}/translations
223
224 Name: Qt5
225 Description: Qt5 Configuration
226 Version: $VERSION
227 EOF
228
229 # Fix internal linking for Qt5WebEngineCore.pc.
230 sed -i \
231   -e 's|-Wl,--start-group.* -Wl,--end-group||' \
232   -e "s|-L${PWD}/qtwebengine/src/core/api/Release||" \
233   $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/Qt5WebEngineCore.pc
234
235 # While we are at it, there isn't any reason to keep references to $PKG in the *.prl files.
236 for PRL in $(find $PKG -name "*\.prl"); do
237   sed -i '/^QMAKE_PRL_BUILD_DIR/d' $PRL
238 done
239
240 # One more for the road.
241 sed -i "s|$PWD/qtbase|/usr/lib${LIBDIRSUFFIX}/$PRGNAM|" \
242   $PKG/usr/lib${LIBDIRSUFFIX}/$PRGNAM/mkspecs/modules/qt_lib_bootstrap_private.pri
243
244 sed -i "s|-L${PWD}/\w*/lib ||g" \
245   $PKG/usr/lib${LIBDIRSUFFIX}/libqgsttools_p.prl
246
247 for i in $CWD/desktop/*.desktop; do
248   install -D -m 0644 $i $PKG/usr/share/applications/$(basename $i)
249 done
250 sed -i "s|@LIBDIR@|$LIBDIRSUFFIX|" $PKG/usr/share/applications/*
251
252 # Currently not working for qt version 5.4.0.  Extra layer added to *.ico file
253 # freaks out ImageMagick and fails image conversion.
254 # Eg.
255 #   $ convert assistant.ico -resize 96x96! assistant.png
256 #     convert: file format version mismatch `assistant.ico' @ error/xwd.c/ReadXWDImage/241.
257 #     convert: no images defined `assistant.png' @ error/convert.c/ConvertImageCommand/3127.
258 #for i in $(find . -name "assistant.ico" -o -name "designer.ico" \
259 #  -o -name "linguist.ico" -o -name "qdbusviewer.ico"); do
260 #  for j in 16 24 32 48 64 96 128; do
261 #    convert $i -resize ${j}x${j}! $(basename $i)-$j.png
262 #    install -D -m 0644 $(basename $i)-$j-0.png \
263 #      $PKG/usr/share/icons/hicolor/${j}x${j}/apps/$(basename $i | sed 's|.ico||')-$PRGNAM.png
264 #  done
265 #done
266
267 install -D -m 0644 qttools/src/assistant/assistant/images/assistant-128.png \
268   $PKG/usr/share/icons/hicolor/128x128/apps/assistant-qt5.png
269 install -D -m 0644 qttools/src/designer/src/designer/images/designer.png \
270   $PKG/usr/share/icons/hicolor/128x128/apps/designer-qt5.png
271 install -D -m 0644 qttools/src/qdbus/qdbusviewer/images/qdbusviewer-128.png \
272   $PKG/usr/share/icons/hicolor/128x128/apps/qdbusviewer-qt5.png
273 for i in 16 32 48 64 128; do
274   install -D -m 0644 qttools/src/linguist/linguist/images/icons/linguist-${i}-32.png \
275     $PKG/usr/share/icons/hicolor/${i}x${i}/apps/linguist-qt5.png
276 done
277
278 # Remove executable bits from files.
279 find $PKG \( -name "*.qml" -o -name "*.app" \) -perm 755 -exec chmod 644 '{}' \;
280
281 mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
282 cp -a \
283   README qtbase/{header*,LGPL_EXCEPTION.txt,LICENSE.*L} \
284   $PKG/usr/doc/$PRGNAM-$VERSION
285 cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
286
287 mkdir -p $PKG/install
288 cat $CWD/slack-desc > $PKG/install/slack-desc
289 cat $CWD/doinst.sh > $PKG/install/doinst.sh
290
291 cd $PKG
292 /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}