qt4-tools-native; added dependency on libsm-native
[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 QtMultimedia QtOpenVG"
27
28 QT_EXTRA_LIBS = "pvrQWSWSEGL"
29
30 python __anonymous () {
31     import bb
32
33     lib_packages = []
34     dev_packages = []
35     dbg_packages = []
36     for name in bb.data.getVar("QT_LIB_NAMES", d, 1).split():
37         pkg = "${QT_BASE_LIB}" + name.lower().replace("qt", "") + "4"
38         # NOTE: the headers for QtAssistantClient are different
39         incname = name.replace("QtAssistantClient", "QtAssistant")
40         bb.data.setVar("FILES_%s" % pkg, "${libdir}/lib%(name)s${QT_LIBINFIX}.so.*" % locals(), d)
41         bb.data.setVar("FILES_%s-dev" % pkg, """${libdir}/lib%(name)s${QT_LIBINFIX}.prl
42                   ${libdir}/lib%(name)s${QT_LIBINFIX}.a
43                   ${libdir}/lib%(name)s${QT_LIBINFIX}.la
44                   ${libdir}/lib%(name)s${QT_LIBINFIX}.so
45                   ${includedir}/${QT_DIR_NAME}/%(incname)s
46                   ${libdir}/pkgconfig/%(name)s${QT_LIBINFIX}.pc""" % locals(), d)
47         bb.data.setVar("FILES_%s-dbg" % pkg, "${libdir}/.debug/lib%(name)s${QT_LIBINFIX}.so.*" % locals(), d)
48         lib_packages.append(pkg)
49         dev_packages.append("%s-dev" % pkg)
50         dbg_packages.append("%s-dbg" % pkg)
51     for name in bb.data.getVar("OTHER_PACKAGES", d, 1).split():
52         dbg_packages.append("%s-dbg" % name)
53
54     for name in bb.data.getVar("QT_EXTRA_LIBS", d, 1).split():
55         pkg = "${QT_BASE_LIB}" + name.lower().replace("qt", "") + "4"
56         bb.data.setVar("FILES_%s" % pkg, "${libdir}/lib%(name)s.so.*" % locals(), d)
57         bb.data.setVar("FILES_%s-dev" % pkg, """${libdir}/lib%(name)s.prl
58                   ${libdir}/lib%(name)s.a
59                   ${libdir}/lib%(name)s.la
60                   ${libdir}/lib%(name)s.so
61                   ${includedir}/${QT_DIR_NAME}/%(incname)s
62                   ${libdir}/pkgconfig/%(name)s.pc""" % locals(), d)
63         bb.data.setVar("FILES_%s-dbg" % pkg, "${libdir}/.debug/lib%(name)s.so.*" % locals(), d)
64         lib_packages.append(pkg)
65         dev_packages.append("%s-dev" % pkg)
66         dbg_packages.append("%s-dbg" % pkg)
67
68     bb.data.setVar("LIB_PACKAGES", " ".join(lib_packages), d)
69     bb.data.setVar("DEV_PACKAGES", " ".join(dev_packages), d)
70     bb.data.setVar("DBG_PACKAGES", " ".join(dbg_packages), d)
71 }
72
73 OTHER_PACKAGES = "\
74              ${QT_BASE_NAME}-tools \
75              ${QT_BASE_NAME}-assistant \
76              ${QT_BASE_NAME}-common \
77              ${QT_BASE_NAME}-dbus \
78              ${QT_BASE_NAME}-demos \
79              ${QT_BASE_NAME}-designer \
80              ${QT_BASE_NAME}-examples \
81              ${QT_BASE_NAME}-fonts \
82              ${QT_BASE_NAME}-linguist \
83              ${QT_BASE_NAME}-makeqpf \
84              ${QT_BASE_NAME}-mkspecs \
85              ${QT_BASE_NAME}-pixeltool \
86              ${QT_BASE_NAME}-qt3to4"
87
88 PACKAGES += "${LIB_PACKAGES} ${DEV_PACKAGES} ${DBG_PACKAGES} ${OTHER_PACKAGES}"
89 PACKAGES_DYNAMIC = "${QT_BASE_NAME}-plugin-*  ${QT_BASE_NAME}-translation-*"
90
91 ALLOW_EMPTY_${PN} = "1"
92 FILES_${PN}     = ""
93 FILES_${PN}-dev = "${includedir}/${QT_DIR_NAME}/Qt/*"
94 FILES_${PN}-dbg = ""
95 RRECOMMENDS_${PN} = "${LIB_PACKAGES} ${OTHER_PACKAGES}"
96 RRECOMMENDS_${PN}-dev = "${DEV_PACKAGES}"
97 RRECOMMENDS_${PN}-dbg = "${DBG_PACKAGES}"
98
99 FILES_${QT_BASE_NAME}-tools                = "${bindir}/uic* ${bindir}/moc ${bindir}/rcc ${bindir}/qttracereplay"
100 FILES_${QT_BASE_NAME}-assistant            = "${bindir}/*assistant* ${bindir}/qcollectiongenerator ${bindir}/qhelpconverter ${bindir}/qhelpgenerator"
101 FILES_${QT_BASE_NAME}-assistant-dbg        = "${bindir}/.debug/*assistant* ${bindir}/.debug/qcollectiongenerator ${bindir}/.debug/qhelpconverter ${bindir}/.debug/qhelpgenerator"
102 FILES_${QT_BASE_NAME}-common               = "${bindir}/qtconfig"
103 FILES_${QT_BASE_NAME}-common-dbg           = "${bindir}/.debug/qtconfig"
104 FILES_${QT_BASE_NAME}-dbus                 = "${bindir}/qdbus ${bindir}/qdbusxml2cpp ${bindir}/qdbuscpp2xml ${bindir}/qdbusviewer"
105 FILES_${QT_BASE_NAME}-dbus-dbg             = "${bindir}/.debug/qdbus ${bindir}/.debug/qdbusxml2cpp ${bindir}/.debug/qdbuscpp2xml ${bindir}/.debug/qdbusviewer"
106 FILES_${QT_BASE_NAME}-demos                = "${bindir}/qtdemo ${bindir}/${QT_DIR_NAME}/demos/*"
107 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"
108 FILES_${QT_BASE_NAME}-designer             = "${bindir}/*designer*"
109 FILES_${QT_BASE_NAME}-designer-dbg         = "${bindir}/.debug/*designer*"
110 FILES_${QT_BASE_NAME}-examples             = "${bindir}/${QT_DIR_NAME}/examples/*"
111 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"
112 FILES_${QT_BASE_NAME}-fonts                = "${libdir}/fonts"
113 FILES_${QT_BASE_NAME}-linguist             = "${bindir}/*linguist* ${bindir}/lrelease ${bindir}/lupdate ${bindir}/lconvert ${bindir}/qm2ts"
114 FILES_${QT_BASE_NAME}-linguist-dbg         = "${bindir}/.debug/*linguist* ${bindir}/.debug/lrelease ${bindir}/.debug/lupdate ${bindir}/.debug/lconvert ${bindir}/.debug/qm2ts"
115 FILES_${QT_BASE_NAME}-pixeltool            = "${bindir}/pixeltool"
116 FILES_${QT_BASE_NAME}-pixeltool-dbg        = "${bindir}/.debug/pixeltool"
117 FILES_${QT_BASE_NAME}-qt3to4               = "${bindir}/qt3to4 ${datadir}/${QT_DIR_NAME}/q3porting.xml"
118 FILES_${QT_BASE_NAME}-qt3to4-dbg           = "${bindir}/.debug/qt3to4"
119 FILES_${QT_BASE_NAME}-makeqpf              = "${bindir}/makeqpf"
120 FILES_${QT_BASE_NAME}-makeqpf-dbg          = "${bindir}/.debug/makeqpf"
121 FILES_${QT_BASE_NAME}-mkspecs              = "${datadir}/${QT_DIR_NAME}/mkspecs/*"
122
123
124 do_configure() {
125     unset QMAKESPEC
126     unset QTDIR
127
128     if [ ! -e bin/qmake ]; then
129         ln -sf ${STAGING_BINDIR_NATIVE}/qmake2 bin/qmake
130     fi
131
132     if [ ! -e mkspecs/${TARGET_OS}-oe-g++ ]; then
133         ln -sf linux-g++ mkspecs/${TARGET_OS}-oe-g++
134     fi
135
136     cp -f ${WORKDIR}/g++.conf ${WORKDIR}/linux.conf mkspecs/common/
137
138     echo "[Paths]"                                 > $QT_CONF_PATH
139     echo "Prefix=${prefix}/"                      >> $QT_CONF_PATH
140     echo "Documentation=${docdir}/${QT_DIR_NAME}" >> $QT_CONF_PATH
141     echo "Headers=${includedir}/${QT_DIR_NAME}"   >> $QT_CONF_PATH
142     echo "Libraries=${libdir}"                    >> $QT_CONF_PATH
143     echo "Binaries=${bindir}"                     >> $QT_CONF_PATH
144     echo "Plugins=${libdir}/${QT_DIR_NAME}/plugins" >> $QT_CONF_PATH
145     echo "Data=${datadir}/${QT_DIR_NAME}"         >> $QT_CONF_PATH
146     echo "Translations=${datadir}/${QT_DIR_NAME}/translations" >> $QT_CONF_PATH
147     echo "Settings=${sysconfdir}/${QT_DIR_NAME}"  >> $QT_CONF_PATH
148     echo "Examples=${bindir}/${QT_DIR_NAME}/examples" >> $QT_CONF_PATH
149     echo "Demos=${bindir}/${QT_DIR_NAME}/demos"   >> $QT_CONF_PATH
150
151     ${EXTRA_QMAKE_MUNGE}|| true
152
153     (echo o; echo yes) | ./configure -v \
154             -prefix ${prefix}/ \
155             -bindir ${bindir} \
156             -libdir ${libdir} \
157             -datadir ${datadir}/${QT_DIR_NAME} \
158             -sysconfdir ${sysconfdir}/${QT_DIR_NAME} \
159             -docdir ${docdir}/${QT_DIR_NAME} \
160             -headerdir ${includedir}/${QT_DIR_NAME} \
161             -plugindir ${libdir}/${QT_DIR_NAME}/plugins \
162             -translationdir ${datadir}/${QT_DIR_NAME}/translations \
163             -examplesdir ${bindir}/${QT_DIR_NAME}/examples \
164             -demosdir ${bindir}/${QT_DIR_NAME}/demos \
165             -platform ${TARGET_OS}-oe-g++ \
166             -xplatform ${TARGET_OS}-oe-g++ \
167             -embedded ${QT_ARCH} ${QT_ENDIAN} -fast \
168             -crossarch ${QT_ARCH} \
169             ${QT_CONFIG_FLAGS} -fast \
170             -L${STAGING_LIBDIR} -I${STAGING_INCDIR} \
171             -I${STAGING_INCDIR}/freetype2 \
172             -I${STAGING_INCDIR}/mysql \
173             -I${STAGING_INCDIR}/postgresql
174 }
175
176 do_compile() {
177     unset CFLAGS CXXFLAGS
178     install -m 0755 ${STAGING_BINDIR_NATIVE}/rcc4 ${S}/bin/rcc
179     install -m 0755 ${STAGING_BINDIR_NATIVE}/moc4 ${S}/bin/moc
180     install -m 0755 ${STAGING_BINDIR_NATIVE}/uic4 ${S}/bin/uic
181
182     oe_runmake ${EXTRA_ENV}
183 }
184
185 python populate_packages_prepend() {
186         translation_dir = bb.data.expand('${datadir}/${QT_DIR_NAME}/translations/', d)
187         translation_name = bb.data.expand('${QT_BASE_NAME}-translation-%s', d)
188         do_split_packages(d, translation_dir, '^(assistant|designer|linguist|qt|qtconfig|qvfb)_(.*)\.qm$', translation_name, '${PN} translation for %s', extra_depends='' )
189  
190         phrasebook_dir = bb.data.expand('${datadir}/${QT_DIR_NAME}/phrasebooks/', d)
191         phrasebook_name = bb.data.expand('${QT_BASE_NAME}-phrasebook-%s', d)
192         do_split_packages(d, phrasebook_dir, '^(.*)\.qph$', phrasebook_name, '${PN} phrasebook for %s', extra_depends='' )
193  
194         # Package all the plugins and their -dbg version and create a meta package
195         import os
196         def qtopia_split(path, name, glob):
197                 """
198                 Split the package into a normal and -dbg package and then add the
199                 new packages to the meta package.
200                 """
201                 plugin_dir = bb.data.expand('${libdir}/${QT_DIR_NAME}/plugins/%s/' % path, d)
202                 if not os.path.exists("%s%s" % (bb.data.expand('${D}',d), plugin_dir)):
203                         bb.note("The path does not exist:", bb.data.expand('${D}', d), plugin_dir)
204                         return
205  
206                 plugin_name = bb.data.expand('${QT_BASE_NAME}-plugin-%s-%%s' % name, d)
207                 dev_packages = []
208                 dev_hook = lambda file,pkg,b,c,d:dev_packages.append((file,pkg))
209                 do_split_packages(d, plugin_dir, glob, plugin_name, '${PN} %s for %%s' % name, extra_depends='', hook=dev_hook)
210                 # Create a -dbg package as well
211                 plugin_dir_dbg = bb.data.expand('${libdir}/${QT_DIR_NAME}/plugins/%s/.debug' % path, d)
212                 packages = bb.data.getVar('PACKAGES',d)
213                 for (file,package) in dev_packages:
214                         packages = "%s %s-dbg" % (packages, package)
215                         file_name = os.path.join(plugin_dir_dbg, os.path.basename(file))
216                         bb.data.setVar("FILES_%s-dbg" % package, file_name, d)
217                         bb.data.setVar("DESCRIPTION_%s-dbg" % package, "${PN} %s for %s" % (name, package), d)
218
219                 bb.data.setVar('PACKAGES', packages, d)
220  
221         qtopia_split('accessible',    'accessible',    '^libq(.*)\.so$')
222         qtopia_split('codecs',        'codec',         '^libq(.*)\.so$')
223         qtopia_split('decorations',   'decoration',    '^libqdecoration(.*)\.so$')
224         qtopia_split('designer',      'designer',      '^lib(.*)\.so$')
225         qtopia_split('gfxdrivers',    'gfxdriver',     '^libq(.*)\.so$')
226         qtopia_split('graphicssystems','graphicssystems', '^libq(.*)\.so$')
227         qtopia_split('mousedrivers',  'mousedriver',   '^libq(.*)mousedriver\.so$')
228         qtopia_split('iconengines',   'iconengine',    '^libq(.*)\.so$')
229         qtopia_split('imageformats',  'imageformat',   '^libq(.*)\.so$')
230         qtopia_split('inputmethods',  'inputmethod',   '^libq(.*)\.so$')
231         qtopia_split('sqldrivers',    'sqldriver',     '^libq(.*)\.so$')
232         qtopia_split('script',        'script',        '^libqtscript(.*)\.so$')
233         qtopia_split('styles',        'style',         '^libq(.*)\.so$')
234         qtopia_split('phonon_backend','phonon-backend','^libphonon_(.*)\.so$')
235 }
236
237 do_install() {
238     oe_runmake install INSTALL_ROOT=${D}
239         
240     # These are host binaries, we should only use them in staging
241     rm -rf ${D}/${bindir}/qmake
242
243     # fix pkgconfig, libtool and prl files
244     sed -i -e s#-L${S}/lib##g \
245            -e s#-L${STAGING_LIBDIR}##g \
246            -e s#-L${libdir}##g \
247            -e s#'$(OE_QMAKE_LIBS_X11)'#"${OE_QMAKE_LIBS_X11}"#g \
248            -e s#"-Wl,-rpath-link,${S}/lib"##g \
249            ${D}${libdir}/*.la ${D}${libdir}/*.prl ${D}${libdir}/pkgconfig/*.pc
250
251     # fix pkgconfig files
252     sed -i -e s#"moc_location=.*$"#"moc_location=${bindir}/moc4"# \
253            -e s#"uic_location=.*$"#"uic_location=${bindir}/uic4"# \
254            ${D}${libdir}/pkgconfig/*.pc
255     for name in ${QT_LIB_NAMES}; do
256            sed -i -e /Requires/s#"${name}"#"${name}${QT_LIBINFIX}"#g ${D}${libdir}/pkgconfig/*.pc
257     done
258
259     install -d ${D}/${libdir}/fonts
260     touch ${D}/${libdir}/fonts/fontdir
261 }
262
263