Skip to content

Commit 7961108

Browse files
committed
refactor Makefile to make easy to change dependencies version, runing tests on different environments
1 parent 4fdb383 commit 7961108

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed

Makefile

+44-36
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ export PATH := $(PWD)/t/build/sbin:$(PWD)/t/build/bin:$(PATH)
22
export PERL5LIB := $(PWD)/t/build/lib/perl5
33
export UNBOUND_PID := $(PWD)/t/build/etc/unbound/unbound.pid
44

5-
nginx=nginx-1.7.7
6-
nginx_url=http://nginx.org/download/$(nginx).tar.gz
5+
unbound_version=1.4.22
6+
lua_jit_version=2.0.3
7+
lua_nginx_module_version=0.9.13rc1
8+
lua_upstream_nginx_module_version=0.02
9+
nginx_version=1.7.7
10+
nginx_no_pool_version?=$(nginx_version)
11+
nginx_url=http://nginx.org/download/nginx-$(nginx_version).tar.gz
712

813
clean:
914
rm -rf t/build t/servroot t/tmp
@@ -38,75 +43,78 @@ t/build/lib/perl5: t/tmp/cpanm
3843
$< -L t/build --notest https://github.com/openresty/test-nginx/archive/8d5c8668364251cdae01ccf1ef933d80b642982d.tar.gz
3944
touch $@
4045

41-
t/tmp/unbound-1.4.22.tar.gz: | t/tmp
42-
curl -o $@ "http://unbound.net/downloads/unbound-1.4.22.tar.gz"
46+
t/tmp/unbound-$(unbound_version).tar.gz: | t/tmp
47+
curl -o $@ "http://unbound.net/downloads/unbound-$(unbound_version).tar.gz"
4348

44-
t/tmp/unbound-1.4.22: t/tmp/unbound-1.4.22.tar.gz
49+
t/tmp/unbound-$(unbound_version): t/tmp/unbound-$(unbound_version).tar.gz
4550
tar -C t/tmp -xf $<
4651
touch $@
4752

48-
t/tmp/unbound-1.4.22/Makefile: | t/tmp/unbound-1.4.22
49-
cd t/tmp/unbound-1.4.22 && ./configure --prefix=$(PWD)/t/build
53+
t/tmp/unbound-$(unbound_version)/Makefile: | t/tmp/unbound-$(unbound_version)
54+
cd t/tmp/unbound-$(unbound_version) && ./configure --prefix=$(PWD)/t/build
5055
touch $@
5156

52-
t/tmp/unbound-1.4.22/unbound: t/tmp/unbound-1.4.22/Makefile
53-
cd t/tmp/unbound-1.4.22 && make
57+
t/tmp/unbound-$(unbound_version)/unbound: t/tmp/unbound-$(unbound_version)/Makefile
58+
cd t/tmp/unbound-$(unbound_version) && make
5459
touch $@
5560

56-
t/build/sbin/unbound: t/tmp/unbound-1.4.22/unbound
57-
cd t/tmp/unbound-1.4.22 && make install
61+
t/build/sbin/unbound: t/tmp/unbound-$(unbound_version)/unbound
62+
cd t/tmp/unbound-$(unbound_version) && make install
5863
touch $@
5964

60-
t/tmp/LuaJIT-2.0.3.tar.gz: | t/tmp
61-
curl -o $@ "http://luajit.org/download/LuaJIT-2.0.3.tar.gz"
65+
t/tmp/LuaJIT-$(lua_jit_version).tar.gz: | t/tmp
66+
curl -o $@ "http://luajit.org/download/LuaJIT-$(lua_jit_version).tar.gz"
6267

63-
t/tmp/LuaJIT-2.0.3: t/tmp/LuaJIT-2.0.3.tar.gz
68+
t/tmp/LuaJIT-$(lua_jit_version): t/tmp/LuaJIT-$(lua_jit_version).tar.gz
6469
tar -C t/tmp -xf $<
6570
touch $@
6671

67-
t/tmp/LuaJIT-2.0.3/src/luajit: | t/tmp/LuaJIT-2.0.3
68-
cd t/tmp/LuaJIT-2.0.3 && make PREFIX=$(PWD)/t/build
72+
t/tmp/LuaJIT-$(lua_jit_version)/src/luajit: | t/tmp/LuaJIT-$(lua_jit_version)
73+
cd t/tmp/LuaJIT-$(lua_jit_version) && make PREFIX=$(PWD)/t/build
6974
touch $@
7075

71-
t/build/bin/luajit: t/tmp/LuaJIT-2.0.3/src/luajit
72-
cd t/tmp/LuaJIT-2.0.3 && make install PREFIX=$(PWD)/t/build
76+
t/build/bin/luajit: t/tmp/LuaJIT-$(lua_jit_version)/src/luajit
77+
cd t/tmp/LuaJIT-$(lua_jit_version) && make install PREFIX=$(PWD)/t/build
7378
touch $@
7479

75-
t/tmp/lua-nginx-module-0.9.13rc1.tar.gz: | t/tmp
76-
curl -Lo $@ "https://github.com/openresty/lua-nginx-module/archive/v0.9.13rc1.tar.gz"
80+
t/tmp/lua-nginx-module-$(lua_nginx_module_version).tar.gz: | t/tmp
81+
curl -Lo $@ "https://github.com/openresty/lua-nginx-module/archive/v$(lua_nginx_module_version).tar.gz"
7782

