1 # This file is part of ranger, the console file manager.
2 # License: GNU GPL version 3, see the file "AUTHORS" for details.
5 VERSION
= $(shell grep
-m
1 -o
'[0-9][0-9.]\+\S*' README.md
)
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):
11 (python
-c
'import sys; sys.exit(sys.version < "2.6")' && \
14 ||
(python2
-c
'import sys; sys.exit(sys.version < "2.6")' && \
18 $(error No suitable python found.
)
20 SETUPOPTS ?
= '--record=install_log.txt'
30 @echo
'Run `make options` for a list of all options'
35 @echo
'PYTHON = $(PYTHON)'
36 @echo
'PYOPTIMIZE = $(PYOPTIMIZE)'
37 @echo
'DOCDIR = $(DOCDIR)'
38 @echo
'DESTDIR = $(DESTDIR)'
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'
61 $(PYTHON
) setup.py
install $(SETUPOPTS
) \
62 '--prefix=$(PREFIX)' '--root=$(DESTDIR)' \
63 --optimize
=$(PYOPTIMIZE
)
66 PYTHONOPTIMIZE
=$(PYOPTIMIZE
) $(PYTHON
) -m compileall
-q ranger
69 find ranger
-regex .\
*\.py
[co]\
$$ -delete
70 find ranger
-depth
-name __pycache__
-type d
-exec
rm -r
-- {} \
;
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' -- {} \
;
81 $(shell find .
/ranger
-mindepth
1 -maxdepth
1 -type d \
82 ! -name
'__pycache__' \
83 ! -path
'./ranger/config' \
84 ! -path
'./ranger/data' \
86 .
/ranger
/__init__.py \
87 $(shell find .
/doc
/tools .
/examples
-type f
-name
'*.py') \
91 TEST_PATH_CONFIG
= .
/ranger
/config
94 @echo
"Running pylint..."
95 pylint
$(TEST_PATHS_MAIN
)
96 pylint
--rcfile
=$(TEST_PATH_CONFIG
)/.pylintrc
$(TEST_PATH_CONFIG
)
99 @echo
"Running flake8..."
100 flake8
$(TEST_PATHS_MAIN
) $(TEST_PATH_CONFIG
)
103 @echo
"Running doctests..."
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; \
111 @echo
"Running py.test tests..."
114 test_py
: test_pylint test_flake8 test_doctest test_pytest test_other
115 @echo
"Finished python and documentation tests!"
118 @echo
"Running shellcheck..."
119 sed
'2,$$s/^\(\s*\)#/\1/' .
/ranger
/data
/scope.sh | shellcheck
-a
-
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!"
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
135 pod2html doc
/ranger.pod
--outfile
=doc
/ranger
.1.html
138 test -d
$(DOCDIR
) && rm -- $(DOCDIR
)/*.html || true
141 git archive
--prefix='$(NAME)-$(VERSION)/' --format
=tar HEAD | gzip
> $(SNAPSHOT_NAME
)
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