I’m not expert on Makefiles, and I was hoping that someone during all Stan years would have gained lot of experience. Before making the pull request, here’s what I would use (it now also gives more informative error message), but I could test this only in Ubuntu
# Old distros have python to default to Python2
PYTHON2 ?= python
# Check version, because new distros have python to default to Python3
PYTHON_VERSION = $(shell $(PYTHON2) -c "print(__import__('sys').version.split(' ' )[0].split('.')[0])")
ifneq ($(PYTHON_VERSION),2)
# Check if python2 is installed with name python2
PYTHON2 = python2
PYTHON_VERSION = $(shell $(PYTHON2) -c "print(__import__('sys').version.split(' ' )[0].split('.')[0])")
ifneq ($(PYTHON_VERSION),2)
$(error Python2 required by cpplint, but not found. See 'make help')
endif
endif
.PHONY: cpplint
cpplint:
@$(PYTHON2) $(CPPLINT)/cpplint.py --output=vs7 --counting=detailed --root=src --extension=hpp,cpp --filter=-runtime/indentation_namespace,-readability/namespace,-legal/copyright,-whitespace/indent,-runtime/reference $(shell find src/stan -name '*.hpp' -o -name '*.cpp')