[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Running case commands with the shell function?
From: |
John Calcote |
Subject: |
Re: Running case commands with the shell function? |
Date: |
Thu, 14 Sep 2017 12:26:23 -0600 |
$ cat Makefile
TARGET := i386-x-openbsd5.5y
iflags := \
case "$(TARGET)" in \
i386-*-openbsd5.[5-9]*|i386-*-openbsd[6-9].*)\
echo "-ccopt -nopie";; \
*);; \
esac
flags := $(shell $(iflags))
all:
echo $(flags)
$ make
echo -ccopt -nopie
-ccopt -nopie
If you can't get make to parse a macro properly due to embedded special
chars, I've found that often embedding the bad stuff in an internal macro
and then calling the internal macro from the outer macro works wonders.
Regards,
John
On Thu, Sep 14, 2017 at 5:52 AM, Sébastien Hinderer <
address@hidden> wrote:
> Dear all,
>
> I'd like to be able to write something like this:
>
> flags := \
> $(shell \
> case "$(TARGET)" in \
> i386-*-openbsd5.[5-9]*|i386-*-openbsd[6-9].*) \
> echo "-ccopt -nopie";; \
> *);; \
> esac \
> )
>
> Of course this does not work because the first closing parenthesis is
> interpreted as ending the call to the shell function.
>
> Is there a way to actually achieve this, please?
>
> Thanks!
>
> Sébastien.
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-make
>
Re: Running case commands with the shell function?, Rakesh Sharma, 2017/09/16