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 24*1289Sdefan@nginx.cominclude Makefile.python38 251040Sdefan@nginx.cominclude Makefile.go110 261040Sdefan@nginx.cominclude Makefile.go111 271040Sdefan@nginx.cominclude Makefile.perl 281040Sdefan@nginx.cominclude Makefile.ruby 291040Sdefan@nginx.cominclude Makefile.jsc-common 301040Sdefan@nginx.cominclude Makefile.jsc11 311040Sdefan@nginx.comendif 321040Sdefan@nginx.com 33902Sdefan@nginx.com# Ubuntu 18.10 34902Sdefan@nginx.comifeq ($(CODENAME),cosmic) 35902Sdefan@nginx.cominclude Makefile.php 36902Sdefan@nginx.cominclude Makefile.python27 37902Sdefan@nginx.cominclude Makefile.python36 38902Sdefan@nginx.cominclude Makefile.python37 39902Sdefan@nginx.cominclude Makefile.go19 40902Sdefan@nginx.cominclude Makefile.go110 41902Sdefan@nginx.cominclude Makefile.perl 42902Sdefan@nginx.cominclude Makefile.ruby 43980Sdefan@nginx.cominclude Makefile.jsc-common 44980Sdefan@nginx.cominclude Makefile.jsc8 45980Sdefan@nginx.cominclude Makefile.jsc11 46902Sdefan@nginx.comendif 47902Sdefan@nginx.com 48672Sdefan@nginx.com# Ubuntu 18.04 49672Sdefan@nginx.comifeq ($(CODENAME),bionic) 50672Sdefan@nginx.cominclude Makefile.php 51672Sdefan@nginx.cominclude Makefile.python27 52672Sdefan@nginx.cominclude Makefile.python36 531074Sdefan@nginx.cominclude Makefile.python37 54*1289Sdefan@nginx.cominclude Makefile.python38 55672Sdefan@nginx.cominclude Makefile.go19 56672Sdefan@nginx.cominclude Makefile.go110 57672Sdefan@nginx.cominclude Makefile.perl 58672Sdefan@nginx.cominclude Makefile.ruby 59980Sdefan@nginx.cominclude Makefile.jsc-common 60980Sdefan@nginx.cominclude Makefile.jsc8 611076Sdefan@nginx.cominclude Makefile.jsc11 62672Sdefan@nginx.comendif 63672Sdefan@nginx.com 64373Sdefan@nginx.com# Ubuntu 16.04 65373Sdefan@nginx.comifeq ($(CODENAME),xenial) 66373Sdefan@nginx.cominclude Makefile.php 67373Sdefan@nginx.cominclude Makefile.python27 68373Sdefan@nginx.cominclude Makefile.python35 69373Sdefan@nginx.cominclude Makefile.go 70524Sdefan@nginx.cominclude Makefile.perl 71600Sdefan@nginx.cominclude Makefile.ruby 72980Sdefan@nginx.cominclude Makefile.jsc-common 73980Sdefan@nginx.cominclude Makefile.jsc8 74373Sdefan@nginx.comendif 75373Sdefan@nginx.com 76373Sdefan@nginx.com# Ubuntu 14.04 77373Sdefan@nginx.comifeq ($(CODENAME),trusty) 78373Sdefan@nginx.cominclude Makefile.php 79373Sdefan@nginx.cominclude Makefile.python 80524Sdefan@nginx.cominclude Makefile.perl 81373Sdefan@nginx.comendif 82373Sdefan@nginx.com 831094Sdefan@nginx.com# Debian 10 841094Sdefan@nginx.comifeq ($(CODENAME),buster) 851094Sdefan@nginx.cominclude Makefile.php 861094Sdefan@nginx.cominclude Makefile.python27 871094Sdefan@nginx.cominclude Makefile.python37 881094Sdefan@nginx.cominclude Makefile.go111 891094Sdefan@nginx.cominclude Makefile.perl 901094Sdefan@nginx.cominclude Makefile.ruby 911094Sdefan@nginx.cominclude Makefile.jsc-common 921094Sdefan@nginx.cominclude Makefile.jsc11 931094Sdefan@nginx.comendif 941094Sdefan@nginx.com 95373Sdefan@nginx.com# Debian 9 96373Sdefan@nginx.comifeq ($(CODENAME),stretch) 97373Sdefan@nginx.cominclude Makefile.php 98373Sdefan@nginx.cominclude Makefile.python27 99373Sdefan@nginx.cominclude Makefile.python35 100373Sdefan@nginx.cominclude Makefile.go17 101373Sdefan@nginx.cominclude Makefile.go18 102524Sdefan@nginx.cominclude Makefile.perl 103600Sdefan@nginx.cominclude Makefile.ruby 104980Sdefan@nginx.cominclude Makefile.jsc-common 105980Sdefan@nginx.cominclude Makefile.jsc8 106373Sdefan@nginx.comendif 107373Sdefan@nginx.com 108373Sdefan@nginx.com# Debian 8 109373Sdefan@nginx.comifeq ($(CODENAME),jessie) 110373Sdefan@nginx.cominclude Makefile.php 111373Sdefan@nginx.cominclude Makefile.python27 112440Sdefan@nginx.cominclude Makefile.python34 113524Sdefan@nginx.cominclude Makefile.perl 114600Sdefan@nginx.cominclude Makefile.ruby 115373Sdefan@nginx.comendif 116373Sdefan@nginx.com 117373Sdefan@nginx.comCONFIGURE_ARGS=\ 118373Sdefan@nginx.com --prefix=/usr \ 119373Sdefan@nginx.com --state=/var/lib/unit \ 120373Sdefan@nginx.com --control="unix:/var/run/control.unit.sock" \ 121373Sdefan@nginx.com --pid=/var/run/unit.pid \ 122373Sdefan@nginx.com --log=/var/log/unit.log \ 123778Sdefan@nginx.com --tests \ 124778Sdefan@nginx.com --openssl 125373Sdefan@nginx.com 126373Sdefan@nginx.comexport CR=\\n 127373Sdefan@nginx.com 128373Sdefan@nginx.comdefault: 129501Sdefan@nginx.com @echo "valid targets: all modules unit $(addprefix unit-, $(MODULES)) test test-debug clean" 130373Sdefan@nginx.com 131559Sdefan@nginx.comall: check-build-depends-all unit modules 132373Sdefan@nginx.com 133373Sdefan@nginx.commodules: $(addprefix unit-, $(MODULES)) 134373Sdefan@nginx.com 135559Sdefan@nginx.comcheck-build-depends-%: 136373Sdefan@nginx.com @{ \ 137559Sdefan@nginx.com case "$*" in \ 138559Sdefan@nginx.com all) pkgs="$(BUILD_DEPENDS)" ;; \ 139559Sdefan@nginx.com unit) pkgs="$(BUILD_DEPENDS_unit)" ;; \ 140559Sdefan@nginx.com *) pkgs="$(BUILD_DEPENDS_unit) $(BUILD_DEPENDS_$*)" ;; \ 141559Sdefan@nginx.com esac ; \ 142373Sdefan@nginx.com not_installed= ; \ 143559Sdefan@nginx.com for pkg in $${pkgs}; do \ 144373Sdefan@nginx.com dpkg -s $${pkg} >/dev/null 2>&1 ; \ 145373Sdefan@nginx.com if [ $$? -ne 0 ]; then \ 146373Sdefan@nginx.com not_installed="$${not_installed} $${pkg}" ; \ 147373Sdefan@nginx.com fi ; \ 148373Sdefan@nginx.com done ; \ 149373Sdefan@nginx.com if test -n "$${not_installed}" ; then \ 150373Sdefan@nginx.com echo "" >&2 ; \ 151373Sdefan@nginx.com echo "The following packages are required in order to proceed:" >&2 ; \ 152373Sdefan@nginx.com echo "" >&2 ; \ 153373Sdefan@nginx.com echo $${not_installed} >&2 ; \ 154373Sdefan@nginx.com echo "" >&2 ; \ 155373Sdefan@nginx.com exit 1 ; \ 156373Sdefan@nginx.com fi \ 157373Sdefan@nginx.com } 158559Sdefan@nginx.com touch $@ 159489Sdefan@nginx.com 160373Sdefan@nginx.comdebuild/$(SRCDIR)/debian: 161373Sdefan@nginx.com @{ \ 162373Sdefan@nginx.com set -e ; \ 163373Sdefan@nginx.com mkdir -p debuild/$(SRCDIR) ; \ 164373Sdefan@nginx.com cp -pr debian debuild/$(SRCDIR) ; \ 165373Sdefan@nginx.com echo '9' > debuild/$(SRCDIR)/debian/compat ; \ 166373Sdefan@nginx.com mkdir -p debuild/$(SRCDIR)/debian/source ; \ 167373Sdefan@nginx.com echo '3.0 (quilt)' > debuild/$(SRCDIR)/debian/source/format ; \ 168373Sdefan@nginx.com cat debian/rules.in | sed \ 169373Sdefan@nginx.com -e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \ 170373Sdefan@nginx.com > debuild/$(SRCDIR)/debian/rules ; \ 171373Sdefan@nginx.com } 172373Sdefan@nginx.com 173373Sdefan@nginx.comdebuild/$(SRCDIR)/debian/changelog: ../../docs/changes.xml | debuild/$(SRCDIR)/debian 174373Sdefan@nginx.com cd ../../docs && make ../build/unit.deb-changelog 175373Sdefan@nginx.comifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE)) 176373Sdefan@nginx.com cat ../../build/unit.deb-changelog | sed \ 177373Sdefan@nginx.com -e "s/unit ($(DEFAULT_VERSION)-$(DEFAULT_RELEASE)~/unit ($(VERSION)-$(RELEASE)~/" \ 178373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 179373Sdefan@nginx.com > debuild/$(SRCDIR)/debian/changelog 180373Sdefan@nginx.comelse 181373Sdefan@nginx.com cat ../../build/unit.deb-changelog | sed \ 182373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 183373Sdefan@nginx.com > debuild/$(SRCDIR)/debian/changelog 184373Sdefan@nginx.comendif 185373Sdefan@nginx.com 186373Sdefan@nginx.comdebuild/unit_$(VERSION).orig.tar.gz: | debuild/$(SRCDIR)/debian 187373Sdefan@nginx.com cd ../.. && tar -czf pkg/deb/debuild/$(SRCDIR).tar.gz \ 188373Sdefan@nginx.com --transform "s#^#$(SRCDIR)/#" \ 189958Sdefan@nginx.com LICENSE NOTICE CHANGES README configure auto src test version 190373Sdefan@nginx.com mv debuild/$(SRCDIR).tar.gz debuild/unit_$(VERSION).orig.tar.gz 191373Sdefan@nginx.com cd debuild && tar zxf unit_$(VERSION).orig.tar.gz 192373Sdefan@nginx.com 193489Sdefan@nginx.comunit: check-build-depends-unit debuild/unit_$(VERSION).orig.tar.gz debuild/$(SRCDIR)/debian/changelog 194373Sdefan@nginx.com @echo "===> Building $@ package" 195373Sdefan@nginx.com cd debuild/$(SRCDIR) && debuild -us -uc 196373Sdefan@nginx.com mkdir -p debs 197373Sdefan@nginx.com find debuild/ -maxdepth 1 -type f -exec cp {} debs/ \; 198373Sdefan@nginx.com ln -s debuild/$(SRCDIR)/build $@ 199373Sdefan@nginx.com 200373Sdefan@nginx.comdebuild-%: debuild/unit_$(VERSION).orig.tar.gz ../../docs/changes.xml 201373Sdefan@nginx.com mkdir $@ 202373Sdefan@nginx.com cp debuild/unit_$(VERSION).orig.tar.gz debuild-$*/unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz 203373Sdefan@nginx.com cd $@ && tar zxf unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz 204373Sdefan@nginx.com mkdir $@/$(SRCDIR)/debian 205373Sdefan@nginx.com echo '9' > $@/$(SRCDIR)/debian/compat 206373Sdefan@nginx.com mkdir $@/$(SRCDIR)/debian/source 207373Sdefan@nginx.com echo '3.0 (quilt)' > $@/$(SRCDIR)/debian/source/format 208373Sdefan@nginx.com cd ../../docs && make ../build/unit-$(MODULE_SUFFIX_$*).deb-changelog 209525Sdefan@nginx.comifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE)) 210525Sdefan@nginx.com cat ../../build/unit-$(MODULE_SUFFIX_$*).deb-changelog | sed \ 211525Sdefan@nginx.com -e "s/unit-$* ($(DEFAULT_VERSION)-$(DEFAULT_RELEASE)~/unit-$* ($(VERSION)-$(RELEASE)~/" \ 212525Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 213525Sdefan@nginx.com > $@/$(SRCDIR)/debian/changelog 214525Sdefan@nginx.comelse 215373Sdefan@nginx.com cat ../../build/unit-$(MODULE_SUFFIX_$*).deb-changelog | sed \ 216373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 217373Sdefan@nginx.com > $@/$(SRCDIR)/debian/changelog 218525Sdefan@nginx.comendif 219980Sdefan@nginx.com if [ -f debian.module/copyright.unit-$(MODULE_SUFFIX_$*) ]; then \ 220980Sdefan@nginx.com cp debian.module/copyright.unit-$(MODULE_SUFFIX_$*) debuild-$*/$(SRCDIR)/debian/copyright ; \ 221980Sdefan@nginx.com else \ 222980Sdefan@nginx.com cp debian/copyright debuild-$*/$(SRCDIR)/debian/ ; \ 223980Sdefan@nginx.com fi 224373Sdefan@nginx.com @{ \ 225399Smax.romanov@nginx.com set -e ; \ 226373Sdefan@nginx.com for src in $(MODULE_SOURCES_$*); do \ 227373Sdefan@nginx.com cp debian.module/$${src} $@/$(SRCDIR)/debian/ ; \ 228373Sdefan@nginx.com done ; \ 229373Sdefan@nginx.com definitions=`echo "$$MODULE_DEFINITIONS_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 230373Sdefan@nginx.com prebuild=`echo "$$MODULE_PREBUILD_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 231373Sdefan@nginx.com preinstall=`echo "$$MODULE_PREINSTALL_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 232980Sdefan@nginx.com postinstall=`echo "$$MODULE_POSTINSTALL_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 233373Sdefan@nginx.com post=`echo "$$MODULE_POST_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 234980Sdefan@nginx.com cat debian.module/$(if $(MODULE_NOARCH_$*),control-noarch.in,control.in) | sed \ 235373Sdefan@nginx.com -e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \ 236373Sdefan@nginx.com -e "s#%%SUMMARY%%#$(MODULE_SUMMARY_$*)#g" \ 237373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 238373Sdefan@nginx.com -e "s#%%UNIT_VERSION%%#$(VERSION)#g" \ 239373Sdefan@nginx.com -e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \ 240373Sdefan@nginx.com -e "s#%%VERSION%%#$(MODULE_VERSION_$*)#g" \ 241373Sdefan@nginx.com -e "s#%%RELEASE%%#$(MODULE_RELEASE_$*)#g" \ 242373Sdefan@nginx.com -e "s#%%MODULE_BUILD_DEPENDS%%#$(MODULE_BUILD_DEPENDS_$*)#g" \ 243373Sdefan@nginx.com -e "s#%%MODULE_DEPENDS%%#$(MODULE_DEPENDS_$*)#g" \ 244373Sdefan@nginx.com > $@/$(SRCDIR)/debian/control ; \ 245980Sdefan@nginx.com cat debian.module/$(if $(MODULE_NOARCH_$*),rules-noarch.in,rules.in) | sed \ 246373Sdefan@nginx.com -e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \ 247373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 248373Sdefan@nginx.com -e "s#%%UNIT_VERSION%%#$(VERSION)#g" \ 249373Sdefan@nginx.com -e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \ 250373Sdefan@nginx.com -e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \ 251373Sdefan@nginx.com -e "s#%%MODULE_CONFARGS%%#$(MODULE_CONFARGS_$*)#g" \ 252373Sdefan@nginx.com -e "s#%%MODULE_MAKEARGS%%#$(MODULE_MAKEARGS_$*)#g" \ 253373Sdefan@nginx.com -e "s#%%MODULE_INSTARGS%%#$(MODULE_INSTARGS_$*)#g" \ 254373Sdefan@nginx.com -e "s#%%MODULE_DEFINITIONS%%#$${definitions}#g" \ 255373Sdefan@nginx.com -e "s#%%MODULE_PREBUILD%%#$${prebuild}#g" \ 256373Sdefan@nginx.com -e "s#%%MODULE_PREINSTALL%%#$${preinstall}#g" \ 257980Sdefan@nginx.com -e "s#%%MODULE_POSTINSTALL%%#$${postinstall}#g" \ 258373Sdefan@nginx.com > $@/$(SRCDIR)/debian/rules ; \ 259373Sdefan@nginx.com cat debian.module/preinst.in | sed \ 260373Sdefan@nginx.com -e "s#%%MODULE_POST%%#$$post#g" \ 261373Sdefan@nginx.com > $@/$(SRCDIR)/debian/preinst ; \ 262373Sdefan@nginx.com chmod +x $@/$(SRCDIR)/debian/rules ; \ 263373Sdefan@nginx.com } 264373Sdefan@nginx.com 265489Sdefan@nginx.comunit-%: check-build-depends-% | debuild-% 266373Sdefan@nginx.com @echo "===> Building $@ package" 267373Sdefan@nginx.com cd debuild-$*/$(SRCDIR) && debuild -us -uc 268373Sdefan@nginx.com mkdir -p debs 269373Sdefan@nginx.com find debuild-$*/ -maxdepth 1 -type f -exec cp {} debs/ \; 270373Sdefan@nginx.com ln -s debuild-$*/$(SRCDIR)/build $@ 271373Sdefan@nginx.com 272501Sdefan@nginx.comtest: unit modules 273501Sdefan@nginx.com @{ \ 274980Sdefan@nginx.com for so in `find debuild-*/unit-$(VERSION)/debian/build-unit/ -type f \( -name "*.so" -o -name "*.jar" \)`; do \ 275501Sdefan@nginx.com soname=`basename $${so}` ; \ 276980Sdefan@nginx.com test "$${soname}" = "java.unit.so" && continue ; \ 277501Sdefan@nginx.com test -h debuild/unit-$(VERSION)/debian/build-unit/build/$${soname} || \ 278501Sdefan@nginx.com ln -fs `pwd`/$${so} debuild/unit-$(VERSION)/debian/build-unit/build/$${soname} ; \ 279501Sdefan@nginx.com done ; \ 280501Sdefan@nginx.com ( cd debuild/unit-$(VERSION)/debian/build-unit && ./test/run.py ) ; \ 281501Sdefan@nginx.com } 282501Sdefan@nginx.com 283501Sdefan@nginx.comtest-debug: unit modules 284501Sdefan@nginx.com @{ \ 285980Sdefan@nginx.com for so in `find debuild-*/unit-$(VERSION)/debian/build-unit-debug/ -type f \( -name "*.so" -o -name "*.jar" \)`; do \ 286501Sdefan@nginx.com soname=`basename $${so}` ; \ 287980Sdefan@nginx.com test "$${soname}" = "java.unit.so" && continue ; \ 288501Sdefan@nginx.com test -h debuild/unit-$(VERSION)/debian/build-unit-debug/build/$${soname} || \ 289501Sdefan@nginx.com ln -fs `pwd`/$${so} debuild/unit-$(VERSION)/debian/build-unit-debug/build/$${soname} ; \ 290501Sdefan@nginx.com done ; \ 291501Sdefan@nginx.com ( cd debuild/unit-$(VERSION)/debian/build-unit-debug && ./test/run.py ) ; \ 292501Sdefan@nginx.com } 293501Sdefan@nginx.com 294373Sdefan@nginx.comclean: 295373Sdefan@nginx.com rm -rf debuild debuild-* debs ../../build 296559Sdefan@nginx.com rm -f check-build-depends-* 297373Sdefan@nginx.com find . -maxdepth 1 -type l -delete 298373Sdefan@nginx.com 299559Sdefan@nginx.com.PHONY: default all modules test test-debug clean 300373Sdefan@nginx.com 301559Sdefan@nginx.com.SECONDARY: $(addprefix check-build-depends-, $(MODULES)) $(addprefix debuild-, $(MODULES)) 302