In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to find makefile, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
By default, the make command looks in the current directory for files named "GNUmakefile", "makefile", and "Makefile" in order, and finds an explanation for the file.
Of the three file names, it is best to use the file name "Makefile", because the first character of the file name is uppercase, which makes it obvious. It is best not to use "GNUmakefile", which is recognized by GNU's make.
Target: dependents_1 dependents_2... Dependents_n
Command_1
Command_2
Command_3
(1) variable assignment in makefile
For the variables defined in makefile, there are other reference variables in the assignment. Makefile expands the variables step by step.
There can be several spaces before and after the assignment operator
1 > operator =
Recursively expand the reference variable until you find the latest value of the referenced variable (search makefile)
Var = I love
Variable = linux
Var + = $(variable)
Variable = magic
All:
@ echo $(var)
Output:
I love magic
2 > operator: =
Recursively expand the reference variable and only find the value of the latest reference variable before the variable assignment (do not search the entire makefile)
M: = mm
X: = $(m)
Y: = $(x) bar
X: = later
All:
@ echo $(x) $(y)
Output:
$x-> later
$y-> mm bar
(if the value of y = is changed from y = to y =, the value of $y is: later bar)
3 > operator + =
You can add a new value to a defined variable through + =
When a variable has not been defined before, + = and = are the same, it defines a recursively expanded variable, but when the variable is already defined, + = is simply adding characters.
If you initially use: = to define a variable, then + = is simply added using the current value of the variable
If you initially use = to define a variable, the behavior of + = becomes a bit odd. It does not expand the variable immediately where it is used, but will postpone the expansion work until it finds the final definition of the variable. this is similar to the behavior of defining a variable.
4 > operator? = (does not work)
Assign a default value, and if the variable is not initialized, give it a default value. Such as:
ARCH=arm
ARCH? = i386
All:
@ echo $(ARCH)
Output:
Arm
ARCH=
ARCH? = i386
All:
@ echo $(ARCH)
Output:
I386
(2) main predetermined variables of makefile
$* does not include the name of the target file with the extension
All dependent files, separated by spaces and in order of occurrence, may contain duplicate dependent files
The name of the first dependent file of HTML_CONTENT%lt;
$? All dependent files, separated by spaces, are modified later than the target creation date
Full name of the $@ target
All dependent files are separated by spaces and do not contain duplicate dependent files
$% if the target is an archive member, this variable represents the archive member name of the target
(3) the use of default functions in makefile
1 > wildcard
2 > patsubst
3 > notdir
SUB_DIR=./ locate order_maker scheduler transmit
INCLUDE = $(foreach temp,$ (SUB_DIR),-I. Universe $(temp))
SRC = $(foreach temp,$ (SUB_DIR), $(wildcard $(temp) / * .cpp))
OBJS = $(foreach temp,$ (SRC), $(patsubst% .cpp,% .o, $(temp)
OBJS_LINK = $(foreach temp,$ (OBJS), obj/$ (patsubst% .cpp,% .o, $(notdir $(temp)
(4) File search path in makefile
In makefile, you can set the search directory for the target and dependent files in the rule by assigning a value to VPATH.
Make first searches the current directory, and if no dependent files are found, make will search for VPATH according to the directory given in VPATH. VPATH is valid for all files in makefile.
Such as:
VPATH:=/c/ming\
/ c/ming/head
You can also use the instruction vpath, which differs from VPATH in that vpath can specify different search directories for different types of files.
Such as:
Vpath% .c / c/ming
Vpath% .h / c/ming/head
Vpath% .c means to clear all search directories set by vpath for% .c
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.