What does a wildcard mean in a makefile?

I found the following lines in a makefile tutorial, but I have some problems with bold lines.

In line 1, if I write

program_C_SRCS:=$(*.c) 

he does not work. So please tell me what the wildcard is in this here. Is this word specific to the makefile only?

The textbook says that the second line will perform test substitution. Can someone tell me something about this text replacement?

Please excuse me if my questions are very simple because I am new to filament creation.

textbook link

 CC:=g++ program_NAME:=myprogram **program_C_SRCS:=$(wildcard *.c)** # 1 line program_CXX_SRCS:=$(wildcard *.cc) **program_C_OBJ:=$(program_C_SRCS:.c=.o)** # 2 line program_CXX_OBJ:=$(program_CXX_SRCS:.c=.o) program_OBJ:= $(program_C_OBJ) $(program_CXX_OBJ) 
+8
makefile
source share
2 answers

Suppose you have two source files. foo.c and bar.c

 program_C_SRCS:=$(wildcard *.c) # 1 line 

The wildcard function is the syntax of Make. The program_C_SRCS variable will now have the value foo.c bar.c (possibly in the wrong order).

 program_C_OBJ:=$(program_C_SRCS:.c=.o) # 2 line 

This is a link to substitution . It converts the text, replacing one substring with another. The variable program_C_OBJ now has the value foo.o bar.o

+10
source share

Using the wildcard function in the make file is a list of all source files with a specific extension. For example:

 program_C_SRCS:=$(*.c) // In this the variable program_C_SRCS will have all the files with ".c" extension. 

Suppose you want to convert .c files to .o files, then the following syntax may be needed:

 program_C_OBJS:=$(patsubst %.c,%.o,$(wildcard *.c)) 
+1
source share

All Articles