/[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.18 - (hide annotations) (download)
Tue Jun 9 20:16:59 2015 UTC (3 years, 11 months ago) by pesa
Branch: MAIN
Changes since 1.17: +2 -2 lines
More accurate LICENSE.

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

  ViewVC Help
Powered by ViewVC 1.1.20