In gnu make 3.80 the authors introduced a couple of new features that make it feasible to print out the value of all the variables defined in a makefile with a single rule. I am using red hat linux 9.0. You can also define a rule.
Makefile的使用 和 基本语法 及Makefile中变量的使用【入门必看】_makefile,在规则里定义变量CSDN博客
To print a variable named my_var defined in a makefile:
I can check the variables' name with command like this:
Now set the environment variable var on. The command uses $* (a special gnu make variable that will have the value matched by the % in the rule) to print the name of the variable and then by doing $($*) gets the value of the variable. To print the value of a. Given makefile in which libdir is defined as libdir = ${exec_prefix}/lib, how to print its final (expanded) value?
@echo ${.variables} | tr ' ' '\n' Makefiles aren't like shell scripts. Say i have this makefile. So, you will see the message you are printing twice.

You need to create targets (objects that make tries to create).
What if you want to print out every variable defined in a makefile? A variable is a name defined in a makefile to represent a string of text, called the variable’s value. This comes from this stackoverflow post. How to print environment variables from makefile?
The make command only looks for commands to execute related to a specific target, and also. Gnu make provides.variables which holds all global variables' names. I want to print variable value of makefile, but it seems that simple echo command is not working. These values are substituted by explicit request into targets, prerequisites, recipes, and other.

Note that make typically parses a file twice before it executes what is needed to satisfy its targets.
I found the.variables variable which holds all the variables valid in makefile. You can do exactly as you say in the question.


