PDA

View Full Version : qmake INSTALLS creates dangerous makefile



whites11
17th January 2010, 10:06
Hi all.
i have a qmake project file that is generating a strange Makefile.

the interesting part of the .pro is:

headers.path = /usr/local/include/gdata
headers.files = common/*.h contacts/*.h

binaries.path = /usr/local/lib
binaries.files = libgdata.so*

INSTALLS += headers binaries

and here is the generated Makefile (only interesting part):

####### Install

install_headers: first FORCE
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/local/include/gdata/ || $(MKDIR) $(INSTALL_ROOT)/usr/local/include/gdata/
# MORE FILES HERE
-$(INSTALL_FILE) /home/whites/qtcreator/workspace/libgdata-cpp/contacts/webrequestmanager.h $(INSTALL_ROOT)/usr/local/include/gdata/


uninstall_headers: FORCE
-$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/include/gdata/httprequestmanager.h
#MORE FILES HERE
-$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/include/gdata/webrequestmanager.h
-$(DEL_DIR) $(INSTALL_ROOT)/usr/local/include/gdata/


install_binaries: first FORCE
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/usr/local/lib/ || $(MKDIR) $(INSTALL_ROOT)/usr/local/lib/
-$(INSTALL_PROGRAM) /home/whites/qtcreator/workspace/libgdata-cpp/libgdata.so $(INSTALL_ROOT)/usr/local/lib/
-$(INSTALL_PROGRAM) /home/whites/qtcreator/workspace/libgdata-cpp/libgdata.so.0 $(INSTALL_ROOT)/usr/local/lib/
-$(INSTALL_PROGRAM) /home/whites/qtcreator/workspace/libgdata-cpp/libgdata.so.0.0 $(INSTALL_ROOT)/usr/local/lib/
-$(INSTALL_PROGRAM) /home/whites/qtcreator/workspace/libgdata-cpp/libgdata.so.0.0.1 $(INSTALL_ROOT)/usr/local/lib/


uninstall_binaries: FORCE
-$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/lib/libgdata.so
-$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/lib/libgdata.so.0
-$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/lib/libgdata.so.0.0
-$(DEL_FILE) -r $(INSTALL_ROOT)/usr/local/lib/libgdata.so.0.0.1
-$(DEL_DIR) $(INSTALL_ROOT)/usr/local/lib/


install: install_headers install_binaries FORCE

uninstall: uninstall_headers uninstall_binaries FORCE

FORCE:

the installation part is ok, but the uninstall is not, because of this line:


-$(DEL_DIR) $(INSTALL_ROOT)/usr/local/lib/

of course this line is not a good idea.
where's the problem?

wysota
17th January 2010, 19:12
Why is it not a good idea?

whites11
17th January 2010, 20:12
your question makes me think that i misunderstood the sense of that line.
in my mind, when i call "make uninstall" i expect to get this executed:


rm -rf /usr/local/lib/

which is not good, because /usr/local/lib may contain other files than the ones installed by make install.

is this wrong?

wysota
17th January 2010, 20:26
It's more likely you will get "rmdir /usr/local/lib" which is quite safe.

whites11
18th January 2010, 14:17
hi.
i verified and you're right.

DEL_DIR = rmdir

so that command is perfectly safe

thanks :)

33333
6th July 2014, 04:43
Actually this bit me in the arse. I used:


etc.files = conf/*
etc.path = etc/


Where conf/ dir had a partial subtree of directories to deploy to etc/ like `init.d/`. On uninstall Qt rm my `/etc/init.d/` :).