- Make install, but not to default directories?
- 7 Answers 7
- unixforum.org
- Когда делаешь .configure && make && make install, куда устанавливается программа?
- Когда делаешь .configure && make && make install, куда устанавливается программа?
- Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
- Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
- Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
- Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
- Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
- What files did `make install` copy, and where?
- 6 Answers 6
- «make install» — Changing output destination for all builds
- 3 Answers 3
Make install, but not to default directories?
I want to run ‘make install’ so I have everything I need, but I’d like it to install the things in their own folder as opposed to the system’s /usr/bin etc. is that possible? even if it references tools in the /usr/bin etc.?
If you have already built the project and you ran ./configure without a prefix and you want to install it in a custom path, see stackoverflow.com/a/17679654/313113
7 Answers 7
It depends on the package. If the Makefile is generated by GNU autotools ( ./configure ) you can usually set the target location like so:
./configure --prefix=/somewhere/else/than/usr/local
If the Makefile is not generated by autotools, but distributed along with the software, simply open it up in an editor and change it. The install target directory is probably defined in a variable somewhere.
The problem i have with —prefix is that if you run a strings on the resulting binary afterwards, you see that the path is stored inside. I don’t know why this happends, but I certainly dont want my machine paths on binaries that I ship to other users.
Erik, it looks like there will be references to the path you run make in anyway, if you build from source.
This is the correct answer if you intend to run the software from the /somewhere/else/than/usr/local . If you instead wish to gather up the files in one directory (in preparation for creating a tarball or install package), but intend for them to eventually be installed and run from elsewhere, set prefix to the final install directory, and use DESTDIR to specify the staging directory.
Since don’t know which version of automake you can use DESTDIR environment variable.
See Makefile to be sure.
export DESTDIR="$HOME/Software/LocalInstall" && make -j4 install
This works when you ran configure without —prefix command line argument and you already built the project but you don’t want to install it in the default locations but instead specify a custom installation path. This will append the default usr/local/bin/ path to the DESTDIR and your project will get installed into $HOME/Software/LocalInstall/usr/local/bin/
This is a brilliant solution. I don’t know why this is not the picked answer! Nearly all the other answers ask to re-configure, which means one needs to re-make also. Imagine having compiled after 2~3 hours the entire MITK superbuild and then be asked to redo it, just because I want to install the compiled files to a different location. This here is a wonderful work around to avoid that situation.
The original question is ambiguous, but I think this answer is actually the correct one. DESTDIR is used to install the files to a specific place while the system is configured for the standard location. gnu.org/software/automake/manual/html_node/DESTDIR.html
@AlexBitek DESTDIR won’t always work in that situation. There may be cases where the software in question uses the —prefix set by configure when generating the contents of it’s files (for example hardcoding the default path to look in for config files). DESTDIR is intended for gathering files into a temporary staging directory which you would use to build tarballs or install packages, and not for running directly out of that directory. It might work, or it might not, or there may be some caveats where the software uses relative paths for somethings, and absolute paths for others.
unixforum.org
Когда делаешь .configure && make && make install, куда устанавливается программа?
Когда делаешь .configure && make && make install, куда устанавливается программа?
Сообщение BashOrgRu » 01.12.2009 21:35
Я имею в виду каталог, из которого компилируешь, или в некую системную папку?
И второй вопрос: как правильно и красиво компилировать из исходников, чтоб не оставалось лишнего мусора?
Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
Сообщение romuil » 01.12.2009 21:38
drBatty Сообщения: 8735 Статус: GPG ID: 4DFBD1D6 дом горит, козёл не видит. ОС: Slackware-current Контактная информация:
Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
Сообщение drBatty » 01.12.2009 21:48
./configure --help less README less INSTALL
arkhnchul Сообщения: 2284 Статус: Толчковый инженер ОС: Debian, Fedora Контактная информация:
Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
Сообщение arkhnchul » 01.12.2009 21:55
в некий системный. В тот, который указан в —prefix при выполнении ./configure, или, если такового не указано, в тот, который прописан в Makefile, а если и такового нет — дистрозависимо (/usr или /usr/local).
Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
Сообщение mailman137 » 02.12.2009 15:15
Имхо, вопрос все же имеет право прозвучать, поскольку не все и не всегда бывает однозначно.
Например, захотелось мне поднять и испытать irc сервер. Навскидку выбрал inspircd,
скачал исходники с сайта разработчика. При запуске ./configure без параметров возник
приятный интерактивый диалог с предожением выбора опций и директорий для установки;
в итоге все было поставлено в ту же директорию, где и компилировалось. Другое дело,
что потом пришлось пыхтеть с конфигурацией. Так что случаи разные бывают.
(приведенный пример — не призыв к подражанию)
Kido Сообщения: 949 Статус: Космический Засланец ОС: ArchLinux x86_64 Current Контактная информация:
Re: Когда делаешь .configure && make && make install, куда устанавливается программа?
Сообщение Kido » 02.12.2009 16:04
Имхо, вопрос все же имеет право прозвучать, поскольку не все и не всегда бывает однозначно.
Например, захотелось мне поднять и испытать irc сервер. Навскидку выбрал inspircd,
скачал исходники с сайта разработчика. При запуске ./configure без параметров возник
приятный интерактивый диалог с предожением выбора опций и директорий для установки;
в итоге все было поставлено в ту же директорию, где и компилировалось. Другое дело,
что потом пришлось пыхтеть с конфигурацией. Так что случаи разные бывают.
(приведенный пример — не призыв к подражанию)
What files did `make install` copy, and where?
Is there a way to get a list of filenames/paths that make install copies to the filesystem? Some packages come with a MANIFEST file, but not the ones that I am working with.
The porg package helps you log the list of files with make install . Uninstalling is as simple as reading the list of files from the porg package log and deleting them.
6 Answers 6
I was just investigating this myself while compiling a custom version of QEMU. I used the following method to work out what was installed and where (as well as using it as a basis for a .deb file):
mkdir /tmp/installer ./configure --target-list=i386-softmmu make sudo make install DESTDIR=/tmp/installer cd /tmp/installer tree .
Tree is a utility that recursively displays the contents of a directory in a visually appealing manner — sudo apt-get install tree for Debian / Ubuntu users
Hope that helps someone. it took me a bit of poking around to nut it out, but I found it quite a useful way of visualising what was going on.
ls -R (along with whatever other formatting options you want) and the -printf option to GNU find are also relevant to answering the «what’s in this directory» question.
The most fool-proof way is to use chroot: have «make install» run inside a chroot jail; compute a list of the files that you had before the installation, and compare that to the list of files after the installation.
Many installations will support either a —prefix configuration option, and/or a DESTDIR environment variable. You can use those for a lighter-wait version of chroot (trusting that the installation will fail if it tries to write to a location outside these if you run installation as a fairly unprivileged user).
Another approach is to replace the install program. Many packages support an INSTALL environment variable that, well, is the install program to use; there are tracing versions of install around.
«make install» — Changing output destination for all builds
I am doing Linux development on a few machines, mainly Slackware 13.37 and Ubuntu 12.04. I am testing and validating the results of a few simple makefiles, and want to confirm the output of make install . However, before I go ahead testing this, I want to know if there is a portable means of changing the default output destination for make install for any makefile. I would prefer if I could somehow stage my output, so all output goes to, for example:
/test/bin /test/lib /test/usr/bin
I know that in QNX development environments, for example, I can set environment variables like QCONF_OVERRIDE and INSTALL_ROOT_nto , and guarantee that no makefile is able to install anywhere other than a subdirectory of /test for example. Is there a similar mechanism for GCC on Ubuntu that just requires setting some environment variables in my ~/.bashrc file? I do all my work via command-line and VIM anyways, so I’m not worried about the case where a pretty IDE doesn’t understand these environment variables due to them not being in a .kderc , .gnomerc , or equivalent. Thank you.
That won’t work; —prefix is not a valid flag to make . To answer the original question, no, there is no variable you can set that will guarantee that regardless of the makefile. Whether there’s a way to do this or not is a function of the makefile. If the makefile has a way to do it you can; if it doesn’t you can’t. However virtually every makefile does have a way to do it.
OK. It’s kind of a shame this isn’t a distribution-independent thing that can be managed, especially given how GCC has been coupled with Linux since its early days (I started on Slackware 3.0). QNX does this beautifully, and allows you to even override cases where the make install target explicitly attempts to install to an absolute path just by setting some environment variables in a script sourced by all users at logon.
3 Answers 3
Short answer: no.
There isn’t a way to set the output destination for any Makefile; the Makefile or some other part of the build system has to be designed to make it possible. make is a very simple tool because it’s intended to function identically across a wide variety of platforms. Consequently, it doesn’t really use environment variables that aren’t present in the Makefile itself. This is good in terms of environment pollution and for keeping things less magic, but bad for achieving your desired goal.
A bit of context: things are a bit more complicated in part because, unlike the QNX development environment (a largely homogeneous cross-compilation environment), a large portion of software that uses make (I’m assuming GNU make but this applies to other versions as well) to build is written for a heterogeneous build and run environment—it may be designed to be able to build for different distributions, operating systems (Linux, MS Windows, Mac OS X, FreeBSD, etc.), and even hardware architecture (x86, arm, mips, power, sparc, sh, etc.). Sometimes you’re building for the same system and sometimes for a different one. Unsurprisingly, there isn’t really a standard way to define an install path across such a variety of systems.
Basile mentioned in his answer that for programs that use the GNU build system, you can use ./configure —prefix=/test . This will typically work for simple programs that use Autotools. For more complicated programs using GNU Autotools, there are usually complications if more diverse options are available:
- cross-compiling? You might want your prefix to be set to where it’s going to be installed on the target system (maybe /usr/local), and to use make install DESTDIR=/test .
- Does your build system expect dependencies in the prefix directory, but you want to find them elsewhere? Better run ./configure —help to see what other options there are for providing alternate paths (often —with-foo=/prefix/of/foo )
I’m sure there’s more that I’m forgetting right now, but I think you get the picture.
Keep in mind that only applies to projects that use Autotools. Other projects may have other systems (perhaps naming a variable or editing a configuration file), so ultimately your best bet is to read the project documentation, and failing that, the Makefile. Fun, eh?
P.S. Having variables defined in the environment is different than passing them as a command argument to make , i.e. SPAM=»alot» make target is different from make target SPAM=»alot» —the latter will override makefile variables. See the GNU make docs on Variables from the Environment.