简体   繁体   English

如何在Makefile中编写“安装”目标

[英]How to write “install” target in Makefile

I am new to Makefile and like to write an install target in Makefile . 我是Makefile新手,喜欢在Makefile编写install目标。 My Makefile is going to be called from another Makefile like this: 我的Makefile将从另一个Makefile像这样被调用:

DESTDIR=$(DIR_A) BINDIR=/dir_b make -C $(CURDIR)/xxxx/yyy all

where /xxxx/yyy is where my Makefile is located. /xxxx/yyy是我的Makefile所在的位置。

My Makefile is going to generate 2 binaries that I like to install them ie by install, I mean to copy both of the binaries to a specific directory ( BINDIR ) and make them executable. 我的Makefile将生成2个我想安装它们的二进制文件,即通过安装,我的意思是将两个二进制文件都复制到特定目录( BINDIR )并使它们可执行。

How should I write the install target in this case if my 2 binaries are generated in /aaaa/bbbb/bin folder? 如果在/aaaa/bbbb/bin文件夹中生成了2个二进制文件,在这种情况下应如何编写install目标?

"Install" is going to be a "phony" target. “安装”将成为“假”目标。 And I strongly advise to use utility install instead of cp and chmod : 并且我强烈建议使用实用程序install而不是cpchmod

.PHONY: install
install:
    install -m 557 /aaaa/bbbb/bin/first /aaaa/bbbb/bin/second $BINDIR

Now, you can do make install . 现在,您可以进行make install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM