1 # Copyright 2016 The Brotli Authors. All rights reserved. 2 # 3 # Distributed under MIT license. 4 # See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 5 6 7 # Default (Build) 8 .PHONY: all 9 # Build 10 .PHONY: build 11 # Develop 12 .PHONY: develop 13 # Install 14 .PHONY: install 15 # Test 16 .PHONY: test 17 # Clean 18 .PHONY: clean 19 # Format 20 .PHONY: fix 21 22 23 PYTHON ?= python 24 YAPF ?= yapf 25 26 EXT_SUFFIX=$(shell $(PYTHON) -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))') 27 EXT_SOURCES=$(shell find . -name '*.cc') 28 EXTENSIONS=$(EXT_SOURCES:%.cc=%$(EXT_SUFFIX)) 29 30 31 all: build 32 33 build: $(EXTENSIONS) 34 35 $(EXTENSIONS): $(EXT_SOURCES) 36 @cd .. && $(PYTHON) setup.py build_ext --inplace 37 38 develop: 39 @cd .. && $(PYTHON) setup.py develop 40 41 install: 42 @cd .. && $(PYTHON) setup.py install 43 44 test: build 45 @echo 'running tests' 46 @$(PYTHON) -m unittest discover -v -p '*_test.py' 47 48 clean: 49 @cd .. && $(PYTHON) setup.py clean 50 @find .. -name '*.pyc' | xargs rm -v 51 @find .. -name '*.so' | xargs rm -v 52 @find .. -type d -name '__pycache__' | xargs rm -v -r 53 @find .. -type d -name '*.egg-info' | xargs rm -v -r 54 55 fix: 56 @echo 'formatting code' 57 -@$(YAPF) --in-place --recursive --verify . 58