| 1 |
# |
| 2 |
# to use a specific python version call |
| 3 |
# `make PYTHON=python2.7' |
| 4 |
# |
| 5 |
|
| 6 |
SHELL = /bin/sh |
| 7 |
|
| 8 |
PYTHON = python |
| 9 |
PYTEST = pytest |
| 10 |
PYFLAKES = pyflakes |
| 11 |
|
| 12 |
PYTHONMAJOR=$$($(PYTHON) -V 2>&1 |awk '{print $$2}' |awk -F. '{print $$1}') |
| 13 |
PYTHONMINOR=$$($(PYTHON) -V 2>&1 |awk '{print $$2}' |awk -F. '{print $$2}') |
| 14 |
|
| 15 |
# -c on linux |
| 16 |
# freebsd does not understand -c |
| 17 |
CHMOD_VERBOSE=-v |
| 18 |
|
| 19 |
BUILD_WWW = build/www |
| 20 |
|
| 21 |
RSYNC = rsync |
| 22 |
##RSYNC_FLAGS = -av --relative -e ssh |
| 23 |
RSYNC_FLAGS = -av --relative --delete --delete-after -e ssh |
| 24 |
|
| 25 |
RSYNC_FILES = \ |
| 26 |
htdocs \ |
| 27 |
htdocs/download/.htaccess \ |
| 28 |
upload |
| 29 |
|
| 30 |
RSYNC_EXCLUDES = \ |
| 31 |
'--exclude=htdocs/download/' \ |
| 32 |
'--exclude=upload/Ignore/' \ |
| 33 |
'--exclude=htdocs/travis-deps/' |
| 34 |
|
| 35 |
RSYNC_TARGET = /home/groups/p/py/pycurl/ |
| 36 |
|
| 37 |
RSYNC_USER = [email protected] |
| 38 |
|
| 39 |
# src/module.c is first because it declares global variables |
| 40 |
# which other files reference; important for single source build |
| 41 |
SOURCES = src/easy.c src/easycb.c src/easyinfo.c src/easyopt.c src/easyperform.c \ |
| 42 |
src/easyws.c src/mime.c src/module.c src/multi.c src/oscompat.c \ |
| 43 |
src/pythoncompat.c src/share.c src/stringcompat.c src/threadsupport.c \ |
| 44 |
src/util.c |
| 45 |
|
| 46 |
GEN_SOURCES = src/docstrings.c src/docstrings.h |
| 47 |
|
| 48 |
ALL_SOURCES = src/pycurl.h $(GEN_SOURCES) $(SOURCES) |
| 49 |
|
| 50 |
RELEASE_SOURCES = src/allpycurl.c |
| 51 |
|
| 52 |
DOCSTRINGS_SOURCES = \ |
| 53 |
doc/docstrings/curl.rst \ |
| 54 |
doc/docstrings/curl_close.rst \ |
| 55 |
doc/docstrings/curl_closed.rst \ |
| 56 |
doc/docstrings/curl_errstr.rst \ |
| 57 |
doc/docstrings/curl_errstr_raw.rst \ |
| 58 |
doc/docstrings/curl_getinfo.rst \ |
| 59 |
doc/docstrings/curl_getinfo_raw.rst \ |
| 60 |
doc/docstrings/curl_multi.rst \ |
| 61 |
doc/docstrings/curl_pause.rst \ |
| 62 |
doc/docstrings/curl_perform.rst \ |
| 63 |
doc/docstrings/curl_recv.rst \ |
| 64 |
doc/docstrings/curl_recv_into.rst \ |
| 65 |
doc/docstrings/curl_reset.rst \ |
| 66 |
doc/docstrings/curl_send.rst \ |
| 67 |
doc/docstrings/curl_setopt.rst \ |
| 68 |
doc/docstrings/curl_ws_close.rst \ |
| 69 |
doc/docstrings/curl_ws_meta.rst \ |
| 70 |
doc/docstrings/curl_ws_recv.rst \ |
| 71 |
doc/docstrings/curl_ws_recv_into.rst \ |
| 72 |
doc/docstrings/curl_ws_send.rst \ |
| 73 |
doc/docstrings/curl_share.rst \ |
| 74 |
doc/docstrings/curl_unpause.rst \ |
| 75 |
doc/docstrings/curl_unsetopt.rst \ |
| 76 |
doc/docstrings/curl_set_ca_certs.rst \ |
| 77 |
doc/docstrings/multi.rst \ |
| 78 |
doc/docstrings/multi_add_handle.rst \ |
| 79 |
doc/docstrings/multi_assign.rst \ |
| 80 |
doc/docstrings/multi_close.rst \ |
| 81 |
doc/docstrings/multi_closed.rst \ |
| 82 |
doc/docstrings/multi_contains.rst \ |
| 83 |
doc/docstrings/multi_fdset.rst \ |
| 84 |
doc/docstrings/multi_info_read.rst \ |
| 85 |
doc/docstrings/multi_perform.rst \ |
| 86 |
doc/docstrings/multi_remove_handle.rst \ |
| 87 |
doc/docstrings/multi_select.rst \ |
| 88 |
doc/docstrings/multi_setopt.rst \ |
| 89 |
doc/docstrings/multi_socket_action.rst \ |
| 90 |
doc/docstrings/multi_socket_all.rst \ |
| 91 |
doc/docstrings/multi_timeout.rst \ |
| 92 |
doc/docstrings/multi_unassign.rst \ |
| 93 |
doc/docstrings/pycurl_global_cleanup.rst \ |
| 94 |
doc/docstrings/pycurl_global_init.rst \ |
| 95 |
doc/docstrings/pycurl_module.rst \ |
| 96 |
doc/docstrings/pycurl_version_info.rst \ |
| 97 |
doc/docstrings/share.rst \ |
| 98 |
doc/docstrings/share_close.rst \ |
| 99 |
doc/docstrings/share_closed.rst \ |
| 100 |
doc/docstrings/share_setopt.rst |
| 101 |
|
| 102 |
all: build |
| 103 |
src-release: $(RELEASE_SOURCES) |
| 104 |
|
| 105 |
src/docstrings.c src/docstrings.h: $(DOCSTRINGS_SOURCES) |
| 106 |
$(PYTHON) setup.py docstrings |
| 107 |
|
| 108 |
src/allpycurl.c: $(ALL_SOURCES) |
| 109 |
echo '#define PYCURL_SINGLE_FILE' >src/.tmp.allpycurl.c |
| 110 |
cat src/pycurl.h >>src/.tmp.allpycurl.c |
| 111 |
cat src/docstrings.c $(SOURCES) |sed -e 's/#include "pycurl.h"//' -e 's/#include "docstrings.h"//' >>src/.tmp.allpycurl.c |
| 112 |
mv src/.tmp.allpycurl.c src/allpycurl.c |
| 113 |
|
| 114 |
gen: $(ALL_SOURCES) |
| 115 |
|
| 116 |
build: $(ALL_SOURCES) |
| 117 |
$(PYTHON) setup.py build |
| 118 |
|
| 119 |
build-release: $(RELEASE_SOURCES) |
| 120 |
PYCURL_RELEASE=1 $(PYTHON) setup.py build |
| 121 |
|
| 122 |
do-test: |
| 123 |
make -C tests/fake-curl/libcurl |
| 124 |
./tests/run.sh |
| 125 |
./tests/ext/test-suite.sh |
| 126 |
$(PYFLAKES) python examples tests setup.py |
| 127 |
|
| 128 |
test: build do-test |
| 129 |
test-release: build-release do-test |
| 130 |
|
| 131 |
# rails-style alias |
| 132 |
c: console |
| 133 |
console: |
| 134 |
PYTHONPATH=$$(ls -d build/lib.*$$PYTHONMAJOR*$$PYTHONMINOR):$$PYTHONPATH \ |
| 135 |
$(PYTHON) |
| 136 |
|
| 137 |
# (needs GNU binutils) |
| 138 |
strip: build |
| 139 |
strip -p --strip-unneeded build/lib*/*.so |
| 140 |
chmod -x build/lib*/*.so |
| 141 |
|
| 142 |
install: |
| 143 |
$(PYTHON) -m pip install . |
| 144 |
|
| 145 |
install_lib: |
| 146 |
$(PYTHON) setup.py install_lib |
| 147 |
|
| 148 |
clean: |
| 149 |
-rm -rf build dist |
| 150 |
-rm -f *.pyc *.pyo */*.pyc */*.pyo */*/*.pyc */*/*.pyo |
| 151 |
-rm -f MANIFEST |
| 152 |
-rm -f src/allpycurl.c $(GEN_SOURCES) |
| 153 |
|
| 154 |
distclean: clean |
| 155 |
|
| 156 |
maintainer-clean: distclean |
| 157 |
|
| 158 |
dist sdist: distclean |
| 159 |
$(PYTHON) setup.py sdist |
| 160 |
|
| 161 |
run-quickstart: |
| 162 |
./tests/run-quickstart.sh |
| 163 |
|
| 164 |
# Rebuild missing or changed documentation. |
| 165 |
# Editing docstrings in Python or C source will not cause the documentation |
| 166 |
# to be rebuilt with this target, use docs-force instead. |
| 167 |
docs: build |
| 168 |
mkdir -p build/docstrings |
| 169 |
for file in doc/docstrings/*.rst; do tail -n +3 $$file >build/docstrings/`basename $$file`; done |
| 170 |
PYTHONPATH=$$(ls -d build/lib.*$$PYTHONMAJOR*$$PYTHONMINOR):$$PYTHONPATH \ |
| 171 |
$(PYTHON) -m sphinx doc build/doc |
| 172 |
cp ChangeLog build/doc |
| 173 |
|
| 174 |
# Rebuild all documentation. |
| 175 |
# As sphinx extracts documentation from pycurl modules, docs targets |
| 176 |
# depend on build target. |
| 177 |
docs-force: build |
| 178 |
# sphinx-docs has an -a option but it does not seem to always |
| 179 |
# rebuild everything |
| 180 |
rm -rf build/doc |
| 181 |
PYTHONPATH=$$(ls -d build/lib.*$$PYTHONMAJOR*$$PYTHONMINOR):$$PYTHONPATH \ |
| 182 |
$(PYTHON) -m sphinx doc build/doc |
| 183 |
cp ChangeLog build/doc |
| 184 |
|
| 185 |
www: docs |
| 186 |
mkdir -p build |
| 187 |
rsync -a www build --delete |
| 188 |
rsync -a build/doc/ build/www/htdocs/doc --exclude .buildinfo --exclude .doctrees |
| 189 |
cp doc/static/favicon.ico build/www/htdocs |
| 190 |
cp ChangeLog build/www/htdocs |
| 191 |
|
| 192 |
rsync: rsync-prepare |
| 193 |
cd $(BUILD_WWW) && \ |
| 194 |
$(RSYNC) $(RSYNC_FLAGS) $(RSYNC_EXCLUDES) $(RSYNC_FILES) $(RSYNC_USER):$(RSYNC_TARGET) |
| 195 |
|
| 196 |
rsync-dry: |
| 197 |
$(MAKE) rsync 'RSYNC=rsync --dry-run' |
| 198 |
|
| 199 |
rsync-check: |
| 200 |
$(MAKE) rsync 'RSYNC=rsync --dry-run -c' |
| 201 |
|
| 202 |
# NOTE: Git does not maintain metadata like owners and file permissions, |
| 203 |
# so we have to care manually. |
| 204 |
# NOTE: rsync targets depend on www. |
| 205 |
rsync-prepare: |
| 206 |
chgrp $(CHMOD_VERBOSE) -R pycurl $(BUILD_WWW) |
| 207 |
chmod $(CHMOD_VERBOSE) g+r `find $(BUILD_WWW) -perm +400 -print` |
| 208 |
chmod $(CHMOD_VERBOSE) g+w `find $(BUILD_WWW) -perm +200 -print` |
| 209 |
chmod $(CHMOD_VERBOSE) g+s `find $(BUILD_WWW) -type d -print` |
| 210 |
## chmod $(CHMOD_VERBOSE) g+rws `find $(BUILD_WWW) -type d -perm -770 -print` |
| 211 |
chmod $(CHMOD_VERBOSE) g+rws `find $(BUILD_WWW) -type d -print` |
| 212 |
chmod $(CHMOD_VERBOSE) o-rwx $(BUILD_WWW)/upload |
| 213 |
#-rm -rf `find $(BUILD_WWW) -name .xvpics -type d -print` |
| 214 |
|
| 215 |
.PHONY: all build test do-test strip install install_lib \ |
| 216 |
clean distclean maintainer-clean dist sdist \ |
| 217 |
docs docs-force \ |
| 218 |
rsync rsync-dry rsync-check rsync-prepare |
| 219 |
|
| 220 |
.NOEXPORT: |