#!/usr/bin/make -f include /usr/share/cdbs/1/class/python-module.mk include /usr/share/cdbs/1/rules/debhelper.mk # the equivalent of "uwsgi-core --dot-h | md5sum" at runtime abi = $(firstword $(shell echo | cat uwsgi.h - | md5sum)) # resolve supported architectures for arch-varying build-dependencies # (in maintainer mode only: uses network and messes with control file) ifneq (,$(DEB_MAINTAINER_MODE)) $(shell sh debian/pkgarchs.sh glusterfs-common > debian/ARCHS_glusterfs) $(shell sh debian/pkgarchs.sh python-greenlet-dev > debian/ARCHS_greenlet) $(shell sh debian/pkgarchs.sh openjdk-17-jdk > debian/ARCHS_openjdk17) $(shell sh debian/pkgarchs.sh librados-dev > debian/ARCHS_rados) $(shell sh debian/pkgarchs.sh gccgo > debian/ARCHS_gccgo) endif UWSGI_ARCHLISTS = glusterfs greenlet openjdk17 rados gccgo $(foreach list,$(UWSGI_ARCHLISTS),\ $(eval UWSGI_ARCHS_$(list) := $(shell cat debian/ARCHS_$(list)))) ifneq (,$(DEB_MAINTAINER_MODE)) debian/control:: perl -sgpi \ -e 'BEGIN { %re = (' \ -e ' glusterfs => qr/glusterfs/,' \ -e ' greenlet => qr/(gevent|greenlet)/,' \ -e ' openjdk17 => qr/jdk/,' \ -e ' rados => qr/rados/,' \ -e ' gccgo => qr/gccgo/,' \ -e ')}' \ -e 'while ( my ($$key, $$pat) = each %re ) {' \ -e ' my $$list = $${$$key};' \ -e ' s/^# autogenerated:.+\n\s+\S*$$pat.*\[\K[^\]\n]*/$$list/gm;' \ -e ' s/^Package:.*$$pat.*\n# autogenerated:.+\nArchitecture:\s+\K[^\n]*/$$list/gm;' \ -e '};' \ -- $(foreach list,$(UWSGI_ARCHLISTS),-$(list)='$(UWSGI_ARCHS_$(list))') \ -- $@ endif # Common variables # ================ UWSGI_ENV = CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" UWSGI_BUILDER = uwsgiconfig.py -v # Transform plugin's package name to plugin's name: # * delete dots # * replace '-' with '_' pkg_name_to_plugin_name = $(strip $(subst -,_,$(subst .,,$(1)))) UWSGI_PLUGIN_INFILES := $(wildcard debian/*__PLUGIN__*.in) UWSGI_PLUGIN_PACKAGES = $(filter uwsgi-plugin-%,$(DEB_PACKAGES)) UWSGI_SRCPLUGINS_AVAILABLE := $(sort $(notdir $(wildcard plugins/*))) UWSGI_SRCPLUGINS_ZEROMQ = emperor_zeromq logzmq mongrel2 # TODO: enable PyPy when supported by CDBS UWSGI_SRCPLUGINS_TODO = pypy # plugins not yet ready for production use UWSGI_SRCPLUGINS_EXPERIMENTAL = libffi libtcc router_spnego # plugins irrelevant/unusable for Debian or built separately (by another # dedicated source package. UWSGI_SRCPLUGINS_ALIEN = airbrake alarm_speech matheval mongodb \ stackless emperor_mongodb gridfs mongodblog mono php \ stats_pusher_mongodb v8 gccgo jvm ring servlet jwsgi \ glusterfs rados rack fiber rbthreads lua \ python tornado asyncio greenlet gevent psgi coroae UWSGI_SRCPLUGINS_DEMO = cplusplus dumbloop dummy example exception_log UWSGI_SRCPLUGINS_UNKNOWN = legion_cache_fetch objc_gc pyuwsgi ruby19 UWSGI_SRCPLUGINS_EXCLUDE = $(UWSGI_SRCPLUGINS_ALIEN) \ $(UWSGI_SRCPLUGINS_DEMO) $(UWSGI_SRCPLUGINS_EXPERIMENTAL) \ $(UWSGI_SRCPLUGINS_TODO) $(UWSGI_SRCPLUGINS_UNKNOWN) UWSGI_SRCPLUGINS_WANTED = $(filter-out $(UWSGI_SRCPLUGINS_EXCLUDE),\ $(UWSGI_SRCPLUGINS_AVAILABLE)) UWSGI_SRCPLUGINS_ADDON_LANG = $(call pkg_name_to_plugin_name,\ $(UWSGI_SRCPLUGINS_LANG_SELF) \ $(foreach lang,$(UWSGI_PLUGINLANGS),$(UWSGI_SRCPLUGINS_$(lang)))) UWSGI_SRCPLUGINS_ADDON_MISC = alarm_curl alarm_xmpp curl_cron \ emperor_pg geoip graylog2 ldap \ router_access sqlite3 xslt # tun/tap is unavailable on the Hurd # systemd is available only on linux # tuntap plugin broken on kFreeBSD: https://github.com/unbit/uwsgi/issues/695 UWSGI_SRCPLUGINS_SKIP = \ $(foreach list,$(UWSGI_ARCHLISTS),\ $(if $(filter-out $(UWSGI_ARCHS_$(list)),$(DEB_HOST_ARCH)),\ $(UWSGI_SRCPLUGINS_ARCH_$(list)))) \ $(if $(filter hurd,$(DEB_HOST_ARCH_OS)),\ tuntap) \ $(if $(filter kfreebsd,$(DEB_HOST_ARCH_OS)),\ tuntap) \ $(if $(filter-out linux,$(DEB_HOST_ARCH_OS)),\ systemd_logger) UWSGI_SRCPLUGINS_CORE = $(filter-out \ $(UWSGI_SRCPLUGINS_ADDON_LANG) $(UWSGI_SRCPLUGINS_ADDON_MISC) \ $(UWSGI_SRCPLUGINS_SKIP),\ $(UWSGI_SRCPLUGINS_WANTED)) UWSGI_SRCPLUGINS_CORE_INSTALL = $(filter-out \ $(UWSGI_SRCPLUGINS_SKIPINSTALL),\ $(UWSGI_SRCPLUGINS_CORE)) # types of packaging scripts to use (tried from left to right) # * pri: binary and library # * sec: only binary # * aux: only library # * single: only one flavor exist UWSGI_PKGSCRIPTS_DEFAULT = sec # Stem-based variables # ==================== pkg_name = $(cdbs_curpkg) plugin_name = $(call pkg_name_to_plugin_name,$*) plugin_is_lang = $(strip $(or \ $(foreach lang,$(UWSGI_PLUGINLANGS),\ $(if $(filter $(UWSGI_KINDS_$(lang)),$*),$(lang))))) plugin_has_lang = $(strip $(foreach lang,$(UWSGI_PLUGINLANGS),\ $(foreach srcplugin,$(UWSGI_SRCPLUGINS_$(lang)),\ $(foreach kind,$(UWSGI_KINDS_$(lang)),\ $(if $(filter $(srcplugin)-$(kind),$*),\ $(lang)))))) plugin_lang = $(strip $(or \ $(plugin_is_lang),\ $(plugin_has_lang))) plugin_stem = $(strip $(or \ $(plugin_is_lang),\ $(foreach kind,$(UWSGI_KINDS_$(plugin_has_lang)),\ $(patsubst %-$(kind),%,$(filter %-$(kind),$*))))) plugin_kind = $(strip $(or \ $(if $(plugin_is_lang),\ $*),\ $(foreach kind,$(UWSGI_KINDS_$(plugin_has_lang)),\ $(if $(filter %-$(kind),$*),\ $(kind))))) plugin_src = $(strip \ $(call pkg_name_to_plugin_name,$(or \ $(plugin_stem),\ $*))) plugin_lang_stem = $(strip \ $(if $(filter java,$(plugin_lang)),\ $(firstword $(subst -, ,$(plugin_kind))))) plugin_lang_kind = $(strip \ $(if $(filter java python,$(plugin_lang)),\ $(lastword $(subst -, ,$(plugin_kind))))) # workaround for #868752 #plugin_flavors = $(strip \ # $(if $(filter python,$(plugin_lang)),\ # $(cdbs_$(plugin_lang_kind:python=python2)_allflavors))) plugin_flavors = $(plugin_defaultflavor) # workaround end plugin_defaultflavor = $(strip \ $(if $(filter python,$(plugin_lang)),\ $(cdbs_$(plugin_lang_kind:python=python2)_defaultflavor))) plugin_alternatives_name = uwsgi-plugin-$(strip $(or \ $(if $(filter python,$(plugin_is_lang)),\ $(plugin_lang_kind)),\ $(if $(filter python,$(plugin_has_lang)),\ $(plugin_stem)-$(plugin_lang_kind)),\ $(plugin_stem),\ $(plugin_name))) plugin_alternatives_stem = $(strip $(or \ $(if $(filter python,$(plugin_is_lang)),\ $(plugin_lang_kind)),\ $(plugin_stem))) plugin_alternatives_priority = $(strip \ $(if $(filter $(plugin_kind),$(UWSGI_DEFAULTKIND_$(plugin_lang))),\ 75,\ 35)) plugin_flavor_prefix = $(strip \ $(if $(filter python,$(plugin_is_lang)),\ ,\ $(plugin_stem)_)) # per-infile variables, relying on $(infile) and optional $(plugin_src) plugin_pkgtypes = $(or $(UWSGI_PKGSCRIPTS_$(plugin_src)),$(UWSGI_PKGSCRIPTS_DEFAULT)) plugin_has_binary = $(filter pri sec,$(plugin_pkgtypes)) # plugin_infile picks first existing infile variant: # 1. $(infile).$(UWSGI_PKGSCRIPTS_$(plugin_src)) # 2. $(infile).$(UWSGI_PKGSCRIPTS_DEFAULT) # 3. $(infile) plugin_infile = $(firstword $(wildcard \ $(foreach suffix,$(plugin_pkgtypes),\ $(addsuffix .$(suffix),$(infile))) \ $(infile) \ )) # Package-specific variables # ========================== DEB_COMPRESS_EXCLUDE_uwsgi-core = .ini .lua .pl .png .psgi .py .ru .ws .xml \ .yml DEB_COMPRESS_EXCLUDE_uwsgi-extra = .class .java .rb .c DEB_DH_STRIP_ARGS_ALL := $(strip $(subst COND,(<< 2.0.26-3~),\ --dbgsym-migration='uwsgi-dbg COND')) DEB_INSTALL_DOCS_ALL += $(DEB_SRCDIR)/CONTRIBUTORS DEB_DH_INSTALL_ARGS_uwsgi-core = \ $(addsuffix _plugin.so,$(UWSGI_SRCPLUGINS_CORE_INSTALL)) \ usr/lib/uwsgi/plugins DEB_DH_GENCONTROL_ARGS_uwsgi-core = -- -V'uwsgi:Provides=uwsgi-abi-$(abi)' # Rules # ===== clean:: $(cdbs_python3_defaultruntime) $(UWSGI_BUILDER) --clean find -type f -name '*.pyc' -delete find -type d -name __pycache__ -delete rm -f debian/stamp-* # add per-package hook to expand packaging files as patch before configure apply-patches:: \ $(patsubst %,debian/expand-files/%,$(DEB_ALL_PACKAGES)) $(patsubst %,debian/expand-files/%,$(DEB_ALL_PACKAGES)): \ debian/expand-files/%: \ | debian/expand-files debian/expand-files: post-patches mkdir debian/expand-files clean:: rm -rf debian/expand-files # uwsgi-core package # ------------------ substvars-list-encode = perl -0 -F'/\s+/' -ane 'print " * ", join("\$${Newline} * ",@F)' uwsgi-coreplugins := $(call pkg_name_to_plugin_name,$(UWSGI_SRCPLUGINS_CORE_INSTALL)) uwsgi-corepluginlist := $(shell echo $(uwsgi-coreplugins) | $(substvars-list-encode)) build/uwsgi-core:: bin/uwsgi-core bin/uwsgi-core: $(UWSGI_ENV) $(cdbs_python3_defaultruntime) $(UWSGI_BUILDER) \ --build debian/buildconf/uwsgi-core.ini set -e; \ for PLUGIN_NAME in $(UWSGI_SRCPLUGINS_CORE); do \ $(UWSGI_ENV) $(cdbs_python3_defaultruntime) $(UWSGI_BUILDER) \ --plugin plugins/$${PLUGIN_NAME} \ debian/buildconf/uwsgi-plugin.ini \ $${PLUGIN_NAME}; \ done install/uwsgi-core:: echo 'uwsgi:corepluginlist=$(uwsgi-corepluginlist)' >> debian/$(cdbs_curpkg).substvars # move installed examples into subdirs by type ex_types = conffile psgi rack router wsapi wsgi ex_conffile = mega.xml multi.* sites.xml uwsgi.xml vassals werkzeug_strict.yml werkzeug.* ex_rack = config.ru config2.ru fibers.* ex_router = router.lua uwsgirouter* ex_psgi = mojoapp.pl ex_wsapi = *.ws ex_wsgi = mjpeg_stream.py multiapp.py simple_app.py simple_app_wsgi2.py taskqueue.py ex_drop = bootstrap* config*.lua config??.ru corostream.pl debug.ini ex_drop += flaskpost.py heavytest.* info_uwsgi.php logic.ini ex_drop += protected.ini welcome.ini welcome3.py binary-post-install/uwsgi-core:: set -e; \ cd debian/$(cdbs_curpkg)/usr/share/doc/$(cdbs_curpkg)/examples; \ $(foreach type, $(ex_types),mkdir $(type); mv -t $(type) $(ex_$(type));) \ rm $(ex_drop) install/uwsgi-core:: help2man \ --name 'fast (pure C), self-healing, developer-friendly WSGI server' \ --section 1 \ --no-info \ bin/uwsgi-core \ > debian/uwsgi-core.1 # uwsgi-plugin-% packages # ----------------------- # setup hook for building plugins $(patsubst %,build/%,$(UWSGI_PLUGIN_PACKAGES)):: \ build/uwsgi-plugin-%: \ bin/uwsgi-core debian/stamp-uwsgi-plugin-% $(patsubst %,debian/stamp-%,$(UWSGI_PLUGIN_PACKAGES)): \ debian/stamp-uwsgi-plugin-%: $(UWSGI_ENV) $(cdbs_python3_defaultruntime) $(UWSGI_BUILDER) \ --plugin plugins/$(plugin_src) \ debian/buildconf/uwsgi-plugin.ini \ $(plugin_name) touch $@ # resolve packaging scripts and man pages # --------------------------------------- $(patsubst %,debian/expand-files/%,$(UWSGI_PLUGIN_PACKAGES)): \ debian/expand-files/uwsgi-plugin-%: set -e; \ $(foreach infile,$(UWSGI_PLUGIN_INFILES),\ $(if $(shell test -s "$(plugin_infile)" && echo "not empty"),\ sed \ -e 's/@@pkg_name@@/$(pkg_name)/g' \ -e 's/@@plugin_name@@/$(plugin_name)/g' \ -e 's/@@plugin_stem@@/$(plugin_stem)/g' \ -e 's/@@plugin_alternatives_name@@/$(plugin_alternatives_name)/g' \ -e 's/@@plugin_alternatives_stem@@/$(plugin_alternatives_stem)/g' \ -e 's/@@plugin_alternatives_priority@@/$(plugin_alternatives_priority)/g' \ -e 's/@@plugin_lang_kind@@/$(plugin_lang_kind)/g' \ -e 's/@@plugin_flavors_dotless@@/$(subst .,,$(plugin_flavors))/g' \ -e 's/@@plugin_defaultflavor_dotless@@/$(subst .,,$(plugin_defaultflavor))/g' \ < $(plugin_infile) \ > $(subst __PLUGIN__,$*,$(basename $(infile)));))\ $(if $(filter python,$(plugin_lang)),\ $(foreach flavor,$(plugin_flavors),\ $(foreach infile,install $(if $(plugin_has_binary),links manpages),sed \ -e "s/@@plugin_name@@/$(plugin_flavor_prefix)$(subst .,,$(flavor))/g" \ < debian/uwsgi-plugin-__PLUGIN__.$(infile).in \ >> debian/$(cdbs_curpkg).$(infile);))\ chmod 755 debian/$(cdbs_curpkg).rtupdate;\ echo "debian/$(cdbs_curpkg).rtupdate usr/share/$(plugin_lang_kind)/runtime.d" \ >> debian/$(cdbs_curpkg).install ) touch $@ $(patsubst %,install/%,$(UWSGI_PLUGIN_PACKAGES)):: \ install/uwsgi-plugin-%: set -e; \ $(if $(plugin_has_binary),\ ln -sf uwsgi-core bin/uwsgi_$(plugin_name);\ help2man \ --name 'fast (pure C)$(comma) self-healing$(comma) developer-friendly WSGI server' \ --section 1 \ --no-info \ bin/uwsgi_$(plugin_name) \ > debian/uwsgi_$(plugin_name).1) # put aside a copy of plugins code before configure common-configure-arch common-configure-indep:: debian/stamp-codemirror debian/stamp-codemirror:: post-patches rm -rf plugins-src cp -a plugins plugins-src touch $@ clean:: rm -f debian/stamp-codemirror ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) common-build-indep:: debian/test-shellcheck endif debian/test-shellcheck: find debian \ -type f -not -empty -regextype egrep \ -regex '.*(postinst|prerm|rtupdate|init\.d).*' \ -exec shellcheck -e SC1090,SC1091,SC2034,SC2043 -s sh {} + shellcheck -e SC1091,SC2001,SC2034,SC2162 -s bash debian/uwsgi-files/init/* touch $@ clean:: rm -f debian/test-shellcheck # source package # -------------- binary-post-install/uwsgi-src:: find debian/$(cdbs_curpkg)/usr/src/uwsgi \ -type f -name '*.key' -or -name '*.dll' -delete # Generate manpages during build common-post-build-arch:: debian/stamp-manpage-build debian/stamp-manpage-build: pod2man debian/debhelper/dh_uwsgi > debian/debhelper/dh_uwsgi.1 touch $@