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