126fa459cSmrg# Copyright 2016 The Brotli Authors. All rights reserved.
226fa459cSmrg#
326fa459cSmrg# Distributed under MIT license.
426fa459cSmrg# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
526fa459cSmrg
626fa459cSmrg
726fa459cSmrg# Default (Build)
826fa459cSmrg.PHONY: all
926fa459cSmrg# Build
1026fa459cSmrg.PHONY: build
1126fa459cSmrg# Develop
1226fa459cSmrg.PHONY: develop
1326fa459cSmrg# Install
1426fa459cSmrg.PHONY: install
1526fa459cSmrg# Test
1626fa459cSmrg.PHONY: test
1726fa459cSmrg# Clean
1826fa459cSmrg.PHONY: clean
1926fa459cSmrg# Format
2026fa459cSmrg.PHONY: fix
2126fa459cSmrg
2226fa459cSmrg
2326fa459cSmrgPYTHON ?= python
2426fa459cSmrgYAPF ?= yapf
2526fa459cSmrg
2626fa459cSmrgEXT_SUFFIX=$(shell $(PYTHON) -c 'import sysconfig; print(sysconfig.get_config_var("EXT_SUFFIX"))')
2726fa459cSmrgEXT_SOURCES=$(shell find . -name '*.cc')
2826fa459cSmrgEXTENSIONS=$(EXT_SOURCES:%.cc=%$(EXT_SUFFIX))
2926fa459cSmrg
3026fa459cSmrg
3126fa459cSmrgall: build
3226fa459cSmrg
3326fa459cSmrgbuild: $(EXTENSIONS)
3426fa459cSmrg
3526fa459cSmrg$(EXTENSIONS): $(EXT_SOURCES)
3626fa459cSmrg	@cd .. && $(PYTHON) setup.py build_ext --inplace
3726fa459cSmrg
3826fa459cSmrgdevelop:
3926fa459cSmrg	@cd .. && $(PYTHON) setup.py develop
4026fa459cSmrg
4126fa459cSmrginstall:
4226fa459cSmrg	@cd .. && $(PYTHON) setup.py install
4326fa459cSmrg
4426fa459cSmrgtest: build
4526fa459cSmrg	@echo 'running tests'
4626fa459cSmrg	@$(PYTHON) -m unittest discover -v -p '*_test.py'
4726fa459cSmrg
4826fa459cSmrgclean:
4926fa459cSmrg	@cd .. && $(PYTHON) setup.py clean
5026fa459cSmrg	@find .. -name '*.pyc' | xargs rm -v
5126fa459cSmrg	@find .. -name '*.so' | xargs rm -v
5226fa459cSmrg	@find .. -type d -name '__pycache__' | xargs rm -v -r
5326fa459cSmrg	@find .. -type d -name '*.egg-info' | xargs rm -v -r
5426fa459cSmrg
5526fa459cSmrgfix:
5626fa459cSmrg	@echo 'formatting code'
5726fa459cSmrg	-@$(YAPF) --in-place --recursive --verify .
58