Correct the description of 'quit'
[ranger.git] / Makefile
blob7e2c62dacc1b22b6db3619e21bd5055778b49596
1 # This file is part of ranger, the console file manager.
2 # License: GNU GPL version 3, see the file "AUTHORS" for details.
4 NAME = ranger
5 VERSION = $(shell grep -m 1 -o '[0-9][0-9.]\+\S*' README.md)
6 NAME_RIFLE = rifle
7 VERSION_RIFLE = $(VERSION)
8 SNAPSHOT_NAME ?= $(NAME)-$(VERSION)-$(shell git rev-parse HEAD | cut -b 1-8).tar.gz
9 # Find suitable python version (need python >= 2.6 or 3.1):
10 PYTHON ?= $(shell \
11 (python -c 'import sys; sys.exit(sys.version < "2.6")' && \
12 which python) \
13 || (which python3) \
14 || (python2 -c 'import sys; sys.exit(sys.version < "2.6")' && \
15 which python2) \
17 ifeq ($(PYTHON),)
18 $(error No suitable python found.)
19 endif
20 SETUPOPTS ?= '--record=install_log.txt'
21 DOCDIR ?= doc/pydoc
22 DESTDIR ?= /
23 PREFIX ?= /usr/local
24 PYOPTIMIZE ?= 1
25 FILTER ?= .
27 CWD = $(shell pwd)
29 default: test compile
30 @echo 'Run `make options` for a list of all options'
32 options: help
33 @echo
34 @echo 'Options:'
35 @echo 'PYTHON = $(PYTHON)'
36 @echo 'PYOPTIMIZE = $(PYOPTIMIZE)'
37 @echo 'DOCDIR = $(DOCDIR)'
38 @echo 'DESTDIR = $(DESTDIR)'
40 help:
41 @echo 'make: Test and compile ranger.'
42 @echo 'make install: Install $(NAME)'
43 @echo 'make pypi_sdist: Release a new sdist to PyPI'
44 @echo 'make clean: Remove the compiled files (*.pyc, *.pyo)'
45 @echo 'make doc: Create the pydoc documentation'
46 @echo 'make cleandoc: Remove the pydoc documentation'
47 @echo 'make man: Compile the manpage with "pod2man"'
48 @echo 'make manhtml: Compile the html manpage with "pod2html"'
49 @echo 'make snapshot: Create a tar.gz of the current git revision'
50 @echo 'make test: Test everything'
51 @echo 'make test_pylint: Test using pylint'
52 @echo 'make test_flake8: Test using flake8'
53 @echo 'make test_doctest: Test using doctest'
54 @echo 'make test_pytest: Test using pytest'
55 @echo 'make test_other: Verify the manpage is complete'
56 @echo 'make test_py: Run all python tests, including manpage completeness'
57 @echo 'make test_shellcheck: Test using shellcheck'
58 @echo 'make todo: Look for TODO and XXX markers in the source code'
60 install:
61 $(PYTHON) setup.py install $(SETUPOPTS) \
62 '--prefix=$(PREFIX)' '--root=$(DESTDIR)' \
63 --optimize=$(PYOPTIMIZE)
65 compile: clean
66 PYTHONOPTIMIZE=$(PYOPTIMIZE) $(PYTHON) -m compileall -q ranger
68 clean:
69 find ranger -regex .\*\.py[co]\$$ -delete
70 find ranger -depth -name __pycache__ -type d -exec rm -r -- {} \;
72 doc: cleandoc
73 mkdir -p $(DOCDIR)
74 cd $(DOCDIR); \
75 $(PYTHON) -c 'import pydoc, sys; \
76 sys.path[0] = "$(CWD)"; \
77 pydoc.writedocs("$(CWD)")'
78 find . -name \*.html -exec sed -i 's|'"$(CWD)"'|../..|g' -- {} \;
80 TEST_PATHS_MAIN = \
81 $(shell find ./ranger -mindepth 1 -maxdepth 1 -type d \
82 ! -name '__pycache__' \
83 ! -path './ranger/config' \
84 ! -path './ranger/data' \
85 ) \
86 ./ranger/__init__.py \
87 $(shell find ./doc/tools ./examples -type f -name '*.py') \
88 ./ranger.py \
89 ./setup.py \
90 ./tests
91 TEST_PATH_CONFIG = ./ranger/config
93 test_pylint:
94 @echo "Running pylint..."
95 pylint $(TEST_PATHS_MAIN)
96 pylint --rcfile=$(TEST_PATH_CONFIG)/.pylintrc $(TEST_PATH_CONFIG)
98 test_flake8:
99 @echo "Running flake8..."
100 flake8 $(TEST_PATHS_MAIN) $(TEST_PATH_CONFIG)
102 test_doctest:
103 @echo "Running doctests..."
104 @set -e; \
105 for FILE in $(shell grep -IHm 1 doctest -r ranger | grep $(FILTER) | cut -d: -f1); do \
106 echo "Testing $$FILE..."; \
107 RANGER_DOCTEST=1 PYTHONPATH=".:"$$PYTHONPATH ${PYTHON} $$FILE; \
108 done
110 test_pytest:
111 @echo "Running py.test tests..."
112 py.test tests
114 test_py: test_pylint test_flake8 test_doctest test_pytest test_other
115 @echo "Finished python and documentation tests!"
117 test_shellcheck:
118 @echo "Running shellcheck..."
119 sed '2,$$s/^\(\s*\)#/\1/' ./ranger/data/scope.sh | shellcheck -a -
121 test_other:
122 @echo "Checking completeness of man page..."
123 @tests/manpage_completion_test.py
125 test: test_py test_shellcheck
126 @echo "Finished testing: All tests passed!"
128 man:
129 pod2man --stderr --center='ranger manual' --date='$(NAME)-$(VERSION)' \
130 --release=$(shell date -u '+%Y-%m-%d') doc/ranger.pod doc/ranger.1
131 pod2man --stderr --center='rifle manual' --date='$(NAME_RIFLE)-$(VERSION_RIFLE)' \
132 --release=$(shell date -u '+%Y-%m-%d') doc/rifle.pod doc/rifle.1
134 manhtml:
135 pod2html doc/ranger.pod --outfile=doc/ranger.1.html
137 cleandoc:
138 test -d $(DOCDIR) && rm -- $(DOCDIR)/*.html || true
140 snapshot:
141 git archive --prefix='$(NAME)-$(VERSION)/' --format=tar HEAD | gzip > $(SNAPSHOT_NAME)
143 dist: snapshot
145 todo:
146 @grep --color -Ion '\(TODO\|XXX\).*' -r ranger
148 .PHONY: clean cleandoc compile default dist doc help install man manhtml \
149 options snapshot test test_pylint test_flake8 test_doctest test_pytest \
150 test_other todo pypi_sdist