help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Substring function (GMSL)


From: Oleksandr Gavenko
Subject: Re: Substring function (GMSL)
Date: Thu, 26 Jul 2012 22:26:21 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

On 2012-07-14, Michael Ludwig wrote:

> VPATH = 01-eins 02-zwei 03-drei 11-elf
>
> What could I do to transform the VPATH input list
> such as to obtain the following output list?
>
> EXEN = eins.exe zwei.exe drei.exe elf.exe
>
> (Strip the leading number and add the suffix.)
>
As you can see this task is not indented to be solved in GNU Make in natural
way.

If you have such task in real project this show that you give wrong names to
project files, etc (in case of Makefile ideology).

In such situation I use cache technique and real shell scripts, like:

  old := 01-xxx 02-yyy 002-zzz

  -include Makefile.vars

  .PHONY: Makefile.vars
  Makefile.vars:
      { \
    printf 'new :='; \
    for i in $(old); do printf " "$${i#*-}.exe; done; \
    echo; \
  } >$@

I try make string manipulation in plain sh to avoid creation of another
process. Note that printf and echo are shell built-in for most shells...

This is more verbose as inline solution and readers can find it in same
Makefile...

> ==== Solution ====
>
> http://gmsl.sourceforge.net/ GNU Make Standard Library
>
> Okay, I did some more googling and found a solution
> involving the *map* and *substr* functions from GMSL:
>
> include D:/Opt/MakeGMSL/gmsl
>
> dir2exe = $(call substr,$1,4,99).exe
>
> EXEN = $(call map,dir2exe,$(VPATH))
>
> I didn't know about GMSL before. Considered useful.
> No further questions for today, just posting for the
> archives. Thanks.
>
If you consider that GMSL is useful look to author articles at:

  http://www.cmcrossroads.com/ask-mr-make

for in-depth GNU Make tips.

GMSL is good thing for learning GNU Make (how make logical or, and, etc) but
it is not widely used. For example it is not packaged in Debian project...

Many function implemented very tricky, for example this shown limitation of
chars in string functions:

  __gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
  __gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z
  __gmsl_characters += 0 1 2 3 4 5 6 7 8 9
  __gmsl_characters += ` ~ ! @ \# $$ % ^ & * ( ) - _ = +
  __gmsl_characters += { } [ ] \ : ; ' " < > , . / ? |

to printable ASCII chars only...

-- 
Best regards!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]