Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make use of the INSTALL_ROOT that resides in generated Makefiles?

Tags:

qt

qmake

qmake generates the following (among the others) rule for installing a target:

-$(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(TARGET)"

I cannot set INSTALL_ROOT with something like this in a *.pro file

isEmpty(INSTALL_ROOT) {
    INSTALL_ROOT=/usr
}

because INSTALL_ROOT is somehow local to generated Makefiles. According to what I've found out so far INSTALL_ROOT is empty by default. It could be used like

INSTALL_ROOT=$HOME make install

when invoking make, which is fine. However I want to be able to specify default installation root, say /usr. I can do it introducing a new variable PREFIX as suggested here. Then generated rule will look like (if PREFIX was set to /usr)

-$(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/usr/$(TARGET)"

however

INSTALL_ROOT=$HOME make install

installs target to /home/<user_name>/usr/$(TARGET) which is not that one would expect.

So setting INSTALL_ROOT to some default value will produce consistent behavior, which is superior to adding PREFIX, but how to set INSTALL_ROOT in a *.pro file?

What is the purpose of INSTALL_ROOT is it supposed to be used at all?

like image 818
Roman Byshko Avatar asked Dec 02 '11 18:12

Roman Byshko


1 Answers

INSTALL_ROOT is for use with package building systems, like NSIS, debian, or any other way for parcelling up built software and delivering it.

For this purpose you want the result of

INSTALL_ROOT=$PWD/package_root make install

to create a tree under $PWD/package_root that exactly mimics that on your target system you plan to deliver to. Note that you need INSTALL_ROOT to be a full path (hence the $PWD), not a relative path.

When you create your package you can compress that tree into an archive and then your installation process simply uncompresses the same tree on to the target file-system.

$PWD/package_root/usr/bin/my_binary

would get installed to

/usr/bin/my_binary

on the target.

So that is the answer to the question what INSTALL_ROOT is for. To answer how to specify "default installation root" requires more information about what you want to achieve.

Have a look at the output of qmake -query:

[email protected]:~$ qmake -query
QT_INSTALL_PREFIX:/usr
QT_INSTALL_DATA:/usr/share/qt4
QT_INSTALL_DOCS:/usr/share/qt4/doc
QT_INSTALL_HEADERS:/usr/include/qt4
QT_INSTALL_LIBS:/usr/lib/i386-linux-gnu
QT_INSTALL_BINS:/usr/bin
<snipped>
QT_VERSION:4.7.4

and the use of the INSTALLS variable in qmake: http://doc.qt.digia.com/qt/qmake-environment-reference.html#installs - and How do I specify input the QMake INSTALLS variable?

By default if you just do

target.path = $$[QT_INSTALL_BINS]
INSTALLS += target

Then your binary will get installed in whatever qt thinks is the right place, QT_INSTALL_BINS. You can change those defaults of course by setting target.path to something else. Qt supplies those paths but its up to you to use them or not.

You could do

MY_DEFAULT_INSTALL=/opt/myproj

somedocs.files = docs/index.html
somedocs.path = $$MY_DEFAULT_INSTALL/docs

target.path = $$MY_DEFAULT_INSTALL/bin

INSTALLS += somedocs target

for example, where MY_DEFAULT_INSTALL is the one place in your .pro file that defines the default for installs.

like image 112
Sez Avatar answered Sep 25 '22 14:09

Sez