From e242b44eedb39afa0dbd72a74f56b2863c2aaf55 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Wed, 1 May 2013 23:26:42 +0200 Subject: [PATCH] make flags analysis: refactor, to reduce code duplication And make it a little more reliable. * t/header-vars.am (am__make_running_with_option): Here. Signed-off-by: Stefano Lattarini --- lib/am/header-vars.am | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am index 4ad1783..3de46dc 100644 --- a/lib/am/header-vars.am +++ b/lib/am/header-vars.am @@ -44,15 +44,11 @@ am__make_running_with_option = \ exit 1;; \ esac; \ am__has_opt=no; \ + am__flags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ -## GNU make: $(MAKEFLAGS) is quite tricky there, while the older variable -## $(MFLAGS) behaves much better. So use the latter. - for am__flg in $$MFLAGS; do \ - case $$am__flg in \ - *=*|--*) ;; \ - -*$$am__target_option*) am__has_opt=yes; break;; \ - esac; \ - done; \ +## The format of $(MAKEFLAGS) is quite tricky with GNU make; the +## variable $(MFLAGS) behaves much better in that regard. So use it. + am__flags=$$MFLAGS; \ else \ ## Non-GNU make: we must rely on $(MAKEFLAGS). This is tricker and more ## brittle, but is the best we can do. @@ -68,24 +64,22 @@ am__make_running_with_option = \ am__bs=\\; \ am__flags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$am__bs$$am__bs[$$am__bs $$am__bs ]*//g"`;; \ - *) \ - am__flags=$$MAKEFLAGS;; \ esac; \ - am__skip_next=no; \ - for am__flg in $$am__flags; do \ - if test $$am__skip_next = yes; then \ - am__skip_next=no; \ - continue; \ - fi; \ - case $$am__flg in \ - *=*|--*) ;; \ + fi; \ + am__skip_next=no; \ + for am__flg in $$am__flags; do \ + if test $$am__skip_next = yes; then \ + am__skip_next=no; \ + continue; \ + fi; \ + case $$am__flg in \ + *=*|--*) ;; \ ## Quite ugly special-casing. We might need other similar ones actually, ## but let's wait until the need arises. - -I) am__skip_next=yes;; \ - *$$am__target_option*) am__has_opt=yes; break;; \ - esac; \ - done;\ - fi; \ + -I) am__skip_next=yes;; \ + *$$am__target_option*) am__has_opt=yes; break;; \ + esac; \ + done;\ unset am__skip_next am__flg am__flags am__target_option; \ test $$am__has_opt = yes; \ } -- 2.7.4