autoconf
[Top][All Lists]
Advanced

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

RE: Handling multiple conditions in if statements


From: Daily, Jeff A
Subject: RE: Handling multiple conditions in if statements
Date: Thu, 7 Apr 2011 10:02:08 -0700

> -----Original Message-----
> From: address@hidden [mailto:autoconf-
> address@hidden On Behalf Of Adam Mercer
> Sent: Thursday, April 07, 2011 9:53 AM
> To: address@hidden
> Subject: Handling multiple conditions in if statements
> 
> Hi
> 
> In one of my macros I need to do one thing on linux platforms and another
> on others, in the macro I have the followings:
> 
>   if test "x$build_os" = "xlinux"; then
>     # case for linux
>   else
>     # other platforms
>   fi
> 
> I recently received a bug report that this wasn't working as the users system
> had $build_os defined as 'linux-gnu', whereas on others it was just 'linux'. I
> then tried to change the if statement to:
> 
>   if test "x$build_os" = "xlinux" -o test "x$build_os" = "xlinux-gnu"; then
> 
> but that didn't work, in fact any of the usual ways I would do an OR in shell
> script didn't work.
> 
> How can I have an if statement with multiple conditions? Or is there a better
> way to accomplish this?

Try a case statement.  I use the m4sh version e.g.

AS_CASE([$build_os],
        [*linux*], [AS_ECHO(["case for linux"])],
        [AS_ECHO(["other platforms"])])



reply via email to

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