Skip to contentSkip to conversation

Qt4: adapt for X11

PATCH New Cédric Chépied 2 participants 2 messages Jan 31, 2014 – Feb 1, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Qt4: adapt for X11

Qt4 can now be built with X11 support

I found the original patch here:
http://lists.busybox.net/pipermail/buildroot/2011-October/046706.html

---
 package/qt/Config.in |  8 ++++++++
 package/qt/qt.mk     | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
package/qt/Config.in +8 -0
index 926d54c..7f8de3b 100644
@@ -15,6 +15,12 @@ menuconfig BR2_PACKAGE_QT
 
 if BR2_PACKAGE_QT
 
+config BR2_PACKAGE_QT_X11
+	bool "X server support"
+	default n
+	help
+	  Build Qt with X11 support
+
 config BR2_PACKAGE_QT_DEBUG
 	bool "Compile with debug support"
 	help
@@ -96,6 +102,7 @@ config BR2_PACKAGE_QT_GUI_MODULE
 	  video output, or you don't require Qt GUI, say n.
 
 if BR2_PACKAGE_QT_GUI_MODULE
+if !BR2_PACKAGE_QT_X11
 menu "Pixel depths"
 comment "Deselecting each option leads to Qt's default (8,16,32)"
 
@@ -176,6 +183,7 @@ config BR2_PACKAGE_QT_SYSTEMFREETYPE
 	  Use shared libfreetype from the target system.
 	  See http://www.freetype.org/
 endchoice
+endif # !BR2_PACKAGE_QT_X11
 
 config BR2_PACKAGE_QT_GIF
 	bool "Enable GIF support"
package/qt/qt.mk +36 -0
index bc329f0..1fb350c 100644
@@ -111,6 +111,10 @@ ifneq ($(QT_PIXEL_DEPTHS),)
 QT_CONFIGURE_OPTS += -depths $(subst $(space),$(comma),$(strip $(QT_PIXEL_DEPTHS)))
 endif
 
+ifneq ($(BR2_PACKAGE_QT_X11),y)
+### Embedded options
+QT_CONFIGURE_OPTS += -no-gfx-qnx -no-kbd-qnx -no-mouse-qnx
+
 ### Display drivers
 ifeq ($(BR2_PACKAGE_QT_GFX_LINUXFB),y)
 QT_CONFIGURE_OPTS += -qt-gfx-linuxfb
@@ -197,6 +201,12 @@ else
 QT_CONFIGURE_OPTS += -no-kbd-qvfb
 endif
 
+else
+### X11 options
+QT_CONFIGURE_OPTS += -no-gtkstyle -no-openvg -no-glib --disable-script
+endif
+
+
 ifeq ($(BR2_PACKAGE_QT_DEBUG),y)
 QT_CONFIGURE_OPTS += -debug
 else
@@ -236,7 +246,12 @@ else
 QT_EMB_PLATFORM = generic
 endif
 
+ifneq ($(BR2_PACKAGE_QT_X11),y)
 QT_CONFIGURE_OPTS += -embedded $(QT_EMB_PLATFORM)
+else
+QT_CONFIGURE_OPTS += -xplatform linux-$(QT_EMB_PLATFORM)-g++ -v
+QT_DEPENDENCIES   += fontconfig xlib_libXi xlib_libX11 xlib_libXrender xlib_libXcursor xlib_libXinerama xlib_libXrandr xlib_libXext xlib_libXv
+endif
 
 ifneq ($(BR2_PACKAGE_QT_GUI_MODULE),y)
 QT_CONFIGURE_OPTS += -no-gui
@@ -453,7 +468,11 @@ endif
 # End of workaround.
 
 # Variable for other Qt applications to use
+ifneq ($(BR2_PACKAGE_QT_X11),y)
 QT_QMAKE = $(HOST_DIR)/usr/bin/qmake -spec qws/linux-$(QT_EMB_PLATFORM)-g++
