DESTDIR and PREFIX of make

来源:互联网 发布:谷雨软件下载 编辑:程序博客网 时间:2024/06/10 14:46


up vote38down votefavorite
18

I am trying to make software install to a specific directory. I found several ways, but not sure what are the differences between them.

  1. ./configure --prefix=*
  2. make install --prefix=*
  3. make install DESTDIR=*

I am confused about the functions of these three. Do they achieve the same goal? Thanks.

shareimprove this question
 
 
For the second one, I am not sure either. Some page says "make install PREFIX", while others say "make install prefix" and "make install --prefix". I have not tried them yet. –  Sean Jul 3 '12 at 9:28

1 Answer

activeoldestvotes
up vote64down voteaccepted

Number 2 is simply an error as far as I know.

Number 1 determines where the package will go when it is installed, and where it will look for its associated files when it is run. It's what you should use if you're just compiling something for use on a single host.

Number 3 is for installing to a temporary directory which is not where the package will be run from. For example this is used when building deb packages. The person building the package doesn't actually install everything into its final place on his own system. He may have a different version installed already and not want to disturb it, or he may not even be root. So he uses configure --prefix=/usr so the program will expect to be installed in /usr when it runs, then make install DESTDIR=debian/tmp to actually create the directory structure.

shareimprove this answer
 
21 
Very good answer. There's a fourth case that isn't asked about: make install prefix=/foo/bar/baz. That's going to install it to a different place but not create all the directories asDESTDIR=/foo/bar/baz would. It's commonly used with GNU stow via ./configure --prefix=/usr/local && make && sudo make install prefix=/usr/local/stow/foo, which would install binaries in /usr/local/stow/foo/bin. (make install DESTDIR=/usr/local/stow/foo, by comparison, would install binaries in /usr/local/stow/foo/usr/local/bin.) –  Jack Kelly Jul 3 '12 at 9:14
2 
good addition. That's probably what Number 2 was really supposed to be –  Alan Curry Jul 3 '12 at 9:25
 
Thanks for your answer. I have voted for you guys. –  Sean Jul 3 '12 at 9:29
2 
For what it's worth, in a cmake-based build you can emulate "case 4" (for stow, etc) by runningcmake -DCMAKE_INSTALL_PREFIX=/foo/bar/baz -P cmake_install.cmake in the build directory. – rpavlik Sep 6 '12 at 17:12
 
@JackKelly: Thanks! I've been using DESTDIR with GNU stow and have had to fix-up the directory structure with a mv usr/local/* . && rmdir usr/local && rmdir usr typically -- using prefix= is much better! –  thinkski Aug 24 '14 at 7:35
up vote38down votefavorite
18

I am trying to make software install to a specific directory. I found several ways, but not sure what are the differences between them.

  1. ./configure --prefix=*
  2. make install --prefix=*
  3. make install DESTDIR=*

I am confused about the functions of these three. Do they achieve the same goal? Thanks.

shareimprove this question
 
   
For the second one, I am not sure either. Some page says "make install PREFIX", while others say "make install prefix" and "make install --prefix". I have not tried them yet. –  Sean Jul 3 '12 at 9:28

1 Answer

activeoldestvotes
up vote64down voteaccepted

Number 2 is simply an error as far as I know.

Number 1 determines where the package will go when it is installed, and where it will look for its associated files when it is run. It's what you should use if you're just compiling something for use on a single host.

Number 3 is for installing to a temporary directory which is not where the package will be run from. For example this is used when building deb packages. The person building the package doesn't actually install everything into its final place on his own system. He may have a different version installed already and not want to disturb it, or he may not even be root. So he uses configure --prefix=/usr so the program will expect to be installed in /usr when it runs, then make install DESTDIR=debian/tmp to actually create the directory structure.

shareimprove this answer
 
21 
Very good answer. There's a fourth case that isn't asked about: make install prefix=/foo/bar/baz. That's going to install it to a different place but not create all the directories asDESTDIR=/foo/bar/baz would. It's commonly used with GNU stow via ./configure --prefix=/usr/local && make && sudo make install prefix=/usr/local/stow/foo, which would install binaries in /usr/local/stow/foo/bin. (make install DESTDIR=/usr/local/stow/foo, by comparison, would install binaries in /usr/local/stow/foo/usr/local/bin.) –  Jack Kelly Jul 3 '12 at 9:14
2 
good addition. That's probably what Number 2 was really supposed to be –  Alan Curry Jul 3 '12 at 9:25
   
Thanks for your answer. I have voted for you guys. –  Sean Jul 3 '12 at 9:29
2 
For what it's worth, in a cmake-based build you can emulate "case 4" (for stow, etc) by runningcmake -DCMAKE_INSTALL_PREFIX=/foo/bar/baz -P cmake_install.cmake in the build directory. – rpavlik Sep 6 '12 at 17:12
   
@JackKelly: Thanks! I've been using DESTDIR with GNU stow and have had to fix-up the directory structure with a mv usr/local/* . && rmdir usr/local && rmdir usr typically -- using prefix= is much better! –  thinkski Aug 24 '14 at 7:35
0 0
原创粉丝点击