diff --git a/make/program b/make/program index 6aa40348e1..16f2818be5 100644 --- a/make/program +++ b/make/program @@ -16,19 +16,20 @@ $(CMDSTAN_MAIN_O) : $(CMDSTAN_MAIN) ## # Precompiled model header ## -$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).d : $(STAN)src/stan/model/model_header.hpp +$(patsub %.d,%.hpp.gch,$(PRECOMPILED_MODEL_HEADER)) : $(STAN)src/stan/model/model_header.hpp $(COMPILE.cpp) $(DEPFLAGS) $< ifneq ($(PRECOMPILED_MODEL_HEADER),) -$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).d : DEPTARGETS = -MT $(patsubst %.d,%.hpp.gch,$@) -MT $@ -$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch : $(STAN)src/stan/model/model_header.hpp +$(patsub %.d,%.hpp.gch,$(PRECOMPILED_MODEL_HEADER)) : DEPTARGETS = -MT $(patsubst %.d,%.hpp.gch,$@) -MT $@ +$(PRECOMPILED_MODEL_HEADER) : $(STAN)src/stan/model/model_header.hpp @echo '' @echo '--- Compiling pre-compiled header. This might take a few seconds. ---' + @mkdir $(dir $@) $(COMPILE.cpp) $< $(OUTPUT_OPTION) ifeq ($(CXX_TYPE),clang) -CXXFLAGS_PROGRAM += -include-pch $(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch -$(STAN_TARGETS) : %$(EXE) : $(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch +CXXFLAGS_PROGRAM += -include-pch $(PRECOMPILED_MODEL_HEADER) +$(STAN_TARGETS) : %$(EXE) : $(PRECOMPILED_MODEL_HEADER) endif endif diff --git a/makefile b/makefile index 2fe8e82524..2ccd2eeab9 100644 --- a/makefile +++ b/makefile @@ -132,7 +132,7 @@ PRECOMPILED_HEADERS ?= true endif ifeq ($(PRECOMPILED_HEADERS),true) -PRECOMPILED_MODEL_HEADER=$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch +PRECOMPILED_MODEL_HEADER=$(STAN)src/stan/model/model_header.hpp.gch/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch ifeq ($(CXX_TYPE),gcc) CXXFLAGS_PROGRAM+= -Wno-ignored-attributes $(CXXFLAGS_OPTIM) $(CXXFLAGS_FLTO) endif @@ -284,6 +284,7 @@ clean: clean-tests $(RM) -r bin/cmdstan @echo ' removing cached compiler objects' $(RM) $(wildcard src/cmdstan/main*.o) $(wildcard $(STAN)src/stan/model/model_header*.hpp.gch) + $(RM) -r $(STAN)src/stan/model/model_header.hpp.gch/ @echo ' removing built example model' $(RM) examples/bernoulli/bernoulli$(EXE) examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.d examples/bernoulli/bernoulli.hpp $(wildcard examples/bernoulli/*.csv)