> -----Original Message-----
> From: [email protected] [mailto:autoconf-
> [email protected]] On Behalf Of Adam Mercer
> Sent: Thursday, April 07, 2011 9:53 AM
> To: [email protected]
> 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"])])

_______________________________________________
Autoconf mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/autoconf

Reply via email to