从零开始学习makefile(9) makefile的DESTDIR变量

19 篇文章 2 订阅

 原文来源:DESTDIR (GNU Coding Standards)

DESTDIR should be supported only in the install* and uninstall* targets, as those are the only targets where it is useful.

If your installation step would normally install /usr/local/bin/foo and /usr/local/lib/libfoo.a, then an installation invoked as in the example above would install /tmp/stage/usr/local/bin/foo and /tmp/stage/usr/local/lib/libfoo.a instead.

Prepending the variable DESTDIR to each target in this way provides for staged installs, where the installed files are not placed directly into their expected location but are instead copied into a temporary location (DESTDIR). However, installed files maintain their relative directory structure and any embedded file names will not be modified.

You should not set the value of DESTDIR in your Makefile at all; then the files are installed into their expected locations by default. Also, specifying DESTDIR should not change the operation of the software in any way, so its value should not be included in any file contents.

仅在make install和make uninstall指令中可以给DESTDIR赋值,这也是DESTDIR唯一发挥作用的场合。

假如你的makefile install在不赋值DESTDIR的时候将程序(可执行程序,或者so,a)安装在了/usr/local/bin/foo,那么make DESTDIR=/tmp/stage/ install将把程序安装在/tmp/stage/usr/local/bin/foo。

假如安装的程序不止一个,而且出现文件夹嵌套的情况,那么增加DESTDIR后,安装文件之间的相对路径不改变。

你不能在makefile里面设置DESTDIR,这样不会起任何作用,就好像你没有设置DESTDIR一样。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值