Make中的默认规则

Make中的默认规则

本文介绍了Make中的默认规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个机制允许默认的全局隐式规则在任何地方可用,类似于内置的规则?

Is there a mechanism in make to allow for default global implicit rules that are available anywhere, similar to the built-in rules?

Make提供了一些内置的用于编译C / C ++ / Fortran文件的规则,对于简单情况甚至不需要 Makefile 。但是,当编译其他语言(例如Go编程语言文件)时,总是需要一个 Makefile 。我想扩展我的Makeenvironment默认隐式规则可用。

Make provides some built-inimplicit rules for compiling C/C++/Fortran files, without even requiring a Makefile for simple cases. However, when compiling other languages (e.g. Go programming language files), a Makefile is always required. I would like to extend my Makeenvironment to have implicit rules available by default.

推荐答案

这通常是不可取的,你的Makefile更不便携;

This is not normally desirable, as it would cause your Makefile to be less portable; it wouldn't work on somebody else's machine if they didn't have it set up that way.

但是,如果你想这样做,创建一个全局 Makefile在某处使用Go文件的默认规则,然后将其路径添加到MAKEFILES环境变量。在运行make时,这个全局Makefile将在任何Makefile之前被处理,就像你将源文件包含在文件的顶部一样。

However, if you want to do this, create a "global" Makefile somewhere with your default rules for Go files, then add its path to the MAKEFILES environment variable. This global Makefile will be processed before any Makefile when you run "make", just as if you had included its source at the top of the file.

这篇关于Make中的默认规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 13:13