/[gentoo-x86]/eclass/qt4-build-multilib.eclass
Gentoo

Contents of /eclass/qt4-build-multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Mon Mar 23 02:15:14 2015 UTC (4 years, 2 months ago) by pesa
Branch: MAIN
Changes since 1.7: +15 -7 lines
Workaround toolchain bug on x86 with -Os and --as-needed, see bug #503500.

1 pesa 1.4 # Copyright 1999-2015 Gentoo Foundation
2 pesa 1.1 # Distributed under the terms of the GNU General Public License v2
3 pesa 1.8 # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build-multilib.eclass,v 1.7 2015/03/15 01:25:19 pesa Exp $
4 pesa 1.1
5     # @ECLASS: qt4-build-multilib.eclass
6     # @MAINTAINER:
7     # Qt herd <qt@gentoo.org>
8     # @AUTHOR:
9     # Davide Pesavento <pesa@gentoo.org>
10     # @BLURB: Eclass for Qt4 split ebuilds with multilib support.
11     # @DESCRIPTION:
12     # This eclass contains various functions that are used when building Qt4.
13     # Requires EAPI 5.
14    
15     case ${EAPI} in
16     5) : ;;
17     *) die "qt4-build-multilib.eclass: unsupported EAPI=${EAPI:-0}" ;;
18     esac
19    
20     inherit eutils flag-o-matic multilib multilib-minimal toolchain-funcs
21    
22     HOMEPAGE="https://www.qt.io/ https://qt-project.org/"
23     LICENSE="|| ( LGPL-2.1 GPL-3 )"
24     SLOT="4"
25    
26     case ${PV} in
27     4.?.9999)
28     QT4_BUILD_TYPE="live"
29     EGIT_REPO_URI=(
30     "git://gitorious.org/qt/qt.git"
31     "https://git.gitorious.org/qt/qt.git"
32     )
33     EGIT_BRANCH=${PV%.9999}
34     inherit git-r3
35     ;;
36     *)
37     QT4_BUILD_TYPE="release"
38     MY_P=qt-everywhere-opensource-src-${PV/_/-}
39 pesa 1.4 SRC_URI="http://download.qt.io/official_releases/qt/${PV%.*}/${PV}/${MY_P}.tar.gz"
40 pesa 1.1 S=${WORKDIR}/${MY_P}
41     ;;
42     esac
43    
44     if [[ ${PN} != qttranslations ]]; then
45     IUSE="aqua debug pch"
46     [[ ${PN} != qtxmlpatterns ]] && IUSE+=" +exceptions"
47     fi
48    
49     DEPEND="
50     dev-lang/perl
51     virtual/pkgconfig[${MULTILIB_USEDEP}]
52     "
53     RDEPEND="
54     dev-qt/qtchooser
55 pesa 1.2 abi_x86_32? ( !app-emulation/emul-linux-x86-qtlibs[-abi_x86_32(-)] )
56 pesa 1.1 "
57    
58    
59     # src_{configure,compile,test,install} are inherited from multilib-minimal
60     EXPORT_FUNCTIONS src_unpack src_prepare pkg_postinst pkg_postrm
61    
62     multilib_src_configure() { qt4_multilib_src_configure; }
63     multilib_src_compile() { qt4_multilib_src_compile; }
64     multilib_src_test() { qt4_multilib_src_test; }
65     multilib_src_install() { qt4_multilib_src_install; }
66     multilib_src_install_all() { qt4_multilib_src_install_all; }
67    
68    
69     # @ECLASS-VARIABLE: PATCHES
70     # @DEFAULT_UNSET
71     # @DESCRIPTION:
72     # Array variable containing all the patches to be applied. This variable
73     # is expected to be defined in the global scope of ebuilds. Make sure to
74     # specify the full path. This variable is used in src_prepare phase.
75     #
76     # Example:
77     # @CODE
78     # PATCHES=(
79     # "${FILESDIR}/mypatch.patch"
80     # "${FILESDIR}/mypatch2.patch"
81     # )
82     # @CODE
83    
84     # @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
85     # @DEFAULT_UNSET
86     # @DESCRIPTION:
87     # Space-separated list of directories that will be configured,
88     # compiled, and installed. All paths must be relative to ${S}.
89    
90     # @ECLASS-VARIABLE: QT4_VERBOSE_BUILD
91     # @DESCRIPTION:
92     # Set to false to reduce build output during compilation.
93     : ${QT4_VERBOSE_BUILD:=true}
94    
95     # @ECLASS-VARIABLE: QCONFIG_ADD
96     # @DEFAULT_UNSET
97     # @DESCRIPTION:
98     # List of options that must be added to QT_CONFIG in qconfig.pri
99    
100     # @ECLASS-VARIABLE: QCONFIG_REMOVE
101     # @DEFAULT_UNSET
102     # @DESCRIPTION:
103     # List of options that must be removed from QT_CONFIG in qconfig.pri
104    
105     # @ECLASS-VARIABLE: QCONFIG_DEFINE
106     # @DEFAULT_UNSET
107     # @DESCRIPTION:
108     # List of macros that must be defined in QtCore/qconfig.h
109    
110     # @FUNCTION: qt4-build-multilib_src_unpack
111     # @DESCRIPTION:
112     # Unpacks the sources.
113     qt4-build-multilib_src_unpack() {
114     if [[ $(gcc-major-version) -lt 4 ]] || [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 4 ]]; then
115     ewarn
116     ewarn "Using a GCC version lower than 4.4 is not supported."
117     ewarn
118     fi
119    
120     if [[ ${PN} == qtwebkit ]]; then
121     eshopts_push -s extglob
122     if is-flagq '-g?(gdb)?([1-9])'; then
123     ewarn
124     ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
125     ewarn "You may experience really long compilation times and/or increased memory usage."
126     ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
127     ewarn "For more info check out https://bugs.gentoo.org/307861"
128     ewarn
129     fi
130     eshopts_pop
131     fi
132    
133     case ${QT4_BUILD_TYPE} in
134     live) git-r3_src_unpack ;;
135     release) default ;;
136     esac
137     }
138    
139     # @FUNCTION: qt4-build-multilib_src_prepare
140     # @DESCRIPTION:
141     # Prepare the sources before the configure phase. Strip CFLAGS if necessary, and fix
142     # the build system in order to respect CFLAGS/CXXFLAGS/LDFLAGS specified in make.conf.
143     qt4-build-multilib_src_prepare() {
144     if [[ ${PN} != qtcore ]]; then
145     # avoid unnecessary qmake recompilations
146     sed -i -e 's/^if true;/if false;/' configure \
147     || die "sed failed (skip qmake bootstrap)"
148     fi
149    
150     # skip X11 tests in non-gui packages to avoid spurious dependencies
151     if has ${PN} qtbearer qtcore qtdbus qtscript qtsql qttest qttranslations qtxmlpatterns; then
152     sed -i -e '/^if.*PLATFORM_X11.*CFG_GUI/,/^fi$/d' configure \
153     || die "sed failed (skip X11 tests)"
154     fi
155    
156     if use_if_iuse aqua; then
157     sed -i \
158     -e '/^CONFIG/s:app_bundle::' \
159     -e '/^CONFIG/s:plugin_no_soname:plugin_with_soname absolute_library_soname:' \
160     mkspecs/$(qt4_get_mkspec)/qmake.conf \
161     || die "sed failed (aqua)"
162    
163     # we are crazy and build cocoa + qt3support
164     if { ! in_iuse qt3support || use qt3support; } && [[ ${CHOST##*-darwin} -ge 9 ]]; then
165     sed -i -e "/case \"\$PLATFORM,\$CFG_MAC_COCOA\" in/,/;;/ s|CFG_QT3SUPPORT=\"no\"|CFG_QT3SUPPORT=\"yes\"|" \
166     configure || die "sed failed (cocoa + qt3support)"
167     fi
168     fi
169    
170 pesa 1.8 if [[ ${PN} == qtcore ]]; then
171     # Bug 373061
172     # qmake bus errors with -O2 or -O3 but -O1 works
173     if [[ ${CHOST} == *86*-apple-darwin* ]]; then
174     replace-flags -O[23] -O1
175     fi
176    
177     # Bug 503500
178     # undefined reference with -Os and --as-needed
179     if use x86 || use_if_iuse abi_x86_32; then
180     replace-flags -Os -O2
181     fi
182     fi
183    
184 pesa 1.1 # Bug 261632
185     if use ppc64; then
186     append-flags -mminimal-toc
187     fi
188    
189     # Bug 417105
190     # graphite on gcc 4.7 causes miscompilations
191     if [[ $(gcc-version) == "4.7" ]]; then
192     filter-flags -fgraphite-identity
193     fi
194    
195     # Read also AR from the environment
196     sed -i -e 's/^SYSTEM_VARIABLES="/&AR /' \
197     configure || die "sed SYSTEM_VARIABLES failed"
198    
199     # Reset QMAKE_*FLAGS_{RELEASE,DEBUG} variables,
200     # or they will override user's flags (.qmake.cache)
201     sed -i -e '/^SYSTEM_VARIABLES=/ i \
202     QMakeVar set QMAKE_CFLAGS_RELEASE\
203     QMakeVar set QMAKE_CFLAGS_DEBUG\
204     QMakeVar set QMAKE_CXXFLAGS_RELEASE\
205     QMakeVar set QMAKE_CXXFLAGS_DEBUG\
206     QMakeVar set QMAKE_LFLAGS_RELEASE\
207     QMakeVar set QMAKE_LFLAGS_DEBUG\n' \
208     configure || die "sed QMAKE_*FLAGS_{RELEASE,DEBUG} failed"
209    
210     # Respect CC, CXX, LINK and *FLAGS in config.tests
211     find config.tests/unix -name '*.test' -type f -print0 | xargs -0 \
212     sed -i -e "/bin\/qmake/ s: \"\$SRCDIR/: \
213     'QMAKE_CC=$(tc-getCC)' 'QMAKE_CXX=$(tc-getCXX)' 'QMAKE_LINK=$(tc-getCXX)' \
214     'QMAKE_CFLAGS+=${CFLAGS}' 'QMAKE_CXXFLAGS+=${CXXFLAGS}' 'QMAKE_LFLAGS+=${LDFLAGS}'&:" \
215     || die "sed config.tests failed"
216    
217     # Bug 172219
218     sed -e 's:/X11R6/:/:' -i mkspecs/$(qt4_get_mkspec)/qmake.conf || die
219    
220     if [[ ${CHOST} == *-darwin* ]]; then
221     # Set FLAGS and remove -arch, since our gcc-apple is multilib crippled (by design)
222     sed -i \
223     -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
224     -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
225     -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=-headerpad_max_install_names ${LDFLAGS}:" \
226     -e "s:-arch\s\w*::g" \
227     mkspecs/common/g++-macx.conf \
228     || die "sed g++-macx.conf failed"
229    
230     # Fix configure's -arch settings that appear in qmake/Makefile and also
231     # fix arch handling (automagically duplicates our -arch arg and breaks
232     # pch). Additionally disable Xarch support.
233     sed -i \
234     -e "s:-arch i386::" \
235     -e "s:-arch ppc::" \
236     -e "s:-arch x86_64::" \
237     -e "s:-arch ppc64::" \
238     -e "s:-arch \$i::" \
239     -e "/if \[ ! -z \"\$NATIVE_64_ARCH\" \]; then/,/fi/ d" \
240     -e "s:CFG_MAC_XARCH=yes:CFG_MAC_XARCH=no:g" \
241     -e "s:-Xarch_x86_64::g" \
242     -e "s:-Xarch_ppc64::g" \
243     configure mkspecs/common/gcc-base-macx.conf mkspecs/common/g++-macx.conf \
244     || die "sed -arch/-Xarch failed"
245    
246     # On Snow Leopard don't fall back to 10.5 deployment target.
247     if [[ ${CHOST} == *-apple-darwin10 ]]; then
248     sed -i \
249     -e "s:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET.*:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.6:g" \
250     -e "s:-mmacosx-version-min=10.[0-9]:-mmacosx-version-min=10.6:g" \
251     configure mkspecs/common/g++-macx.conf \
252     || die "sed deployment target failed"
253     fi
254     fi
255    
256     # this is needed for all systems with a separate -liconv, except
257     # Darwin, for which the sources already cater for -liconv
258     if use !elibc_glibc && [[ ${CHOST} != *-darwin* ]]; then
259     sed -e 's|mac:\(LIBS += -liconv\)|\1|g' \
260     -i config.tests/unix/iconv/iconv.pro \
261     || die "sed iconv.pro failed"
262     fi
263    
264     # we need some patches for Solaris
265     sed -i -e '/^QMAKE_LFLAGS_THREAD/a\QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,' \
266     mkspecs/$(qt4_get_mkspec)/qmake.conf || die
267     # use GCC over SunStudio
268     sed -i -e '/PLATFORM=solaris-cc/s/cc/g++/' configure || die
269     # do not flirt with non-Prefix stuff, we're quite possessive
270     sed -i -e '/^QMAKE_\(LIB\|INC\)DIR\(_X11\|_OPENGL\|\)\t/s/=.*$/=/' \
271     mkspecs/$(qt4_get_mkspec)/qmake.conf || die
272    
273     # apply patches
274     [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
275     epatch_user
276     }
277    
278     qt4_multilib_src_configure() {
279     qt4_prepare_env
280    
281     qt4_symlink_tools_to_build_dir
282    
283 pesa 1.3 # toolchain setup ('local -x' because of bug 532510)
284     local -x \
285     AR="$(tc-getAR) cqs" \
286     CC=$(tc-getCC) \
287     CXX=$(tc-getCXX) \
288     LD=$(tc-getCXX) \
289     OBJCOPY=$(tc-getOBJCOPY) \
290     STRIP=$(tc-getSTRIP)
291 pesa 1.1
292     # convert tc-arch to the values supported by Qt
293     local arch=
294     case $(tc-arch) in
295     amd64|x64-*) arch=x86_64 ;;
296     ppc*-macos) arch=ppc ;;
297     ppc*) arch=powerpc ;;
298     sparc*) arch=sparc ;;
299     x86-macos) arch=x86 ;;
300     x86*) arch=i386 ;;
301 dlan 1.6 alpha|arm|ia64|mips|s390) arch=$(tc-arch) ;;
302 pesa 1.7 arm64|hppa|sh) arch=generic ;;
303 pesa 1.1 *) die "qt4-build-multilib.eclass: unsupported tc-arch '$(tc-arch)'" ;;
304     esac
305    
306     # configure arguments
307     local conf=(
308     # installation paths
309     -prefix "${QT4_PREFIX}"
310     -bindir "${QT4_BINDIR}"
311     -libdir "${QT4_LIBDIR}"
312     -docdir "${QT4_DOCDIR}"
313     -headerdir "${QT4_HEADERDIR}"
314     -plugindir "${QT4_PLUGINDIR}"
315     -importdir "${QT4_IMPORTDIR}"
316     -datadir "${QT4_DATADIR}"
317     -translationdir "${QT4_TRANSLATIONDIR}"
318     -sysconfdir "${QT4_SYSCONFDIR}"
319     -examplesdir "${QT4_EXAMPLESDIR}"
320     -demosdir "${QT4_DEMOSDIR}"
321    
322     # debug/release
323     $(use_if_iuse debug && echo -debug || echo -release)
324     -no-separate-debug-info
325    
326     # licensing stuff
327     -opensource -confirm-license
328    
329     # build shared libraries
330     -shared
331    
332     # skip recursive processing of .pro files at the end of configure
333     # (we run qmake by ourselves), thus saving quite a bit of time
334     -dont-process
335    
336     # always enable large file support
337     -largefile
338    
339     # exceptions USE flag
340     $(in_iuse exceptions && qt_use exceptions || echo -exceptions)
341    
342     # build STL support
343     -stl
344    
345     # architecture/platform (mkspec)
346     -arch ${arch}
347     -platform $(qt4_get_mkspec)
348    
349     # prefer system libraries
350     -system-zlib
351    
352     # exclude examples and demos from default build
353     -nomake examples
354     -nomake demos
355    
356     # disable rpath on non-prefix (bugs 380415 and 417169)
357     $(use prefix || echo -no-rpath)
358    
359     # verbosity of the configure and build phases
360     -verbose $(${QT4_VERBOSE_BUILD} || echo -silent)
361    
362     # precompiled headers don't work on hardened, where the flag is masked
363     $(in_iuse pch && qt_use pch || echo -no-pch)
364    
365     # enable linker optimizations to reduce relocations, except on Solaris
366     # where this flag seems to introduce major breakage to applications,
367     # mostly to be seen as a core dump with the message:
368     # "QPixmap: Must construct a QApplication before a QPaintDevice"
369     $([[ ${CHOST} != *-solaris* ]] && echo -reduce-relocations)
370    
371     # this one is needed for all systems with a separate -liconv, apart from
372     # Darwin, for which the sources already cater for -liconv
373     $(use !elibc_glibc && [[ ${CHOST} != *-darwin* ]] && echo -liconv)
374     )
375    
376     if use_if_iuse aqua; then
377     if [[ ${CHOST##*-darwin} -ge 9 ]]; then
378     conf+=(
379     # on (snow) leopard use the new (frameworked) cocoa code
380     -cocoa -framework
381     # add hint for the framework location
382     -F"${QT4_LIBDIR}"
383     )
384     else
385     conf+=(-no-framework)
386     fi
387     fi
388    
389     conf+=(
390     # module-specific options
391     "${myconf[@]}"
392     )
393    
394     einfo "Configuring with: ${conf[@]}"
395     "${S}"/configure "${conf[@]}" || die "configure failed"
396    
397     # configure is stupid and assigns QMAKE_LFLAGS twice,
398     # thus the previous -rpath-link flag gets overwritten
399     # and some packages (e.g. qthelp) fail to link
400     sed -i -e '/^QMAKE_LFLAGS =/ s:$: $$QMAKE_LFLAGS:' \
401     .qmake.cache || die "sed .qmake.cache failed"
402    
403     qt4_qmake
404     qt4_foreach_target_subdir qt4_qmake
405     }
406    
407     qt4_multilib_src_compile() {
408     qt4_prepare_env
409    
410     qt4_foreach_target_subdir emake
411     }
412    
413     qt4_multilib_src_test() {
414     qt4_prepare_env
415    
416     qt4_foreach_target_subdir emake -j1 check
417     }
418    
419     qt4_multilib_src_install() {
420     qt4_prepare_env
421    
422     qt4_foreach_target_subdir emake INSTALL_ROOT="${D}" install
423    
424     if [[ ${PN} == qtcore ]]; then
425     set -- emake INSTALL_ROOT="${D}" install_{mkspecs,qmake}
426     einfo "Running $*"
427     "$@"
428    
429     # install env.d file
430     cat > "${T}/44qt4-${CHOST}" <<-_EOF_
431     LDPATH="${QT4_LIBDIR}"
432     _EOF_
433     doenvd "${T}/44qt4-${CHOST}"
434    
435     # install qtchooser configuration file
436     cat > "${T}/qt4-${CHOST}.conf" <<-_EOF_
437     ${QT4_BINDIR}
438     ${QT4_LIBDIR}
439     _EOF_
440    
441     (
442     insinto /etc/xdg/qtchooser
443     doins "${T}/qt4-${CHOST}.conf"
444     )
445    
446     if multilib_is_native_abi; then
447     # convenience symlinks
448     dosym qt4-"${CHOST}".conf /etc/xdg/qtchooser/4.conf
449     dosym qt4-"${CHOST}".conf /etc/xdg/qtchooser/qt4.conf
450     # TODO bug 522646: write an eselect module to manage default.conf
451     dosym qt4.conf /etc/xdg/qtchooser/default.conf
452     fi
453     fi
454    
455     install_qconfigs
456     fix_library_files
457     fix_includes
458     }
459    
460     qt4_multilib_src_install_all() {
461     if [[ ${PN} == qtcore ]]; then
462     # include gentoo-qconfig.h at the beginning of Qt{,Core}/qconfig.h
463     if use aqua && [[ ${CHOST#*-darwin} -ge 9 ]]; then
464     sed -i -e '1i #include <QtCore/Gentoo/gentoo-qconfig.h>\n' \
465     "${D}${QT4_LIBDIR}"/QtCore.framework/Headers/qconfig.h \
466     || die "sed failed (qconfig.h)"
467     dosym "${QT4_HEADERDIR#${EPREFIX}}"/Gentoo \
468     "${QT4_LIBDIR#${EPREFIX}}"/QtCore.framework/Headers/Gentoo
469     else
470     sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
471     "${D}${QT4_HEADERDIR}"/Qt{,Core}/qconfig.h \
472     || die "sed failed (qconfig.h)"
473     fi
474    
475     dodir "${QT4_DATADIR#${EPREFIX}}"/mkspecs/gentoo
476     mv "${D}${QT4_DATADIR}"/mkspecs/{qconfig.pri,gentoo/} || die
477     fi
478    
479     # install private headers of a few modules
480     if has ${PN} qtcore qtdeclarative qtgui qtscript; then
481     local moduledir=${PN#qt}
482     local modulename=Qt$(tr 'a-z' 'A-Z' <<< ${moduledir:0:1})${moduledir:1}
483     [[ ${moduledir} == core ]] && moduledir=corelib
484    
485     einfo "Installing private headers into ${QT4_HEADERDIR}/${modulename}/private"
486     insinto "${QT4_HEADERDIR#${EPREFIX}}"/${modulename}/private
487     find "${S}"/src/${moduledir} -type f -name '*_p.h' -exec doins '{}' + || die
488     fi
489    
490     # remove .la files since we are building only shared libraries
491     prune_libtool_files
492     }
493    
494     # @FUNCTION: qt4-build-multilib_pkg_postinst
495     # @DESCRIPTION:
496     # Regenerate configuration, plus throw a message about possible
497     # breakages and proposed solutions.
498     qt4-build-multilib_pkg_postinst() {
499     generate_qconfigs
500     }
501    
502     # @FUNCTION: qt4-build-multilib_pkg_postrm
503     # @DESCRIPTION:
504     # Regenerate configuration when the package is completely removed.
505     qt4-build-multilib_pkg_postrm() {
506     generate_qconfigs
507     }
508    
509     # @FUNCTION: qt_use
510     # @USAGE: <flag> [feature] [enableval]
511     # @DESCRIPTION:
512     # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
513     # otherwise. If [feature] is not specified, <flag> is used in its place.
514     # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
515     qt_use() {
516     use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}"
517     }
518    
519     # @FUNCTION: qt_native_use
520     # @USAGE: <flag> [feature] [enableval]
521     # @DESCRIPTION:
522     # Outputs "-${enableval}-${feature}" if <flag> is enabled and we are currently
523     # building for the native ABI, "-no-${feature}" otherwise. If [feature] is not
524     # specified, <flag> is used in its place. If [enableval] is not specified,
525     # the "-${enableval}" prefix is omitted.
526     qt_native_use() {
527     multilib_is_native_abi && use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}"
528     }
529    
530    
531     ###### Internal functions ######
532    
533     # @FUNCTION: qt4_prepare_env
534     # @INTERNAL
535     # @DESCRIPTION:
536     # Prepares the environment for building Qt.
537     qt4_prepare_env() {
538     # setup installation directories
539     QT4_PREFIX=${EPREFIX}/usr
540     QT4_HEADERDIR=${QT4_PREFIX}/include/qt4
541     QT4_LIBDIR=${QT4_PREFIX}/$(get_libdir)/qt4
542     QT4_PCDIR=${QT4_PREFIX}/$(get_libdir)/pkgconfig
543     QT4_BINDIR=${QT4_LIBDIR}/bin
544     QT4_PLUGINDIR=${QT4_LIBDIR}/plugins
545     QT4_IMPORTDIR=${QT4_LIBDIR}/imports
546     QT4_DATADIR=${QT4_PREFIX}/share/qt4
547     QT4_DOCDIR=${QT4_PREFIX}/share/doc/qt-${PV}
548     QT4_TRANSLATIONDIR=${QT4_DATADIR}/translations
549     QT4_EXAMPLESDIR=${QT4_DATADIR}/examples
550     QT4_DEMOSDIR=${QT4_DATADIR}/demos
551     QT4_SYSCONFDIR=${EPREFIX}/etc/qt4
552     QMAKE_LIBDIR_QT=${QT4_LIBDIR}
553    
554     export XDG_CONFIG_HOME="${T}"
555     }
556    
557     # @FUNCTION: qt4_foreach_target_subdir
558     # @INTERNAL
559     # @DESCRIPTION:
560     # Executes the given command inside each directory listed in QT4_TARGET_DIRECTORIES.
561     qt4_foreach_target_subdir() {
562     local subdir
563     for subdir in ${QT4_TARGET_DIRECTORIES}; do
564     mkdir -p "${subdir}" || die
565     pushd "${subdir}" >/dev/null || die
566    
567     einfo "Running $* ${subdir:+in ${subdir}}"
568     "$@"
569    
570     popd >/dev/null || die
571     done
572     }
573    
574     # @FUNCTION: qt4_symlink_tools_to_build_dir
575     # @INTERNAL
576     # @DESCRIPTION:
577     # Symlinks qtcore tools to BUILD_DIR,
578     # so that they can be used when building other modules.
579     qt4_symlink_tools_to_build_dir() {
580     local tool= tools=()
581     if [[ ${PN} != qtcore ]]; then
582     tools+=(qmake moc rcc uic)
583     fi
584    
585     mkdir -p "${BUILD_DIR}"/bin || die
586     pushd "${BUILD_DIR}"/bin >/dev/null || die
587    
588     for tool in "${tools[@]}"; do
589     [[ -e ${QT4_BINDIR}/${tool} ]] || continue
590     ln -s "${QT4_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
591     done
592    
593     popd >/dev/null || die
594     }
595    
596     # @FUNCTION: qt4_qmake
597     # @INTERNAL
598     # @DESCRIPTION:
599     # Helper function that runs qmake in the current target subdir.
600     # Intended to be called by qt4_foreach_target_subdir().
601     qt4_qmake() {
602     local projectdir=${PWD/#${BUILD_DIR}/${S}}
603    
604     "${BUILD_DIR}"/bin/qmake \
605     CONFIG+=nostrip \
606     LIBS+=-L"${QT4_LIBDIR}" \
607     "${projectdir}" \
608     || die "qmake failed (${projectdir})"
609     }
610    
611     # @FUNCTION: install_qconfigs
612     # @INTERNAL
613     # @DESCRIPTION:
614     # Install gentoo-specific mkspecs configurations.
615     install_qconfigs() {
616     local x
617     if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
618     for x in QCONFIG_ADD QCONFIG_REMOVE; do
619     [[ -n ${!x} ]] && echo ${x}=${!x} >> "${BUILD_DIR}"/${PN}-qconfig.pri
620     done
621     insinto ${QT4_DATADIR#${EPREFIX}}/mkspecs/gentoo
622     doins "${BUILD_DIR}"/${PN}-qconfig.pri
623     fi
624    
625     if [[ -n ${QCONFIG_DEFINE} ]]; then
626     for x in ${QCONFIG_DEFINE}; do
627     echo "#define ${x}" >> "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
628     done
629     insinto ${QT4_HEADERDIR#${EPREFIX}}/Gentoo
630     doins "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
631     fi
632     }
633    
634     # @FUNCTION: generate_qconfigs
635     # @INTERNAL
636     # @DESCRIPTION:
637     # Generates gentoo-specific qconfig.{h,pri}.
638     generate_qconfigs() {
639     if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${PN} == qtcore ]]; then
640     local x qconfig_add qconfig_remove qconfig_new
641     for x in "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
642     [[ -f ${x} ]] || continue
643     qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
644     qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
645     done
646    
647     # these error checks do not use die because dying in pkg_post{inst,rm}
648     # just makes things worse.
649     if [[ -e "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
650     # start with the qconfig.pri that qtcore installed
651     if ! cp "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri \
652     "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
653     eerror "cp qconfig failed."
654     return 1
655     fi
656    
657     # generate list of QT_CONFIG entries from the existing list
658     # including qconfig_add and excluding qconfig_remove
659     for x in $(sed -n 's/^QT_CONFIG +=//p' \
660     "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
661     has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
662     done
663    
664     # replace the existing QT_CONFIG list with qconfig_new
665     if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
666     "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
667     eerror "Sed for QT_CONFIG failed"
668     return 1
669     fi
670    
671     # create Gentoo/qconfig.h
672     if [[ ! -e ${ROOT}${QT4_HEADERDIR}/Gentoo ]]; then
673     if ! mkdir -p "${ROOT}${QT4_HEADERDIR}"/Gentoo; then
674     eerror "mkdir ${QT4_HEADERDIR}/Gentoo failed"
675     return 1
676     fi
677     fi
678     : > "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
679     for x in "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
680     [[ -f ${x} ]] || continue
681     cat "${x}" >> "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
682     done
683     else
684     rm -f "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri
685     rm -f "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
686     rmdir "${ROOT}${QT4_DATADIR}"/mkspecs \
687     "${ROOT}${QT4_DATADIR}" \
688     "${ROOT}${QT4_HEADERDIR}"/Gentoo \
689     "${ROOT}${QT4_HEADERDIR}" 2>/dev/null
690     fi
691     fi
692     }
693    
694     # @FUNCTION: fix_library_files
695     # @INTERNAL
696     # @DESCRIPTION:
697     # Fixes the paths in *.prl and *.pc, as they are wrong due to sandbox, and
698     # moves the *.pc files into the pkgconfig directory.
699     fix_library_files() {
700     local libfile
701     for libfile in "${D}"/${QT4_LIBDIR}/{*.prl,pkgconfig/*.pc}; do
702     if [[ -e ${libfile} ]]; then
703     sed -i -e "s:${S}/lib:${QT4_LIBDIR}:g" ${libfile} || die "sed on ${libfile} failed"
704     fi
705     done
706    
707     # pkgconfig files refer to WORKDIR/bin as the moc and uic locations
708     for libfile in "${D}"/${QT4_LIBDIR}/pkgconfig/*.pc; do
709     if [[ -e ${libfile} ]]; then
710     sed -i -e "s:${S}/bin:${QT4_BINDIR}:g" ${libfile} || die "sed on ${libfile} failed"
711    
712     # Move .pc files into the pkgconfig directory
713     dodir ${QT4_PCDIR#${EPREFIX}}
714     mv ${libfile} "${D}"/${QT4_PCDIR}/ || die "moving ${libfile} to ${D}/${QT4_PCDIR}/ failed"
715     fi
716     done
717    
718     # Don't install an empty directory
719     rmdir "${D}"/${QT4_LIBDIR}/pkgconfig
720     }
721    
722     # @FUNCTION: fix_includes
723     # @DESCRIPTION:
724     # For MacOS X we need to add some symlinks when frameworks are
725     # being used, to avoid complications with some more or less stupid packages.
726     fix_includes() {
727     if use_if_iuse aqua && [[ ${CHOST##*-darwin} -ge 9 ]]; then
728     local frw dest f h rdir
729     # Some packages tend to include <Qt/...>
730     dodir "${QT4_HEADERDIR#${EPREFIX}}"/Qt
731    
732     # Fake normal headers when frameworks are installed... eases life later
733     # on, make sure we use relative links though, as some ebuilds assume
734     # these dirs exist in src_install to add additional files
735     f=${QT4_HEADERDIR}
736     h=${QT4_LIBDIR}
737     while [[ -n ${f} && ${f%%/*} == ${h%%/*} ]] ; do
738     f=${f#*/}
739     h=${h#*/}
740     done
741     rdir=${h}
742     f="../"
743     while [[ ${h} == */* ]] ; do
744     f="${f}../"
745     h=${h#*/}
746     done
747     rdir="${f}${rdir}"
748    
749     for frw in "${D}${QT4_LIBDIR}"/*.framework; do
750     [[ -e "${frw}"/Headers ]] || continue
751     f=$(basename ${frw})
752     dest="${QT4_HEADERDIR#${EPREFIX}}"/${f%.framework}
753     dosym "${rdir}"/${f}/Headers "${dest}"
754    
755     # Link normal headers as well.
756     for hdr in "${D}/${QT4_LIBDIR}/${f}"/Headers/*; do
757     h=$(basename ${hdr})
758     dosym "../${rdir}"/${f}/Headers/${h} \
759     "${QT4_HEADERDIR#${EPREFIX}}"/Qt/${h}
760     done
761     done
762     fi
763     }
764    
765     # @FUNCTION: qt4_get_mkspec
766     # @INTERNAL
767     # @DESCRIPTION:
768     # Returns the right mkspec for the current CHOST/CXX combination.
769     qt4_get_mkspec() {
770     local spec=
771    
772     case ${CHOST} in
773     *-linux*)
774     spec=linux ;;
775     *-darwin*)
776     use_if_iuse aqua &&
777     spec=macx || # mac with carbon/cocoa
778     spec=darwin ;; # darwin/mac with X11
779     *-freebsd*|*-dragonfly*)
780     spec=freebsd ;;
781     *-netbsd*)
782     spec=netbsd ;;
783     *-openbsd*)
784     spec=openbsd ;;
785     *-aix*)
786     spec=aix ;;
787     hppa*-hpux*)
788     spec=hpux ;;
789     ia64*-hpux*)
790     spec=hpuxi ;;
791     *-solaris*)
792     spec=solaris ;;
793     *)
794     die "qt4-build-multilib.eclass: unsupported CHOST '${CHOST}'" ;;
795     esac
796    
797     case $(tc-getCXX) in
798     *g++*)
799     spec+=-g++ ;;
800     *clang*)
801     if [[ -d ${S}/mkspecs/unsupported/${spec}-clang ]]; then
802     spec=unsupported/${spec}-clang
803     else
804     ewarn "${spec}-clang mkspec does not exist, falling back to ${spec}-g++"
805     spec+=-g++
806     fi ;;
807     *icpc*)
808     if [[ -d ${S}/mkspecs/${spec}-icc ]]; then
809     spec+=-icc
810     else
811     ewarn "${spec}-icc mkspec does not exist, falling back to ${spec}-g++"
812     spec+=-g++
813     fi ;;
814     *)
815     die "qt4-build-multilib.eclass: unsupported compiler '$(tc-getCXX)'" ;;
816     esac
817    
818     # Add -64 for 64-bit prefix profiles
819     if use amd64-linux || use ia64-linux || use ppc64-linux ||
820     use x64-macos ||
821     use sparc64-freebsd || use x64-freebsd || use x64-openbsd ||
822     use ia64-hpux ||
823     use sparc64-solaris || use x64-solaris
824     then
825     [[ -d ${S}/mkspecs/${spec}-64 ]] && spec+=-64
826     fi
827    
828     echo ${spec}
829     }

  ViewVC Help
Powered by ViewVC 1.1.20