+else
+QT_QMAKE:=$(HOST_DIR)/usr/bin/qmake -spec linux-$(QT_EMB_PLATFORM)-g++
+endif
 
 ################################################################################
 # QT_QMAKE_SET -- helper macro to set <variable> = <value> in
@@ -467,10 +486,26 @@ QT_QMAKE = $(HOST_DIR)/usr/bin/qmake -spec qws/linux-$(QT_EMB_PLATFORM)-g++
 # E.G. use like this:
 # $(call QT_QMAKE_SET,variable,value,directory)
 ################################################################################
+ifneq ($(BR2_PACKAGE_QT_X11),y)
 define QT_QMAKE_SET
 	$(SED) '/$(1)/d' $(3)/mkspecs/qws/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
 	$(SED) '/include.*qws.conf/a$(1) = $(2)' $(3)/mkspecs/qws/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
 endef
+else
+define QT_QMAKE_SET
+	$(SED) '/$(1)/d' $(3)/mkspecs/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
+	$(SED) '/load(qt_config)/i$(1) = $(2)' $(3)/mkspecs/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
+endef
+endif
+
+ifeq ($(BR2_PACKAGE_QT_X11),y)
+define QT_CONFIGURE_MKSPECS
+	cp -R $(@D)/mkspecs/linux-g++ $(@D)/mkspecs/linux-$(QT_EMB_PLATFORM)-g++
+	$(call QT_QMAKE_SET,QMAKE_INCDIR_X11,$(STAGING_DIR)/usr/X11R6/include,$(@D))
+	$(call QT_QMAKE_SET,QMAKE_LIBDIR,$(STAGING_DIR)/lib/ $(STAGING_DIR)/usr/lib/,$(@D))
+	$(call QT_QMAKE_SET,QMAKE_LIBDIR_X11,$(STAGING_DIR)/lib/ $(STAGING_DIR)/usr/lib/,$(@D))
+endef
+endif
 
 ifneq ($(BR2_INET_IPV6),y)
 define QT_CONFIGURE_IPV6
@@ -487,6 +522,7 @@ endif
 
 define QT_CONFIGURE_CMDS
 	-[ -f $(@D)/Makefile ] && $(MAKE) -C $(@D) confclean
+	$(QT_CONFIGURE_MKSPECS)
 	$(QT_CONFIGURE_IPV6)
 	$(QT_CONFIGURE_CONFIG_FILE)
 	# Fix compiler path
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 1/1 Qt4: adapt for X11

Dear C?dric Ch?pied,

Great! X11 support in qt4 is definitely something nice to have!

package/qt/Config.in menuconfig BR2_PACKAGE_QT · line 19

Quoted 2 lines · C?dric Ch?pied
package/qt/Config.in +2 -0
+config BR2_PACKAGE_QT_X11
+	bool "X server support"

This should probably "depends on BR2_PACKAGE_XORG7", and it should select all the X.org libraries that this option depends on (fontconfig xlib_libXi xlib_libX11 xlib_libXrender xlib_libXcursor xlib_libXinerama xlib_libXrandr xlib_libXext xlib_libXv).

package/qt/Config.in menuconfig BR2_PACKAGE_QT · line 20

Quoted 1 line
package/qt/Config.in +1 -0
+	default n

Not needed, that's the default.

package/qt/Config.in menuconfig BR2_PACKAGE_QT · line 22

Quoted 2 lines
package/qt/Config.in +2 -0
+	help
+	  Build Qt with X11 support

Also, there is already a choice of possible graphics backend in Config.gfx.in. But I understand that there is actually a two-level choice:

* The normal Qt, for X11 support
* The embedded Qt, for framebuffer, VNC, DirectFB, PowerVR support

Many we should reflect this choice in the Config.in menu.

package/qt/Config.in config BR2_PACKAGE_QT_GUI_MODULE · line 105

Quoted 9 lines
package/qt/Config.in +2 -0
+
 config BR2_PACKAGE_QT_DEBUG
 	bool "Compile with debug support"
 	help
