/[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.14 - (hide annotations) (download)
Sun May 10 01:06:49 2015 UTC (4 years ago) by pesa
Branch: MAIN
Changes since 1.13: +1 -5 lines
Delete obsolete code that is now causing problems on freebsd (bug 493310).

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

  ViewVC Help
Powered by ViewVC 1.1.20