eclass/qt4-qt-copy.eclass: whoops, forgot how dumb bash is ...
[gentoo-soor-overlay.git] / x11-libs / qt / qt-3.3.8-r4.ebuild
blobb257c397cb515f98cabfe987f5ee7611d6ea15be
1 # Copyright 1999-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
5 EAPI="1"
6 inherit eutils flag-o-matic toolchain-funcs
8 SRCTYPE="free"
9 QT_COPY_SNAP="1.1"
10 DESCRIPTION="The Qt toolkit is a comprehensive C++ application development framework."
11 HOMEPAGE="http://www.trolltech.com/"
13 RESTRICT="primaryuri"
15 IMMQT_P="qt-x11-immodule-unified-qt3.3.8-20070321-gentoo"
17 SRC_URI="mirror://gentoo/qt-x11-${SRCTYPE}-${PV}.tar.gz
18 ftp://ftp.trolltech.com/qt/source/qt-x11-${SRCTYPE}-${PV}.tar.gz
19 qt-copy? ( http://jyujin.de/~creidiki/qt-copy/qt-copy-${PV}-patches-${QT_COPY_SNAP}.tar.lzma )
20 immqt? ( mirror://gentoo/${IMMQT_P}.diff.bz2 )
21 immqt-bc? ( mirror://gentoo/${IMMQT_P}.diff.bz2 )"
22 LICENSE="|| ( QPL-1.0 GPL-2 )"
24 SLOT="3"
25 KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
26 IUSE="cups debug doc examples firebird gif ipv6 mysql nas nis odbc opengl postgres qt-copy sqlite xinerama immqt immqt-bc"
28 DEPEND="x11-libs/libXcursor
29 x11-libs/libXi
30 x11-libs/libXrandr
31 x11-libs/libSM
32 x11-proto/inputproto
33 x11-proto/xextproto
34 xinerama? ( x11-proto/xineramaproto x11-libs/libXinerama )
35 immqt? ( x11-proto/xineramaproto )
36 immqt-bc? ( x11-proto/xineramaproto )
37 virtual/xft
38 media-libs/libpng
39 media-libs/jpeg
40 >=media-libs/libmng-1.0.9
41 media-libs/freetype:2
42 sys-libs/zlib
43 nas? ( >=media-libs/nas-1.5 )
44 mysql? ( virtual/mysql )
45 firebird? ( dev-db/firebird )
46 opengl? ( virtual/opengl virtual/glu )
47 postgres? ( dev-db/libpq )
48 cups? ( net-print/cups )"
49 RDEPEND="${DEPEND}
50 qt-copy? ( app-arch/lzma-utils )"
51 PDEPEND="odbc? ( ~dev-db/qt-unixODBC-$PV )"
53 S=${WORKDIR}/qt-x11-${SRCTYPE}-${PV}
55 QTBASE=/usr/qt/3
57 pkg_setup() {
58 if use immqt && use immqt-bc ; then
59 ewarn
60 ewarn "immqt and immqt-bc are exclusive. You cannot set both."
61 ewarn "Please specify either immqt or immqt-bc."
62 ewarn
63 die
64 elif use immqt ; then
65 ewarn
66 ewarn "You are going to compile binary imcompatible immodule for Qt. This means"
67 ewarn "you have to recompile everything depending on Qt after you install it."
68 ewarn "Be aware."
69 ewarn
72 export QTDIR=${S}
74 CXX=$(tc-getCXX)
75 if [[ ${CXX/g++/} != ${CXX} ]]; then
76 PLATCXX="g++"
77 elif [[ ${CXX/icpc/} != ${CXX} ]]; then
78 PLATCXX="icc"
79 else
80 die "Unknown compiler ${CXX}."
83 case ${CHOST} in
84 *-freebsd*|*-dragonfly*)
85 PLATNAME="freebsd" ;;
86 *-openbsd*)
87 PLATNAME="openbsd" ;;
88 *-netbsd*)
89 PLATNAME="netbsd" ;;
90 *-darwin*)
91 PLATNAME="darwin" ;;
92 *-linux-*|*-linux)
93 PLATNAME="linux" ;;
95 die "Unknown CHOST, no platform choosed."
96 esac
98 # probably this should be '*-64' for 64bit archs
99 # in a fully multilib environment (no compatibility symlinks)
100 export PLATFORM="${PLATNAME}-${PLATCXX}"
103 src_unpack() {
104 unpack ${A}
105 cd ${S}
107 sed -i -e 's:read acceptance:acceptance=yes:' configure
109 # Do not link with -rpath. See bug #75181.
110 find ${S}/mkspecs -name qmake.conf | xargs \
111 sed -i -e 's:QMAKE_RPATH.*:QMAKE_RPATH =:'
113 # Patch for uic includehint errors (aseigo patch)
114 epatch ${FILESDIR}/${P}-uic-fix.patch
116 # Patch for mysql unload crash (Bug #171883)
117 epatch ${FILESDIR}/${P}-mysql-unload-crash.diff
119 # KDE related patches
120 epatch ${FILESDIR}/0001-dnd_optimization.patch
121 epatch ${FILESDIR}/0002-dnd_active_window_fix.patch
122 epatch ${FILESDIR}/0038-dragobject-dont-prefer-unknown.patch
123 epatch ${FILESDIR}/0044-qscrollview-windowactivate-fix.diff
124 epatch ${FILESDIR}/0047-fix-kmenu-widget.diff
125 epatch ${FILESDIR}/0048-qclipboard_hack_80072.patch
127 # possible rce, CVE-2007-3388
128 epatch ${FILESDIR}/0081-format-string-fixes.diff
130 # Bug #192472
131 epatch ${FILESDIR}/${P}-unicode-off-by-one.patch
133 # ulibc patch (bug #100246)
134 epatch ${FILESDIR}/qt-ulibc.patch
136 # xinerama patch: http://ktown.kde.org/~seli/xinerama/
137 epatch "${FILESDIR}/${P}-seli-xinerama.patch"
139 epatch ${FILESDIR}/utf8-bug-qt3.diff
141 # Visibility patch, apply only on GCC 4.1 and later for safety
142 # [[ $(gcc-major-version)$(gcc-minor-version) -ge 41 ]] && \
143 epatch "${FILESDIR}/${P}-visibility.patch"
145 if use immqt || use immqt-bc ; then
146 epatch ../${IMMQT_P}.diff
147 sh make-symlinks.sh || die "make symlinks failed"
148 EPATCH_EXCLUDE="0080_all_net-wm-sync-request.diff"
149 else
150 EPATCH_EXCLUDE="0080_all_net-wm-sync-request-immqt-fix.diff"
153 if use ppc-macos ; then
154 epatch "${FILESDIR}/${PN}-3.3.5-macos.patch"
157 # Apply QT Copy patches:
158 if use qt-copy; then
159 ebegin "Applying the KDE Qt Copy patches"
160 for diff in $(ls "${WORKDIR}/qt-copy-${PV}-patches-${QT_COPY_SNAP}"/* | sort); do
161 epatch "${diff}" || die
162 done
163 einfo "Done with patching"
166 # known working flags wrt #77623
167 use sparc && export CFLAGS="-O1" && export CXXFLAGS="${CFLAGS}"
168 # set c/xxflags and ldflags
169 strip-flags
170 append-flags -fno-strict-aliasing
172 if [[ $( gcc-fullversion ) == "3.4.6" && gcc-specs-ssp ]] ; then
173 ewarn "Appending -fno-stack-protector to CFLAGS/CXXFLAGS"
174 append-flags -fno-stack-protector
177 sed -i -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
178 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
179 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
180 -e "s:\<QMAKE_CC\>.*=.*:QMAKE_CC=$(tc-getCC):" \
181 -e "s:\<QMAKE_CXX\>.*=.*:QMAKE_CXX=$(tc-getCXX):" \
182 -e "s:\<QMAKE_LINK\>.*=.*:QMAKE_LINK=$(tc-getCXX):" \
183 -e "s:\<QMAKE_LINK_SHLIB\>.*=.*:QMAKE_LINK_SHLIB=$(tc-getCXX):" \
184 ${S}/mkspecs/${PLATFORM}/qmake.conf || die
186 if [ $(get_libdir) != "lib" ] ; then
187 sed -i -e "s:/lib$:/$(get_libdir):" \
188 ${S}/mkspecs/${PLATFORM}/qmake.conf || die
192 src_compile() {
193 export SYSCONF=${D}${QTBASE}/etc/settings
195 # Let's just allow writing to these directories during Qt emerge
196 # as it makes Qt much happier.
197 addwrite "${QTBASE}/etc/settings"
198 addwrite "${HOME}/.qt"
200 [ $(get_libdir) != "lib" ] && myconf="${myconf} -L/usr/$(get_libdir)"
202 # unixODBC support is now a PDEPEND on dev-db/qt-unixODBC; see bug 14178.
203 use nas && myconf="${myconf} -system-nas-sound"
204 use nis && myconf="${myconf} -nis" || myconf="${myconf} -no-nis"
205 use gif && myconf="${myconf} -qt-gif" || myconf="${myconf} -no-gif"
206 use mysql && myconf="${myconf} -plugin-sql-mysql -I/usr/include/mysql -L/usr/$(get_libdir)/mysql" || myconf="${myconf} -no-sql-mysql"
207 use postgres && myconf="${myconf} -plugin-sql-psql -I/usr/include/postgresql/server -I/usr/include/postgresql/pgsql -I/usr/include/postgresql/pgsql/server" || myconf="${myconf} -no-sql-psql"
208 use firebird && myconf="${myconf} -plugin-sql-ibase -I/opt/firebird/include" || myconf="${myconf} -no-sql-ibase"
209 use sqlite && myconf="${myconf} -plugin-sql-sqlite" || myconf="${myconf} -no-sql-sqlite"
210 use cups && myconf="${myconf} -cups" || myconf="${myconf} -no-cups"
211 use opengl && myconf="${myconf} -enable-module=opengl" || myconf="${myconf} -disable-opengl"
212 use debug && myconf="${myconf} -debug" || myconf="${myconf} -release -no-g++-exceptions"
213 use xinerama && myconf="${myconf} -xinerama" || myconf="${myconf} -no-xinerama"
215 myconf="${myconf} -system-zlib"
217 use ipv6 && myconf="${myconf} -ipv6" || myconf="${myconf} -no-ipv6"
218 use immqt-bc && myconf="${myconf} -inputmethod"
219 use immqt && myconf="${myconf} -inputmethod -inputmethod-ext"
221 if use ppc-macos ; then
222 myconf="${myconf} -no-sql-ibase -no-sql-mysql -no-sql-psql -no-cups -lresolv -shared"
223 myconf="${myconf} -I/usr/X11R6/include -L/usr/X11R6/lib"
224 myconf="${myconf} -L${S}/lib -I${S}/include"
225 sed -i -e "s,#define QT_AOUT_UNDERSCORE,," mkspecs/${PLATFORM}/qplatformdefs.h || die
228 export YACC='byacc -d'
229 tc-export CC CXX
230 export LINK="$(tc-getCXX)"
232 ./configure -sm -thread -stl -system-libjpeg -verbose -largefile \
233 -qt-imgfmt-{jpeg,mng,png} -tablet -system-libmng \
234 -system-libpng -xft -platform ${PLATFORM} -xplatform \
235 ${PLATFORM} -xrender -prefix ${QTBASE} -libdir ${QTBASE}/$(get_libdir) \
236 -fast -no-sql-odbc ${myconf} -dlopen-opengl || die
238 emake src-qmake src-moc sub-src || die
240 export DYLD_LIBRARY_PATH="${S}/lib:/usr/X11R6/lib:${DYLD_LIBRARY_PATH}"
241 export LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}"
243 emake sub-tools || die
245 if use examples; then
246 emake sub-tutorial sub-examples || die
249 # Make the msg2qm utility (not made by default)
250 cd ${S}/tools/msg2qm
251 ../../bin/qmake
252 emake
254 # Make the qembed utility (not made by default)
255 cd ${S}/tools/qembed
256 ../../bin/qmake
257 emake
261 src_install() {
262 # binaries
263 into ${QTBASE}
264 dobin bin/*
265 dobin tools/msg2qm/msg2qm
266 dobin tools/qembed/qembed
268 # libraries
269 if use ppc-macos; then
270 # dolib is broken on BSD because of missing readlink(1)
271 dodir ${QTBASE}/$(get_libdir)
272 cp -fR lib/*.{dylib,la,a} ${D}/${QTBASE}/$(get_libdir) || die
274 cd ${D}/${QTBASE}/$(get_libdir)
275 for lib in libqt-mt* ; do
276 ln -s ${lib} ${lib/-mt/}
277 done
278 else
279 dolib.so lib/lib{editor,qassistantclient,designercore}.a
280 dolib.so lib/libqt-mt.la
281 dolib.so lib/libqt-mt.so.${PV} lib/libqui.so.1.0.0
282 cd ${D}/${QTBASE}/$(get_libdir)
284 for x in libqui.so ; do
285 ln -s $x.1.0.0 $x.1.0
286 ln -s $x.1.0 $x.1
287 ln -s $x.1 $x
288 done
290 # version symlinks - 3.3.5->3.3->3->.so
291 ln -s libqt-mt.so.${PV} libqt-mt.so.3.3
292 ln -s libqt-mt.so.3.3 libqt-mt.so.3
293 ln -s libqt-mt.so.3 libqt-mt.so
295 # libqt -> libqt-mt symlinks
296 ln -s libqt-mt.so.${PV} libqt.so.${PV}
297 ln -s libqt-mt.so.3.3 libqt.so.3.3
298 ln -s libqt-mt.so.3 libqt.so.3
299 ln -s libqt-mt.so libqt.so
302 # plugins
303 cd ${S}
304 local plugins=$(find plugins -name "lib*.so" -print)
305 for x in ${plugins}; do
306 exeinto ${QTBASE}/$(dirname ${x})
307 doexe ${x}
308 done
310 # Past this point just needs to be done once
311 is_final_abi || return 0
313 # includes
314 cd ${S}
315 dodir ${QTBASE}/include/private
316 cp include/* ${D}/${QTBASE}/include/
317 cp include/private/* ${D}/${QTBASE}/include/private/
319 # prl files
320 sed -i -e "s:${S}:${QTBASE}:g" ${S}/lib/*.prl
321 insinto ${QTBASE}/$(get_libdir)
322 doins ${S}/lib/*.prl
324 # pkg-config file
325 insinto ${QTBASE}/$(get_libdir)/pkgconfig
326 doins ${S}/lib/*.pc
328 # List all the multilib libdirs
329 local libdirs
330 for libdir in $(get_all_libdirs); do
331 libdirs="${libdirs}:${QTBASE}/${libdir}"
332 done
334 # environment variables
335 if use ppc-macos; then
336 cat <<EOF > ${T}/45qt3
337 PATH=${QTBASE}/bin
338 ROOTPATH=${QTBASE}/bin
339 DYLD_LIBRARY_PATH=${libdirs:1}
340 QMAKESPEC=${PLATFORM}
341 MANPATH=${QTBASE}/doc/man
342 PKG_CONFIG_PATH=${QTBASE}/$(get_libdir)/pkgconfig
344 else
345 cat <<EOF > ${T}/45qt3
346 PATH=${QTBASE}/bin
347 ROOTPATH=${QTBASE}/bin
348 LDPATH=${libdirs:1}
349 QMAKESPEC=${PLATFORM}
350 MANPATH=${QTBASE}/doc/man
351 PKG_CONFIG_PATH=${QTBASE}/$(get_libdir)/pkgconfig
354 cat <<EOF > ${T}/50qtdir3
355 QTDIR=${QTBASE}
358 cat <<EOF > ${T}/50-qt3-revdep
359 SEARCH_DIRS="${QTBASE}"
362 insinto /etc/revdep-rebuild
363 doins ${T}/50-qt3-revdep
365 doenvd ${T}/45qt3 ${T}/50qtdir3
367 if [ "${SYMLINK_LIB}" = "yes" ]; then
368 dosym $(get_abi_LIBDIR ${DEFAULT_ABI}) ${QTBASE}/lib
371 insinto ${QTBASE}/tools/designer
372 doins -r tools/designer/templates
374 insinto ${QTBASE}
375 doins -r translations
377 keepdir ${QTBASE}/etc/settings
379 if use doc; then
380 insinto ${QTBASE}
381 doins -r ${S}/doc
384 if use examples; then
385 find ${S}/examples ${S}/tutorial -name Makefile | \
386 xargs sed -i -e "s:${S}:${QTBASE}:g"
388 cp -r ${S}/examples ${D}${QTBASE}/
389 cp -r ${S}/tutorial ${D}${QTBASE}/
392 # misc build reqs
393 insinto ${QTBASE}/mkspecs
394 doins -r ${S}/mkspecs/${PLATFORM}
396 sed -e "s:${S}:${QTBASE}:g" \
397 ${S}/.qmake.cache > ${D}${QTBASE}/.qmake.cache
399 dodoc FAQ README README-QT.TXT changes*
400 if use immqt || use immqt-bc ; then
401 dodoc ${S}/README.immodule
405 pkg_postinst() {
406 echo
407 elog "After a rebuild of Qt, it can happen that Qt plugins (such as Qt/KDE styles,"
408 elog "or widgets for the Qt designer) are no longer recognized. If this situation"
409 elog "occurs you should recompile the packages providing these plugins,"
410 elog "and you should also make sure that Qt and its plugins were compiled with the"
411 elog "same version of gcc. Packages that may need to be rebuilt are, for instance,"
412 elog "kde-base/kdelibs, kde-base/kdeartwork and kde-base/kdeartwork-styles."
413 elog "See http://doc.trolltech.com/3.3/plugins-howto.html for more infos."
414 echo
416 if use qt-copy ; then
417 echo
418 ewarn "Do NOT report bugs to Gentoo's bugzilla when built with qt-copy!!!"