/[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.10
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.10 2008/03/11 16:39:43 ingmar 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 # Bug 178652
90 if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then
91 ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS"
92 append-flags -fno-gcse
93 fi
94
95 myconf="$(standard_configure_options) ${myconf}"
96
97 echo ./configure ${myconf}
98 ./configure ${myconf} || die "./configure failed"
99
100 build_target_directories
53} 101}
54 102
55qt4-build_src_install() { 103qt4-build_src_install() {
56 install_directories "${QT4_TARGET_DIRECTORIES}" 104 install_directories "${QT4_TARGET_DIRECTORIES}"
105 install_qconfigs
57 fix_library_files 106 fix_library_files
58} 107}
59 108
60standard_configure_options() { 109standard_configure_options() {
61 local myconf="" 110 local myconf=""
62 111
63 [ $(get_libdir) != "lib" ] && myconf="${myconf} -L/usr/$(get_libdir)" 112 [[ $(get_libdir) != "lib" ]] && myconf="${myconf} -L/usr/$(get_libdir)"
64 113
65 # Disable visibility explicitly if gcc version isn't 4 114 # Disable visibility explicitly if gcc version isn't 4
66 if [[ "$(gcc-major-version)" != "4" ]]; then 115 if [[ "$(gcc-major-version)" -lt "4" ]]; then
67 myconf="${myconf} -no-reduce-exports" 116 myconf="${myconf} -no-reduce-exports"
68 fi 117 fi
69 118
70 use debug && myconf="${myconf} -debug -no-separate-debug-info" || myconf="${myconf} -release -no-separate-debug-info" 119 if use debug; then
120 myconf="${myconf} -debug -no-separate-debug-info"
121 else
122 myconf="${myconf} -release -no-separate-debug-info"
123 fi
71 124
72 myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath\ 125 myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath
73 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} -datadir ${QTDATADIR} \ 126 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR}
74 -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} -plugindir ${QTPLUGINDIR} \ 127 -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR}
75 -sysconfdir ${QTSYSCONFDIR} -translationdir ${QTTRANSDIR} \ 128 -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR}
76 -examplesdir ${QTEXAMPLESDIR} -demosdir ${QTDEMOSDIR}" 129 -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR}
77 130 -demosdir ${QTDEMOSDIR} -silent -fast -reduce-relocations
78 myconf="${myconf} -silent -fast -reduce-relocations -nomake examples -nomake demos" 131 -nomake examples -nomake demos"
79 132
80 echo "${myconf}" 133 echo "${myconf}"
81} 134}
82 135
83build_target_directories() { 136build_target_directories() {
86 139
87build_directories() { 140build_directories() {
88 local dirs="$@" 141 local dirs="$@"
89 for x in ${dirs}; do 142 for x in ${dirs}; do
90 cd "${S}"/${x} 143 cd "${S}"/${x}
91 "${S}"/bin/qmake "LIBS+=-L${QTLIBDIR}" "CONFIG+=nostrip" && emake || die 144 "${S}"/bin/qmake "LIBS+=-L${QTLIBDIR}" "CONFIG+=nostrip" || die "qmake failed"
145 emake || die "emake failed"
92 done 146 done
93} 147}
94 148
95install_directories() { 149install_directories() {
96 local dirs="$@" 150 local dirs="$@"
97 for x in ${dirs}; do 151 for x in ${dirs}; do
98 cd "${S}"/${x} 152 pushd "${S}"/${x} >/dev/null || die "Can't pushd ${S}/${x}"
99 emake INSTALL_ROOT="${D}" install || die 153 emake INSTALL_ROOT="${D}" install || die "emake install failed"
154 popd >/dev/null || die "Can't popd from ${S}/${x}"
155 done
156}
157
158# @ECLASS-VARIABLE: QCONFIG_ADD
159# @DESCRIPTION:
160# List options that need to be added to QT_CONFIG in qconfig.pri
161QCONFIG_ADD="${QCONFIG_ADD:-}"
162
163# @ECLASS-VARIABLE: QCONFIG_REMOVE
164# @DESCRIPTION:
165# List options that need to be removed from QT_CONFIG in qconfig.pri
166QCONFIG_REMOVE="${QCONFIG_REMOVE:-}"
167
168# @ECLASS-VARIABLE: QCONFIG_DEFINE
169# @DESCRIPTION:
170# List variables that should be defined at the top of QtCore/qconfig.h
171QCONFIG_DEFINE="${QCONFIG_DEFINE:-}"
172
173install_qconfigs() {
174 local x
175 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
176 for x in QCONFIG_ADD QCONFIG_REMOVE; do
177 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${T}"/${PN}-qconfig.pri
100 done 178 done
101} 179 insinto ${QTDATADIR}/mkspecs/gentoo
180 doins "${T}"/${PN}-qconfig.pri || die "installing ${PN}-qconfig.pri failed"
181 fi
102 182
183 if [[ -n ${QCONFIG_DEFINE} ]]; then
184 for x in ${QCONFIG_DEFINE}; do
185 echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h
186 done
187 insinto ${QTHEADERDIR}/Gentoo
188 doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed"
189 fi
190}
191
192# Stubs for functions used by the Qt 4.4.0_technical_preview_1.
103qconfig_add_option() { 193qconfig_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() { 194qconfig_remove_option() { : ; }
110 local option=$1 195
111 sed -i -e "s: ${option}::g" /usr/share/qt4/mkspecs/qconfig.pri 196generate_qconfigs() {
197 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${CATEGORY}/${PN} == x11-libs/qt-core ]]; then
198 local x qconfig_add qconfig_remove qconfig_new
199 for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
200 [[ -f ${x} ]] || continue
201 qconfig_add="${qconfig_add} $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
202 qconfig_remove="${qconfig_remove} $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
203 done
204
205 # these error checks do not use die because dying in pkg_post{inst,rm}
206 # just makes things worse.
207 if [[ -e "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
208 # start with the qconfig.pri that qt-core installed
209 if ! cp "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri \
210 "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then
211 eerror "cp qconfig failed."
212 return 1
213 fi
214
215 # generate list of QT_CONFIG entries from the existing list
216 # including qconfig_add and excluding qconfig_remove
217 for x in $(sed -n 's/^QT_CONFIG +=//p' \
218 "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
219 hasq ${x} ${qconfig_remove} || qconfig_new="${qconfig_new} ${x}"
220 done
221
222 # replace the existing QT_CONFIG list with qconfig_new
223 if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
224 "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then
225 eerror "Sed for QT_CONFIG failed"
226 return 1
227 fi
228
229 # create Gentoo/qconfig.h
230 if [[ ! -e ${ROOT}${QTHEADERDIR}/Gentoo ]]; then
231 if ! mkdir -p "${ROOT}${QTHEADERDIR}"/Gentoo; then
232 eerror "mkdir ${QTHEADERDIR}/Gentoo failed"
233 return 1
234 fi
235 fi
236 : > "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
237 for x in "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
238 [[ -f ${x} ]] || continue
239 cat "${x}" >> "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
240 done
241 else
242 rm -f "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri
243 rm -f "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
244 rmdir "${ROOT}${QTDATADIR}"/mkspecs \
245 "${ROOT}${QTDATADIR}" \
246 "${ROOT}${QTHEADERDIR}"/Gentoo \
247 "${ROOT}${QTHEADERDIR}" 2>/dev/null
248 fi
249 fi
250}
251
252qt4-build_pkg_postrm() {
253 generate_qconfigs
254}
255
256qt4-build_pkg_postinst() {
257 generate_qconfigs
112} 258}
113 259
114skip_qmake_build_patch() { 260skip_qmake_build_patch() {
115 # Don't need to build qmake, as it's already installed from qmake-core 261 # 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 262 sed -i -e "s:if true:if false:g" "${S}"/configure || die "Sed failed"
117} 263}
118 264
119skip_project_generation_patch() { 265skip_project_generation_patch() {
120 # Exit the script early by throwing in an exit before all of the .pro files are scanned 266 # 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 267 sed -e "s:echo \"Finding:exit 0\n\necho \"Finding:g" \
268 -i "${S}"/configure || die "Sed failed"
122} 269}
123 270
124install_binaries_to_buildtree() 271symlink_binaries_to_buildtree() {
125{ 272 for bin in qmake moc uic rcc; do
126 cp ${QTBINDIR}/qmake ${S}/bin 273 ln -s ${QTBINDIR}/${bin} "${S}"/bin/ || die "Symlinking ${bin} to ${S}/bin failed."
127 cp ${QTBINDIR}/moc ${S}/bin 274 done
128 cp ${QTBINDIR}/uic ${S}/bin
129 cp ${QTBINDIR}/rcc ${S}/bin
130} 275}
131 276
132fix_library_files() { 277fix_library_files() {
133 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/*.la 278 for libfile in "${D}"/${QTLIBDIR}/{*.la,*.prl,pkgconfig/*.pc}; do
134 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/*.prl 279 if [[ -e ${libfile} ]]; then
135 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/pkgconfig/*.pc 280 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" ${libfile} || die "Sed on ${libfile} failed."
281 fi
282 done
136 283
137 # pkgconfig files refer to WORKDIR/bin as the moc and uic locations. Fix: 284 # 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 285 for libfile in "${D}"/${QTLIBDIR}/pkgconfig/*.pc; do
286 if [[ -e ${libfile} ]]; then
287 sed -i -e "s:${S}/bin:${QTBINDIR}:g" ${libfile} || die "Sed failed"
139 288
140 # Move .pc files into the pkgconfig directory 289 # Move .pc files into the pkgconfig directory
290
141 dodir ${QTPCDIR} 291 dodir ${QTPCDIR}
142 mv "${D}"/${QTLIBDIR}/pkgconfig/*.pc "${D}"/${QTPCDIR} 292 mv ${libfile} "${D}"/${QTPCDIR}/ \
293 || die "Moving ${libfile} to ${D}/${QTPCDIR}/ failed."
294 fi
295 done
296
297 # Don't install an empty directory
298 rmdir "${D}"/${QTLIBDIR}/pkgconfig
143} 299}
144 300
145qt_use() { 301qt_use() {
146 local flag="$1" 302 local flag="${1}"
147 local feature="$1" 303 local feature="${1}"
148 local enableval= 304 local enableval=
149 305
150 [[ -n $2 ]] && feature=$2 306 [[ -n ${2} ]] && feature=${2}
151 [[ -n $3 ]] && enableval="-$3" 307 [[ -n ${3} ]] && enableval="-${3}"
152 308
153 useq $flag && echo "${enableval}-${feature}" || echo "-no-${feature}" 309 if use ${flag}; then
310 echo "${enableval}-${feature}"
311 else
312 echo "-no-${feature}"
313 fi
314}
315
316# @ECLASS-VARIABLE: QT4_BUILT_WITH_USE_CHECK
317# @DESCRIPTION:
318# The contents of $QT4_BUILT_WITH_USE_CHECK gets fed to built_with_use
319# (eutils.eclass), line per line.
320#
321# Example:
322# @CODE
323# pkg_setup() {
324# use qt3support && QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK}
325# ~x11-libs/qt-gui-${PV} qt3support"
326# qt4-build_check_use
327# }
328# @CODE
329
330# Run built_with_use on each flag and print appropriate error messages if any
331# flags are missing
332_qt_built_with_use() {
333 local missing opt pkg flag flags
334
335 if [[ ${1} = "--missing" ]]; then
336 missing="${1} ${2}" && shift 2
337 fi
338 if [[ ${1:0:1} = "-" ]]; then
339 opt=${1} && shift
340 fi
341
342 pkg=${1} && shift
343
344 for flag in "${@}"; do
345 flags="${flags} ${flag}"
346 if ! built_with_use ${missing} ${opt} ${pkg} ${flag}; then
347 flags="${flags}*"
348 else
349 [[ ${opt} = "-o" ]] && return 0
350 fi
351 done
352 if [[ "${flags# }" = "${@}" ]]; then
154 return 0 353 return 0
354 fi
355 if [[ ${opt} = "-o" ]]; then
356 eerror "This package requires '${pkg}' to be built with any of the following USE flags: '$*'."
357 else
358 eerror "This package requires '${pkg}' to be built with the following USE flags: '${flags# }'."
359 fi
360 return 1
361}
362
363# @FUNCTION: qt4-build_check_use
364# @DESCRIPTION:
365# Check if the listed packages in $QT4_BUILT_WITH_USE_CHECK are built with the
366# USE flags listed.
367#
368# If any of the required USE flags are missing, an eerror will be printed for
369# each package with missing USE flags.
370qt4-build_check_use() {
371 local line missing
372 while read line; do
373 [[ -z ${line} ]] && continue
374 if ! _qt_built_with_use ${line}; then
375 missing=true
376 fi
377 done <<< "${QT4_BUILT_WITH_USE_CHECK}"
378 if [[ -n ${missing} ]]; then
379 echo
380 eerror "Flags marked with an * are missing."
381 die "Missing USE flags found"
382 fi
155} 383}
156 384
157qt_mkspecs_dir() { 385qt_mkspecs_dir() {
158 # Allows us to define which mkspecs dir we want to use. 386 # Allows us to define which mkspecs dir we want to use.
159 local spec 387 local spec
163 spec="freebsd" ;; 391 spec="freebsd" ;;
164 *-openbsd*) 392 *-openbsd*)
165 spec="openbsd" ;; 393 spec="openbsd" ;;
166 *-netbsd*) 394 *-netbsd*)
167 spec="netbsd" ;; 395 spec="netbsd" ;;
168 *-darwin*) 396 *-darwin*)
169 spec="darwin" ;; 397 spec="darwin" ;;
170 *-linux-*|*-linux) 398 *-linux-*|*-linux)
171 spec="linux" ;; 399 spec="linux" ;;
172 *) 400 *)
173 die "Unknown CHOST, no platform choosed." 401 die "Unknown CHOST, no platform choosen."
174 esac 402 esac
175 403
176 CXX=$(tc-getCXX) 404 CXX=$(tc-getCXX)
177 if [[ ${CXX/g++/} != ${CXX} ]]; then 405 if [[ ${CXX/g++/} != ${CXX} ]]; then
178 spec="${spec}-g++" 406 spec="${spec}-g++"
183 fi 411 fi
184 412
185 echo "${spec}" 413 echo "${spec}"
186} 414}
187 415
188EXPORT_FUNCTIONS pkg_setup src_unpack src_install 416EXPORT_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.10

  ViewVC Help
Powered by ViewVC 1.1.20