help-make
[Top][All Lists]
Advanced

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

Impossible to do this in make :-(


From: Rakesh Sharma
Subject: Impossible to do this in make :-(
Date: Wed, 5 Feb 2014 10:55:04 -0800

Hello GNU Makers,

I stumbled on a simple feature which I thought should be very doable in GNU 
Make (I use 3.82)

but found it stubbornly resisting a make-bulitins based solution. 😞

Wanted to do a lowercase => uppercase conversion so wrote this (picked from 
stackoverflow)

lc = $(subst a,A,$(subst b,B,$(subst c,C,.....,$(subst z,Z,$1))....)

As is, the above works. But I wanted to bring in "eval" here to avoid typing 
this whole thing.😎

But to my utter surprise & then dismay, I found it impossible to write the RHS 
in any manner amenable to be eval-ed.

I am sure someone would have been thru this & would have resolved this. I would 
like to know how gnu-make can do such an expression.

my attempt looked like: ( assuming just 5 characters)

L1 :=   a   b   c    d    e
L2 :=   A   B   C    D    E
lp := (
rp := )
uc = $(strip \
         $(foreach i,$(join $(addsuffix /,$(L1)),$(L2)),\
        \$$$(lp)subst $(word 1,$(subst /,,$i)),$(word 2,$(subst /,,$i)),)\
    $1\
    $(patsubst %,$(rp),$(L1))\
)
# usage: $(call uc, input_string)

Thanks,
Rakesh

                                          

reply via email to

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