LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Determine install folder when building from source (https://www.linuxquestions.org/questions/linux-newbie-8/determine-install-folder-when-building-from-source-922165/)

mrpc_cambodia 01-05-2012 03:52 AM

Determine install folder when building from source
 
Hi,

When building binary from source using make command line, is it possible to know the destination directory that all files will be copied to when running make install?

I suppose a few lines in the makefile will indicate this. Someone tells I could check then value of these variable prefix and exec_prefix, but what i've found is only this:

prefix = @prefix@
exec_prefix = @exec_prefix@

Don't really know what does it mean?


Thanks,

mrpc_cambodia

tronayne 01-05-2012 07:04 AM

By default most software you download and build with configure, make, make install will be installed in /usr/local -- and that's not a bad idea.

You can override the default when you execute configure. The easy way to find out what the options are is to do this:
Code:

configure --help | more
You'll see
Code:


Usage: configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version          display version information and exit
  -q, --quiet, --silent  do not print `checking...' messages
      --cache-file=FILE  cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create        do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX        install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX  install architecture-dependent files in EPREFIX
                          [PREFIX]


By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.


For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR          user executables [EPREFIX/bin]
  --sbindir=DIR          system admin executables [EPREFIX/sbin]
  --libexecdir=DIR      program executables [EPREFIX/libexec]
  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
  --sysconfdir=DIR      read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR  modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
  --libdir=DIR          object code libraries [EPREFIX/lib]
  --includedir=DIR      C header files [PREFIX/include]
  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
  --infodir=DIR          info documentation [PREFIX/info]
  --mandir=DIR          man documentation [PREFIX/man]

You really only need to set PREFIX to some other tree if you want to do that; however, installing "add-on" software in /usr/local (the default) is so that you don't mix your distributed software (what you installed) with additional software; it makes it easier to keep track of what you've added.

Hope this helps some.

mrpc_cambodia 01-05-2012 09:45 AM

Thanks for the comment.

But I am really curious about the value @prefix@ that is assigned to the prefix variable in my case. What does it really mean?

Mrpc_cambodia

tronayne 01-05-2012 11:44 AM

Oh, sorry about that -- the @ as the first character on a line in a Makefile prevents the command from being echoed.

Also,
Quote:

14.5 Variables for Installation Directories

Installation directories should always be named by variables, so it is easy to install in a nonstandard place. The standard names for these variables and the values they should have in GNU packages are described below. They are based on a standard file system layout; variants of it are used in GNU/Linux and other modern operating systems.

Installers are expected to override these values when calling make (e.g., make prefix=/usr install or configure (e.g., configure --prefix=/usr). GNU packages should not try to guess which value should be appropriate for these variables on the system they are being installed onto: use the default settings specified here so that all GNU packages behave identically, allowing the installer to achieve any desired layout.

All installation directories, and their parent directories, should be created (if necessary) before they are installed into.

These first two variables set the root for the installation. All the other installation directories should be subdirectories of one of these two, and nothing should be directly installed into these two directories.

prefix
A prefix used in constructing the default values of the variables listed below. The default value of prefix should be /usr/local. When building the complete GNU system, the prefix will be empty and /usr will be a symbolic link to /. (If you are using Autoconf, write it as ‘@prefix@’.)

Running ‘make install’ with a different value of prefix from the one used to build the program should not recompile the program.
exec_prefix
A prefix used in constructing the default values of some of the variables listed below. The default value of exec_prefix should be $(prefix). (If you are using Autoconf, write it as ‘@exec_prefix@’.)

Generally, $(exec_prefix) is used for directories that contain machine-specific files (such as executables and subroutine libraries), while $(prefix) is used directly for other directories.

Running ‘make install’ with a different value of exec_prefix from the one used to build the program should not recompile the program.
See the entire section at http://www.gnu.org/software/make/man...tory-Variables.

Hope this helps some.

mrpc_cambodia 01-05-2012 09:17 PM

Make is the command to compile source into binary. I wonder if it's possible to inspect what's has been compiled, ex: binary, lib, etc.. before running the "make install" command so that I know what will be copied to my computer?


Thanks,

tronayne 01-06-2012 04:30 AM

You can read through the Makefile to see what is being "made" and what's going to happen to it; you ought to start, however, with The Gnu Make Manual, http://www.gnu.org/software/make/manual/ (this may be on your system as an info document).

You can execute make with (from the man make page)
Code:

-n, --just-print, --dry-run, --recon
Print the commands that would be executed, but do not execute them (except in certain circumstances).

Hope this helps some.


All times are GMT -5. The time now is 06:43 PM.