/[gentoo-x86]/eclass/qt4-build.eclass
Gentoo

Diff of /eclass/qt4-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.5 Revision 1.9
1# Copyright 2005 Gentoo Foundation 1# Copyright 2007-2008 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build.eclass,v 1.5 2007/12/22 17:32:55 caleb Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build.eclass,v 1.9 2008/03/06 14:44:13 zlin Exp $
4 4
5# @ECLASS: qt4-build.eclass 5# @ECLASS: qt4-build.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Caleb Tennis <caleb@gentoo.org> 7# Caleb Tennis <caleb@gentoo.org>
8# @BLURB: 8# @BLURB: Eclass for Qt4 split ebuilds.
9# Eclass for Qt4
10# @DESCRIPTION: 9# @DESCRIPTION:
11# This eclass contains various functions that are used when building Qt4 10# This eclass contains various functions that are used when building Qt4
12 11
13inherit eutils multilib toolchain-funcs flag-o-matic 12inherit eutils multilib toolchain-funcs flag-o-matic
14 13
15IUSE="${IUSE} debug" 14IUSE="${IUSE} debug"
16 15
16case "${PV}" in
17 4.4.0_beta*)
18 SRCTYPE="${SRCTYPE:-opensource-src}"
19 MY_PV="${PV/_beta/-beta}"
20 ;;
21 *)
22 SRCTYPE="${SRCTYPE:-opensource-src}"
23 MY_PV="${PV}"
24 ;;
25esac
26S=${WORKDIR}/qt-x11-${SRCTYPE}-${MY_PV}
27
28SRC_URI="ftp://ftp.trolltech.com/qt/source/qt-x11-${SRCTYPE}-${MY_PV}.tar.bz2"
29
17qt4-build_pkg_setup() { 30qt4-build_pkg_setup() {
31 # Check USE requirements
32 qt4-build_check_use
33
18 # Set up installation directories 34 # Set up installation directories
19
20 QTBASEDIR=/usr/$(get_libdir)/qt4 35 QTBASEDIR=/usr/$(get_libdir)/qt4
21 QTPREFIXDIR=/usr 36 QTPREFIXDIR=/usr
22 QTBINDIR=/usr/bin 37 QTBINDIR=/usr/bin
23 QTLIBDIR=/usr/$(get_libdir)/qt4 38 QTLIBDIR=/usr/$(get_libdir)/qt4
24 QTPCDIR=/usr/$(get_libdir)/pkgconfig 39 QTPCDIR=/usr/$(get_libdir)/pkgconfig
25 QTDATADIR=/usr/share/qt4 40 QTDATADIR=/usr/share/qt4
26 QTDOCDIR=/usr/share/doc/${PF} 41 QTDOCDIR=/usr/share/doc/qt-${PV}
27 QTHEADERDIR=/usr/include/qt4 42 QTHEADERDIR=/usr/include/qt4
28 QTPLUGINDIR=${QTLIBDIR}/plugins 43 QTPLUGINDIR=${QTLIBDIR}/plugins
29 QTSYSCONFDIR=/etc/qt4 44 QTSYSCONFDIR=/etc/qt4
30 QTTRANSDIR=${QTDATADIR}/translations 45 QTTRANSDIR=${QTDATADIR}/translations
31 QTEXAMPLESDIR=${QTDATADIR}/examples 46 QTEXAMPLESDIR=${QTDATADIR}/examples
36 PATH="${S}/bin:${PATH}" 51 PATH="${S}/bin:${PATH}"
37 LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}" 52 LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}"
38} 53}
39 54
40qt4-build_src_unpack() { 55qt4-build_src_unpack() {
56 # TODO: partial unpacks, cfr split KDE ebuilds.
41 unpack ${A} 57 unpack ${A}
42 cd "${S}" 58 cd "${S}"
43 59
60 if [[ ${PN} != qt-core ]]; then
61 skip_qmake_build_patch
62 skip_project_generation_patch
63 symlink_binaries_to_buildtree
64 fi
65
66 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
67 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
68 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
69 -e "s:X11R6/::" \
70 -i "${S}"/mkspecs/$(qt_mkspecs_dir)/qmake.conf || die "sed ${S}/mkspecs/$(qt_mkspecs_dir)/qmake.conf failed"
71
72 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
73 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
74 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
75 -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed"
76}
77
78qt4-build_src_compile() {
44 # Don't let the user go too overboard with flags. If you really want to, uncomment 79 # Don't let the user go too overboard with flags. If you really want to, uncomment
45 # out the line below and give 'er a whirl. 80 # out the line below and give 'er a whirl.
46 strip-flags 81 strip-flags
47 replace-flags -O3 -O2 82 replace-flags -O3 -O2
48 83
49 if [[ $( gcc-fullversion ) == "3.4.6" && gcc-specs-ssp ]] ; then 84 if [[ $(gcc-fullversion) == "3.4.6" && gcc-specs-ssp ]] ; then
50 ewarn "Appending -fno-stack-protector to CFLAGS/CXXFLAGS" 85 ewarn "Appending -fno-stack-protector to CFLAGS/CXXFLAGS"
51 append-flags -fno-stack-protector 86 append-flags -fno-stack-protector
52 fi 87 fi
88
89 myconf="$(standard_configure_options) ${myconf}"
90
91 echo ./configure ${myconf}
92 ./configure ${myconf} || die "./configure failed"
93
94 build_target_directories
53} 95}
54 96
55qt4-build_src_install() { 97qt4-build_src_install() {
56 install_directories "${QT4_TARGET_DIRECTORIES}" 98 install_directories "${QT4_TARGET_DIRECTORIES}"
99 install_qconfigs
57 fix_library_files 100 fix_library_files
58} 101}
59 102
60standard_configure_options() { 103standard_configure_options() {
61 local myconf="" 104 local myconf=""
62 105
63 [ $(get_libdir) != "lib" ] && myconf="${myconf} -L/usr/$(get_libdir)" 106 [[ $(get_libdir) != "lib" ]] && myconf="${myconf} -L/usr/$(get_libdir)"
64 107
65 # Disable visibility explicitly if gcc version isn't 4 108 # Disable visibility explicitly if gcc version isn't 4
66 if [[ "$(gcc-major-version)" != "4" ]]; then 109 if [[ "$(gcc-major-version)" -lt "4" ]]; then
67 myconf="${myconf} -no-reduce-exports" 110 myconf="${myconf} -no-reduce-exports"
68 fi 111 fi
69 112
70 use debug && myconf="${myconf} -debug -no-separate-debug-info" || myconf="${myconf} -release -no-separate-debug-info" 113 if use debug; then
114 myconf="${myconf} -debug -no-separate-debug-info"
115 else
116 myconf="${myconf} -release -no-separate-debug-info"
117 fi
71 118
72 myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath\ 119 myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath
73 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} -datadir ${QTDATADIR} \ 120 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR}
74 -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} -plugindir ${QTPLUGINDIR} \ 121 -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR}
75 -sysconfdir ${QTSYSCONFDIR} -translationdir ${QTTRANSDIR} \ 122 -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR}
76 -examplesdir ${QTEXAMPLESDIR} -demosdir ${QTDEMOSDIR}" 123 -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR}
77 124 -demosdir ${QTDEMOSDIR} -silent -fast -reduce-relocations
78 myconf="${myconf} -silent -fast -reduce-relocations -nomake examples -nomake demos" 125 -nomake examples -nomake demos"
79 126
80 echo "${myconf}" 127 echo "${myconf}"
81} 128}
82 129
83build_target_directories() { 130build_target_directories() {
86 133
87build_directories() { 134build_directories() {
88 local dirs="$@" 135 local dirs="$@"
89 for x in ${dirs}; do 136 for x in ${dirs}; do
90 cd "${S}"/${x} 137 cd "${S}"/${x}
91 "${S}"/bin/qmake "LIBS+=-L${QTLIBDIR}" "CONFIG+=nostrip" && emake || die 138 "${S}"/bin/qmake "LIBS+=-L${QTLIBDIR}" "CONFIG+=nostrip" || die "qmake failed"
139 emake || die "emake failed"
92 done 140 done
93} 141}
94 142
95install_directories() { 143install_directories() {
96 local dirs="$@" 144 local dirs="$@"
97 for x in ${dirs}; do 145 for x in ${dirs}; do
98 cd "${S}"/${x} 146 pushd "${S}"/${x} >/dev/null || die "Can't pushd ${S}/${x}"
99 emake INSTALL_ROOT="${D}" install || die 147 emake INSTALL_ROOT="${D}" install || die "emake install failed"
148 popd >/dev/null || die "Can't popd from ${S}/${x}"
149 done
150}
151
152# @ECLASS-VARIABLE: QCONFIG_ADD
153# @DESCRIPTION:
154# List options that need to be added to QT_CONFIG in qconfig.pri
155QCONFIG_ADD="${QCONFIG_ADD:-}"
156
157# @ECLASS-VARIABLE: QCONFIG_REMOVE
158# @DESCRIPTION:
159# List options that need to be removed from QT_CONFIG in qconfig.pri
160QCONFIG_REMOVE="${QCONFIG_REMOVE:-}"
161
162# @ECLASS-VARIABLE: QCONFIG_DEFINE
163# @DESCRIPTION:
164# List variables that should be defined at the top of QtCore/qconfig.h
165QCONFIG_DEFINE="${QCONFIG_DEFINE:-}"
166
167install_qconfigs() {
168 local x
169 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
170 for x in QCONFIG_ADD QCONFIG_REMOVE; do
171 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${T}"/${PN}-qconfig.pri
100 done 172 done
101} 173 insinto ${QTDATADIR}/mkspecs/gentoo
174 doins "${T}"/${PN}-qconfig.pri || die "installing ${PN}-qconfig.pri failed"
175 fi
102 176
177 if [[ -n ${QCONFIG_DEFINE} ]]; then
178 for x in ${QCONFIG_DEFINE}; do
179 echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h
180 done
181 insinto ${QTHEADERDIR}/Gentoo
182 doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed"
183 fi
184}
185
186# Stubs for functions used by the Qt 4.4.0_technical_preview_1.
103qconfig_add_option() { 187qconfig_add_option() { : ; }
104 local option=$1
105 qconfig_remove_option $1
106 sed -i -e "s:QT_CONFIG +=:QT_CONFIG += ${option}:g" /usr/share/qt4/mkspecs/qconfig.pri
107}
108
109qconfig_remove_option() { 188qconfig_remove_option() { : ; }
110 local option=$1 189
111 sed -i -e "s: ${option}::g" /usr/share/qt4/mkspecs/qconfig.pri 190generate_qconfigs() {
191 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${CATEGORY}/${PN} == x11-libs/qt-core ]]; then
192 local x qconfig_add qconfig_remove qconfig_new
193 for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
194 [[ -f ${x} ]] || continue
195 qconfig_add="${qconfig_add} $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
196 qconfig_remove="${qconfig_remove} $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
197 done
198
199 # these error checks do not use die because dying in pkg_post{inst,rm}
200 # just makes things worse.
201 if [[ -e "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
202 # start with the qconfig.pri that qt-core installed
203 if ! cp "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri \
204 "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then
205 eerror "cp qconfig failed."
206 return 1
207 fi
208
209 # generate list of QT_CONFIG entries from the existing list
210 # including qconfig_add and excluding qconfig_remove
211 for x in $(sed -n 's/^QT_CONFIG +=//p' \
212 "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
213 hasq ${x} ${qconfig_remove} || qconfig_new="${qconfig_new} ${x}"
214 done
215
216 # replace the existing QT_CONFIG list with qconfig_new
217 if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
218 "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then
219 eerror "Sed for QT_CONFIG failed"
220 return 1
221 fi
222
223 # create Gentoo/qconfig.h
224 if [[ ! -e ${ROOT}${QTHEADERDIR}/Gentoo ]]; then
225 if ! mkdir -p "${ROOT}${QTHEADERDIR}"/Gentoo; then
226 eerror "mkdir ${QTHEADERDIR}/Gentoo failed"
227 return 1
228 fi
229 fi
230 : > "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
231 for x in "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
232 [[ -f ${x} ]] || continue
233 cat "${x}" >> "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
234 done
235 else
236 rm -f "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri
237 rm -f "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
238 rmdir "${ROOT}${QTDATADIR}"/mkspecs \
239 "${ROOT}${QTDATADIR}" \
240 "${ROOT}${QTHEADERDIR}"/Gentoo \
241 "${ROOT}${QTHEADERDIR}" 2>/dev/null
242 fi
243 fi
244}
245
246qt4-build_pkg_postrm() {
247 generate_qconfigs
248}
249
250qt4-build_pkg_postinst() {
251 generate_qconfigs
112} 252}
113 253
114skip_qmake_build_patch() { 254skip_qmake_build_patch() {
115 # Don't need to build qmake, as it's already installed from qmake-core 255 # Don't need to build qmake, as it's already installed from qt-core
116 sed -i -e "s:if true:if false:g" "${S}"/configure 256 sed -i -e "s:if true:if false:g" "${S}"/configure || die "Sed failed"
117} 257}
118 258
119skip_project_generation_patch() { 259skip_project_generation_patch() {
120 # Exit the script early by throwing in an exit before all of the .pro files are scanned 260 # Exit the script early by throwing in an exit before all of the .pro files are scanned
121 sed -i -e "s:echo \"Finding:exit 0\n\necho \"Finding:g" "${S}"/configure 261 sed -e "s:echo \"Finding:exit 0\n\necho \"Finding:g" \
262 -i "${S}"/configure || die "Sed failed"
122} 263}
123 264
124install_binaries_to_buildtree() 265symlink_binaries_to_buildtree() {
125{ 266 for bin in qmake moc uic rcc; do
126 cp ${QTBINDIR}/qmake ${S}/bin 267 ln -s ${QTBINDIR}/${bin} "${S}"/bin/ || die "Symlinking ${bin} to ${S}/bin failed."
127 cp ${QTBINDIR}/moc ${S}/bin 268 done
128 cp ${QTBINDIR}/uic ${S}/bin
129 cp ${QTBINDIR}/rcc ${S}/bin
130} 269}
131 270
132fix_library_files() { 271fix_library_files() {
133 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/*.la 272 for libfile in "${D}"/${QTLIBDIR}/{*.la,*.prl,pkgconfig/*.pc}; do
134 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/*.prl 273 if [[ -e ${libfile} ]]; then
135 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/pkgconfig/*.pc 274 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" ${libfile} || die "Sed on ${libfile} failed."
275 fi
276 done
136 277
137 # pkgconfig files refer to WORKDIR/bin as the moc and uic locations. Fix: 278 # pkgconfig files refer to WORKDIR/bin as the moc and uic locations. Fix:
138 sed -i -e "s:${S}/bin:${QTBINDIR}:g" "${D}"/${QTLIBDIR}/pkgconfig/*.pc 279 for libfile in "${D}"/${QTLIBDIR}/pkgconfig/*.pc; do
280 if [[ -e ${libfile} ]]; then
281 sed -i -e "s:${S}/bin:${QTBINDIR}:g" ${libfile} || die "Sed failed"
139 282
140 # Move .pc files into the pkgconfig directory 283 # Move .pc files into the pkgconfig directory
284
141 dodir ${QTPCDIR} 285 dodir ${QTPCDIR}
142 mv "${D}"/${QTLIBDIR}/pkgconfig/*.pc "${D}"/${QTPCDIR} 286 mv ${libfile} "${D}"/${QTPCDIR}/ \
287 || die "Moving ${libfile} to ${D}/${QTPCDIR}/ failed."
288 fi
289 done
290
291 # Don't install an empty directory
292 rmdir "${D}"/${QTLIBDIR}/pkgconfig
143} 293}
144 294
145qt_use() { 295qt_use() {
146 local flag="$1" 296 local flag="${1}"
147 local feature="$1" 297 local feature="${1}"
148 local enableval= 298 local enableval=
149 299
150 [[ -n $2 ]] && feature=$2 300 [[ -n ${2} ]] && feature=${2}
151 [[ -n $3 ]] && enableval="-$3" 301 [[ -n ${3} ]] && enableval="-${3}"
152 302
153 useq $flag && echo "${enableval}-${feature}" || echo "-no-${feature}" 303 if use ${flag}; then
304 echo "${enableval}-${feature}"
305 else
306 echo "-no-${feature}"
307 fi
308}
309
310# @ECLASS-VARIABLE: QT4_BUILT_WITH_USE_CHECK
311# @DESCRIPTION:
312# The contents of $QT4_BUILT_WITH_USE_CHECK gets fed to built_with_use
313# (eutils.eclass), line per line.
314#
315# Example:
316# @CODE
317# pkg_setup() {
318# use qt3support && QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK}
319# ~x11-libs/qt-gui-${PV} qt3support"
320# qt4-build_check_use
321# }
322# @CODE
323
324# Run built_with_use on each flag and print appropriate error messages if any
325# flags are missing
326_qt_built_with_use() {
327 local missing opt pkg flag flags
328
329 if [[ ${1} = "--missing" ]]; then
330 missing="${1} ${2}" && shift 2
331 fi
332 if [[ ${1:0:1} = "-" ]]; then
333 opt=${1} && shift
334 fi
335
336 pkg=${1} && shift
337
338 for flag in "${@}"; do
339 flags="${flags} ${flag}"
340 if ! built_with_use ${missing} ${opt} ${pkg} ${flag}; then
341 flags="${flags}*"
342 else
343 [[ ${opt} = "-o" ]] && return 0
344 fi
345 done
346 if [[ "${flags# }" = "${@}" ]]; then
154 return 0 347 return 0
348 fi
349 if [[ ${opt} = "-o" ]]; then
350 eerror "This package requires '${pkg}' to be built with any of the following USE flags: '$*'."
351 else
352 eerror "This package requires '${pkg}' to be built with the following USE flags: '${flags# }'."
353 fi
354 return 1
355}
356
357# @FUNCTION: qt4-build_check_use
358# @DESCRIPTION:
359# Check if the listed packages in $QT4_BUILT_WITH_USE_CHECK are built with the
360# USE flags listed.
361#
362# If any of the required USE flags are missing, an eerror will be printed for
363# each package with missing USE flags.
364qt4-build_check_use() {
365 local line missing
366 while read line; do
367 [[ -z ${line} ]] && continue
368 if ! _qt_built_with_use ${line}; then
369 missing=true
370 fi
371 done <<< "${QT4_BUILT_WITH_USE_CHECK}"
372 if [[ -n ${missing} ]]; then
373 echo
374 eerror "Flags marked with an * are missing."
375 die "Missing USE flags found"
376 fi
155} 377}
156 378
157qt_mkspecs_dir() { 379qt_mkspecs_dir() {
158 # Allows us to define which mkspecs dir we want to use. 380 # Allows us to define which mkspecs dir we want to use.
159 local spec 381 local spec
163 spec="freebsd" ;; 385 spec="freebsd" ;;
164 *-openbsd*) 386 *-openbsd*)
165 spec="openbsd" ;; 387 spec="openbsd" ;;
166 *-netbsd*) 388 *-netbsd*)
167 spec="netbsd" ;; 389 spec="netbsd" ;;
168 *-darwin*) 390 *-darwin*)
169 spec="darwin" ;; 391 spec="darwin" ;;
170 *-linux-*|*-linux) 392 *-linux-*|*-linux)
171 spec="linux" ;; 393 spec="linux" ;;
172 *) 394 *)
173 die "Unknown CHOST, no platform choosed." 395 die "Unknown CHOST, no platform choosen."
174 esac 396 esac
175 397
176 CXX=$(tc-getCXX) 398 CXX=$(tc-getCXX)
177 if [[ ${CXX/g++/} != ${CXX} ]]; then 399 if [[ ${CXX/g++/} != ${CXX} ]]; then
178 spec="${spec}-g++" 400 spec="${spec}-g++"
183 fi 405 fi
184 406
185 echo "${spec}" 407 echo "${spec}"
186} 408}
187 409
188EXPORT_FUNCTIONS pkg_setup src_unpack src_install 410EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postrm pkg_postinst

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20