在makefile中,前缀@-是什么意思? [英] What does prefix @- mean in makefile?

查看:71
本文介绍了在makefile中,前缀@-是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

makefile中的前缀 @-是什么意思?与不使用- @ 有什么区别?例如,在以下情况下:

What does the prefix @- mean in a makefile? Any difference from using @ without -? For example, in the following case:

ifndef NO_CBLAS
    @echo Generating cblas.h in $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)
    @sed 's/common/openblas_config/g' cblas.h > $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/cblas.h
endif

ifndef NO_LAPACKE
    @echo Copying LAPACKE header files to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
    @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke.h
    @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_config.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_config.h
    @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_mangling_with_flags.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_mangling.h
    @-install -pDm644 $(NETLIB_LAPACK_DIR)/lapacke/include/lapacke_utils.h $(DESTDIR)$(OPENBLAS_INCLUDE_DIR)/lapacke_utils.h
endif
ifndef NO_STATIC
    @echo Copying the static library to $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
    @install -pm644 $(LIBNAME) $(DESTDIR)$(OPENBLAS_LIBRARY_DIR)
    @cd $(DESTDIR)$(OPENBLAS_LIBRARY_DIR) ; \
    ln -fs $(LIBNAME) $(LIBPREFIX).$(LIBSUFFIX)
endif

推荐答案

第5部分中包含有关这两个方面的信息.具体来说是第5.2和5.5节.

Section 5 Writing Recipes in Rules of the GNU make Manual has information about both of these things in it. Specifically section 5.2 and 5.5.

5.2配方回显

5.2 Recipe Echoing

通常在执行配方之前,make将其打印在配方的每一行上.我们之所以称呼它为回声,是因为它看起来像是您自己在键入线条.

Normally make prints each line of the recipe before it is executed. We call this echoing because it gives the appearance that you are typing the lines yourself.

当一行以"@"开头时,该行的回显被抑制.在将行传递到外壳程序之前,将丢弃"@".通常,您会将此命令用于唯一的效果是打印某些内容的命令,例如echo命令,以指示生成文件的进度:

When a line starts with ‘@’, the echoing of that line is suppressed. The ‘@’ is discarded before the line is passed to the shell. Typically you would use this for a command whose only effect is to print something, such as an echo command to indicate progress through the makefile:

5.5食谱中的错误

5.5 Errors in Recipes

在每次shell调用返回后,make查看其退出状态.如果外壳程序成功完成(退出状态为零),则在新外壳程序中执行配方中的下一行;否则,在新外壳程序中执行该命令.最后一行完成后,规则完成.

After each shell invocation returns, make looks at its exit status. If the shell completed successfully (the exit status is zero), the next line in the recipe is executed in a new shell; after the last line is finished, the rule is finished.

如果出现错误(退出状态为非零),请make放弃当前规则,也可能放弃所有规则.

If there is an error (the exit status is nonzero), make gives up on the current rule, and perhaps on all rules.

有时某个配方行的失败并不表示有问题.例如,您可以使用mkdir命令来确保目录存在.如果该目录已经存在,则mkdir将报告错误,但是无论如何您都可能希望继续执行.

Sometimes the failure of a certain recipe line does not indicate a problem. For example, you may use the mkdir command to ensure that a directory exists. If the directory already exists, mkdir will report an error, but you probably want make to continue regardless.

要忽略配方行中的错误,请在该行文本的开头(初始标签之后)写一个-".在将行传递到外壳程序执行之前,将丢弃-".

To ignore errors in a recipe line, write a ‘-’ at the beginning of the line’s text (after the initial tab). The ‘-’ is discarded before the line is passed to the shell for execution.

这篇关于在makefile中,前缀@-是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