0

Suppose I want to install a package under /opt, which of the three should be appended with "prefix"? I read a few materials and still am very confused. Thank you.

In which command(s) should I add the location?

./configure prefix=/opt
make prefix=/opt
make prefix=/opt install

jww
  • 97,681
  • 90
  • 411
  • 885
qitian ma
  • 25
  • 4
  • 1
    Possible duplicate of [Linux configure/make, --prefix?](https://stackoverflow.com/q/8902698/608639) Also see questions like [Configuring install path: prefix=\[PREFIX\] not fully understood](https://stackoverflow.com/q/36998572/608639) and [What does --prefix do exactly when used in ./configure?](https://askubuntu.com/q/891835). – jww Sep 29 '19 at 19:15
  • The command is `./configure --prefix=/opt/` . ... I.e. you are missing the two hyphens before prefix. ... See `./configure --help` – Knud Larsen Sep 29 '19 at 21:51

1 Answers1

0

An Autotools-based build system affords you two main alternatives: you may specify the installation prefix (and other installation locations) either at configuration time or at build time.

To specify at configuration time, you use the --prefix option to the configure script, as ./configure --help will describe to you. For example,

./configure --prefix=/opt/mypackage

Typically, one then proceeds with unadorned

make
sudo make install

To specify at build time, you configure without the --prefix option, maybe simply

./configure

then you specify the prefix via the corresponding make variable. It might in some cases suffice to specify it only to make install, but in others you need to specify it to both make runs, so it is wisest to adopt that as a general rule:

make prefix=/opt/mypackage
sudo make install prefix=/opt/mypackage

I note also that nothing should be installed directly in /opt -- that is, /opt/bin, /opt/lib, etc. It ought instead to be installed in per-package subdirectories of /opt, possibly even grouped under provider-associated subdirectories.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157