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):
10 PYTHON ?
= $(shell python
-c
'import sys; sys.exit(sys.version < "2.6")' && \
11 which python || which python3.3 || which python3.2 || which python3.1 || \
12 which python3 || which python2.7 || which python2.6
)
13 SETUPOPTS ?
= '--record=install_log.txt'
22 @echo
'Run `make options` for a list of all options'
27 @echo
'PYTHON = $(PYTHON)'
28 @echo
'PYOPTIMIZE = $(PYOPTIMIZE)'
29 @echo
'DOCDIR = $(DOCDIR)'
30 @echo
'DESTDIR = $(DESTDIR)'
33 @echo
'make: Test and compile ranger.'
34 @echo
'make install: Install $(NAME)'
35 @echo
'make pypi_sdist: Release a new sdist to PyPI'
36 @echo
'make clean: Remove the compiled files (*.pyc, *.pyo)'
37 @echo
'make doc: Create the pydoc documentation'
38 @echo
'make cleandoc: Remove the pydoc documentation'
39 @echo
'make man: Compile the manpage with "pod2man"'
40 @echo
'make manhtml: Compile the html manpage with "pod2html"'
41 @echo
'make snapshot: Create a tar.gz of the current git revision'
42 @echo
'make test: Test everything'
43 @echo
'make test_pylint: Test using pylint'
44 @echo
'make test_flake8: Test using flake8'
45 @echo
'make test_doctest: Test using doctest'
46 @echo
'make test_pytest: Test using pytest'
47 @echo
'make todo: Look for TODO and XXX markers in the source code'
50 $(PYTHON
) setup.py
install $(SETUPOPTS
) \
51 '--root=$(DESTDIR)' --optimize
=$(PYOPTIMIZE
)
54 PYTHONOPTIMIZE
=$(PYOPTIMIZE
) $(PYTHON
) -m compileall
-q ranger
57 find ranger
-regex .\
*\.py
[co]\
$$ -delete
58 find ranger
-depth
-name __pycache__
-type d
-exec
rm -r
-- {} \
;
63 $(PYTHON
) -c
'import pydoc, sys; \
64 sys.path[0] = "$(CWD)"; \
65 pydoc.writedocs("$(CWD)")'
66 find .
-name \
*.html
-exec sed
-i
's|'"$(CWD)"'|../..|g' -- {} \
;
69 $(shell find .
/ranger
-mindepth
1 -maxdepth
1 -type d \
70 -and
-not
-name
'__pycache__' \
71 -and
-not
-path
'./ranger/config' \
72 -and
-not
-path
'./ranger/data' \
74 .
/ranger
/__init__.py \
75 $(shell find .
/doc
/tools .
/examples
-type f
-name
'*.py') \
79 TEST_PATH_CONFIG
= .
/ranger
/config
82 @echo
"Running pylint..."
83 pylint
$(TEST_PATHS_MAIN
)
84 pylint
--rcfile
=$(TEST_PATH_CONFIG
)/.pylintrc
$(TEST_PATH_CONFIG
)
87 @echo
"Running flake8..."
88 flake8
$(TEST_PATHS_MAIN
) $(TEST_PATH_CONFIG
)
91 @echo
"Running doctests..."
92 @for FILE in
$(shell grep
-IHm
1 doctest
-r ranger | grep
$(FILTER
) | cut
-d
: -f1
); do \
93 echo
"Testing $$FILE..."; \
94 RANGER_DOCTEST
=1 PYTHONPATH
=".:"$$PYTHONPATH ${PYTHON} $$FILE; \
98 @echo
"Running py.test tests..."
101 test: test_pylint test_flake8 test_doctest test_pytest
102 @echo
"Finished testing: All tests passed!"
105 pod2man
--stderr
--center
='ranger manual' --date
='$(NAME)-$(VERSION)' \
106 --release
=$(shell date
+%x
) doc
/ranger.pod doc
/ranger
.1
107 pod2man
--stderr
--center
='rifle manual' --date
='$(NAME_RIFLE)-$(VERSION_RIFLE)' \
108 --release
=$(shell date
+%x
) doc
/rifle.pod doc
/rifle
.1
111 pod2html doc
/ranger.pod
--outfile
=doc
/ranger
.1.html
114 test -d
$(DOCDIR
) && rm -- $(DOCDIR
)/*.html || true
117 git archive
--prefix='$(NAME)-$(VERSION)/' --format
=tar HEAD | gzip
> $(SNAPSHOT_NAME
)
122 @grep
--color
-Ion
'\(TODO\|XXX\).*' -r ranger
124 .PHONY
: clean cleandoc compile default
dist doc help
install man manhtml \
125 options snapshot
test test_pylint test_flake8 test_doctest test_pytest todo pypi_sdist