Sérgio
Sérgio

Reputation: 7249

Modify $PATH from configure.ac

I need add /usr/lib64/qt5/bin to $PATH in configure.ac where /usr/lib64/qt5/bin is the result of:

pkg-config --variable=host_bins Qt5Core 

What is the correct way?

From [1] it says "Searches $PATH and queries qmake" but qmake is not in default $PATH , because we may have qmake for qt4 and qmake for qt5, but it is in $PATH qmake-qt5 . How I make configure.ac find qmake for qt5 or qmake-qt5 ?

[1] https://www.gnu.org/software/autoconf-archive/ax_have_qt.html

Upvotes: 0

Views: 443

Answers (1)

John Bollinger
John Bollinger

Reputation: 180048

I need add /usr/lib64/qt5/bin to $PATH in configure.ac where /usr/lib64/qt5/bin is the result of:

pkg-config --variable=host_bins Qt5Core 

What is the correct way?

The configure program generated from configure.ac is a shell script. It can put that directory in its own path, so that AX_HAVE_QT works correctly, via ordinary shell syntax. You can express that directly in configure.ac. There are third-party macros for using pkg-config, and something along those lines might be more portable for that bit, but the simplest approach would be something like this:

QT5BIN_PATH=$(pkg-config --variable=host_bins Qt5Core)
# ... check for error / validate result ...
PATH=${QT5BIN_PATH}:${PATH}
export PATH

You would want to do that before AX_HAVE_QT.

That will not modify the path for make and the commands it executes, but you will have the correct flags, and you will have full paths by which to run the various tools discovered by AX_HAVE_QT. If you want to export the discovered path itself to make or to templated files built by AC_CONFIG_FILES, then you can additionally make QT5BIN_PATH an output variable:

AC_OUTPUT([QT5BIN_PATH])

Upvotes: 1

Related Questions