Certain standard ways of remaking target files are used very often. For example, one customary way to make an object file is from a C source file using the C compiler, cc
.
Implicit rules tell make
how to use customary techniques so that you do not have to specify them in detail when you want to use them. For example, there is an implicit rule for C compilation. File names determine which implicit rules are run. For example, C compilation typically takes a .c file and makes a .o file. So make
applies the implicit rule for C compilation when it sees this combination of file name endings.
A chain of implicit rules can apply in sequence; for example, make
will remake a .o file from a .y file by way of a .c file.
The built-in implicit rules use several variables in their recipes so that, by changing the values of the variables, you can change the way the implicit rule works. For example, the variable CFLAGS
controls the flags given to the C compiler by the implicit rule for C compilation.
You can define your own implicit rules by writing pattern rules.
Suffix rules are a more limited way to define implicit rules. Pattern rules are more general and clearer, but suffix rules are retained for compatibility.
• Using Implicit | How to use an existing implicit rule to get the recipes for updating a file. | |
• Catalogue of Rules | A list of built-in rules. | |
• Implicit Variables | How to change what predefined rules do. | |
• Chained Rules | How to use a chain of implicit rules. | |
• Pattern Rules | How to define new implicit rules. | |
• Last Resort | How to define a recipe for rules which cannot find any. | |
• Suffix Rules | The old-fashioned style of implicit rule. | |
• Implicit Rule Search | The precise algorithm for applying implicit rules. |
Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Free Software Foundation, Inc.
Licensed under the GNU Free Documentation License.
https://www.gnu.org/software/make/manual/html_node/Implicit-Rules.html