@@ -96,6 +102,7 @@ config BR2_PACKAGE_QT_GUI_MODULE
 	  video output, or you don't require Qt GUI, say n.
 
 if BR2_PACKAGE_QT_GUI_MODULE
+if !BR2_PACKAGE_QT_X11

And if we have the "choice" I described above, make this a positive if rather than the negative one you have now.

package/qt/Config.in config BR2_PACKAGE_QT_SYSTEMFREETYPE · line 189

Quoted 11 lines
package/qt/Config.in +1 -0
 menu "Pixel depths"
 comment "Deselecting each option leads to Qt's default (8,16,32)"
 
@@ -176,6 +183,7 @@ config BR2_PACKAGE_QT_SYSTEMFREETYPE
 	  Use shared libfreetype from the target system.
 	  See http://www.freetype.org/
 endchoice
+endif # !BR2_PACKAGE_QT_X11
 
 config BR2_PACKAGE_QT_GIF
 	bool "Enable GIF support"

From the Config.in side, I'm wondering why you're not touching Config.gfx.in and how it is included. I believe that in the X11-capable Qt, we can't enable framebuffer support and so on. Can we?

Quoted 16 lines
package/qt/qt.mk +4 -0
index bc329f0..1fb350c 100644
@@ -111,6 +111,10 @@ ifneq ($(QT_PIXEL_DEPTHS),)
 QT_CONFIGURE_OPTS += -depths $(subst $(space),$(comma),$(strip $(QT_PIXEL_DEPTHS)))
 endif
 
+ifneq ($(BR2_PACKAGE_QT_X11),y)
+### Embedded options
+QT_CONFIGURE_OPTS += -no-gfx-qnx -no-kbd-qnx -no-mouse-qnx
+
 ### Display drivers
 ifeq ($(BR2_PACKAGE_QT_GFX_LINUXFB),y)
 QT_CONFIGURE_OPTS += -qt-gfx-linuxfb

package/qt/qt.mk else · line 207

Quoted 7 lines
package/qt/qt.mk +4 -0
@@ -197,6 +201,12 @@ else
 QT_CONFIGURE_OPTS += -no-kbd-qvfb
 endif
 
+else
+### X11 options
+QT_CONFIGURE_OPTS += -no-gtkstyle -no-openvg -no-glib --disable-script
+endif

It would be better to use some positive logic here for the test. So either you completely invert the two cases, or thanks to the "choice" I'm mentioning above, you can turn this into positive logic.

Also, why is the glib support always disable in the X11 case?

The --disable-script option looks weird since all options have only one "-" at the beginning, and this one has two.

package/qt/qt.mk else · line 252

Quoted 13 lines
package/qt/qt.mk +5 -0
+
+
 ifeq ($(BR2_PACKAGE_QT_DEBUG),y)
 QT_CONFIGURE_OPTS += -debug
 else
@@ -236,7 +246,12 @@ else
 QT_EMB_PLATFORM = generic
 endif
 
+ifneq ($(BR2_PACKAGE_QT_X11),y)
 QT_CONFIGURE_OPTS += -embedded $(QT_EMB_PLATFORM)
+else
+QT_CONFIGURE_OPTS += -xplatform linux-$(QT_EMB_PLATFORM)-g++ -v

Is the "-v" really really to X11.

package/qt/qt.mk else · line 254

Quoted 2 lines
package/qt/qt.mk +2 -0
+QT_DEPENDENCIES   += fontconfig xlib_libXi xlib_libX11 xlib_libXrender xlib_libXcursor xlib_libXinerama xlib_libXrandr xlib_libXext xlib_libXv
+endif

Again, some positive logic would be good here. And probably you can group this with the test case above.

package/qt/qt.mk endif · line 474

Quoted 11 lines
package/qt/qt.mk +3 -0
 ifneq ($(BR2_PACKAGE_QT_GUI_MODULE),y)
 QT_CONFIGURE_OPTS += -no-gui
