In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the example analysis of make in linux, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Rules
The rule rule is an instruction that tells make how and when to build a file called the target target. The target can rely on other files called premise prerequisite.
You will instruct make how to recipe the goal step by step, which is a set of shell commands that are executed one at a time in the order in which they appear. The grammar looks like this:
Target_name: prerequisites recipe
Once you have defined the rules, you can build the goal by executing the following command from the command line:
$make target_name
Once the goal is built, make will be smart enough not to run this step unless the premise changes.
More information about premises
The premise indicates two things:
When the goal should be built: if one of the premises is newer than the goal, make assumes that the goal should be built.
Order of execution: given that premises can in turn be constructed by another set of rules in makefile, they also imply an order in which rules are executed.
If you want to define an order but you don't want to rebuild the goal when the premise changes, you can use a special premise called "sequence-only order only". This premise can be placed after the normal premise and separated by a pipe character (|).
Style
For convenience, make accepts the style of goals and premises. You can define a style by including the% symbol. This symbol is a wildcard that can match any length of text symbol or space. Here are some examples:
%: match any file
% .md: matches all files ending with .md
Prefix%.go: matches all files that start with prefix and end with .go
Special goal
There are a series of target names that have a special meaning to make and are called special target special target.
You can find a full set of special goals in this document. As a rule of thumb, special goals start with a dot followed by uppercase letters.
Here are a few useful special goals:
.PHONY: the premise that indicates to the make that this goal can be treated as a pseudo-target. This means that make will always run, regardless of whether a file with that name exists or when it was last modified.
.DEFAULT: used for any target that does not have a specified rule.
.ignore: if you specify .IGNORE as the premise, make will ignore errors in the execution steps.
Substitution
It is useful to replace substitution when you need to change the value of a variable in the way you specify.
The alternative format is $(var:a=b), which means to get the value of the variable var and replace each an at the end of the word with the b in the value to replace the final string. For example:
Foo: = a.obar: = $(foo:.o=.c) # sets bar to a.c
Note: special thanks to Luis Lavena for letting us know that alternatives exist.
Archival document
Archive files are used to collect multiple data documents (similar to the concept of compressed files) into a single file. They are built by ar Unix tools. Ar can be used to create archives for any purpose, but apart from static libraries, it has been largely replaced by tar.
In make, you can use a single member of an archive file as a target or premise, like this:
Archive (member): the above prerequisite recipe is all the content of the article "sample Analysis of make in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.