/[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.7 - (hide annotations) (download)
Sun Mar 15 01:25:19 2015 UTC (4 years, 2 months ago) by pesa
Branch: MAIN
Changes since 1.6: +2 -2 lines
Fix indentation.

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

  ViewVC Help
Powered by ViewVC 1.1.20