@@ -453,7 +468,11 @@ endif
 # End of workaround.
 
 # Variable for other Qt applications to use
+ifneq ($(BR2_PACKAGE_QT_X11),y)
 QT_QMAKE = $(HOST_DIR)/usr/bin/qmake -spec qws/linux-$(QT_EMB_PLATFORM)-g++
+else
+QT_QMAKE:=$(HOST_DIR)/usr/bin/qmake -spec linux-$(QT_EMB_PLATFORM)-g++

Use = and not :=.

Quoted 9 lines
package/qt/qt.mk +2 -0
+endif
 
 ################################################################################
 # QT_QMAKE_SET -- helper macro to set <variable> = <value> in
@@ -467,10 +486,26 @@ QT_QMAKE = $(HOST_DIR)/usr/bin/qmake -spec qws/linux-$(QT_EMB_PLATFORM)-g++
 # E.G. use like this:
 # $(call QT_QMAKE_SET,variable,value,directory)
 ################################################################################
+ifneq ($(BR2_PACKAGE_QT_X11),y)

package/qt/qt.mk QT_QMAKE = $(HOST_DIR)/usr/bin/qmake -spec qws/linux-$(QT_EMB_PLATFORM)-g++ · line 499

Quoted 10 lines
package/qt/qt.mk +6 -0
 define QT_QMAKE_SET
 	$(SED) '/$(1)/d' $(3)/mkspecs/qws/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
 	$(SED) '/include.*qws.conf/a$(1) = $(2)' $(3)/mkspecs/qws/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
 endef
+else
+define QT_QMAKE_SET
+	$(SED) '/$(1)/d' $(3)/mkspecs/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
+	$(SED) '/load(qt_config)/i$(1) = $(2)' $(3)/mkspecs/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
+endef
+endif

Instead of redefining the macro completely, what about making the path to the qmake.conf file a variable, and change it depending on whether you're building X11 or not.

package/qt/qt.mk QT_QMAKE = $(HOST_DIR)/usr/bin/qmake -spec qws/linux-$(QT_EMB_PLATFORM)-g++ · line 503

Quoted 4 lines
package/qt/qt.mk +4 -0
+
+ifeq ($(BR2_PACKAGE_QT_X11),y)
+define QT_CONFIGURE_MKSPECS
+	cp -R $(@D)/mkspecs/linux-g++ $(@D)/mkspecs/linux-$(QT_EMB_PLATFORM)-g++

Hum, why?

package/qt/qt.mk QT_QMAKE = $(HOST_DIR)/usr/bin/qmake -spec qws/linux-$(QT_EMB_PLATFORM)-g++ · line 506

Quoted 3 lines
package/qt/qt.mk +3 -0
+	$(call QT_QMAKE_SET,QMAKE_INCDIR_X11,$(STAGING_DIR)/usr/X11R6/include,$(@D))
+	$(call QT_QMAKE_SET,QMAKE_LIBDIR,$(STAGING_DIR)/lib/ $(STAGING_DIR)/usr/lib/,$(@D))
+	$(call QT_QMAKE_SET,QMAKE_LIBDIR_X11,$(STAGING_DIR)/lib/ $(STAGING_DIR)/usr/lib/,$(@D))

Ok, but move these into a variable named QT_CONFIGURE_X11_MKSPECS

package/qt/qt.mk endif · line 528

Quoted 13 lines
package/qt/qt.mk +3 -0
+endef
+endif
 
 ifneq ($(BR2_INET_IPV6),y)
 define QT_CONFIGURE_IPV6
@@ -487,6 +522,7 @@ endif
 
 define QT_CONFIGURE_CMDS
 	-[ -f $(@D)/Makefile ] && $(MAKE) -C $(@D) confclean
+	$(QT_CONFIGURE_MKSPECS)
 	$(QT_CONFIGURE_IPV6)
 	$(QT_CONFIGURE_CONFIG_FILE)
 	# Fix compiler path

Thanks a lot!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com