CGLAGS= -std=c++17 -I. -I$(VULKAN_SDK_PATH)/include
LDFLAGS = -L$(VULKAN_SDK_PATH)/lib `pkg-config --static --libs glfw3` -lvulkan
OUTPUT_DIR = ./bin
a.out: *.cpp *.hpp
g++ $(CFLAGS) -o $(OUTPUT_DIR)/a.out *.cpp $(LDFLAGS)
.PHONY: test clean
test: a.out
./a.out
clean:
rm -f $(OUTPUT_DIR)/a.out
This is the error I'm getting
make: *** No rule to make target `*.hpp', needed by `a.out'. Stop.
make
is interpreting *.hpp
as a file name, not a glob. This is because either
*.hpp
in the working directory, ormake
does not recognize glob patterns in the first place,or both.
Note well that POSIX does not specify that wildcards should be recognized in target and prerequisite names, and many make
's indeed don't recognize them. Accordingly, using wildcards in targets and prerequisites is poor style.
Conventionally, you would explicitly list all the relevant filenames in your makefile, possibly in the value of a variable instead of directly in the rule. This has considerable advantages, and generally is not onerous.
If you happen to be using GNU make
, and are willing to be dependent on that particular flavor, then you should probably use its $(wildcard)
function to expand globs instead of using them directly in rule targets or prerequisites.