From 6731314639c67ed533827113f2bc381b8bc87693 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 27 Oct 2010 19:52:17 +0200 Subject: [PATCH] Makefile: Generalize bootstrap script generator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- Makefile.am | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index 59819aafd..edbe23b94 100644 --- a/Makefile.am +++ b/Makefile.am @@ -633,28 +633,31 @@ $(REPLACE_VARS_SED): Makefile echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \ } > $@ +# Using deferred evaluation +scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@)) + $(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles) + test -n "$(MODULE)" || { echo Missing module; exit 1; } set -e; \ - module='$(subst -,_,$(notdir $@))'; \ { echo '#!/usr/bin/python'; \ echo '# This file is automatically generated, do not edit!'; \ - echo "# Edit ganeti.client.$$module instead."; \ + echo "# Edit $(MODULE) instead."; \ echo; \ - echo '"""Bootstrap script for L{ganeti.client.'"$$module"'}"""'; \ + echo '"""Bootstrap script for L{$(MODULE)}"""'; \ echo; \ echo '# pylint: disable-msg=C0103'; \ echo '# C0103: Invalid name'; \ echo; \ echo 'import sys'; \ - echo "from ganeti.client import $$module"; \ + echo 'import $(MODULE) as main'; \ echo; \ echo '# Temporarily alias commands until bash completion'; \ echo '# generator is changed'; \ - echo "if hasattr($$module, \"commands\"):"; \ - echo " commands = $$module.commands"; \ + echo 'if hasattr(main, "commands"):'; \ + echo ' commands = main.commands'; \ echo; \ echo 'if __name__ == "__main__":'; \ - echo " sys.exit($$module.Main())"; \ + echo ' sys.exit(main.Main())'; \ } > $@ chmod u+x $@ -- GitLab