| 1 |
# Copyright 2005 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.5 2007/12/22 17:32:55 caleb Exp $
|
| 4 |
|
| 5 |
# @ECLASS: qt4-build.eclass
|
| 6 |
# @MAINTAINER:
|
| 7 |
# Caleb Tennis <caleb@gentoo.org>
|
| 8 |
# @BLURB:
|
| 9 |
# Eclass for Qt4
|
| 10 |
# @DESCRIPTION:
|
| 11 |
# This eclass contains various functions that are used when building Qt4
|
| 12 |
|
| 13 |
inherit eutils multilib toolchain-funcs flag-o-matic
|
| 14 |
|
| 15 |
IUSE="${IUSE} debug"
|
| 16 |
|
| 17 |
qt4-build_pkg_setup() {
|
| 18 |
# Set up installation directories
|
| 19 |
|
| 20 |
QTBASEDIR=/usr/$(get_libdir)/qt4
|
| 21 |
QTPREFIXDIR=/usr
|
| 22 |
QTBINDIR=/usr/bin
|
| 23 |
QTLIBDIR=/usr/$(get_libdir)/qt4
|
| 24 |
QTPCDIR=/usr/$(get_libdir)/pkgconfig
|
| 25 |
QTDATADIR=/usr/share/qt4
|
| 26 |
QTDOCDIR=/usr/share/doc/qt-${PV}
|
| 27 |
QTHEADERDIR=/usr/include/qt4
|
| 28 |
QTPLUGINDIR=${QTLIBDIR}/plugins
|
| 29 |
QTSYSCONFDIR=/etc/qt4
|
| 30 |
QTTRANSDIR=${QTDATADIR}/translations
|
| 31 |
QTEXAMPLESDIR=${QTDATADIR}/examples
|
| 32 |
QTDEMOSDIR=${QTDATADIR}/demos
|
| 33 |
|
| 34 |
PLATFORM=$(qt_mkspecs_dir)
|
| 35 |
|
| 36 |
PATH="${S}/bin:${PATH}"
|
| 37 |
LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}"
|
| 38 |
}
|
| 39 |
|
| 40 |
qt4-build_src_unpack() {
|
| 41 |
unpack ${A}
|
| 42 |
cd "${S}"
|
| 43 |
|
| 44 |
# 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.
|
| 46 |
strip-flags
|
| 47 |
replace-flags -O3 -O2
|
| 48 |
|
| 49 |
if [[ $( gcc-fullversion ) == "3.4.6" && gcc-specs-ssp ]] ; then
|
| 50 |
ewarn "Appending -fno-stack-protector to CFLAGS/CXXFLAGS"
|
| 51 |
append-flags -fno-stack-protector
|
| 52 |
fi
|
| 53 |
}
|
| 54 |
|
| 55 |
qt4-build_src_install() {
|
| 56 |
install_directories "${QT4_TARGET_DIRECTORIES}"
|
| 57 |
fix_library_files
|
| 58 |
}
|
| 59 |
|
| 60 |
standard_configure_options() {
|
| 61 |
local myconf=""
|
| 62 |
|
| 63 |
[ $(get_libdir) != "lib" ] && myconf="${myconf} -L/usr/$(get_libdir)"
|
| 64 |
|
| 65 |
# Disable visibility explicitly if gcc version isn't 4
|
| 66 |
if [[ "$(gcc-major-version)" != "4" ]]; then
|
| 67 |
myconf="${myconf} -no-reduce-exports"
|
| 68 |
fi
|
| 69 |
|
| 70 |
use debug && myconf="${myconf} -debug -no-separate-debug-info" || myconf="${myconf} -release -no-separate-debug-info"
|
| 71 |
|
| 72 |
myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath\
|
| 73 |
-prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} -datadir ${QTDATADIR} \
|
| 74 |
-docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} -plugindir ${QTPLUGINDIR} \
|
| 75 |
-sysconfdir ${QTSYSCONFDIR} -translationdir ${QTTRANSDIR} \
|
| 76 |
-examplesdir ${QTEXAMPLESDIR} -demosdir ${QTDEMOSDIR}"
|
| 77 |
|
| 78 |
myconf="${myconf} -silent -fast -reduce-relocations -nomake examples -nomake demos"
|
| 79 |
|
| 80 |
echo "${myconf}"
|
| 81 |
}
|
| 82 |
|
| 83 |
build_target_directories() {
|
| 84 |
build_directories "${QT4_TARGET_DIRECTORIES}"
|
| 85 |
}
|
| 86 |
|
| 87 |
build_directories() {
|
| 88 |
local dirs="$@"
|
| 89 |
for x in ${dirs}; do
|
| 90 |
cd "${S}"/${x}
|
| 91 |
"${S}"/bin/qmake "LIBS+=-L${QTLIBDIR}" "CONFIG+=nostrip" && emake || die
|
| 92 |
done
|
| 93 |
}
|
| 94 |
|
| 95 |
install_directories() {
|
| 96 |
local dirs="$@"
|
| 97 |
for x in ${dirs}; do
|
| 98 |
cd "${S}"/${x}
|
| 99 |
emake INSTALL_ROOT="${D}" install || die
|
| 100 |
done
|
| 101 |
}
|
| 102 |
|
| 103 |
qconfig_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 |
|
| 109 |
qconfig_remove_option() {
|
| 110 |
local option=$1
|
| 111 |
sed -i -e "s: ${option}::g" /usr/share/qt4/mkspecs/qconfig.pri
|
| 112 |
}
|
| 113 |
|
| 114 |
skip_qmake_build_patch() {
|
| 115 |
# Don't need to build qmake, as it's already installed from qmake-core
|
| 116 |
sed -i -e "s:if true:if false:g" "${S}"/configure
|
| 117 |
}
|
| 118 |
|
| 119 |
skip_project_generation_patch() {
|
| 120 |
# 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
|
| 122 |
}
|
| 123 |
|
| 124 |
install_binaries_to_buildtree()
|
| 125 |
{
|
| 126 |
cp ${QTBINDIR}/qmake ${S}/bin
|
| 127 |
cp ${QTBINDIR}/moc ${S}/bin
|
| 128 |
cp ${QTBINDIR}/uic ${S}/bin
|
| 129 |
cp ${QTBINDIR}/rcc ${S}/bin
|
| 130 |
}
|
| 131 |
|
| 132 |
fix_library_files() {
|
| 133 |
sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/*.la
|
| 134 |
sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/*.prl
|
| 135 |
sed -i -e "s:${S}/lib:${QTLIBDIR}:g" "${D}"/${QTLIBDIR}/pkgconfig/*.pc
|
| 136 |
|
| 137 |
# 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
|
| 139 |
|
| 140 |
# Move .pc files into the pkgconfig directory
|
| 141 |
dodir ${QTPCDIR}
|
| 142 |
mv "${D}"/${QTLIBDIR}/pkgconfig/*.pc "${D}"/${QTPCDIR}
|
| 143 |
}
|
| 144 |
|
| 145 |
qt_use() {
|
| 146 |
local flag="$1"
|
| 147 |
local feature="$1"
|
| 148 |
local enableval=
|
| 149 |
|
| 150 |
[[ -n $2 ]] && feature=$2
|
| 151 |
[[ -n $3 ]] && enableval="-$3"
|
| 152 |
|
| 153 |
useq $flag && echo "${enableval}-${feature}" || echo "-no-${feature}"
|
| 154 |
return 0
|
| 155 |
}
|
| 156 |
|
| 157 |
qt_mkspecs_dir() {
|
| 158 |
# Allows us to define which mkspecs dir we want to use.
|
| 159 |
local spec
|
| 160 |
|
| 161 |
case ${CHOST} in
|
| 162 |
*-freebsd*|*-dragonfly*)
|
| 163 |
spec="freebsd" ;;
|
| 164 |
*-openbsd*)
|
| 165 |
spec="openbsd" ;;
|
| 166 |
*-netbsd*)
|
| 167 |
spec="netbsd" ;;
|
| 168 |
*-darwin*)
|
| 169 |
spec="darwin" ;;
|
| 170 |
*-linux-*|*-linux)
|
| 171 |
spec="linux" ;;
|
| 172 |
*)
|
| 173 |
die "Unknown CHOST, no platform choosed."
|
| 174 |
esac
|
| 175 |
|
| 176 |
CXX=$(tc-getCXX)
|
| 177 |
if [[ ${CXX/g++/} != ${CXX} ]]; then
|
| 178 |
spec="${spec}-g++"
|
| 179 |
elif [[ ${CXX/icpc/} != ${CXX} ]]; then
|
| 180 |
spec="${spec}-icc"
|
| 181 |
else
|
| 182 |
die "Unknown compiler ${CXX}."
|
| 183 |
fi
|
| 184 |
|
| 185 |
echo "${spec}"
|
| 186 |
}
|
| 187 |
|
| 188 |
EXPORT_FUNCTIONS pkg_setup src_unpack src_install
|