/[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.10 - (hide annotations) (download)
Wed Apr 22 20:23:47 2015 UTC (4 years, 1 month ago) by pesa
Branch: MAIN
Changes since 1.9: +12 -20 lines
Sync with qt overlay: cleanup prefix-related patching and fix bug #542780.

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

  ViewVC Help
Powered by ViewVC 1.1.20