DESTDIR and PREFIX of make



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.

share improve 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

up vote 64 down vote accepted

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.

share improve 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

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.

share improve 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

up vote 64 down vote accepted

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.

share improve 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
cd /mnt/openresty-1.27.1.1/build/LuaJIT-2.1-20240815 && make TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT' CC=cc PREFIX=/data/apps/or/luajit make[1]: 进入目录“/mnt/openresty-1.27.1.1/build/LuaJIT-2.1-20240815” ==== Building LuaJIT 2.1 ==== make -C src make[2]: 进入目录“/mnt/openresty-1.27.1.1/build/LuaJIT-2.1-20240815/src” make[2]: 对“default”无需做任何事。 make[2]: 离开目录“/mnt/openresty-1.27.1.1/build/LuaJIT-2.1-20240815/src” ==== Successfully built LuaJIT 2.1 ==== make[1]: 离开目录“/mnt/openresty-1.27.1.1/build/LuaJIT-2.1-20240815” cd /mnt/openresty-1.27.1.1/build/lua-cjson-2.1.0.14 && make DESTDIR= LUA_INCLUDE_DIR=/mnt/openresty-1.27.1.1/build/luajit-root/data/apps/or/luajit/include/luajit-2.1 LUA_CMODULE_DIR=/data/apps/or/lualib LUA_MODULE_DIR=/data/apps/or/lualib CJSON_CFLAGS="-g -fpic" CC=cc make[1]: 进入目录“/mnt/openresty-1.27.1.1/build/lua-cjson-2.1.0.14” make[1]: 对“all”无需做任何事。 make[1]: 离开目录“/mnt/openresty-1.27.1.1/build/lua-cjson-2.1.0.14” cd /mnt/openresty-1.27.1.1/build/lua-resty-signal-0.04 && make DESTDIR= LUA_INCLUDE_DIR=/mnt/openresty-1.27.1.1/build/luajit-root/data/apps/or/luajit/include/luajit-2.1 LUA_LIB_DIR=/data/apps/or/lualib CC=cc make[1]: 进入目录“/mnt/openresty-1.27.1.1/build/lua-resty-signal-0.04” make[1]: 对“all”无需做任何事。 make[1]: 离开目录“/mnt/openresty-1.27.1.1/build/lua-resty-signal-0.04” cd /mnt/openresty-1.27.1.1/build/lua-redis-parser-0.13 && make DESTDIR= LUA_INCLUDE_DIR=/mnt/openresty-1.27.1.1/build/luajit-root/data/apps/or/luajit/include/luajit-2.1 LUA_LIB_DIR=/data/apps/or/lualib CC=cc make[1]: 进入目录“/mnt/openresty-1.27.1.1/build/lua-redis-parser-0.13” make[1]: 对“all”无需做任何事。 make[1]: 离开目录“/mnt/openresty-1.27.1.1/build/lua-redis-parser-0.13” cd /mnt/openresty-1.27.1.1/build/lua-rds-parser-0.06 && make DESTDIR= LUA_INCLUDE_DIR=/mnt/openresty-1.27.1.1/build/luajit-root/data/apps/or/luajit/include/luajit-2.1 LUA_LIB_DIR=/data/apps/or/lualib CC=cc make[1]: 进入目录“/mnt/openresty-1.27.1.1/build/lua-rds-parser-0.06” make[1]: 对“all”无需做任何事。 make[1]: 离开目录“/mnt/openresty-1.27.1.1/build/lua-rds-parser-0.06” cd /mnt/openresty-1.27.1.1/build/nginx-1.27.1 && make make[1]: 进入目录“/mnt/openresty-1.27.1.1/build/nginx-1.27.1” make[1]: *** 没有指明目标并且找不到 makefile。 停止。 make[1]: 离开目录“/mnt/openresty-1.27.1.1/build/nginx-1.27.1” make: *** [all] 错误 2
最新发布
04-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值