Reputation: 423
I'm trying to use GNU Make's pattern rules to automatically generate precompiled headers from a directory full of headers. However, despite the simplicity of this usage case, I'm getting errors.
HEADERS=$(patsubst %.h,%.h.gch,$(wildcard *.h))
CXX=g++
WARNINGS=-Wno-unused-result -Wall
WARNINGSH=-w
CFLAGS=-c -g -flto=8 -fuse-linker-plugin -Ofast -std=c++11 -pthread $(WARNINGS)
HFLAGS= $(CFLAGS) $(WARNINGSH)
all: $(HEADERS)
debug: CFLAGS=-c -g3 -ggdb -O0 -std=c++11 -pthread -DSTACK_TRACE $(WARNINGS) \
-D_GNU_SOURCE
debug: HFLAGS=$(CFLAGS) $(WARNINGSH)
debug: clean all
%.h.ghc : %.h
$(CXX) $(HFLAGS) $<
clean:
rm -f *.gch
Running $ make
results in the error
make: *** No rule to make target 'my_header.h.gch', needed by 'all'. Stop.
What am I missing here?
Upvotes: 1
Views: 105