6f13d84aa5f49ab848b76953ce05fc664cf958ef
[gentoo-soor-overlay.git] / x11-libs / qt / qt-4.3.4-r1.ebuild
blob6f13d84aa5f49ab848b76953ce05fc664cf958ef
1 # Copyright 1999-2008 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 multilib
8 SRCTYPE="opensource-src"
9 QT_COPY_SNAP="1.0"
10 DESCRIPTION="The Qt toolkit is a comprehensive C++ application development framework."
11 HOMEPAGE="http://www.trolltech.com/"
13 RESTRICT="primaryuri"
15 SRC_URI="mirror://gentoo/qt-x11-${SRCTYPE}-${PV}.tar.gz
16 ftp://ftp.trolltech.com/pub/qt/source/qt-x11-${SRCTYPE}-${PV}.tar.gz
17 qt-copy? ( http://jyujin.de/~creidiki/qt-copy/qt-copy-${PV}-patches-${QT_COPY_SNAP}.tar.lzma )"
18 S=${WORKDIR}/qt-x11-${SRCTYPE}-${PV}
20 LICENSE="|| ( QPL-1.0 GPL-2 GPL-3 )"
21 SLOT="4"
22 KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
24 IUSE_INPUT_DEVICES="input_devices_wacom"
26 IUSE="+accessibility cups dbus debug doc examples firebird gif glib jpeg mng
27 mysql nas nis odbc opengl pch png postgres +qt3support +qt-copy sqlite sqlite3 ssl tiff
28 xinerama zlib ${IUSE_INPUT_DEVICES}"
30 RDEPEND="x11-libs/libXrandr
31 x11-libs/libXcursor
32 x11-libs/libXfont
33 x11-libs/libSM
34 !x11-libs/qt-core
35 xinerama? ( x11-libs/libXinerama )
36 media-libs/fontconfig
37 media-libs/freetype:2
38 png? ( media-libs/libpng )
39 jpeg? ( media-libs/jpeg )
40 mng? ( >=media-libs/libmng-1.0.9 )
41 tiff? ( media-libs/tiff )
42 nas? ( >=media-libs/nas-1.5 )
43 odbc? ( dev-db/unixODBC )
44 mysql? ( virtual/mysql )
45 firebird? ( dev-db/firebird )
46 sqlite3? ( dev-db/sqlite:3 )
47 sqlite? ( dev-db/sqlite:0 )
48 opengl? ( virtual/opengl virtual/glu )
49 postgres? ( dev-db/libpq )
50 cups? ( net-print/cups )
51 zlib? ( sys-libs/zlib )
52 glib? ( dev-libs/glib )
53 dbus? ( >=sys-apps/dbus-1.0.2 )
54 ssl? ( dev-libs/openssl )
55 input_devices_wacom? ( x11-libs/libXi x11-drivers/linuxwacom )"
57 DEPEND="${RDEPEND}
58 qt-copy? ( app-arch/lzma-utils )
59 xinerama? ( x11-proto/xineramaproto )
60 x11-proto/xextproto
61 x11-proto/inputproto
62 dev-util/pkgconfig"
64 pkg_setup() {
65 QTBASEDIR=/usr/$(get_libdir)/qt4
66 QTPREFIXDIR=/usr
67 QTBINDIR=/usr/bin
68 QTLIBDIR=/usr/$(get_libdir)/qt4
69 QTPCDIR=/usr/$(get_libdir)/pkgconfig
70 QTDATADIR=/usr/share/qt4
71 QTDOCDIR=/usr/share/doc/${P}
72 QTHEADERDIR=/usr/include/qt4
73 QTPLUGINDIR=${QTLIBDIR}/plugins
74 QTSYSCONFDIR=/etc/qt4
75 QTTRANSDIR=${QTDATADIR}/translations
76 QTEXAMPLESDIR=${QTDATADIR}/examples
77 QTDEMOSDIR=${QTDATADIR}/demos
79 PLATFORM=$(qt_mkspecs_dir)
81 }
83 qt_use() {
84 local flag="$1"
85 local feature="$1"
86 local enableval=
88 [[ -n $2 ]] && feature=$2
89 [[ -n $3 ]] && enableval="-$3"
91 useq $flag && echo "${enableval}-${feature}" || echo "-no-${feature}"
92 return 0
93 }
95 qt_mkspecs_dir() {
96 # Allows us to define which mkspecs dir we want to use.
97 local spec
99 case ${CHOST} in
100 *-freebsd*|*-dragonfly*)
101 spec="freebsd" ;;
102 *-openbsd*)
103 spec="openbsd" ;;
104 *-netbsd*)
105 spec="netbsd" ;;
106 *-darwin*)
107 spec="darwin" ;;
108 *-linux-*|*-linux)
109 spec="linux" ;;
110 *)
111 die "Unknown CHOST, no platform choosed."
112 esac
114 CXX=$(tc-getCXX)
115 if [[ ${CXX/g++/} != ${CXX} ]]; then
116 spec="${spec}-g++"
117 elif [[ ${CXX/icpc/} != ${CXX} ]]; then
118 spec="${spec}-icc"
119 else
120 die "Unknown compiler ${CXX}."
121 fi
123 echo "${spec}"
126 src_unpack() {
128 unpack ${A}
129 cd "${S}"
130 epatch "${FILESDIR}"/qt-4.2.3-hppa-ldcw-fix.patch
132 # Apply QT Copy patches:
133 if use qt-copy; then
134 ebegin "Applying the KDE Qt Copy patches"
135 for diff in $(ls "${WORKDIR}/qt-copy-${PV}-patches-${QT_COPY_SNAP}"/* | sort); do
136 epatch "${diff}" || die
137 done
138 einfo "Done with patching"
139 fi
141 cd "${S}"/mkspecs/$(qt_mkspecs_dir)
142 # set c/xxflags and ldflags
144 # Don't let the user go too overboard with flags. If you really want to, uncomment
145 # out the line below and give 'er a whirl.
146 strip-flags
147 replace-flags -O3 -O2
149 if [[ $( gcc-fullversion ) == "3.4.6" && gcc-specs-ssp ]] ; then
150 ewarn "Appending -fno-stack-protector to CFLAGS/CXXFLAGS"
151 append-flags -fno-stack-protector
152 fi
154 # Bug 178652
155 if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then
156 ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS"
157 append-flags -fno-gcse
158 fi
160 # Anti-aliasing rules are broken in qt-4.3*, causing random runtime failures
161 # in Qt programs. bug 213411.
162 append-flags -fno-strict-aliasing
164 sed -i -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
165 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
166 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
167 -e "/CONFIG/s:$: nostrip:" \
168 qmake.conf
170 # Do not link with -rpath. See bug #75181.
171 sed -i -e "s:QMAKE_RPATH.*=.*:QMAKE_RPATH=:" qmake.conf
173 # Replace X11R6/ directories, so /usr/X11R6/lib -> /usr/lib
174 sed -i -e "s:X11R6/::" qmake.conf
176 # The trolls moved the definitions of the above stuff for g++, so we need to edit those files
177 # separately as well.
178 cd "${S}"/mkspecs/common
180 sed -i -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CPPFLAGS} ${CFLAGS} ${ASFLAGS}:" \
181 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CPPFLAGS} ${CXXFLAGS} ${ASFLAGS}:" \
182 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
183 g++.conf
185 # Do not link with -rpath. See bug #75181.
186 sed -i -e "s:QMAKE_RPATH.*=.*:QMAKE_RPATH=:" g++.conf
188 # Replace X11R6/ directories, so /usr/X11R6/lib -> /usr/lib
189 sed -i -e "s:X11R6/::" linux.conf
191 cd "${S}"/qmake
193 sed -i -e "s:CXXFLAGS.*=:CXXFLAGS=${CPPFLAGS} ${CXXFLAGS} ${ASFLAGS} :" \
194 -e "s:LFLAGS.*=:LFLAGS=${LDFLAGS} :" Makefile.unix
196 cd "${S}"
200 src_compile() {
201 export PATH="${S}/bin:${PATH}"
202 export LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}"
204 [ $(get_libdir) != "lib" ] && myconf="${myconf} -L/usr/$(get_libdir)"
206 # Disable visibility explicitly if gcc version isn't 4
207 if [[ "$(gcc-major-version)" != "4" ]]; then
208 myconf="${myconf} -no-reduce-exports"
209 fi
211 # Add a switch that will attempt to use recent binutils to reduce relocations. Should be harmless for other
212 # cases. From bug #178535
213 myconf="${myconf} -reduce-relocations"
215 myconf="${myconf} $(qt_use accessibility) $(qt_use cups) $(qt_use xinerama)"
216 myconf="${myconf} $(qt_use opengl) $(qt_use nis)"
218 use nas && myconf="${myconf} -system-nas-sound"
220 myconf="${myconf} $(qt_use gif gif qt) $(qt_use png libpng system)"
221 myconf="${myconf} $(qt_use jpeg libjpeg system) $(qt_use tiff libtiff system)"
222 myconf="${myconf} $(qt_use zlib zlib system) $(qt_use mng libmng system)"
224 use debug && myconf="${myconf} -debug -no-separate-debug-info" || myconf="${myconf} -release -no-separate-debug-info"
226 use mysql && myconf="${myconf} -plugin-sql-mysql -I/usr/include/mysql -L/usr/$(get_libdir)/mysql" || myconf="${myconf} -no-sql-mysql"
227 use postgres && myconf="${myconf} -plugin-sql-psql -I/usr/include/postgresql/pgsql" || myconf="${myconf} -no-sql-psql"
228 use firebird && myconf="${myconf} -plugin-sql-ibase -I/opt/firebird/include" || myconf="${myconf} -no-sql-ibase"
229 use sqlite3 && myconf="${myconf} -plugin-sql-sqlite -system-sqlite" || myconf="${myconf} -no-sql-sqlite"
230 use sqlite && myconf="${myconf} -plugin-sql-sqlite2" || myconf="${myconf} -no-sql-sqlite2"
231 use odbc && myconf="${myconf} -plugin-sql-odbc" || myconf="${myconf} -no-sql-odbc"
233 use dbus && myconf="${myconf} -qdbus" || myconf="${myconf} -no-qdbus"
234 use glib && myconf="${myconf} -glib" || myconf="${myconf} -no-glib"
235 use qt3support && myconf="${myconf} -qt3support" || myconf="${myconf} -no-qt3support"
236 use ssl && myconf="${myconf} -openssl" || myconf="${myconf} -no-openssl"
238 use pch && myconf="${myconf} -pch" || myconf="${myconf} -no-pch"
240 use input_devices_wacom && myconf="${myconf} -tablet" || myconf="${myconf} -no-tablet"
242 myconf="${myconf} -xrender -xrandr -xkb -xshape -sm"
244 if ! use examples; then
245 myconf="${myconf} -nomake examples"
246 fi
248 myconf="-stl -verbose -largefile -confirm-license \
249 -platform ${PLATFORM} -xplatform ${PLATFORM} -no-rpath \
250 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} -datadir ${QTDATADIR} \
251 -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} -plugindir ${QTPLUGINDIR} \
252 -sysconfdir ${QTSYSCONFDIR} -translationdir ${QTTRANSDIR} \
253 -examplesdir ${QTEXAMPLESDIR} -demosdir ${QTDEMOSDIR} ${myconf}"
255 echo ./configure ${myconf}
256 ./configure ${myconf} || die
258 emake all || die
261 src_install() {
262 export PATH="${S}/bin:${PATH}"
263 export LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}"
265 emake INSTALL_ROOT="${D}" install_subtargets || die
266 emake INSTALL_ROOT="${D}" install_qmake || die
267 emake INSTALL_ROOT="${D}" install_mkspecs || die
269 if use doc; then
270 emake INSTALL_ROOT="${D}" install_htmldocs || die
271 fi
273 # Install the translations. This may get use flagged later somehow
274 emake INSTALL_ROOT="${D}" install_translations || die
276 keepdir "${QTSYSCONFDIR}"
278 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/*.la
279 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/*.prl
280 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/pkgconfig/*.pc
282 # pkgconfig files refer to WORKDIR/bin as the moc and uic locations. Fix:
283 sed -i -e "s:${S}/bin:${QTBINDIR}:g" "${D}"/${QTLIBDIR}/pkgconfig/*.pc
285 # Move .pc files into the pkgconfig directory
286 dodir ${QTPCDIR}
287 mv "${D}"/${QTLIBDIR}/pkgconfig/*.pc "${D}"/${QTPCDIR}
289 # Install .desktop files, from bug #174033
290 insinto /usr/share/applications
291 doins "${FILESDIR}"/qt4/*.desktop
293 # List all the multilib libdirs
294 local libdirs
295 for libdir in $(get_all_libdirs); do
296 libdirs="${libdirs}:/usr/${libdir}/qt4"
297 done
299 cat > "${T}/44qt4" << EOF
300 LDPATH=${libdirs:1}
301 EOF
302 doenvd "${T}/44qt4"
305 pkg_postinst() {
306 if use qt-copy ; then
307 ewarn "Do NOT report bugs to Gentoo's bugzilla when built with qt-copy!!!"
308 fi