xref: /unit/pkg/deb/Makefile (revision 1094)
1373Sdefan@nginx.com#!/usr/bin/make
2373Sdefan@nginx.com
3953Salexander.borisov@nginx.cominclude ../../version
4373Sdefan@nginx.com
5821Svbart@nginx.comDEFAULT_RELEASE := 1
6373Sdefan@nginx.com
7953Salexander.borisov@nginx.comVERSION ?= $(NXT_VERSION)
8373Sdefan@nginx.comRELEASE ?= $(DEFAULT_RELEASE)
9373Sdefan@nginx.com
10373Sdefan@nginx.comSRCDIR=	unit-$(VERSION)
11373Sdefan@nginx.com
12373Sdefan@nginx.comCODENAME = $(shell lsb_release -cs)
13373Sdefan@nginx.com
14778Sdefan@nginx.comBUILD_DEPENDS_unit = build-essential debhelper devscripts fakeroot libxml2-utils lintian lsb-release xsltproc libssl-dev
15489Sdefan@nginx.comBUILD_DEPENDS = $(BUILD_DEPENDS_unit)
16373Sdefan@nginx.com
17373Sdefan@nginx.comMODULES=
18373Sdefan@nginx.com
191040Sdefan@nginx.com# Ubuntu 19.04
201040Sdefan@nginx.comifeq ($(CODENAME),disco)
211040Sdefan@nginx.cominclude Makefile.php
221040Sdefan@nginx.cominclude Makefile.python27
231040Sdefan@nginx.cominclude Makefile.python37
241040Sdefan@nginx.cominclude Makefile.go110
251040Sdefan@nginx.cominclude Makefile.go111
261040Sdefan@nginx.cominclude Makefile.perl
271040Sdefan@nginx.cominclude Makefile.ruby
281040Sdefan@nginx.cominclude Makefile.jsc-common
291040Sdefan@nginx.cominclude Makefile.jsc11
301040Sdefan@nginx.comendif
311040Sdefan@nginx.com
32902Sdefan@nginx.com# Ubuntu 18.10
33902Sdefan@nginx.comifeq ($(CODENAME),cosmic)
34902Sdefan@nginx.cominclude Makefile.php
35902Sdefan@nginx.cominclude Makefile.python27
36902Sdefan@nginx.cominclude Makefile.python36
37902Sdefan@nginx.cominclude Makefile.python37
38902Sdefan@nginx.cominclude Makefile.go19
39902Sdefan@nginx.cominclude Makefile.go110
40902Sdefan@nginx.cominclude Makefile.perl
41902Sdefan@nginx.cominclude Makefile.ruby
42980Sdefan@nginx.cominclude Makefile.jsc-common
43980Sdefan@nginx.cominclude Makefile.jsc8
44980Sdefan@nginx.cominclude Makefile.jsc11
45902Sdefan@nginx.comendif
46902Sdefan@nginx.com
47672Sdefan@nginx.com# Ubuntu 18.04
48672Sdefan@nginx.comifeq ($(CODENAME),bionic)
49672Sdefan@nginx.cominclude Makefile.php
50672Sdefan@nginx.cominclude Makefile.python27
51672Sdefan@nginx.cominclude Makefile.python36
521074Sdefan@nginx.cominclude Makefile.python37
53672Sdefan@nginx.cominclude Makefile.go19
54672Sdefan@nginx.cominclude Makefile.go110
55672Sdefan@nginx.cominclude Makefile.perl
56672Sdefan@nginx.cominclude Makefile.ruby
57980Sdefan@nginx.cominclude Makefile.jsc-common
58980Sdefan@nginx.cominclude Makefile.jsc8
591076Sdefan@nginx.cominclude Makefile.jsc11
60672Sdefan@nginx.comendif
61672Sdefan@nginx.com
62373Sdefan@nginx.com# Ubuntu 16.04
63373Sdefan@nginx.comifeq ($(CODENAME),xenial)
64373Sdefan@nginx.cominclude Makefile.php
65373Sdefan@nginx.cominclude Makefile.python27
66373Sdefan@nginx.cominclude Makefile.python35
67373Sdefan@nginx.cominclude Makefile.go
68524Sdefan@nginx.cominclude Makefile.perl
69600Sdefan@nginx.cominclude Makefile.ruby
70980Sdefan@nginx.cominclude Makefile.jsc-common
71980Sdefan@nginx.cominclude Makefile.jsc8
72373Sdefan@nginx.comendif
73373Sdefan@nginx.com
74373Sdefan@nginx.com# Ubuntu 14.04
75373Sdefan@nginx.comifeq ($(CODENAME),trusty)
76373Sdefan@nginx.cominclude Makefile.php
77373Sdefan@nginx.cominclude Makefile.python
78524Sdefan@nginx.cominclude Makefile.perl
79373Sdefan@nginx.comendif
80373Sdefan@nginx.com
81*1094Sdefan@nginx.com# Debian 10
82*1094Sdefan@nginx.comifeq ($(CODENAME),buster)
83*1094Sdefan@nginx.cominclude Makefile.php
84*1094Sdefan@nginx.cominclude Makefile.python27
85*1094Sdefan@nginx.cominclude Makefile.python37
86*1094Sdefan@nginx.cominclude Makefile.go111
87*1094Sdefan@nginx.cominclude Makefile.perl
88*1094Sdefan@nginx.cominclude Makefile.ruby
89*1094Sdefan@nginx.cominclude Makefile.jsc-common
90*1094Sdefan@nginx.cominclude Makefile.jsc11
91*1094Sdefan@nginx.comendif
92*1094Sdefan@nginx.com
93373Sdefan@nginx.com# Debian 9
94373Sdefan@nginx.comifeq ($(CODENAME),stretch)
95373Sdefan@nginx.cominclude Makefile.php
96373Sdefan@nginx.cominclude Makefile.python27
97373Sdefan@nginx.cominclude Makefile.python35
98373Sdefan@nginx.cominclude Makefile.go17
99373Sdefan@nginx.cominclude Makefile.go18
100524Sdefan@nginx.cominclude Makefile.perl
101600Sdefan@nginx.cominclude Makefile.ruby
102980Sdefan@nginx.cominclude Makefile.jsc-common
103980Sdefan@nginx.cominclude Makefile.jsc8
104373Sdefan@nginx.comendif
105373Sdefan@nginx.com
106373Sdefan@nginx.com# Debian 8
107373Sdefan@nginx.comifeq ($(CODENAME),jessie)
108373Sdefan@nginx.cominclude Makefile.php
109373Sdefan@nginx.cominclude Makefile.python27
110440Sdefan@nginx.cominclude Makefile.python34
111524Sdefan@nginx.cominclude Makefile.perl
112600Sdefan@nginx.cominclude Makefile.ruby
113373Sdefan@nginx.comendif
114373Sdefan@nginx.com
115373Sdefan@nginx.comCONFIGURE_ARGS=\
116373Sdefan@nginx.com	--prefix=/usr \
117373Sdefan@nginx.com	--state=/var/lib/unit \
118373Sdefan@nginx.com	--control="unix:/var/run/control.unit.sock" \
119373Sdefan@nginx.com	--pid=/var/run/unit.pid \
120373Sdefan@nginx.com	--log=/var/log/unit.log \
121778Sdefan@nginx.com	--tests \
122778Sdefan@nginx.com	--openssl
123373Sdefan@nginx.com
124373Sdefan@nginx.comexport CR=\\n
125373Sdefan@nginx.com
126373Sdefan@nginx.comdefault:
127501Sdefan@nginx.com	@echo "valid targets: all modules unit $(addprefix unit-, $(MODULES)) test test-debug clean"
128373Sdefan@nginx.com
129559Sdefan@nginx.comall: check-build-depends-all unit modules
130373Sdefan@nginx.com
131373Sdefan@nginx.commodules: $(addprefix unit-, $(MODULES))
132373Sdefan@nginx.com
133559Sdefan@nginx.comcheck-build-depends-%:
134373Sdefan@nginx.com	@{ \
135559Sdefan@nginx.com	case "$*" in \
136559Sdefan@nginx.com		all) pkgs="$(BUILD_DEPENDS)" ;; \
137559Sdefan@nginx.com		unit) pkgs="$(BUILD_DEPENDS_unit)" ;; \
138559Sdefan@nginx.com		*) pkgs="$(BUILD_DEPENDS_unit) $(BUILD_DEPENDS_$*)" ;; \
139559Sdefan@nginx.com	esac ; \
140373Sdefan@nginx.com	not_installed= ; \
141559Sdefan@nginx.com	for pkg in $${pkgs}; do \
142373Sdefan@nginx.com		dpkg -s $${pkg} >/dev/null 2>&1 ; \
143373Sdefan@nginx.com		if [ $$? -ne 0 ]; then \
144373Sdefan@nginx.com			not_installed="$${not_installed} $${pkg}" ; \
145373Sdefan@nginx.com		fi ; \
146373Sdefan@nginx.com	done ; \
147373Sdefan@nginx.com	if test -n "$${not_installed}" ; then \
148373Sdefan@nginx.com		echo "" >&2 ; \
149373Sdefan@nginx.com		echo "The following packages are required in order to proceed:" >&2 ; \
150373Sdefan@nginx.com		echo "" >&2 ; \
151373Sdefan@nginx.com		echo $${not_installed} >&2 ; \
152373Sdefan@nginx.com		echo "" >&2 ; \
153373Sdefan@nginx.com		exit 1 ; \
154373Sdefan@nginx.com	fi \
155373Sdefan@nginx.com	}
156559Sdefan@nginx.com	touch $@
157489Sdefan@nginx.com
158373Sdefan@nginx.comdebuild/$(SRCDIR)/debian:
159373Sdefan@nginx.com	@{ \
160373Sdefan@nginx.com	set -e ; \
161373Sdefan@nginx.com	mkdir -p debuild/$(SRCDIR) ; \
162373Sdefan@nginx.com	cp -pr debian debuild/$(SRCDIR) ; \
163373Sdefan@nginx.com	echo '9' > debuild/$(SRCDIR)/debian/compat ; \
164373Sdefan@nginx.com	mkdir -p debuild/$(SRCDIR)/debian/source ; \
165373Sdefan@nginx.com	echo '3.0 (quilt)' > debuild/$(SRCDIR)/debian/source/format ; \
166373Sdefan@nginx.com        cat debian/rules.in | sed \
167373Sdefan@nginx.com                -e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \
168373Sdefan@nginx.com        > debuild/$(SRCDIR)/debian/rules ; \
169373Sdefan@nginx.com	}
170373Sdefan@nginx.com
171373Sdefan@nginx.comdebuild/$(SRCDIR)/debian/changelog: ../../docs/changes.xml | debuild/$(SRCDIR)/debian
172373Sdefan@nginx.com	cd ../../docs && make ../build/unit.deb-changelog
173373Sdefan@nginx.comifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE))
174373Sdefan@nginx.com	cat ../../build/unit.deb-changelog | sed \
175373Sdefan@nginx.com		-e "s/unit ($(DEFAULT_VERSION)-$(DEFAULT_RELEASE)~/unit ($(VERSION)-$(RELEASE)~/" \
176373Sdefan@nginx.com		-e "s#%%CODENAME%%#$(CODENAME)#g" \
177373Sdefan@nginx.com		> debuild/$(SRCDIR)/debian/changelog
178373Sdefan@nginx.comelse
179373Sdefan@nginx.com	cat ../../build/unit.deb-changelog | sed \
180373Sdefan@nginx.com		-e "s#%%CODENAME%%#$(CODENAME)#g" \
181373Sdefan@nginx.com		> debuild/$(SRCDIR)/debian/changelog
182373Sdefan@nginx.comendif
183373Sdefan@nginx.com
184373Sdefan@nginx.comdebuild/unit_$(VERSION).orig.tar.gz: | debuild/$(SRCDIR)/debian
185373Sdefan@nginx.com	cd ../.. && tar -czf pkg/deb/debuild/$(SRCDIR).tar.gz \
186373Sdefan@nginx.com		--transform "s#^#$(SRCDIR)/#" \
187958Sdefan@nginx.com		LICENSE NOTICE CHANGES README configure auto src test version
188373Sdefan@nginx.com	mv debuild/$(SRCDIR).tar.gz debuild/unit_$(VERSION).orig.tar.gz
189373Sdefan@nginx.com	cd debuild && tar zxf unit_$(VERSION).orig.tar.gz
190373Sdefan@nginx.com
191489Sdefan@nginx.comunit: check-build-depends-unit debuild/unit_$(VERSION).orig.tar.gz debuild/$(SRCDIR)/debian/changelog
192373Sdefan@nginx.com	@echo "===> Building $@ package"
193373Sdefan@nginx.com	cd debuild/$(SRCDIR) && debuild -us -uc
194373Sdefan@nginx.com	mkdir -p debs
195373Sdefan@nginx.com	find debuild/ -maxdepth 1 -type f -exec cp {} debs/ \;
196373Sdefan@nginx.com	ln -s debuild/$(SRCDIR)/build $@
197373Sdefan@nginx.com
198373Sdefan@nginx.comdebuild-%: debuild/unit_$(VERSION).orig.tar.gz ../../docs/changes.xml
199373Sdefan@nginx.com	mkdir $@
200373Sdefan@nginx.com	cp debuild/unit_$(VERSION).orig.tar.gz debuild-$*/unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz
201373Sdefan@nginx.com	cd $@ && tar zxf unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz
202373Sdefan@nginx.com	mkdir $@/$(SRCDIR)/debian
203373Sdefan@nginx.com	echo '9' > $@/$(SRCDIR)/debian/compat
204373Sdefan@nginx.com	mkdir $@/$(SRCDIR)/debian/source
205373Sdefan@nginx.com	echo '3.0 (quilt)' > $@/$(SRCDIR)/debian/source/format
206373Sdefan@nginx.com	cd ../../docs && make ../build/unit-$(MODULE_SUFFIX_$*).deb-changelog
207525Sdefan@nginx.comifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE))
208525Sdefan@nginx.com	cat ../../build/unit-$(MODULE_SUFFIX_$*).deb-changelog | sed \
209525Sdefan@nginx.com		-e "s/unit-$* ($(DEFAULT_VERSION)-$(DEFAULT_RELEASE)~/unit-$* ($(VERSION)-$(RELEASE)~/" \
210525Sdefan@nginx.com		-e "s#%%CODENAME%%#$(CODENAME)#g" \
211525Sdefan@nginx.com		> $@/$(SRCDIR)/debian/changelog
212525Sdefan@nginx.comelse
213373Sdefan@nginx.com	cat ../../build/unit-$(MODULE_SUFFIX_$*).deb-changelog | sed \
214373Sdefan@nginx.com		-e "s#%%CODENAME%%#$(CODENAME)#g" \
215373Sdefan@nginx.com		> $@/$(SRCDIR)/debian/changelog
216525Sdefan@nginx.comendif
217980Sdefan@nginx.com	if [ -f debian.module/copyright.unit-$(MODULE_SUFFIX_$*) ]; then \
218980Sdefan@nginx.com		cp debian.module/copyright.unit-$(MODULE_SUFFIX_$*) debuild-$*/$(SRCDIR)/debian/copyright ; \
219980Sdefan@nginx.com	else \
220980Sdefan@nginx.com		cp debian/copyright debuild-$*/$(SRCDIR)/debian/ ; \
221980Sdefan@nginx.com	fi
222373Sdefan@nginx.com	@{ \
223399Smax.romanov@nginx.com	set -e ; \
224373Sdefan@nginx.com	for src in $(MODULE_SOURCES_$*); do \
225373Sdefan@nginx.com		cp debian.module/$${src} $@/$(SRCDIR)/debian/ ; \
226373Sdefan@nginx.com	done ; \
227373Sdefan@nginx.com	definitions=`echo "$$MODULE_DEFINITIONS_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
228373Sdefan@nginx.com	prebuild=`echo "$$MODULE_PREBUILD_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
229373Sdefan@nginx.com	preinstall=`echo "$$MODULE_PREINSTALL_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
230980Sdefan@nginx.com	postinstall=`echo "$$MODULE_POSTINSTALL_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
231373Sdefan@nginx.com	post=`echo "$$MODULE_POST_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \
232980Sdefan@nginx.com	cat debian.module/$(if $(MODULE_NOARCH_$*),control-noarch.in,control.in) | sed \
233373Sdefan@nginx.com                -e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \
234373Sdefan@nginx.com                -e "s#%%SUMMARY%%#$(MODULE_SUMMARY_$*)#g" \
235373Sdefan@nginx.com                -e "s#%%CODENAME%%#$(CODENAME)#g" \
236373Sdefan@nginx.com                -e "s#%%UNIT_VERSION%%#$(VERSION)#g" \
237373Sdefan@nginx.com                -e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \
238373Sdefan@nginx.com                -e "s#%%VERSION%%#$(MODULE_VERSION_$*)#g" \
239373Sdefan@nginx.com                -e "s#%%RELEASE%%#$(MODULE_RELEASE_$*)#g" \
240373Sdefan@nginx.com                -e "s#%%MODULE_BUILD_DEPENDS%%#$(MODULE_BUILD_DEPENDS_$*)#g" \
241373Sdefan@nginx.com                -e "s#%%MODULE_DEPENDS%%#$(MODULE_DEPENDS_$*)#g" \
242373Sdefan@nginx.com        > $@/$(SRCDIR)/debian/control ; \
243980Sdefan@nginx.com        cat debian.module/$(if $(MODULE_NOARCH_$*),rules-noarch.in,rules.in) | sed \
244373Sdefan@nginx.com                -e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \
245373Sdefan@nginx.com                -e "s#%%CODENAME%%#$(CODENAME)#g" \
246373Sdefan@nginx.com                -e "s#%%UNIT_VERSION%%#$(VERSION)#g" \
247373Sdefan@nginx.com                -e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \
248373Sdefan@nginx.com                -e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \
249373Sdefan@nginx.com                -e "s#%%MODULE_CONFARGS%%#$(MODULE_CONFARGS_$*)#g" \
250373Sdefan@nginx.com                -e "s#%%MODULE_MAKEARGS%%#$(MODULE_MAKEARGS_$*)#g" \
251373Sdefan@nginx.com                -e "s#%%MODULE_INSTARGS%%#$(MODULE_INSTARGS_$*)#g" \
252373Sdefan@nginx.com                -e "s#%%MODULE_DEFINITIONS%%#$${definitions}#g" \
253373Sdefan@nginx.com                -e "s#%%MODULE_PREBUILD%%#$${prebuild}#g" \
254373Sdefan@nginx.com                -e "s#%%MODULE_PREINSTALL%%#$${preinstall}#g" \
255980Sdefan@nginx.com                -e "s#%%MODULE_POSTINSTALL%%#$${postinstall}#g" \
256373Sdefan@nginx.com        > $@/$(SRCDIR)/debian/rules ; \
257373Sdefan@nginx.com        cat debian.module/preinst.in | sed \
258373Sdefan@nginx.com                -e "s#%%MODULE_POST%%#$$post#g" \
259373Sdefan@nginx.com        > $@/$(SRCDIR)/debian/preinst ; \
260373Sdefan@nginx.com        chmod +x $@/$(SRCDIR)/debian/rules ; \
261373Sdefan@nginx.com	}
262373Sdefan@nginx.com
263489Sdefan@nginx.comunit-%: check-build-depends-% | debuild-%
264373Sdefan@nginx.com	@echo "===> Building $@ package"
265373Sdefan@nginx.com	cd debuild-$*/$(SRCDIR) && debuild -us -uc
266373Sdefan@nginx.com	mkdir -p debs
267373Sdefan@nginx.com	find debuild-$*/ -maxdepth 1 -type f -exec cp {} debs/ \;
268373Sdefan@nginx.com	ln -s debuild-$*/$(SRCDIR)/build $@
269373Sdefan@nginx.com
270501Sdefan@nginx.comtest: unit modules
271501Sdefan@nginx.com	@{ \
272980Sdefan@nginx.com	for so in `find debuild-*/unit-$(VERSION)/debian/build-unit/ -type f \( -name "*.so" -o -name "*.jar" \)`; do \
273501Sdefan@nginx.com		soname=`basename $${so}` ; \
274980Sdefan@nginx.com		test "$${soname}" = "java.unit.so" && continue ; \
275501Sdefan@nginx.com		test -h debuild/unit-$(VERSION)/debian/build-unit/build/$${soname} || \
276501Sdefan@nginx.com		ln -fs `pwd`/$${so} debuild/unit-$(VERSION)/debian/build-unit/build/$${soname} ; \
277501Sdefan@nginx.com	done ; \
278501Sdefan@nginx.com	( cd debuild/unit-$(VERSION)/debian/build-unit && ./test/run.py ) ; \
279501Sdefan@nginx.com	}
280501Sdefan@nginx.com
281501Sdefan@nginx.comtest-debug: unit modules
282501Sdefan@nginx.com	@{ \
283980Sdefan@nginx.com	for so in `find debuild-*/unit-$(VERSION)/debian/build-unit-debug/ -type f \( -name "*.so" -o -name "*.jar" \)`; do \
284501Sdefan@nginx.com		soname=`basename $${so}` ; \
285980Sdefan@nginx.com		test "$${soname}" = "java.unit.so" && continue ; \
286501Sdefan@nginx.com		test -h debuild/unit-$(VERSION)/debian/build-unit-debug/build/$${soname} || \
287501Sdefan@nginx.com		ln -fs `pwd`/$${so} debuild/unit-$(VERSION)/debian/build-unit-debug/build/$${soname} ; \
288501Sdefan@nginx.com	done ; \
289501Sdefan@nginx.com	( cd debuild/unit-$(VERSION)/debian/build-unit-debug && ./test/run.py ) ; \
290501Sdefan@nginx.com	}
291501Sdefan@nginx.com
292373Sdefan@nginx.comclean:
293373Sdefan@nginx.com	rm -rf debuild debuild-* debs ../../build
294559Sdefan@nginx.com	rm -f check-build-depends-*
295373Sdefan@nginx.com	find . -maxdepth 1 -type l -delete
296373Sdefan@nginx.com
297559Sdefan@nginx.com.PHONY: default all modules test test-debug clean
298373Sdefan@nginx.com
299559Sdefan@nginx.com.SECONDARY: $(addprefix check-build-depends-, $(MODULES)) $(addprefix debuild-, $(MODULES))
300