当前位置:网站首页>General introduction to gun make (2)

General introduction to gun make (2)

2022-06-26 01:55:00 Chen_ Hulk

1.makefile File naming

By default ,make Will search in the working directory according to the file order makefile Document and execute :

GUNmakefile,makefile,Makefile

 

If make The program cannot find any of the three files in the working directory , It will not read any other files as parsing objects .

here , Need to pass through -f NAME / --file=NAME Option to specify make Read the makefile file .

 

notes :

When the directory does not exist GUNmakefile,makefile,Makefile Command ,

When a source file exists in the directory getaddinfo.c when , We can use make getaddrinfo.o To use make The implicit rules of are automatically generated getaddrinfo.o:

 

2. Include others makefile file

If in a makefile The file needs to contain another makefile file , Keyword required include.

include The indicator tells make Pause reading current makefile, And turn to read include One or more files specified , Continue with the current... After completion makefile Read .

 Format :
include FILENAME...      

include Between and file name 、 Use spaces or... Between multiple files [tab] Key separation .

 

If include The indicated file is not an absolute address , And this file does not exist in the current directory ,make An attempt will be made to find... In the following directory based on the file name :

  • First , Use command line options -I perhaps --include-dir Specified directory , If the specified file is found , Then use this file ; Otherwise, continue to search the following directories in turn ( If there is ):  /user/gun/include     、  /user/local/include  、 /use/include
  • secondly , When these directories are not found include Specified file time ,make You will be prompted with a warning that the containing file is not found , But not immediately , But continue to deal with makefile Follow up content .
  • Last , When finished reading the entire makefile after ,make Trying to use rules to create pass indicators include Specified but not found file , When it cannot be created ,make A fatal error will be prompted and exit .( have access to -include Instead of include To ignore the error prompt because the file does not exist or cannot be created .)

 

3. makefile Enforcement rules

The first stage :

  1. Read variables in turn MAKEFILES Defined makefile File list .
  2. Read... In the working directory makefile file , Query sequentially GUNmakefile, makefile, Makefile.
  3. Read the working directory in turn makefile Use the indicator in the file include Included files .
  4. Find and rebuild all read makefile The rules of the document .
  5. Initialize variable values and expand variables and functions that need to be expanded immediately , And determine the execution branch according to the preset conditions .
  6. according to The ultimate goal And other target dependencies Dependency linked list .

The second stage :

  1. Carry out division The ultimate goal Rules for all goals other than .
  2. perform The rule of the ultimate goal .

 

4. Immediate and delayed deployment

  • stay make In the first stage of execution, if the variables and functions are expanded , This expansion is called immediate expansion . Non immediate expansion , Until subsequent rules need to be used or make They only unfold in the second stage of processing , Become a postponement .
  • When a variable uses the append symbol += when , If the previous variable is a simple variable , Use   := Definition , It is considered to be immediately unfolded , Other situations are called Postpone the start of .
  • Where conditional statements are used ,ifdef, ifeq, ifdef, ifneq,make The program will expand the correct branch according to the preset conditions , This deployment is immediate .
  • Targets and dependencies refer to other variables , Is immediately expanded . The variable reference in the rule command will be expanded later .

 

 

原网站

版权声明
本文为[Chen_ Hulk]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206252357252890.html