/[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.22 - (hide annotations) (download)
Sat Jun 13 16:10:09 2015 UTC (3 years, 11 months ago) by pesa
Branch: MAIN
Changes since 1.21: +6 -11 lines
Simplify move of .pc files.

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

  ViewVC Help
Powered by ViewVC 1.1.20