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

Contents of /eclass/qt4-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations) (download)
Thu Apr 10 14:23:45 2008 UTC (6 years, 4 months ago) by ingmar
Branch: MAIN
Changes since 1.10: +48 -7 lines
Updates for Qt-4.4.0_rc1.

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

  ViewVC Help
Powered by ViewVC 1.1.20