Alex Nicksay | 6ab0a5c | 2016-12-21 04:17:11 -0500 | [diff] [blame] | 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 | |
Alex Nicksay | 0608253 | 2017-08-02 10:59:46 -0400 | [diff] [blame] | 7 | # Default (Build) |
Alex Nicksay | 6ab0a5c | 2016-12-21 04:17:11 -0500 | [diff] [blame] | 8 | .PHONY: all |
| 9 | # Build |
| 10 | .PHONY: build |
Cosimo Lupo | 4f455ca | 2017-08-23 19:45:13 +0100 | [diff] [blame] | 11 | # Develop |
| 12 | .PHONY: develop |
Alex Nicksay | 0608253 | 2017-08-02 10:59:46 -0400 | [diff] [blame] | 13 | # Install |
| 14 | .PHONY: install |
Alex Nicksay | 6ab0a5c | 2016-12-21 04:17:11 -0500 | [diff] [blame] | 15 | # Test |
Cosimo Lupo | 4f455ca | 2017-08-23 19:45:13 +0100 | [diff] [blame] | 16 | .PHONY: test |
Alex Nicksay | 6ab0a5c | 2016-12-21 04:17:11 -0500 | [diff] [blame] | 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) |
Cosimo Lupo | 4f455ca | 2017-08-23 19:45:13 +0100 | [diff] [blame] | 36 | @cd .. && $(PYTHON) setup.py build_ext --inplace |
| 37 | |
| 38 | develop: |
Alex Nicksay | 6ab0a5c | 2016-12-21 04:17:11 -0500 | [diff] [blame] | 39 | @cd .. && $(PYTHON) setup.py develop |
| 40 | |
Alex Nicksay | 0608253 | 2017-08-02 10:59:46 -0400 | [diff] [blame] | 41 | install: |
| 42 | @cd .. && $(PYTHON) setup.py install |
| 43 | |
Cosimo Lupo | 4f455ca | 2017-08-23 19:45:13 +0100 | [diff] [blame] | 44 | test: build |
Alex Nicksay | 6ab0a5c | 2016-12-21 04:17:11 -0500 | [diff] [blame] | 45 | @echo 'running tests' |
Cosimo Lupo | 4f455ca | 2017-08-23 19:45:13 +0100 | [diff] [blame] | 46 | @$(PYTHON) -m unittest discover -v -p '*_test.py' |
Alex Nicksay | 6ab0a5c | 2016-12-21 04:17:11 -0500 | [diff] [blame] | 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 . |