Makefile
Table of Contents
- Overview
- Which file name should I use?
Makefile
,makefile
,GNUMakefile
, … - Selective Search for files:
vpath
- Refer variables defined later
- Run
make
withinmake
- CLI Options
- Conditionals(
ifeq
, etc)
Overview
Simple usage of requests:
.PHONY: docs
init:
pip install pipenv --upgrade
pipenv install --dev --skip-lock
test:
# This runs all of the tests, on both Python 2 and Python 3.
detox
ci:
pipenv run py.test -n 8 --boxed --junitxml=report.xml
test-readme:
@pipenv run python setup.py check --restructuredtext --strict && ([ $$? -eq 0 ] && echo "README.rst and HISTORY.rst ok") || echo "Invalid markup in README.rst or HISTORY.rst!"
flake8:
pipenv run flake8 --ignore=E501,F401,E128,E402,E731,F821 requests
coverage:
pipenv run py.test --cov-config .coveragerc --verbose --cov-report term --cov-report xml --cov=requests tests
publish:
pip install 'twine>=1.5.0'
python setup.py sdist bdist_wheel
twine upload dist/*
rm -fr build dist .egg requests.egg-info
docs:
cd docs && make html
@echo "\033[95m\n\nBuild successful! View the docs homepage at docs/_build/html/index.html.\n\033[0m"
Which file name should I use? Makefile
, makefile
, GNUMakefile
, … discussion
- The file name can be one of
GNUmakefile
,makefile
andMakefile
. Makefile
is mostly recommended.
Selective Search for files: vpath
dicussion
Using vpath
is easy to make things complicated and brittle. Try not to use vpath
so that you could keep things sane.
Refer variables defined later howto
- Use
.SECONDEXPANSION:
and$$()
onefile
depends ontop
twofile
depends onbottom
Run make
within make
howto
or
- Use
$(MAKE)
instead ofmake
. It will give you the propermake
binary. - Variables defined on the command line are passed to the sub-make through
MAKEFLAGS
. - Flags such as
-s
and-k
are passed automatically to the sub-make through the variableMAKEFLAGS
. - The options
-C
,-f
,-o
, and-W
are not put into MAKEFLAGS; these options are not passed down. -j
option is treated in a special way.- Runs
CLI Options reference
-d
- Print debugging information in addition to normal processing.
Conditionals(ifeq
, etc) reference
make
evaluates conditionals when it reads a makefile.- Consequently, you cannot use automatic variables in the tests of conditionals because they are not defined until recipes are run
- Also, it can slow down the initialization if the tests of conditionals requires time-consuming tasks such as getting file lists from the Internet or so.