/[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.1 - (hide annotations) (download)
Thu Nov 13 01:45:07 2014 UTC (4 years, 6 months ago) by pesa
Branch: MAIN
Initial commit of qt4-build-multilib.eclass

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

  ViewVC Help
Powered by ViewVC 1.1.20