-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
159 lines (139 loc) · 6.21 KB
/
Copy pathMakefile
File metadata and controls
159 lines (139 loc) · 6.21 KB
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
NGINX_VERSION ?= 1.25.5
NGINX_SRC_DIR ?= /opt/nginx-src/nginx-$(NGINX_VERSION)
NGINX_BUILD_PREFIX ?= /opt/nginx
MODULE_DIR ?= $(CURDIR)
JOBS ?= $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)
DOCKER_COMPOSE ?= docker compose
DEBIAN_BUILD_ROOT ?= $(CURDIR)/.pkg-build
DEBIAN_SOURCE_PACKAGE ?= libnginx-mod-http-cache-pilot
DEBIAN_DISTRIBUTION ?=
DEBIAN_VERSION_SUFFIX ?=
LAUNCHPAD_PPA ?= ppa:wpelevator/packages
DEBIAN_PACKAGE_VERSION = $(shell dpkg-parsechangelog -l "$(CURDIR)/debian/changelog" -SVersion)
DEBIAN_UPSTREAM_VERSION = $(shell printf '%s\n' "$(DEBIAN_PACKAGE_VERSION)" | sed 's/-[^-]*$$//')
DEBIAN_SOURCE_DIR = $(DEBIAN_BUILD_ROOT)/$(DEBIAN_SOURCE_PACKAGE)-$(DEBIAN_UPSTREAM_VERSION)
DEBIAN_ORIG_TARBALL = $(DEBIAN_BUILD_ROOT)/$(DEBIAN_SOURCE_PACKAGE)_$(DEBIAN_UPSTREAM_VERSION).orig.tar.gz
.PHONY: help image shell packaging-shell nginx-build nginx-build-dynamic nginx-version format test bench bench-quick debian-package debian-package-smoke debian-package-clean debian-source-tree debian-orig-tarball debian-source-package debian-source-package-signed launchpad-ppa-upload
help:
@printf '%s\n' \
'make shell Open a shell in the development container' \
'make packaging-shell Open a shell in the packaging container' \
'make nginx-build Build NGINX with this module' \
'make nginx-build-dynamic Build this module as objs/ngx_http_cache_pilot_module.so' \
'make nginx-version Build info for the installed NGINX binary' \
'make format Run the repository formatter' \
'make test Run the Test::Nginx suite' \
'make debian-package Build Debian source and binary packages under .pkg-build/' \
'make debian-package-smoke Build Debian packages and run debian/tests/smoke' \
'make debian-orig-tarball Build Debian upstream orig tarball under .pkg-build/' \
'make debian-source-package Build unsigned Debian source package under .pkg-build/' \
'make debian-source-package-signed Build signed Debian source package under .pkg-build/' \
'make launchpad-ppa-upload Build, sign, and upload source package to Launchpad PPA' \
'make bench Run full benchmark suite (60s per scenario)' \
'make bench-quick Run abbreviated benchmark suite (15s per scenario)'
shell:
$(DOCKER_COMPOSE) run --rm dev
packaging-shell:
$(DOCKER_COMPOSE) run --rm packaging
nginx-build:
test -d "$(NGINX_SRC_DIR)"
cd "$(NGINX_SRC_DIR)" && ./configure \
--prefix="$(NGINX_BUILD_PREFIX)" \
--with-debug \
--with-threads \
--with-http_ssl_module \
--add-module="$(MODULE_DIR)"
$(MAKE) -C "$(NGINX_SRC_DIR)" -j"$(JOBS)"
$(MAKE) -C "$(NGINX_SRC_DIR)" install
nginx-build-dynamic:
test -d "$(NGINX_SRC_DIR)"
cd "$(NGINX_SRC_DIR)" && ./configure \
--prefix="$(NGINX_BUILD_PREFIX)" \
--with-compat \
--with-debug \
--with-threads \
--with-http_ssl_module \
--add-dynamic-module="$(MODULE_DIR)"
$(MAKE) -C "$(NGINX_SRC_DIR)" -j"$(JOBS)" modules
nginx-version:
"$(NGINX_BUILD_PREFIX)/sbin/nginx" -V
format:
astyle -v --options=.astylerc src/*.c src/*.h
dos2unix src/*
test:
$(MAKE) nginx-build
TEST_NGINX_BINARY="$(NGINX_BUILD_PREFIX)/sbin/nginx" prove ./t
bench: nginx-build
perl ./bench/bench.pl \
--port 18080 \
--out-dir ./bench/results
bench-quick: nginx-build
perl ./bench/bench.pl \
--quick \
--port 18080 \
--out-dir ./bench/results
debian-package-clean:
rm -rf "$(DEBIAN_BUILD_ROOT)"
debian-source-tree:
rm -rf "$(DEBIAN_SOURCE_DIR)"
mkdir -p "$(DEBIAN_SOURCE_DIR)"
tar \
--exclude-vcs \
--exclude=".pkg-build" \
--exclude=".nginx-debug" \
--exclude="bench/results" \
--exclude="debian/build" \
--exclude="debian/.debhelper" \
--exclude="debian/files" \
--exclude="*.buildinfo" \
--exclude="*.changes" \
--exclude="*.deb" \
--exclude="*.ddeb" \
--exclude="*.debian.tar.*" \
--exclude="*.dsc" \
--exclude="*.orig.tar.gz" \
-cf - . | tar -xf - -C "$(DEBIAN_SOURCE_DIR)"
debian-orig-tarball: debian-source-tree
source_date_epoch="$${SOURCE_DATE_EPOCH:-$$(dpkg-parsechangelog -l "$(CURDIR)/debian/changelog" -STimestamp)}"; \
tar -C "$(DEBIAN_BUILD_ROOT)" \
--sort=name \
--mtime="@$$source_date_epoch" \
--owner=0 \
--group=0 \
--numeric-owner \
-cf - "$(DEBIAN_SOURCE_PACKAGE)-$(DEBIAN_UPSTREAM_VERSION)" | gzip -n > "$(DEBIAN_ORIG_TARBALL)"
debian-source-package: debian-source-tree
@test -f "$(DEBIAN_ORIG_TARBALL)" || $(MAKE) debian-orig-tarball
package_version="$$(dpkg-parsechangelog -l "$(CURDIR)/debian/changelog" -SVersion)"; \
source_version="$${package_version}$(DEBIAN_VERSION_SUFFIX)"; \
changelog_distribution="$$(dpkg-parsechangelog -l "$(CURDIR)/debian/changelog" -SDistribution)"; \
source_distribution="$${DEBIAN_DISTRIBUTION:-$$changelog_distribution}"; \
if [ "$$source_version" != "$$package_version" ] || [ "$$source_distribution" != "$$changelog_distribution" ]; then \
cd "$(DEBIAN_SOURCE_DIR)" && \
DEBFULLNAME="$${DEBFULLNAME:-WPElevator Packaging Team}" \
DEBEMAIL="$${DEBEMAIL:-hi@wpelevator.com}" \
dch --newversion "$$source_version" \
--distribution "$$source_distribution" \
--force-distribution \
"Build for $$source_distribution."; \
fi; \
cd "$(DEBIAN_SOURCE_DIR)" && dpkg-buildpackage -S -sa -us -uc
debian-package: debian-source-package
cd "$(DEBIAN_SOURCE_DIR)" && dpkg-buildpackage -b -us -uc
debian-package-smoke: debian-package
apt-get update
apt-get install -y --no-install-recommends "$(DEBIAN_BUILD_ROOT)"/libnginx-mod-http-cache-pilot_*_$$(dpkg --print-architecture).deb
./debian/tests/smoke
debian-source-package-signed:
@if [ -n "$${DEBIAN_GPG_PRIVATE_KEY:-$${LAUNCHPAD_GPG_PRIVATE_KEY:-}}" ]; then \
printf '%s\n' "$${DEBIAN_GPG_PRIVATE_KEY:-$${LAUNCHPAD_GPG_PRIVATE_KEY:-}}" | gpg --batch --import; \
fi
@key_id="$${DEBIAN_GPG_KEY_ID:-$${LAUNCHPAD_GPG_KEY_ID:-}}"; \
test -n "$$key_id" || { echo "DEBIAN_GPG_KEY_ID or LAUNCHPAD_GPG_KEY_ID is required"; exit 1; }
$(MAKE) debian-source-package
key_id="$${DEBIAN_GPG_KEY_ID:-$${LAUNCHPAD_GPG_KEY_ID:-}}"; \
changes_file="$$(ls -1 "$(DEBIAN_BUILD_ROOT)"/*_source.changes | tail -n 1)"; \
debsign -k"$$key_id" "$$changes_file"
launchpad-ppa-upload: debian-source-package-signed
changes_file="$$(ls -1 "$(DEBIAN_BUILD_ROOT)"/*_source.changes | tail -n 1)"; \
dput "$(LAUNCHPAD_PPA)" "$$changes_file"