Merge branch 'org.openembedded.dev' of git@git.openembedded.org:openembedded into...
[openembedded.git] / recipes / qt4 / qt4.inc
1 inherit qmake_base
2
3 DEPENDS += "qt4-tools-native freetype jpeg libpng zlib dbus openssl glib-2.0 gstreamer gst-plugins-base mysql postgresql sqlite sqlite3"
4
5 require qt4_arch.inc
6 QT_ARCH := "${@qt_arch(d)}"
7 QT_ENDIAN = "${@qt_endian(d)}"
8
9 QT_CONFIG_FLAGS += "-release -no-cups -no-accessibility -reduce-relocations \
10                     -shared -no-nas-sound -no-sm -no-nis \
11                     -qt-gif -system-libjpeg -system-libpng -system-zlib \
12                     -no-sql-ibase -plugin-sql-mysql -no-sql-odbc -plugin-sql-psql -plugin-sql-sqlite -plugin-sql-sqlite2 \
13                     -no-pch -qdbus -stl -glib -phonon -webkit"
14
15 EXTRA_OEMAKE = "-e"
16
17 EXTRA_ENV = 'QMAKE="${STAGING_BINDIR_NATIVE}/qmake2 -after \
18              INCPATH+=${STAGING_INCDIR}/freetype2 LIBS+=-L${STAGING_LIBDIR}" \
19              QMAKESPEC="${QMAKESPEC}" LINK="${CXX} -Wl,-rpath-link,${STAGING_LIBDIR}" \
20              AR="${TARGET_PREFIX}ar cqs" \
21              MOC="${STAGING_BINDIR_NATIVE}/moc4" UIC="${STAGING_BINDIR_NATIVE}/uic4" MAKE="make -e"'
22
23 export QT_CONF_PATH="${WORKDIR}/qt.conf"
24
25 # Library packages
26 QT_LIB_NAMES = "Qt3Support QtAssistantClient QtCLucene QtCore QtDBus QtDesigner QtDesignerComponents QtGui QtHelp QtNetwork QtOpenGL QtScript QtScriptTools QtSql QtSvg QtTest QtUiTools QtWebKit QtXml phonon"
27 python __anonymous () {
28     import bb
29
30     lib_packages = []
31     dev_packages = []
32     dbg_packages = []
33     for name in bb.data.getVar("QT_LIB_NAMES", d, 1).split():
34         pkg = "${QT_BASE_LIB}" + name.lower().replace("qt", "") + "4"
35         # NOTE: the headers for QtAssistantClient are different
36         incname = name.replace("QtAssistantClient", "QtAssistant")
37         bb.data.setVar("FILES_%s" % pkg, "${libdir}/lib%(name)s${QT_LIBINFIX}.so.*" % locals(), d)
38         bb.data.setVar("FILES_%s-dev" % pkg, """${libdir}/lib%(name)s${QT_LIBINFIX}.prl
39                   ${libdir}/lib%(name)s${QT_LIBINFIX}.a
40                   ${libdir}/lib%(name)s${QT_LIBINFIX}.la
41                   ${libdir}/lib%(name)s${QT_LIBINFIX}.so
42                   ${includedir}/${QT_DIR_NAME}/%(incname)s
43                   ${libdir}/pkgconfig/%(name)s${QT_LIBINFIX}.pc""" % locals(), d)
44         bb.data.setVar("FILES_%s-dbg" % pkg, "${libdir}/.debug/lib%(name)s${QT_LIBINFIX}.so.*" % locals(), d)
45         lib_packages.append(pkg)
46         dev_packages.append("%s-dev" % pkg)
47         dbg_packages.append("%s-dbg" % pkg)
48     for name in bb.data.getVar("OTHER_PACKAGES", d, 1).split():
49         dbg_packages.append("%s-dbg" % name)
50
51     bb.data.setVar("LIB_PACKAGES", " ".join(lib_packages), d)
52     bb.data.setVar("DEV_PACKAGES", " ".join(dev_packages), d)
53     bb.data.setVar("DBG_PACKAGES", " ".join(dbg_packages), d)
54 }
55
56 OTHER_PACKAGES = "\
57              ${QT_BASE_NAME}-assistant \
58              ${QT_BASE_NAME}-common \
59              ${QT_BASE_NAME}-dbus \
60              ${QT_BASE_NAME}-demos \
61              ${QT_BASE_NAME}-designer \
62              ${QT_BASE_NAME}-examples \
63              ${QT_BASE_NAME}-fonts \
64              ${QT_BASE_NAME}-linguist \
65              ${QT_BASE_NAME}-makeqpf \
66              ${QT_BASE_NAME}-mkspecs \
67              ${QT_BASE_NAME}-pixeltool \
68              ${QT_BASE_NAME}-qt3to4"
69
70 PACKAGES += "${LIB_PACKAGES} ${DEV_PACKAGES} ${DBG_PACKAGES} ${OTHER_PACKAGES}"
71 PACKAGES_DYNAMIC = "${QT_BASE_NAME}-plugin-*  ${QT_BASE_NAME}-translation-*"
72
73 ALLOW_EMPTY_${PN} = "1"
74 FILES_${PN}     = ""
75 FILES_${PN}-dev = "${includedir}/${QT_DIR_NAME}/Qt/*"
76 FILES_${PN}-dbg = ""
77 RRECOMMENDS_${PN} = "${LIB_PACKAGES} ${OTHER_PACKAGES}"
78 RRECOMMENDS_${PN}-dev = "${DEV_PACKAGES}"
79 RRECOMMENDS_${PN}-dbg = "${DBG_PACKAGES}"
80
81 FILES_${QT_BASE_NAME}-assistant            = "${bindir}/*assistant* ${bindir}/qcollectiongenerator ${bindir}/qhelpconverter ${bindir}/qhelpgenerator"
82 FILES_${QT_BASE_NAME}-assistant-dbg        = "${bindir}/.debug/*assistant* ${bindir}/.debug/qcollectiongenerator ${bindir}/.debug/qhelpconverter ${bindir}/.debug/qhelpgenerator"
83 FILES_${QT_BASE_NAME}-common               = "${bindir}/qtconfig"
84 FILES_${QT_BASE_NAME}-common-dbg           = "${bindir}/.debug/qtconfig"
85 FILES_${QT_BASE_NAME}-dbus                 = "${bindir}/qdbus ${bindir}/qdbusxml2cpp ${bindir}/qdbuscpp2xml ${bindir}/qdbusviewer"
86 FILES_${QT_BASE_NAME}-dbus-dbg             = "${bindir}/.debug/qdbus ${bindir}/.debug/qdbusxml2cpp ${bindir}/.debug/qdbuscpp2xml ${bindir}/.debug/qdbusviewer"
87 FILES_${QT_BASE_NAME}-demos                = "${bindir}/qtdemo ${bindir}/${QT_DIR_NAME}/demos/*"
88 FILES_${QT_BASE_NAME}-demos-dbg            = "${bindir}/.debug/qtdemo ${bindir}/${QT_DIR_NAME}/demos/.debug/*  ${bindir}/${QT_DIR_NAME}/demos/*/.debug  ${bindir}/${QT_DIR_NAME}/demos/*/*/.debug  ${bindir}/${QT_DIR_NAME}/demos/*/*/*/.debug"
89 FILES_${QT_BASE_NAME}-designer             = "${bindir}/*designer*"
90 FILES_${QT_BASE_NAME}-designer-dbg         = "${bindir}/.debug/*designer*"
91 FILES_${QT_BASE_NAME}-examples             = "${bindir}/${QT_DIR_NAME}/examples/*"
92 FILES_${QT_BASE_NAME}-examples-dbg         = "${bindir}/${QT_DIR_NAME}/examples/.debug ${bindir}/${QT_DIR_NAME}/examples/*/.debug ${bindir}/${QT_DIR_NAME}/examples/*/*/.debug ${bindir}/${QT_DIR_NAME}/examples/*/*/*/.debug ${bindir}/${QT_DIR_NAME}/examples/*/*/*/*/.debug"
93 FILES_${QT_BASE_NAME}-fonts                = "${libdir}/fonts"
94 FILES_${QT_BASE_NAME}-linguist             = "${bindir}/*linguist* ${bindir}/lrelease ${bindir}/lupdate ${bindir}/lconvert ${bindir}/qm2ts"
95 FILES_${QT_BASE_NAME}-linguist-dbg         = "${bindir}/.debug/*linguist* ${bindir}/.debug/lrelease ${bindir}/.debug/lupdate ${bindir}/.debug/lconvert ${bindir}/.debug/qm2ts"
96 FILES_${QT_BASE_NAME}-pixeltool            = "${bindir}/pixeltool"
97 FILES_${QT_BASE_NAME}-pixeltool-dbg        = "${bindir}/.debug/pixeltool"
98 FILES_${QT_BASE_NAME}-qt3to4               = "${bindir}/qt3to4 ${datadir}/${QT_DIR_NAME}/q3porting.xml"
99 FILES_${QT_BASE_NAME}-qt3to4-dbg           = "${bindir}/.debug/qt3to4"
100 FILES_${QT_BASE_NAME}-makeqpf              = "${bindir}/makeqpf"
101 FILES_${QT_BASE_NAME}-makeqpf-dbg          = "${bindir}/.debug/makeqpf"
102 FILES_${QT_BASE_NAME}-mkspecs              = "${datadir}/${QT_DIR_NAME}/mkspecs/*"
103
104
105 do_configure() {
106     unset QMAKESPEC
107     unset QTDIR
108     ln -sf ${STAGING_BINDIR_NATIVE}/qmake2 bin/qmake
109     ln -sf linux-g++ mkspecs/${TARGET_OS}-oe-g++
110     cp -f ${WORKDIR}/g++.conf ${WORKDIR}/linux.conf mkspecs/common/
111
112     echo "[Paths]"                                 > $QT_CONF_PATH
113     echo "Prefix=${prefix}/"                      >> $QT_CONF_PATH
114     echo "Documentation=${docdir}/${QT_DIR_NAME}" >> $QT_CONF_PATH
115     echo "Headers=${includedir}/${QT_DIR_NAME}"   >> $QT_CONF_PATH
116     echo "Libraries=${libdir}"                    >> $QT_CONF_PATH
117     echo "Binaries=${bindir}"                     >> $QT_CONF_PATH
118     echo "Plugins=${libdir}/${QT_DIR_NAME}/plugins" >> $QT_CONF_PATH
119     echo "Data=${datadir}/${QT_DIR_NAME}"         >> $QT_CONF_PATH
120     echo "Translations=${datadir}/${QT_DIR_NAME}/translations" >> $QT_CONF_PATH
121     echo "Settings=${sysconfdir}/${QT_DIR_NAME}"  >> $QT_CONF_PATH
122     echo "Examples=${bindir}/${QT_DIR_NAME}/examples" >> $QT_CONF_PATH
123     echo "Demos=${bindir}/${QT_DIR_NAME}/demos"   >> $QT_CONF_PATH
124
125     ${EXTRA_QMAKE_MUNGE}|| true
126
127     (echo o; echo yes) | ./configure -v \
128             -prefix ${prefix}/ \
129             -bindir ${bindir} \
130             -libdir ${libdir} \
131             -datadir ${datadir}/${QT_DIR_NAME} \
132             -sysconfdir ${sysconfdir}/${QT_DIR_NAME} \
133             -docdir ${docdir}/${QT_DIR_NAME} \
134             -headerdir ${includedir}/${QT_DIR_NAME} \
135             -plugindir ${libdir}/${QT_DIR_NAME}/plugins \
136             -translationdir ${datadir}/${QT_DIR_NAME}/translations \
137             -examplesdir ${bindir}/${QT_DIR_NAME}/examples \
138             -demosdir ${bindir}/${QT_DIR_NAME}/demos \
139             -platform ${TARGET_OS}-oe-g++ \
140             -xplatform ${TARGET_OS}-oe-g++ \
141             -embedded ${QT_ARCH} ${QT_ENDIAN} -fast \
142             -crossarch ${QT_ARCH} \
143             ${QT_CONFIG_FLAGS} -fast \
144             -L${STAGING_LIBDIR} -I${STAGING_INCDIR} \
145             -I${STAGING_INCDIR}/freetype2 \
146             -I${STAGING_INCDIR}/mysql
147 }
148
149 do_compile() {
150     unset CFLAGS CXXFLAGS
151     install -m 0755 ${STAGING_BINDIR_NATIVE}/rcc4 ${S}/bin/rcc
152     install -m 0755 ${STAGING_BINDIR_NATIVE}/moc4 ${S}/bin/moc
153     install -m 0755 ${STAGING_BINDIR_NATIVE}/uic4 ${S}/bin/uic
154
155     oe_runmake ${EXTRA_ENV}
156 }
157
158 python populate_packages_prepend() {
159         translation_dir = bb.data.expand('${datadir}/${QT_DIR_NAME}/translations/', d)
160         translation_name = bb.data.expand('${QT_BASE_NAME}-translation-%s', d)
161         do_split_packages(d, translation_dir, '^(assistant|designer|linguist|qt|qtconfig|qvfb)_(.*)\.qm$', translation_name, '${PN} translation for %s', extra_depends='' )
162  
163         phrasebook_dir = bb.data.expand('${datadir}/${QT_DIR_NAME}/phrasebooks/', d)
164         phrasebook_name = bb.data.expand('${QT_BASE_NAME}-phrasebook-%s', d)
165         do_split_packages(d, phrasebook_dir, '^(.*)\.qph$', phrasebook_name, '${PN} phrasebook for %s', extra_depends='' )
166  
167         # Package all the plugins and their -dbg version and create a meta package
168         import os
169         def qtopia_split(path, name, glob):
170                 """
171                 Split the package into a normal and -dbg package and then add the
172                 new packages to the meta package.
173                 """
174                 plugin_dir = bb.data.expand('${libdir}/${QT_DIR_NAME}/plugins/%s/' % path, d)
175                 if not os.path.exists("%s%s" % (bb.data.expand('${D}',d), plugin_dir)):
176                         bb.note("The path does not exist:", bb.data.expand('${D}', d), plugin_dir)
177                         return
178  
179                 plugin_name = bb.data.expand('${QT_BASE_NAME}-plugin-%s-%%s' % name, d)
180                 dev_packages = []
181                 dev_hook = lambda file,pkg,b,c,d:dev_packages.append((file,pkg))
182                 do_split_packages(d, plugin_dir, glob, plugin_name, '${PN} %s for %%s' % name, extra_depends='', hook=dev_hook)
183                 # Create a -dbg package as well
184                 plugin_dir_dbg = bb.data.expand('${libdir}/${QT_DIR_NAME}/plugins/%s/.debug' % path, d)
185                 packages = bb.data.getVar('PACKAGES',d)
186                 for (file,package) in dev_packages:
187                         packages = "%s %s-dbg" % (packages, package)
188                         file_name = os.path.join(plugin_dir_dbg, os.path.basename(file))
189                         bb.data.setVar("FILES_%s-dbg" % package, file_name, d)
190                         bb.data.setVar("DESCRIPTION_%s-dbg" % package, "${PN} %s for %s" % (name, package), d)
191
192                 bb.data.setVar('PACKAGES', packages, d)
193  
194         qtopia_split('accessible',    'accessible',    '^libq(.*)\.so$')
195         qtopia_split('codecs',        'codec',         '^libq(.*)\.so$')
196         qtopia_split('decorations',   'decoration',    '^libqdecoration(.*)\.so$')
197         qtopia_split('designer',      'designer',      '^lib(.*)\.so$')
198         qtopia_split('gfxdrivers',    'gfxdriver',     '^libq(.*)\.so$')
199         qtopia_split('graphicssystems','graphicssystems', '^libq(.*)\.so$')
200         qtopia_split('mousedrivers',  'mousedriver',   '^libq(.*)mousedriver\.so$')
201         qtopia_split('iconengines',   'iconengine',    '^libq(.*)\.so$')
202         qtopia_split('imageformats',  'imageformat',   '^libq(.*)\.so$')
203         qtopia_split('inputmethods',  'inputmethod',   '^libq(.*)\.so$')
204         qtopia_split('sqldrivers',    'sqldriver',     '^libq(.*)\.so$')
205         qtopia_split('script',        'script',        '^libqtscript(.*)\.so$')
206         qtopia_split('styles',        'style',         '^libq(.*)\.so$')
207         qtopia_split('phonon_backend','phonon-backend','^libphonon_(.*)\.so$')
208 }
209
210 do_install() {
211     oe_runmake install INSTALL_ROOT=${D}
212         
213     # These are host binaries, we should only use them in staging
214     rm -rf ${D}/${bindir}/qmake
215
216     # fix pkgconfig, libtool and prl files
217     sed -i -e s#-L${S}/lib##g \
218            -e s#-L${STAGING_LIBDIR}##g \
219            -e s#-L${libdir}##g \
220            -e s#'$(OE_QMAKE_LIBS_X11)'#"${OE_QMAKE_LIBS_X11}"#g \
221            ${D}${libdir}/*.la ${D}${libdir}/*.prl ${D}${libdir}/pkgconfig/*.pc
222
223     # fix pkgconfig files
224     sed -i -e s#"moc_location=.*$"#"moc_location=${bindir}/moc4"# \
225            -e s#"uic_location=.*$"#"uic_location=${bindir}/uic4"# \
226            ${D}${libdir}/pkgconfig/*.pc
227     for name in ${QT_LIB_NAMES}; do
228            sed -i -e /Requires/s#"${name}"#"${name}${QT_LIBINFIX}"#g ${D}${libdir}/pkgconfig/*.pc
229     done
230
231     install -d ${D}/${libdir}/fonts
232     touch ${D}/${libdir}/fonts/fontdir
233 }
234
235 STAGE_TEMP = "${WORKDIR}/temp-staging"
236 do_stage() {
237     rm -rf ${STAGE_TEMP}
238     mkdir -p ${STAGE_TEMP}
239     oe_runmake install INSTALL_ROOT=${STAGE_TEMP}
240
241     # fix pkgconfig, libtool and prl files
242     sed -i -e s#-L${S}/lib##g \
243            -e s#-L${STAGING_LIBDIR}##g \
244            -e s#-L${libdir}##g \
245            -e s#'$(OE_QMAKE_LIBS_X11)'#"${OE_QMAKE_LIBS_X11}"#g \
246            ${STAGE_TEMP}${libdir}/*.la ${STAGE_TEMP}${libdir}/*.prl ${STAGE_TEMP}${libdir}/pkgconfig/*.pc
247
248     # fix pkgconfig files
249     sed -i -e s#"moc_location=.*$"## \
250            -e s#"uic_location=.*$"## \
251            ${STAGE_TEMP}/${libdir}/pkgconfig/*.pc
252     for name in ${QT_LIB_NAMES}; do
253            sed -i -e "/Requires/s#${name}#${name}${QT_LIBINFIX}#"g ${D}${libdir}/pkgconfig/*.pc
254     done
255
256     # fix libtool files
257     sed -i -e s#installed=yes#installed=no#g ${STAGE_TEMP}/${libdir}/*.la
258
259     # install headers
260     install -d ${STAGING_INCDIR}
261     cp -pPRf ${STAGE_TEMP}/${includedir}/* ${STAGING_INCDIR}/
262
263     # install libraries
264     install -d ${STAGING_LIBDIR}
265     for i in ${STAGE_TEMP}/${libdir}/*.prl; do
266         cp -pPRf $i ${STAGING_LIBDIR}
267         cp -pPRf ${STAGE_TEMP}/${libdir}/$(basename $i .prl).la ${STAGING_LIBDIR} || true
268         oe_libinstall -C ${STAGE_TEMP}/${libdir} -a $(basename $i .prl) ${STAGING_LIBDIR} || true
269         oe_libinstall -C ${STAGE_TEMP}/${libdir} -so $(basename $i .prl) ${STAGING_LIBDIR} || true
270     done
271
272     # install pkgconfig files
273     install -d ${STAGING_LIBDIR}/pkgconfig
274     cp -pPRf ${STAGE_TEMP}/${libdir}/pkgconfig/*.pc ${STAGING_LIBDIR}/pkgconfig/
275
276     # install mkspecs
277     install -d ${STAGING_DATADIR}/${QT_DIR_NAME}/mkspecs
278     cp -pPRf ${STAGE_TEMP}/${datadir}/${QT_DIR_NAME}/mkspecs/* ${STAGING_DATADIR}/${QT_DIR_NAME}/mkspecs/
279
280     rm -rf ${STAGE_TEMP}
281
282     # FIXME: install symlinks to tools?
283     #install -d ${STAGING_DATADIR}/${QT_DIR_NAME}/bin
284     #ln -sf ${STAGING_BINDIR_NATIVE}/qmake2 ${STAGING_DATADIR}/${QT_DIR_NAME}/bin/qmake
285     #for qttool in moc uic uic3 rcc lrelease lupdate; do
286     #     ln -sf ${STAGING_BINDIR_NATIVE}/${qttool}4 ${STAGING_DATADIR}/${QT_DIR_NAME}/bin/${qttool}
287     #done
288 }
289