make xconfig no longer works in Fedora
Hi Thiago,
I noticed that with your patch "Update the buildsystem for KConfig finding Qt" I cannot use "make xconfig" in Fedora 22 any longer.
That's what I'm seeing:
-------------------->8---------------------
$ make xconfig CHECK qt /bin/sh: line 1: qmake: command not found * * qmake failed. * make[1]: *** No rule to make target 'scripts/kconfig/.tmp_qtcheck', needed by 'scripts/kconfig/qconf.o'. Stop. Makefile:547: recipe for target 'xconfig' failed make: *** [xconfig] Error 2 -------------------->8---------------------
The reason why xconfig target fails is in Fedora (at least its recent versions) there's no "qmake". Instead there're "qmake-qt4" and/or "qmake-qt5" depending on which Qt packages are installed.
I understand that there're plenty of possible workarounds like creating an alias qmake -> qmake-qtX, usage of "update-alternatives" etc.
But IMHO it would be really nice if we don't break things that used to work.
Still if I revert the patch in question "make xconfig" works again. And that's because we did autodiscovery of moc like that:
-------------------->8--------------------- moc="\$$(shell pkg-config QtCore --variable=moc_location)"; -------------------->8---------------------
In my case it returns:
-------------------->8---------------------
$ pkg-config QtCore --variable=moc_location /usr/lib64/qt4/bin/moc -------------------->8---------------------
If we do want to use "qmake" directly we may first find it similarly:
-------------------->8---------------------
$ pkg-config QtCore --variable=exec_prefix /usr/lib64/qt4 -------------------->8---------------------
And then add "/bin/qmake" like this:
-------------------->8---------------------
qmake="\$$(shell pkg-config QtCore --variable=exec_prefix""/bin/qmake"; -------------------->8---------------------
Regards, Alexey���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 5 lines · On Saturday 31 October 2015 12:39:21 Alexey Brodkin wrote:
Hi Thiago,
I noticed that with your patch "Update the buildsystem for KConfig finding Qt"
I cannot use "make xconfig" in Fedora 22 any longer.
Hello Alexey
Quoted 4 lines
The reason why xconfig target fails is in Fedora (at least its recent versions)
there's no "qmake". Instead there're "qmake-qt4" and/or "qmake-qt5" depending on which Qt packages are installed.
Hmm... you're right. There's no check for a program with a different name in the new Makefile. I apologise, I never tested that case.
Fedora is knowingly deviating from Qt Project recommendations. I will fix this, but please file a bug report against their Qt packages so there's some pressure to adopt a standard solution that everyone else already does.
Quoted 2 lines
But IMHO it would be really nice if we don't break things that used to work.
Right. Can you try the attached patch to see if it solves the problem for you?
Signature · 2 lines
Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
Quoted 1 line
From
fd7d0a2137ece3294703878fc1667e5196f766b9Mon Sep 17 00:00:00 2001
From: Thiago Macieira <[email protected]>
Date: Sun, 1 Nov 2015 21:12:53 -0600
Subject: [PATCH 1/1] Attempt to find qmake-qt5 and qmake-qt4 if no "qmake" is
found in $PATH
The Qt Project recommendation is that there should always be a "qmake" binary and it should never be renamed. If it's necessary to handle multiple Qt versions, the Qt Project recommends using qtchooser.
Unfortunately, some distros do not follow the recommendation, so we need to test different possibilities...
--- scripts/kconfig/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/kconfig/Makefile +3 -1
@@ -227,7 +227,9 @@ $(obj)/.tmp_qtcheck: $(src)/Makefile # Qt needs some extra effort... $(obj)/.tmp_qtcheck: @set -e; $(kecho) " CHECK qt"; \ - qtver=`qmake -query QT_VERSION` || { \ + qtver=`qmake -query QT_VERSION` || \ + qtver=`qmake-qt5 -query QT_VERSION` || \ + qtver=`qmake-qt4 -query QT_VERSION` || { \ echo >&2 "*"; \ echo >&2 "* qmake failed."; \ echo >&2 "*"; \
Signature · 1 line
2.6.2
scripts/kconfig/Makefile $(obj)/.tmp_qtcheck: $(src)/Makefile · line 232
Quoted 4 lines · Thiago Macieira
scripts/kconfig/Makefile +3
-1- qtver=`qmake -query QT_VERSION` || { \ + qtver=`qmake -query QT_VERSION` || \ + qtver=`qmake-qt5 -query QT_VERSION` || \ + qtver=`qmake-qt4 -query QT_VERSION` || { \
The qtlibdir= etc assignments below still use qmake directly, plus this will print an error if the command is not called "qmake." As Alexey says, we do not need qmake, we need moc and the cflags / ldflags. Since pkg-config worked for us previously, I suggest to use pkg-config again and just check which of QtGui or Qt5Widgets is available.
Michal
Quoted 11 lines · On Monday 02 November 2015 11:36:43 Michal Marek wrote:
Review
Quoted 4 lines · Thiago Macieira
(quoted diff) +3
-1- qtver=`qmake -query QT_VERSION` || { \ + qtver=`qmake -query QT_VERSION` || \ + qtver=`qmake-qt5 -query QT_VERSION` || \ + qtver=`qmake-qt4 -query QT_VERSION` || { \The qtlibdir= etc assignments below still use qmake directly, plus this will print an error if the command is not called "qmake." As Alexey says, we do not need qmake, we need moc and the cflags / ldflags. Since pkg-config worked for us previously, I suggest to use pkg-config again and just check which of QtGui or Qt5Widgets is available.
Here's an attempt using pkg-config.
Signature · 2 lines
Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
Quoted 1 line
From
b36464e33f102530abe98e0b5e25dee584f50b59Mon Sep 17 00:00:00 2001
From: Thiago Macieira <[email protected]>
Date: Sun, 1 Nov 2015 21:12:53 -0600
Subject: [PATCH 1/1] Use pkg-config to find Qt 4 and 5 instead of direct qmake
The Qt Project recommendation is that there should always be a "qmake" binary and it should never be renamed. If it's necessary to handle multiple Qt versions, the Qt Project recommends using qtchooser.
Unfortunately, some distros do not follow the recommendation, so we would need to check qmake-qt4, qmake-qt5, etc. So, instead, let's try pkg-config.
--- scripts/kconfig/Makefile | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-)
scripts/kconfig/Makefile +13 -24
@@ -227,35 +227,24 @@ $(obj)/.tmp_qtcheck: $(src)/Makefile # Qt needs some extra effort... $(obj)/.tmp_qtcheck: @set -e; $(kecho) " CHECK qt"; \ - qtver=`qmake -query QT_VERSION` || { \ + if pkg-config --exists Qt5Core; then \ + cflags="-std=c++11 -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets`"; \ + libs=`pkg-config --libs Qt5Core Qt5Gui Qt5Widgets`; \ + moc=`pkg-config --variable=host_bins Qt5Core`/moc; \ + elif pkg-config --exists QtCore; then \ + cflags=`pkg-config --cflags QtCore QtGui`; \ + libs=`pkg-config --libs QtCore QtGui`; \ + moc=`pkg-config --variable=moc_location QtCore`; \ + else \ echo >&2 "*"; \ - echo >&2 "* qmake failed."; \ + echo >&2 "* Could not find Qt via pkg-config."; \ + echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH"; \ echo >&2 "*"; \ exit 1; \ - }; \ - qtlibdir=`qmake -query QT_INSTALL_LIBS`; \ - qthdrdir=`qmake -query QT_INSTALL_HEADERS`; \ - qtbindir=`qmake -query QT_INSTALL_BINS`; \ - cflags="-I$$qthdrdir -I$$qthdrdir/QtCore -I$$qthdrdir/QtGui"; \ - case "$$qtver" in \ - 5.*) \ - cflags="$$cflags -I$$qthdrdir/QtWidgets -std=c++11 -fPIC"; \ - libs="-L$$qtlibdir -lQt5Widgets -lQt5Gui -lQt5Core "; \ - ;; \ - 4.*) \ - libs="-L$$qtlibdir -lQtGui -lQtCore"; \ - ;; \ - *) \ - echo >&2 "*"; \ - echo >&2 "* Found qmake but it is for Qt version $$qtver, which is not supported."; \ - echo >&2 "* Please install either Qt 4.8 or 5.x."; \ - echo >&2 "*"; \ - exit 1; \ - ;; \ - esac; \ + fi; \ echo "KC_QT_CFLAGS=$$cflags" > $@; \ echo "KC_QT_LIBS=$$libs" >> $@; \ - echo "KC_QT_MOC=$$qtbindir/moc" >> $@ + echo "KC_QT_MOC=$$moc" >> $@ endif $(obj)/gconf.o: $(obj)/.tmp_gtkcheck
Signature · 1 line
2.6.2
Quoted 13 lines · Thiago Macieira
Quoted 11 lines · On Monday 02 November 2015 11:36:43 Michal Marek wrote:
Review
Quoted 4 lines · Thiago Macieira
(quoted diff) +3
-1- qtver=`qmake -query QT_VERSION` || { \ + qtver=`qmake -query QT_VERSION` || \ + qtver=`qmake-qt5 -query QT_VERSION` || \ + qtver=`qmake-qt4 -query QT_VERSION` || { \The qtlibdir= etc assignments below still use qmake directly, plus this will print an error if the command is not called "qmake." As Alexey says, we do not need qmake, we need moc and the cflags / ldflags. Since pkg-config worked for us previously, I suggest to use pkg-config again and just check which of QtGui or Qt5Widgets is available.
Quoted 1 line
Here's an attempt using pkg-config.
Works for me on openSUSE, it just started to prefer Qt5 now. But it correctly builds against Qt4 if Qt5 is not available.
Michal
Quoted 14 lines · On Monday 02 November 2015 16:50:33 Michal Marek wrote:
Quoted 13 lines · Thiago Macieira
Quoted 11 lines · On Monday 02 November 2015 11:36:43 Michal Marek wrote:
Review
Quoted 4 lines · Thiago Macieira
(quoted diff) +3
-1- qtver=`qmake -query QT_VERSION` || { \ + qtver=`qmake -query QT_VERSION` || \ + qtver=`qmake-qt5 -query QT_VERSION` || \ + qtver=`qmake-qt4 -query QT_VERSION` || { \The qtlibdir= etc assignments below still use qmake directly, plus this will print an error if the command is not called "qmake." As Alexey says, we do not need qmake, we need moc and the cflags / ldflags. Since pkg-config worked for us previously, I suggest to use pkg-config again and just check which of QtGui or Qt5Widgets is available.
Quoted 4 lines
Quoted 1 line
Here's an attempt using pkg-config.
Works for me on openSUSE, it just started to prefer Qt5 now. But it correctly builds against Qt4 if Qt5 is not available.
That's a consequence of using pkg-config. Now you can no longer choose your preferred Qt version by setting QT_SELECT, like the qmake solution would have allowed, as recommended by the Qt Project. At least, the qtchooser shell function extension does set PKG_CONFIG_PATH, so if you install a different version elsewhere, that version should be picked up.
It would have been the same with CMake too, btw.
Alexey, did this solve the problem for you?
Signature · 2 lines
Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
Quoted 15 lines · Thiago Macieira
Quoted 14 lines · On Monday 02 November 2015 16:50:33 Michal Marek wrote:
Quoted 13 lines · Thiago Macieira
Quoted 11 lines · On Monday 02 November 2015 11:36:43 Michal Marek wrote:
Review
Quoted 4 lines · Thiago Macieira
(quoted diff) +3
-1- qtver=`qmake -query QT_VERSION` || { \ + qtver=`qmake -query QT_VERSION` || \ + qtver=`qmake-qt5 -query QT_VERSION` || \ + qtver=`qmake-qt4 -query QT_VERSION` || { \The qtlibdir= etc assignments below still use qmake directly, plus this will print an error if the command is not called "qmake." As Alexey says, we do not need qmake, we need moc and the cflags / ldflags. Since pkg-config worked for us previously, I suggest to use pkg-config again and just check which of QtGui or Qt5Widgets is available.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Here's an attempt using pkg-config.
Works for me on openSUSE, it just started to prefer Qt5 now. But it correctly builds against Qt4 if Qt5 is not available.
That's a consequence of using pkg-config. Now you can no longer choose your preferred Qt version by setting
QT_SELECT, like the qmake solution would have allowed, as recommended by the Qt Project.
Yeah, but I think this is acceptable for an application like qconf. Use best effort to build against some Qt version to let the user configure their kernel.
Michal
Hi Thiago,
Quoted 26 lines · Thiago Macieira
Quoted 14 lines · On Monday 02 November 2015 16:50:33 Michal Marek wrote:
Quoted 13 lines · Thiago Macieira
Quoted 11 lines · On Monday 02 November 2015 11:36:43 Michal Marek wrote:
Review
Quoted 4 lines · Thiago Macieira
(quoted diff) +3
-1- qtver=`qmake -query QT_VERSION` || { \ + qtver=`qmake -query QT_VERSION` || \ + qtver=`qmake-qt5 -query QT_VERSION` || \ + qtver=`qmake-qt4 -query QT_VERSION` || { \The qtlibdir= etc assignments below still use qmake directly, plus this will print an error if the command is not called "qmake." As Alexey says, we do not need qmake, we need moc and the cflags / ldflags. Since pkg-config worked for us previously, I suggest to use pkg-config again and just check which of QtGui or Qt5Widgets is available.
Quoted 4 lines
Quoted 1 line
Here's an attempt using pkg-config.
Works for me on openSUSE, it just started to prefer Qt5 now. But it correctly builds against Qt4 if Qt5 is not available.
That's a consequence of using pkg-config. Now you can no longer choose your preferred Qt version by setting
QT_SELECT, like the qmake solution would have allowed, as recommended by the Qt Project. At least, the qtchooser shell function extension does setPKG_CONFIG_PATH, so if you install a different version elsewhere, that version should be picked up.
Quoted 3 lines
It would have been the same with CMake too, btw.
Alexey, did this solve the problem for you?
Yep, thanks a lot.
"make xconfig" now works for me!
-Alexey���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Dne 2.11.2015 v 17:28 Alexey Brodkin napsal(a):
Quoted 5 lines · Thiago Macieira
Quoted 1 line
Alexey, did this solve the problem for you?
Yep, thanks a lot.
"make xconfig" now works for me!
Thanks for testing, I will apply it to kbuild.git#kconfig.
Thanks,
Michal
Hi Michal,
Quoted 8 lines · Michal Marek
Dne 2.11.2015 v 17:28 Alexey Brodkin napsal(a):
Quoted 5 lines · Thiago Macieira
Quoted 1 line
Alexey, did this solve the problem for you?
Yep, thanks a lot.
"make xconfig" now works for me!Thanks for testing, I will apply it to kbuild.git#kconfig.
Thank you for doing this.
Feel free to add "Acked-by: Alexey Brodkin <[email protected]>"
-Alexey���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