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 191290Sdefan@nginx.com# Ubuntu 19.10 201290Sdefan@nginx.comifeq ($(CODENAME),eoan) 211290Sdefan@nginx.cominclude Makefile.php 221290Sdefan@nginx.cominclude Makefile.python27 231290Sdefan@nginx.cominclude Makefile.python37 241290Sdefan@nginx.cominclude Makefile.python38 25*1314Smax.romanov@nginx.cominclude Makefile.go 261290Sdefan@nginx.cominclude Makefile.perl 271290Sdefan@nginx.cominclude Makefile.ruby 281290Sdefan@nginx.cominclude Makefile.jsc-common 291290Sdefan@nginx.cominclude Makefile.jsc11 301290Sdefan@nginx.comendif 311290Sdefan@nginx.com 321040Sdefan@nginx.com# Ubuntu 19.04 331040Sdefan@nginx.comifeq ($(CODENAME),disco) 341040Sdefan@nginx.cominclude Makefile.php 351040Sdefan@nginx.cominclude Makefile.python27 361040Sdefan@nginx.cominclude Makefile.python37 371289Sdefan@nginx.cominclude Makefile.python38 38*1314Smax.romanov@nginx.cominclude Makefile.go 391040Sdefan@nginx.cominclude Makefile.perl 401040Sdefan@nginx.cominclude Makefile.ruby 411040Sdefan@nginx.cominclude Makefile.jsc-common 421040Sdefan@nginx.cominclude Makefile.jsc11 431040Sdefan@nginx.comendif 441040Sdefan@nginx.com 45902Sdefan@nginx.com# Ubuntu 18.10 46902Sdefan@nginx.comifeq ($(CODENAME),cosmic) 47902Sdefan@nginx.cominclude Makefile.php 48902Sdefan@nginx.cominclude Makefile.python27 49902Sdefan@nginx.cominclude Makefile.python36 50902Sdefan@nginx.cominclude Makefile.python37 51*1314Smax.romanov@nginx.cominclude Makefile.go 52902Sdefan@nginx.cominclude Makefile.perl 53902Sdefan@nginx.cominclude Makefile.ruby 54980Sdefan@nginx.cominclude Makefile.jsc-common 55980Sdefan@nginx.cominclude Makefile.jsc8 56980Sdefan@nginx.cominclude Makefile.jsc11 57902Sdefan@nginx.comendif 58902Sdefan@nginx.com 59672Sdefan@nginx.com# Ubuntu 18.04 60672Sdefan@nginx.comifeq ($(CODENAME),bionic) 61672Sdefan@nginx.cominclude Makefile.php 62672Sdefan@nginx.cominclude Makefile.python27 63672Sdefan@nginx.cominclude Makefile.python36 641074Sdefan@nginx.cominclude Makefile.python37 651289Sdefan@nginx.cominclude Makefile.python38 66*1314Smax.romanov@nginx.cominclude Makefile.go 67672Sdefan@nginx.cominclude Makefile.perl 68672Sdefan@nginx.cominclude Makefile.ruby 69980Sdefan@nginx.cominclude Makefile.jsc-common 70980Sdefan@nginx.cominclude Makefile.jsc8 711076Sdefan@nginx.cominclude Makefile.jsc11 72672Sdefan@nginx.comendif 73672Sdefan@nginx.com 74373Sdefan@nginx.com# Ubuntu 16.04 75373Sdefan@nginx.comifeq ($(CODENAME),xenial) 76373Sdefan@nginx.cominclude Makefile.php 77373Sdefan@nginx.cominclude Makefile.python27 78373Sdefan@nginx.cominclude Makefile.python35 79373Sdefan@nginx.cominclude Makefile.go 80524Sdefan@nginx.cominclude Makefile.perl 81600Sdefan@nginx.cominclude Makefile.ruby 82980Sdefan@nginx.cominclude Makefile.jsc-common 83980Sdefan@nginx.cominclude Makefile.jsc8 84373Sdefan@nginx.comendif 85373Sdefan@nginx.com 86373Sdefan@nginx.com# Ubuntu 14.04 87373Sdefan@nginx.comifeq ($(CODENAME),trusty) 88373Sdefan@nginx.cominclude Makefile.php 89373Sdefan@nginx.cominclude Makefile.python 90524Sdefan@nginx.cominclude Makefile.perl 91373Sdefan@nginx.comendif 92373Sdefan@nginx.com 931094Sdefan@nginx.com# Debian 10 941094Sdefan@nginx.comifeq ($(CODENAME),buster) 951094Sdefan@nginx.cominclude Makefile.php 961094Sdefan@nginx.cominclude Makefile.python27 971094Sdefan@nginx.cominclude Makefile.python37 98*1314Smax.romanov@nginx.cominclude Makefile.go 991094Sdefan@nginx.cominclude Makefile.perl 1001094Sdefan@nginx.cominclude Makefile.ruby 1011094Sdefan@nginx.cominclude Makefile.jsc-common 1021094Sdefan@nginx.cominclude Makefile.jsc11 1031094Sdefan@nginx.comendif 1041094Sdefan@nginx.com 105373Sdefan@nginx.com# Debian 9 106373Sdefan@nginx.comifeq ($(CODENAME),stretch) 107373Sdefan@nginx.cominclude Makefile.php 108373Sdefan@nginx.cominclude Makefile.python27 109373Sdefan@nginx.cominclude Makefile.python35 110*1314Smax.romanov@nginx.cominclude Makefile.go 111524Sdefan@nginx.cominclude Makefile.perl 112600Sdefan@nginx.cominclude Makefile.ruby 113980Sdefan@nginx.cominclude Makefile.jsc-common 114980Sdefan@nginx.cominclude Makefile.jsc8 115373Sdefan@nginx.comendif 116373Sdefan@nginx.com 117373Sdefan@nginx.com# Debian 8 118373Sdefan@nginx.comifeq ($(CODENAME),jessie) 119373Sdefan@nginx.cominclude Makefile.php 120373Sdefan@nginx.cominclude Makefile.python27 121440Sdefan@nginx.cominclude Makefile.python34 122524Sdefan@nginx.cominclude Makefile.perl 123600Sdefan@nginx.cominclude Makefile.ruby 124373Sdefan@nginx.comendif 125373Sdefan@nginx.com 126373Sdefan@nginx.comCONFIGURE_ARGS=\ 127373Sdefan@nginx.com --prefix=/usr \ 128373Sdefan@nginx.com --state=/var/lib/unit \ 129373Sdefan@nginx.com --control="unix:/var/run/control.unit.sock" \ 130373Sdefan@nginx.com --pid=/var/run/unit.pid \ 131373Sdefan@nginx.com --log=/var/log/unit.log \ 132778Sdefan@nginx.com --tests \ 133778Sdefan@nginx.com --openssl 134373Sdefan@nginx.com 135373Sdefan@nginx.comexport CR=\\n 136373Sdefan@nginx.com 137373Sdefan@nginx.comdefault: 138501Sdefan@nginx.com @echo "valid targets: all modules unit $(addprefix unit-, $(MODULES)) test test-debug clean" 139373Sdefan@nginx.com 140559Sdefan@nginx.comall: check-build-depends-all unit modules 141373Sdefan@nginx.com 142373Sdefan@nginx.commodules: $(addprefix unit-, $(MODULES)) 143373Sdefan@nginx.com 144559Sdefan@nginx.comcheck-build-depends-%: 145373Sdefan@nginx.com @{ \ 146559Sdefan@nginx.com case "$*" in \ 147559Sdefan@nginx.com all) pkgs="$(BUILD_DEPENDS)" ;; \ 148559Sdefan@nginx.com unit) pkgs="$(BUILD_DEPENDS_unit)" ;; \ 149559Sdefan@nginx.com *) pkgs="$(BUILD_DEPENDS_unit) $(BUILD_DEPENDS_$*)" ;; \ 150559Sdefan@nginx.com esac ; \ 151373Sdefan@nginx.com not_installed= ; \ 152559Sdefan@nginx.com for pkg in $${pkgs}; do \ 153373Sdefan@nginx.com dpkg -s $${pkg} >/dev/null 2>&1 ; \ 154373Sdefan@nginx.com if [ $$? -ne 0 ]; then \ 155373Sdefan@nginx.com not_installed="$${not_installed} $${pkg}" ; \ 156373Sdefan@nginx.com fi ; \ 157373Sdefan@nginx.com done ; \ 158373Sdefan@nginx.com if test -n "$${not_installed}" ; then \ 159373Sdefan@nginx.com echo "" >&2 ; \ 160373Sdefan@nginx.com echo "The following packages are required in order to proceed:" >&2 ; \ 161373Sdefan@nginx.com echo "" >&2 ; \ 162373Sdefan@nginx.com echo $${not_installed} >&2 ; \ 163373Sdefan@nginx.com echo "" >&2 ; \ 164373Sdefan@nginx.com exit 1 ; \ 165373Sdefan@nginx.com fi \ 166373Sdefan@nginx.com } 167559Sdefan@nginx.com touch $@ 168489Sdefan@nginx.com 169373Sdefan@nginx.comdebuild/$(SRCDIR)/debian: 170373Sdefan@nginx.com @{ \ 171373Sdefan@nginx.com set -e ; \ 172373Sdefan@nginx.com mkdir -p debuild/$(SRCDIR) ; \ 173373Sdefan@nginx.com cp -pr debian debuild/$(SRCDIR) ; \ 174373Sdefan@nginx.com echo '9' > debuild/$(SRCDIR)/debian/compat ; \ 175373Sdefan@nginx.com mkdir -p debuild/$(SRCDIR)/debian/source ; \ 176373Sdefan@nginx.com echo '3.0 (quilt)' > debuild/$(SRCDIR)/debian/source/format ; \ 177373Sdefan@nginx.com cat debian/rules.in | sed \ 178373Sdefan@nginx.com -e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \ 179373Sdefan@nginx.com > debuild/$(SRCDIR)/debian/rules ; \ 180373Sdefan@nginx.com } 181373Sdefan@nginx.com 182373Sdefan@nginx.comdebuild/$(SRCDIR)/debian/changelog: ../../docs/changes.xml | debuild/$(SRCDIR)/debian 183373Sdefan@nginx.com cd ../../docs && make ../build/unit.deb-changelog 184373Sdefan@nginx.comifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE)) 185373Sdefan@nginx.com cat ../../build/unit.deb-changelog | sed \ 186373Sdefan@nginx.com -e "s/unit ($(DEFAULT_VERSION)-$(DEFAULT_RELEASE)~/unit ($(VERSION)-$(RELEASE)~/" \ 187373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 188373Sdefan@nginx.com > debuild/$(SRCDIR)/debian/changelog 189373Sdefan@nginx.comelse 190373Sdefan@nginx.com cat ../../build/unit.deb-changelog | sed \ 191373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 192373Sdefan@nginx.com > debuild/$(SRCDIR)/debian/changelog 193373Sdefan@nginx.comendif 194373Sdefan@nginx.com 195373Sdefan@nginx.comdebuild/unit_$(VERSION).orig.tar.gz: | debuild/$(SRCDIR)/debian 196373Sdefan@nginx.com cd ../.. && tar -czf pkg/deb/debuild/$(SRCDIR).tar.gz \ 197373Sdefan@nginx.com --transform "s#^#$(SRCDIR)/#" \ 198958Sdefan@nginx.com LICENSE NOTICE CHANGES README configure auto src test version 199373Sdefan@nginx.com mv debuild/$(SRCDIR).tar.gz debuild/unit_$(VERSION).orig.tar.gz 200373Sdefan@nginx.com cd debuild && tar zxf unit_$(VERSION).orig.tar.gz 201373Sdefan@nginx.com 202489Sdefan@nginx.comunit: check-build-depends-unit debuild/unit_$(VERSION).orig.tar.gz debuild/$(SRCDIR)/debian/changelog 203373Sdefan@nginx.com @echo "===> Building $@ package" 204373Sdefan@nginx.com cd debuild/$(SRCDIR) && debuild -us -uc 205373Sdefan@nginx.com mkdir -p debs 206373Sdefan@nginx.com find debuild/ -maxdepth 1 -type f -exec cp {} debs/ \; 207373Sdefan@nginx.com ln -s debuild/$(SRCDIR)/build $@ 208373Sdefan@nginx.com 209373Sdefan@nginx.comdebuild-%: debuild/unit_$(VERSION).orig.tar.gz ../../docs/changes.xml 210373Sdefan@nginx.com mkdir $@ 211373Sdefan@nginx.com cp debuild/unit_$(VERSION).orig.tar.gz debuild-$*/unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz 212373Sdefan@nginx.com cd $@ && tar zxf unit-$(MODULE_SUFFIX_$*)_$(VERSION).orig.tar.gz 213373Sdefan@nginx.com mkdir $@/$(SRCDIR)/debian 214373Sdefan@nginx.com echo '9' > $@/$(SRCDIR)/debian/compat 215373Sdefan@nginx.com mkdir $@/$(SRCDIR)/debian/source 216373Sdefan@nginx.com echo '3.0 (quilt)' > $@/$(SRCDIR)/debian/source/format 217373Sdefan@nginx.com cd ../../docs && make ../build/unit-$(MODULE_SUFFIX_$*).deb-changelog 218525Sdefan@nginx.comifneq ($(DEFAULT_VERSION)$(DEFAULT_RELEASE), $(VERSION)$(RELEASE)) 219525Sdefan@nginx.com cat ../../build/unit-$(MODULE_SUFFIX_$*).deb-changelog | sed \ 220525Sdefan@nginx.com -e "s/unit-$* ($(DEFAULT_VERSION)-$(DEFAULT_RELEASE)~/unit-$* ($(VERSION)-$(RELEASE)~/" \ 221525Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 222525Sdefan@nginx.com > $@/$(SRCDIR)/debian/changelog 223525Sdefan@nginx.comelse 224373Sdefan@nginx.com cat ../../build/unit-$(MODULE_SUFFIX_$*).deb-changelog | sed \ 225373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 226373Sdefan@nginx.com > $@/$(SRCDIR)/debian/changelog 227525Sdefan@nginx.comendif 228980Sdefan@nginx.com if [ -f debian.module/copyright.unit-$(MODULE_SUFFIX_$*) ]; then \ 229980Sdefan@nginx.com cp debian.module/copyright.unit-$(MODULE_SUFFIX_$*) debuild-$*/$(SRCDIR)/debian/copyright ; \ 230980Sdefan@nginx.com else \ 231980Sdefan@nginx.com cp debian/copyright debuild-$*/$(SRCDIR)/debian/ ; \ 232980Sdefan@nginx.com fi 233373Sdefan@nginx.com @{ \ 234399Smax.romanov@nginx.com set -e ; \ 235373Sdefan@nginx.com for src in $(MODULE_SOURCES_$*); do \ 236373Sdefan@nginx.com cp debian.module/$${src} $@/$(SRCDIR)/debian/ ; \ 237373Sdefan@nginx.com done ; \ 238373Sdefan@nginx.com definitions=`echo "$$MODULE_DEFINITIONS_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 239373Sdefan@nginx.com prebuild=`echo "$$MODULE_PREBUILD_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 240373Sdefan@nginx.com preinstall=`echo "$$MODULE_PREINSTALL_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 241980Sdefan@nginx.com postinstall=`echo "$$MODULE_POSTINSTALL_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 242373Sdefan@nginx.com post=`echo "$$MODULE_POST_$*" | sed -e ':a' -e 'N' -e '$$!ba' -e "s/\n/\$$CR/g"` ; \ 243980Sdefan@nginx.com cat debian.module/$(if $(MODULE_NOARCH_$*),control-noarch.in,control.in) | sed \ 244373Sdefan@nginx.com -e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \ 245373Sdefan@nginx.com -e "s#%%SUMMARY%%#$(MODULE_SUMMARY_$*)#g" \ 246373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 247373Sdefan@nginx.com -e "s#%%UNIT_VERSION%%#$(VERSION)#g" \ 248373Sdefan@nginx.com -e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \ 249373Sdefan@nginx.com -e "s#%%VERSION%%#$(MODULE_VERSION_$*)#g" \ 250373Sdefan@nginx.com -e "s#%%RELEASE%%#$(MODULE_RELEASE_$*)#g" \ 251373Sdefan@nginx.com -e "s#%%MODULE_BUILD_DEPENDS%%#$(MODULE_BUILD_DEPENDS_$*)#g" \ 252373Sdefan@nginx.com -e "s#%%MODULE_DEPENDS%%#$(MODULE_DEPENDS_$*)#g" \ 253373Sdefan@nginx.com > $@/$(SRCDIR)/debian/control ; \ 254980Sdefan@nginx.com cat debian.module/$(if $(MODULE_NOARCH_$*),rules-noarch.in,rules.in) | sed \ 255373Sdefan@nginx.com -e "s#%%NAME%%#unit-$(MODULE_SUFFIX_$*)#g" \ 256373Sdefan@nginx.com -e "s#%%CODENAME%%#$(CODENAME)#g" \ 257373Sdefan@nginx.com -e "s#%%UNIT_VERSION%%#$(VERSION)#g" \ 258373Sdefan@nginx.com -e "s#%%UNIT_RELEASE%%#$(RELEASE)#g" \ 259373Sdefan@nginx.com -e "s#%%CONFIGURE_ARGS%%#$(CONFIGURE_ARGS)#g" \ 260373Sdefan@nginx.com -e "s#%%MODULE_CONFARGS%%#$(MODULE_CONFARGS_$*)#g" \ 261373Sdefan@nginx.com -e "s#%%MODULE_MAKEARGS%%#$(MODULE_MAKEARGS_$*)#g" \ 262373Sdefan@nginx.com -e "s#%%MODULE_INSTARGS%%#$(MODULE_INSTARGS_$*)#g" \ 263373Sdefan@nginx.com -e "s#%%MODULE_DEFINITIONS%%#$${definitions}#g" \ 264373Sdefan@nginx.com -e "s#%%MODULE_PREBUILD%%#$${prebuild}#g" \ 265373Sdefan@nginx.com -e "s#%%MODULE_PREINSTALL%%#$${preinstall}#g" \ 266980Sdefan@nginx.com -e "s#%%MODULE_POSTINSTALL%%#$${postinstall}#g" \ 267373Sdefan@nginx.com > $@/$(SRCDIR)/debian/rules ; \ 268373Sdefan@nginx.com cat debian.module/preinst.in | sed \ 269373Sdefan@nginx.com -e "s#%%MODULE_POST%%#$$post#g" \ 270373Sdefan@nginx.com > $@/$(SRCDIR)/debian/preinst ; \ 271373Sdefan@nginx.com chmod +x $@/$(SRCDIR)/debian/rules ; \ 272373Sdefan@nginx.com } 273373Sdefan@nginx.com 274489Sdefan@nginx.comunit-%: check-build-depends-% | debuild-% 275373Sdefan@nginx.com @echo "===> Building $@ package" 276373Sdefan@nginx.com cd debuild-$*/$(SRCDIR) && debuild -us -uc 277373Sdefan@nginx.com mkdir -p debs 278373Sdefan@nginx.com find debuild-$*/ -maxdepth 1 -type f -exec cp {} debs/ \; 279373Sdefan@nginx.com ln -s debuild-$*/$(SRCDIR)/build $@ 280373Sdefan@nginx.com 281501Sdefan@nginx.comtest: unit modules 282501Sdefan@nginx.com @{ \ 283980Sdefan@nginx.com for so in `find debuild-*/unit-$(VERSION)/debian/build-unit/ -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/build/$${soname} || \ 287501Sdefan@nginx.com ln -fs `pwd`/$${so} debuild/unit-$(VERSION)/debian/build-unit/build/$${soname} ; \ 288501Sdefan@nginx.com done ; \ 289501Sdefan@nginx.com ( cd debuild/unit-$(VERSION)/debian/build-unit && ./test/run.py ) ; \ 290501Sdefan@nginx.com } 291501Sdefan@nginx.com 292501Sdefan@nginx.comtest-debug: unit modules 293501Sdefan@nginx.com @{ \ 294980Sdefan@nginx.com for so in `find debuild-*/unit-$(VERSION)/debian/build-unit-debug/ -type f \( -name "*.so" -o -name "*.jar" \)`; do \ 295501Sdefan@nginx.com soname=`basename $${so}` ; \ 296980Sdefan@nginx.com test "$${soname}" = "java.unit.so" && continue ; \ 297501Sdefan@nginx.com test -h debuild/unit-$(VERSION)/debian/build-unit-debug/build/$${soname} || \ 298501Sdefan@nginx.com ln -fs `pwd`/$${so} debuild/unit-$(VERSION)/debian/build-unit-debug/build/$${soname} ; \ 299501Sdefan@nginx.com done ; \ 300501Sdefan@nginx.com ( cd debuild/unit-$(VERSION)/debian/build-unit-debug && ./test/run.py ) ; \ 301501Sdefan@nginx.com } 302501Sdefan@nginx.com 303373Sdefan@nginx.comclean: 304373Sdefan@nginx.com rm -rf debuild debuild-* debs ../../build 305559Sdefan@nginx.com rm -f check-build-depends-* 306373Sdefan@nginx.com find . -maxdepth 1 -type l -delete 307373Sdefan@nginx.com 308559Sdefan@nginx.com.PHONY: default all modules test test-debug clean 309373Sdefan@nginx.com 310559Sdefan@nginx.com.SECONDARY: $(addprefix check-build-depends-, $(MODULES)) $(addprefix debuild-, $(MODULES)) 311