Merge branch 'vuplus-1.6' of ssh://192.168.102.66/~ikseong/work/repo/openembedded...
[vuplus_openembedded] / 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 QtXmlPatterns phonon QtMultimedia QtOpenVG QtMediaServices QtDeclarative"
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", "").replace("_", "-") + "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", "").replace("_", "-") + "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}-fonts-ttf-vera \
83              ${QT_BASE_NAME}-fonts-ttf-dejavu \
84              ${QT_BASE_NAME}-fonts-pfa \
85              ${QT_BASE_NAME}-fonts-pfb \
86              ${QT_BASE_NAME}-fonts-qpf \
87              ${QT_BASE_NAME}-linguist \
88              ${QT_BASE_NAME}-makeqpf \
89              ${QT_BASE_NAME}-mkspecs \
90              ${QT_BASE_NAME}-pixeltool \
91              ${QT_BASE_NAME}-qmlviewer \
92              ${QT_BASE_NAME}-xmlpatterns \
93              ${QT_BASE_NAME}-qt3to4"
94
95 PACKAGES += "${LIB_PACKAGES} ${DEV_PACKAGES} ${DBG_PACKAGES} ${OTHER_PACKAGES}"
96 PACKAGES_DYNAMIC = "${QT_BASE_NAME}-plugin-* ${QT_BASE_NAME}-translation-* ${QT_BASE_NAME}-fonts-*"
97
98 ALLOW_EMPTY_${PN} = "1"
99 ALLOW_EMPTY_${QT_BASE_NAME}-fonts = "1"
100 FILES_${PN}     = ""
101 FILES_${PN}-dev = "${includedir}/${QT_DIR_NAME}/Qt/*"
102 FILES_${PN}-dbg = ""
103 RRECOMMENDS_${PN} = "${LIB_PACKAGES} ${OTHER_PACKAGES}"
104 RRECOMMENDS_${PN}-dev = "${DEV_PACKAGES}"
105 RRECOMMENDS_${PN}-dbg = "${DBG_PACKAGES}"
106 RRECOMMENDS_${QT_BASE_NAME}-fonts = " \
107              ${QT_BASE_NAME}-fonts-ttf-vera \
108              ${QT_BASE_NAME}-fonts-ttf-dejavu \
109              ${QT_BASE_NAME}-fonts-pfa \
110              ${QT_BASE_NAME}-fonts-pfb \
111              ${QT_BASE_NAME}-fonts-qpf"
112
113 FILES_${QT_BASE_NAME}-tools                = "${bindir}/uic* ${bindir}/moc ${bindir}/rcc ${bindir}/qttracereplay ${bindir}/qdoc*"
114 FILES_${QT_BASE_NAME}-tools-dbg            = "${bindir}/.debug/uic* ${bindir}/.debug/moc ${bindir}/.debug/rcc ${bindir}/.debug/qttracereplay ${bindir}/.debug/qdoc*"
115 FILES_${QT_BASE_NAME}-assistant            = "${bindir}/*assistant* ${bindir}/qcollectiongenerator ${bindir}/qhelpconverter ${bindir}/qhelpgenerator"
116 FILES_${QT_BASE_NAME}-assistant-dbg        = "${bindir}/.debug/*assistant* ${bindir}/.debug/qcollectiongenerator ${bindir}/.debug/qhelpconverter ${bindir}/.debug/qhelpgenerator"
117 FILES_${QT_BASE_NAME}-common               = "${bindir}/qtconfig"
118 FILES_${QT_BASE_NAME}-common-dbg           = "${bindir}/.debug/qtconfig"
119 FILES_${QT_BASE_NAME}-dbus                 = "${bindir}/qdbus ${bindir}/qdbusxml2cpp ${bindir}/qdbuscpp2xml ${bindir}/qdbusviewer"
120 FILES_${QT_BASE_NAME}-dbus-dbg             = "${bindir}/.debug/qdbus ${bindir}/.debug/qdbusxml2cpp ${bindir}/.debug/qdbuscpp2xml ${bindir}/.debug/qdbusviewer"
121 FILES_${QT_BASE_NAME}-demos                = "${bindir}/qtdemo* ${bindir}/${QT_DIR_NAME}/demos/*"
122 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"
123 FILES_${QT_BASE_NAME}-designer             = "${bindir}/*designer*"
124 FILES_${QT_BASE_NAME}-designer-dbg         = "${bindir}/.debug/*designer*"
125 FILES_${QT_BASE_NAME}-examples             = "${bindir}/${QT_DIR_NAME}/examples/*"
126 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 ${bindir}/${QT_DIR_NAME}/examples/declarative/*/*/*/*/*/.debug/* ${bindir}/${QT_DIR_NAME}/examples/declarative/*/*/*/*/.debug/*"
127 FILES_${QT_BASE_NAME}-fonts-ttf-vera       = "${libdir}/fonts/Vera*.ttf"
128 FILES_${QT_BASE_NAME}-fonts-ttf-dejavu     = "${libdir}/fonts/DejaVu*.ttf"
129 FILES_${QT_BASE_NAME}-fonts-pfa            = "${libdir}/fonts/*.pfa"
130 FILES_${QT_BASE_NAME}-fonts-pfb            = "${libdir}/fonts/*.pfb"
131 FILES_${QT_BASE_NAME}-fonts-qpf            = "${libdir}/fonts/*.qpf"
132 FILES_${QT_BASE_NAME}-linguist             = "${bindir}/*linguist* ${bindir}/lrelease ${bindir}/lupdate ${bindir}/lconvert ${bindir}/qm2ts"
133 FILES_${QT_BASE_NAME}-linguist-dbg         = "${bindir}/.debug/*linguist* ${bindir}/.debug/lrelease ${bindir}/.debug/lupdate ${bindir}/.debug/lconvert ${bindir}/.debug/qm2ts"
134 FILES_${QT_BASE_NAME}-pixeltool            = "${bindir}/pixeltool"
135 FILES_${QT_BASE_NAME}-pixeltool-dbg        = "${bindir}/.debug/pixeltool"
136 FILES_${QT_BASE_NAME}-qt3to4               = "${bindir}/qt3to4 ${datadir}/${QT_DIR_NAME}/q3porting.xml"
137 FILES_${QT_BASE_NAME}-qt3to4-dbg           = "${bindir}/.debug/qt3to4"
138 FILES_${QT_BASE_NAME}-qmlviewer            = "${bindir}/qmlviewer"
139 FILES_${QT_BASE_NAME}-qmlviewer-dbg        = "${bindir}/.debug/qmlviewer"
140 FILES_${QT_BASE_NAME}-makeqpf              = "${bindir}/makeqpf"
141 FILES_${QT_BASE_NAME}-makeqpf-dbg          = "${bindir}/.debug/makeqpf"
142 FILES_${QT_BASE_NAME}-mkspecs              = "${datadir}/${QT_DIR_NAME}/mkspecs/*"
143 FILES_${QT_BASE_NAME}-xmlpatterns          = "${bindir}/xmlpatterns*"
144 FILES_${QT_BASE_NAME}-xmlpatterns-dbg      = "${bindir}/.debug/xmlpatterns*"
145
146
147 do_configure() {
148     unset QMAKESPEC
149     unset QTDIR
150
151     if [ ! -e bin/qmake ]; then
152         ln -sf ${STAGING_BINDIR_NATIVE}/qmake2 bin/qmake
153     fi
154
155     if [ ! -e mkspecs/${TARGET_OS}-oe-g++ ]; then
156         ln -sf linux-g++ mkspecs/${TARGET_OS}-oe-g++
157     fi
158
159     cp -f ${WORKDIR}/g++.conf ${WORKDIR}/linux.conf mkspecs/common/
160
161     echo "[Paths]"                                 > $QT_CONF_PATH
162     echo "Prefix=${prefix}/"                      >> $QT_CONF_PATH
163     echo "Documentation=${docdir}/${QT_DIR_NAME}" >> $QT_CONF_PATH
164     echo "Headers=${includedir}/${QT_DIR_NAME}"   >> $QT_CONF_PATH
165     echo "Libraries=${libdir}"                    >> $QT_CONF_PATH
166     echo "Binaries=${bindir}"                     >> $QT_CONF_PATH
167     echo "Plugins=${libdir}/${QT_DIR_NAME}/plugins" >> $QT_CONF_PATH
168     echo "Data=${datadir}/${QT_DIR_NAME}"         >> $QT_CONF_PATH
169     echo "Translations=${datadir}/${QT_DIR_NAME}/translations" >> $QT_CONF_PATH
170     echo "Settings=${sysconfdir}/${QT_DIR_NAME}"  >> $QT_CONF_PATH
171     echo "Examples=${bindir}/${QT_DIR_NAME}/examples" >> $QT_CONF_PATH
172     echo "Demos=${bindir}/${QT_DIR_NAME}/demos"   >> $QT_CONF_PATH
173
174     ${EXTRA_QMAKE_MUNGE}|| true
175
176     (echo o; echo yes) | ./configure -v \
177             -prefix ${prefix}/ \
178             -bindir ${bindir} \
179             -libdir ${libdir} \
180             -datadir ${datadir}/${QT_DIR_NAME} \
181             -sysconfdir ${sysconfdir}/${QT_DIR_NAME} \
182             -docdir ${docdir}/${QT_DIR_NAME} \
183             -headerdir ${includedir}/${QT_DIR_NAME} \
184             -plugindir ${libdir}/${QT_DIR_NAME}/plugins \
185             -translationdir ${datadir}/${QT_DIR_NAME}/translations \
186             -examplesdir ${bindir}/${QT_DIR_NAME}/examples \
187             -demosdir ${bindir}/${QT_DIR_NAME}/demos \
188             -platform ${TARGET_OS}-oe-g++ \
189             -xplatform ${TARGET_OS}-oe-g++ \
190             -embedded ${QT_ARCH} ${QT_ENDIAN} \
191             -crossarch ${QT_ARCH} \
192             ${QT_CONFIG_FLAGS} -no-fast \
193             -L${STAGING_LIBDIR} -I${STAGING_INCDIR} \
194             -I${STAGING_INCDIR}/freetype2 \
195             -I${STAGING_INCDIR}/mysql \
196             -I${STAGING_INCDIR}/postgresql
197 }
198
199 do_compile() {
200     unset CFLAGS CXXFLAGS
201     install -m 0755 ${STAGING_BINDIR_NATIVE}/rcc4 ${S}/bin/rcc
202     install -m 0755 ${STAGING_BINDIR_NATIVE}/moc4 ${S}/bin/moc
203     install -m 0755 ${STAGING_BINDIR_NATIVE}/uic4 ${S}/bin/uic
204
205     oe_runmake ${EXTRA_ENV}
206 }
207
208 python populate_packages_prepend() {
209         translation_dir = bb.data.expand('${datadir}/${QT_DIR_NAME}/translations/', d)
210         translation_name = bb.data.expand('${QT_BASE_NAME}-translation-%s', d)
211         do_split_packages(d, translation_dir, '^(assistant|designer|linguist|qt|qtconfig|qvfb)_(.*)\.qm$', translation_name, '${PN} translation for %s', extra_depends='' )
212  
213         phrasebook_dir = bb.data.expand('${datadir}/${QT_DIR_NAME}/phrasebooks/', d)
214         phrasebook_name = bb.data.expand('${QT_BASE_NAME}-phrasebook-%s', d)
215         do_split_packages(d, phrasebook_dir, '^(.*)\.qph$', phrasebook_name, '${PN} phrasebook for %s', extra_depends='' )
216  
217         # Package all the plugins and their -dbg version and create a meta package
218         import os
219         def qtopia_split(path, name, glob):
220                 """
221                 Split the package into a normal and -dbg package and then add the
222                 new packages to the meta package.
223                 """
224                 plugin_dir = bb.data.expand('${libdir}/${QT_DIR_NAME}/plugins/%s/' % path, d)
225                 if not os.path.exists("%s%s" % (bb.data.expand('${D}',d), plugin_dir)):
226                         bb.note("The path does not exist:", bb.data.expand('${D}', d), plugin_dir)
227                         return
228  
229                 plugin_name = bb.data.expand('${QT_BASE_NAME}-plugin-%s-%%s' % name, d)
230                 dev_packages = []
231                 dev_hook = lambda file,pkg,b,c,d:dev_packages.append((file,pkg))
232                 do_split_packages(d, plugin_dir, glob, plugin_name, '${PN} %s for %%s' % name, extra_depends='', hook=dev_hook)
233                 # Create a -dbg package as well
234                 plugin_dir_dbg = bb.data.expand('${libdir}/${QT_DIR_NAME}/plugins/%s/.debug' % path, d)
235                 packages = bb.data.getVar('PACKAGES',d)
236                 for (file,package) in dev_packages:
237                         packages = "%s %s-dbg" % (packages, package)
238                         file_name = os.path.join(plugin_dir_dbg, os.path.basename(file))
239                         bb.data.setVar("FILES_%s-dbg" % package, file_name, d)
240                         bb.data.setVar("DESCRIPTION_%s-dbg" % package, "${PN} %s for %s" % (name, package), d)
241
242                 bb.data.setVar('PACKAGES', packages, d)
243  
244         qtopia_split('accessible',    'accessible',    '^libq(.*)\.so$')
245         qtopia_split('codecs',        'codec',         '^libq(.*)\.so$')
246         qtopia_split('decorations',   'decoration',    '^libqdecoration(.*)\.so$')
247         qtopia_split('designer',      'designer',      '^lib(.*)\.so$')
248         qtopia_split('gfxdrivers',    'gfxdriver',     '^libq(.*)\.so$')
249         qtopia_split('graphicssystems','graphicssystems', '^libq(.*)\.so$')
250         qtopia_split('mousedrivers',  'mousedriver',   '^libq(.*)mousedriver\.so$')
251         qtopia_split('iconengines',   'iconengine',    '^libq(.*)\.so$')
252         qtopia_split('imageformats',  'imageformat',   '^libq(.*)\.so$')
253         qtopia_split('inputmethods',  'inputmethod',   '^libq(.*)\.so$')
254         qtopia_split('sqldrivers',    'sqldriver',     '^libq(.*)\.so$')
255         qtopia_split('script',        'script',        '^libqtscript(.*)\.so$')
256         qtopia_split('styles',        'style',         '^libq(.*)\.so$')
257         qtopia_split('phonon_backend','phonon-backend','^libphonon_(.*)\.so$')
258         qtopia_split('bearer',        'bearer',        '^libq(.*)bearer\.so$')
259 }
260
261 do_install() {
262     oe_runmake install INSTALL_ROOT=${D}
263         
264     # These are host binaries, we should only use them in staging
265     rm -rf ${D}/${bindir}/qmake
266
267     # fix pkgconfig, libtool and prl files
268     sed -i -e s#-L${S}/lib##g \
269            -e s#-L${STAGING_LIBDIR}##g \
270            -e 's#STAGING_LIBDIR}#libdir}'#g \ 
271            -e s#-L${libdir}##g \
272            -e s#'$(OE_QMAKE_LIBS_X11)'#"${OE_QMAKE_LIBS_X11}"#g \
273            -e s#" -Wl,-rpath-link,${S}/lib"##g \
274            -e s#" -Wl,-rpath-link,${libdir}"##g \
275            -e 's#I/usr/include#Iincludedir}#g' \ 
276            -e 's#Iin#I${in#g' \
277            ${D}${libdir}/*.la ${D}${libdir}/*.prl ${D}${libdir}/pkgconfig/*.pc
278
279     sed -i -e s#" -Wl,-rpath-link,${S}/lib"##g \
280             ${D}${datadir}/${QT_DIR_NAME}/mkspecs/common/linux.conf
281
282     # fix pkgconfig files
283     sed -i -e s#"moc_location=.*$"#"moc_location=${bindir}/moc4"# \
284            -e s#"uic_location=.*$"#"uic_location=${bindir}/uic4"# \
285            ${D}${libdir}/pkgconfig/*.pc
286     for name in ${QT_LIB_NAMES}; do
287            sed -i -e /Requires/s#"${name}"#"${name}${QT_LIBINFIX}"#g ${D}${libdir}/pkgconfig/*.pc
288            if [ -f ${D}${libdir}/pkgconfig/${name}${QT_LIBINFIX}.pc ]; then
289                sed -i -e /^includedir=/s#"/${name}"## \
290                       -e /^Cflags:/s#"${QT_DIR_NAME}"#"${name}"# \
291                          ${D}${libdir}/pkgconfig/${name}${QT_LIBINFIX}.pc
292            fi
293     done
294
295     install -d ${D}/${libdir}/fonts
296     touch ${D}/${libdir}/fonts/fontdir
297 }
298
299