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