From: Stefano Lattarini Date: Mon, 21 May 2012 21:15:31 +0000 (+0200) Subject: [ng] am: implement $(am__tolower) and $(am__toupper) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf8fc13a4f3ff8d03cdb93019e5d5c2796937dca;p=thirdparty%2Fautomake.git [ng] am: implement $(am__tolower) and $(am__toupper) These new make functions will be useful in future changes. * lib/am/header-vars.am (am__toupper, am__tolower): New make functions. * t/internals.tap: Test them. Signed-off-by: Stefano Lattarini --- diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am index 79dde9ca6..98a804252 100644 --- a/lib/am/header-vars.am +++ b/lib/am/header-vars.am @@ -83,6 +83,22 @@ am__uniq = $(strip \ $(am__empty), \ $(lastword $(1))))) +## These definitions have been generated by the following Bash 4 script: +## +## #!/bin/bash +## toupper='$1' tolower='$1' +## for c in {a..z}; do +## C=${c^^} +## toupper="\$(subst $c,$C,$toupper)" +## tolower="\$(subst $C,$c,$tolower)" +## done +## echo "am__tolower = $tolower" +## echo "am__toupper = $toupper" + +am__tolower = $(subst Z,z,$(subst Y,y,$(subst X,x,$(subst W,w,$(subst V,v,$(subst U,u,$(subst T,t,$(subst S,s,$(subst R,r,$(subst Q,q,$(subst P,p,$(subst O,o,$(subst N,n,$(subst M,m,$(subst L,l,$(subst K,k,$(subst J,j,$(subst I,i,$(subst H,h,$(subst G,g,$(subst F,f,$(subst E,e,$(subst D,d,$(subst C,c,$(subst B,b,$(subst A,a,$1)))))))))))))))))))))))))) + +am__toupper = $(subst z,Z,$(subst y,Y,$(subst x,X,$(subst w,W,$(subst v,V,$(subst u,U,$(subst t,T,$(subst s,S,$(subst r,R,$(subst q,Q,$(subst p,P,$(subst o,O,$(subst n,N,$(subst m,M,$(subst l,L,$(subst k,K,$(subst j,J,$(subst i,I,$(subst h,H,$(subst g,G,$(subst f,F,$(subst e,E,$(subst d,D,$(subst c,C,$(subst b,B,$(subst a,A,$1)))))))))))))))))))))))))) + ## Simple memoization for recursive make variables. It is useful for ## situations where immediate variables can't be used (due, say, to ## ordering issues with the assignments of the referenced variables), diff --git a/t/internals.tap b/t/internals.tap index f6ea954bd..44b8912ce 100755 --- a/t/internals.tap +++ b/t/internals.tap @@ -19,7 +19,7 @@ am_create_testdir=empty . ./defs || Exit 1 -plan_ 4 +plan_ 6 cp "$am_amdir"/header-vars.am . \ || fatal_ "fetching makefile fragment headers-vars.am" @@ -34,6 +34,9 @@ rm -f header-vars.am cat > Makefile << 'END' include ./defn.mk +lo = abcdefghijklmnopqrstuvwxyz +up = ABCDEFGHIJKLMNOPQRSTUVWXYZ + default: @echo Please select an explicit test; exit 1 .PHONY: default @@ -104,11 +107,50 @@ test-strip-suffixes: = 'foo.b bar' test '$(call am__strip_suffixes, .b.a .a, foo.b.a bar.a)' \ = 'foo bar' + +.PHONY: test-tolower +test-tolower: + +.PHONY: test-toupper +test-toupper: + test '$(call am__toupper,a)' = A + test '$(call am__toupper,A)' = A + test '$(call am__toupper,aba)' = ABA + test '$(call am__toupper,a b)' = 'A B' + test '$(call am__toupper, a B)' = ' A B' + test '$(call am__toupper,Ab )' = 'AB ' + test '$(call am__toupper,A B c )' = 'A B C ' + test '$(call am__toupper,0)' = 0 + test '$(call am__toupper,0d)' = 0D + test '$(call am__toupper,@:&/?-)' = '@:&/?-' + test '$(call am__toupper,a@B)' = A@B + test '$(call am__toupper,zxzxzxZXZxzxzxzxzx)' = ZXZXZXZXZXZXZXZXZX + test '$(call am__toupper,$(lo))' = '$(up)' + test '$(call am__toupper,$(up))' = '$(up)' + +.PHONY: test-tolower +test-tolower: + test '$(call am__tolower,A)' = a + test '$(call am__tolower,a)' = a + test '$(call am__tolower,ABA)' = aba + test '$(call am__tolower,A B)' = 'a b' + test '$(call am__tolower, A b)' = ' a b' + test '$(call am__tolower,aB )' = 'ab ' + test '$(call am__tolower,a b C )' = 'a b c ' + test '$(call am__tolower,0)' = 0 + test '$(call am__tolower,0D)' = 0d + test '$(call am__tolower,@:&/?-)' = '@:&/?-' + test '$(call am__tolower,a@B)' = a@b + test '$(call am__tolower,ZXZXZXzxzXZXZXZXZX)' = zxzxzxzxzxzxzxzxzx + test '$(call am__tolower,$(up))' = '$(lo)' + test '$(call am__tolower,$(lo))' = '$(lo)' END command_ok_ am__strip_firstword $MAKE test-strip-firstword command_ok_ am__strip_lastword $MAKE test-strip-lastword command_ok_ am__uniq $MAKE test-uniq command_ok_ am__test_strip_suffixes $MAKE test-strip-suffixes +command_ok_ am__tolower $MAKE test-tolower +command_ok_ am__toupper $MAKE test-toupper :