diff --git a/make/compiler_flags b/make/compiler_flags index 26e15a0e989..336fb3d9d42 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -70,6 +70,13 @@ CXX_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion 2>&1) CXX_MAJOR := $(word 1,$(subst ., ,$(CXX_VERSION))) CXX_MINOR := $(word 2,$(subst ., ,$(CXX_VERSION))) +# disable Make's implicit suffix rules +# see: https://www.gnu.org/software/make/manual/html_node/Implicit-Rules.html +# this should make Make slightly faster, as well as avoiding some unexpected +# behavior when there are other files lying around with the same name as +# Stan models +.SUFFIXES: .cpp + ################################################################################ # Set optional compiler flags for performance # diff --git a/make/libraries b/make/libraries index e2b347d8388..a5be7d49510 100644 --- a/make/libraries +++ b/make/libraries @@ -252,11 +252,8 @@ endif ############################################################ # Google Test: # Build the google test library. -$(GTEST)/src/gtest-all.o: CXXFLAGS += $(CXXFLAGS_GTEST) -$(GTEST)/src/gtest-all.o: CPPFLAGS += $(CPPFLAGS_GTEST) -$(GTEST)/src/gtest-all.o: INC += $(INC_GTEST) - - +$(GTEST)/src/gtest-all.o: $(GTEST)/src/gtest-all.cc + $(COMPILE.cpp) -x c++ $(CXXFLAGS_GTEST) $(CPPFLAGS_GTEST) $(INC_GTEST) -o $@ -c $< ############################################################ # Clean all libraries