Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
use $(INSTALL) instead of 'cp' in Makefiles #5219
Original bug ID: 5219
The "make install" target does not set proper file permissions on the installed files. Moreover, there is no easy way to fix the permissions once they are messed up.
Suppose some user uses umask 0007, and root uses umask 0022. It is normal to compile the program as an ordinary user, and to install it later as root. Therefore, during compilation, files are generated with umask 0007. Since "make install" uses a simple "cp" to copy most files, this umask 0007 is preserved during installation, and root's umask 0022 is not used. The installed files (owned by root) are therefore not readable by non-root users.
Moreover, once installed, an attempt to correct this problem by re-compiling with a different umask will fail. Suppose the user changes her umask to 0022, and re-compiles from a fresh copy of the sources. Now "make install", run as root, will still use "cp", and since the target file already exists, the permissions of the target file, and not the source file, will be used!! Therefore the files will still not be readable.
Moreover, since there is no "make uninstall" target, there is no simple way to find all the installed files and correct their permissions manually.
Solution: the make system should use $(INSTALL) instead of 'cp', 'cp -f', etc.
Comment author: gerd
Note that there are several versions of install (still). Because of this one should at least have the option to set the path of the install binary in the configure script.
In GODI we added a godi_install program to handle this issue, which always provides a BSD-compatible install. Maybe this is also a way to get here around this difficulty, just add a comparable program to the ocaml distribution.
Comment author: @gasche
I propose a new patch to do this in
I believe that my patch uses 'install' in a portable way, that should work on all the systems we support (Linux distributions use the version from GNU coreutiles, Windows seems to use linux-compatible cygwin tools, and OSX and BSDs use a BSD install):