78-
t/tmp/lua-nginx-module-0.9.13rc1: t/tmp/lua-nginx-module-0.9.13rc1.tar.gz
83+
t/tmp/lua-nginx-module-$(lua_nginx_module_version): t/tmp/lua-nginx-module-$(lua_nginx_module_version).tar.gz
7984
tar -C t/tmp -xf $<
8085
touch $@
8186

82-
t/tmp/lua-upstream-nginx-module-0.02.tar.gz: | t/tmp
83-
curl -Lo $@ "https://github.com/openresty/lua-upstream-nginx-module/archive/v0.02.tar.gz"
87+
t/tmp/lua-upstream-nginx-module-$(lua_upstream_nginx_module_version).tar.gz: | t/tmp
88+
curl -Lo $@ "https://github.com/openresty/lua-upstream-nginx-module/archive/v$(lua_upstream_nginx_module_version).tar.gz"
8489

85-
t/tmp/lua-upstream-nginx-module-0.02: t/tmp/lua-upstream-nginx-module-0.02.tar.gz
90+
t/tmp/lua-upstream-nginx-module-$(lua_upstream_nginx_module_version): t/tmp/lua-upstream-nginx-module-$(lua_upstream_nginx_module_version).tar.gz
8691
tar -C t/tmp -xf $<
8792
touch $@
8893

89-
t/tmp/$(nginx).tar.gz: | t/tmp
94+
t/tmp/nginx-$(nginx_version).tar.gz: | t/tmp
9095
curl -o $@ $(nginx_url)
9196

92-
t/tmp/$(nginx): t/tmp/$(nginx).tar.gz
97+
t/tmp/nginx-$(nginx_version): t/tmp/nginx-$(nginx_version).tar.gz
9398
tar -C t/tmp -xf $<
9499
touch $@
95100

96-
t/tmp/$(nginx)/.patches-applied: | t/tmp/$(nginx)
97-
curl https://raw.githubusercontent.com/openresty/no-pool-nginx/master/$(nginx)-no_pool.patch | patch -d t/tmp/$(nginx) -p1 --quiet
101+
t/tmp/nginx-$(nginx_no_pool_version)-no_pool.patch: | t/tmp
102+
curl -o $@ https://raw.githubusercontent.com/openresty/no-pool-nginx/master/nginx-$(nginx_no_pool_version)-no_pool.patch
103+
104+
t/tmp/nginx-$(nginx_version)/.patches-applied: | t/tmp/nginx-$(nginx_version) t/tmp/nginx-$(nginx_no_pool_version)-no_pool.patch
105+
cat t/tmp/nginx-$(nginx_no_pool_version)-no_pool.patch | sed "s,.*nginx_version.*, `cat t/tmp/nginx-$(nginx_version)/src/core/nginx.h | grep nginx_version`," | sed 's,"$(nginx_no_pool_version),"$(nginx_version),' | patch -d t/tmp/nginx-$(nginx_version) -p1 --quiet
98106
touch $@
99107

100-
t/tmp/$(nginx)/Makefile: config | t/tmp/$(nginx) t/tmp/$(nginx)/.patches-applied t/build/bin/luajit t/tmp/lua-nginx-module-0.9.13rc1 t/tmp/lua-upstream-nginx-module-0.02
101-
cd t/tmp/$(nginx) && env \
108+
t/tmp/nginx-$(nginx_version)/Makefile: config | t/tmp/nginx-$(nginx_version) t/tmp/nginx-$(nginx_version)/.patches-applied t/build/bin/luajit t/tmp/lua-nginx-module-$(lua_nginx_module_version) t/tmp/lua-upstream-nginx-module-$(lua_upstream_nginx_module_version)
109+
cd t/tmp/nginx-$(nginx_version) && env \
102110
LUAJIT_LIB=$(PWD)/t/build/lib \
103111
LUAJIT_INC=$(PWD)/t/build/include/luajit-2.0 \
104112
./configure \
105113
--prefix=$(PWD)/t/build \
106114
--with-debug \
107115
--with-ipv6 \
108-
--add-module=$(PWD)/t/tmp/lua-nginx-module-0.9.13rc1 \
109-
--add-module=$(PWD)/t/tmp/lua-upstream-nginx-module-0.02 \
116+
--add-module=$(PWD)/t/tmp/lua-nginx-module-$(lua_nginx_module_version) \
117+
--add-module=$(PWD)/t/tmp/lua-upstream-nginx-module-$(lua_upstream_nginx_module_version) \
110118
--add-module=$(PWD) \
111119
--without-http_charset_module \
112120
--without-http_userid_module \
@@ -125,8 +133,8 @@ t/tmp/$(nginx)/Makefile: config | t/tmp/$(nginx) t/tmp/$(nginx)/.patches-applied
125133
--without-http_browser_module \
126134
--without-http_upstream_ip_hash_module
127135

128-
t/tmp/$(nginx)/objs/nginx: t/tmp/$(nginx)/Makefile *.c
129-
cd t/tmp/$(nginx) && make
136+
t/tmp/nginx-$(nginx_version)/objs/nginx: t/tmp/nginx-$(nginx_version)/Makefile *.c
137+
cd t/tmp/nginx-$(nginx_version) && make
130138

131-
t/build/sbin/nginx: t/tmp/$(nginx)/objs/nginx
132-
cd t/tmp/$(nginx) && make install
139+
t/build/sbin/nginx: t/tmp/nginx-$(nginx_version)/objs/nginx
140+
cd t/tmp/nginx-$(nginx_version) && make install

0 commit comments

Comments
 (0)