help-make
[Top][All Lists]
Advanced

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

[gnu.org #422525] Passing conditional expression to shell in a make file


From: rajdeep lodh
Subject: [gnu.org #422525] Passing conditional expression to shell in a make file?
Date: Fri, 27 Mar 2009 18:43:08 +0530 (IST)

Hi GNU Team,
 
                   I tried the following, but it does not seem to work.Can you please help ?

dmss : copy_bmp_cefs

USES_BMP_CEFS=yes
USES_EFS=yes

copy_bmp_cefs:
ifeq ($(USES_BMP_CEFS), yes)
    @echo ------------------------------------------------------------------
    if [ "$(USES_EFS)" = yes ]; then \
    $(bmp_cefs); \
    fi
    @echo ------------------------------------------------------------------
endif


define bmp_cefs
    @echo #------------------------------------------------------------------
    @echo Copying BMP CEFS image .....
    @echo Done Copying BMP CEFS image
    @echo #------------------------------------------------------------------
endef

With regards,
Rajdeep R. Lodh

--- On Thu, 26/3/09, Paul Smith <address@hidden> wrote:

From: Paul Smith <address@hidden>
Subject: Re: Fw: [gnu.org #422525] Passing conditional _expression_ to shell in a make file?
To: "rajdeep lodh" <address@hidden>
Cc: address@hidden
Date: Thursday, 26 March, 2009, 10:41 PM

On Thu, 2009-03-26 at 21:50 +0530, rajdeep lodh wrote:
>
>                     Can you please let me know if this is possible and
> the syntax for the same ?
>
>         > ifeq
>         > ($(USES_BMP_CEFS), yes)
>         >
>         >             @echo
>         > ------------------------------------------------------------------
>         >
>         >             ifeq
>         > ($(USES_EFS) ,  yes)
>         >
>         >             $(bmp_cefs)
>         >
>         >             endif
>         >
>         >             @echo
>         > ------------------------------------------------------------------

Hi Rajdeep.

Questions about working with GNU make are best sent to the
address@hidden mailing list.

In your particular case above, note that you cannot put make
conditionals (like ifeq etc.) into a recipe (command lines beginning
with TAB): recipe lines are passed to the shell for execution.  Make
does not do any parsing whatsoever on those lines except to expand
variables and functions.  It definitely does NOT handle make
conditionals like ifeq.

If you want to use an if-statement inside a recipe, you have to use the
shell's syntax for conditionals.  So it would be something like:

    @echo ------------------------------------
    if [ "$(USES_EFS)" = yes ]; then \
            $(bmp_cefs); \
        fi
        @echo ------------------------------------

Further questions or requests for help should, as I mentioned, be
addressed tothe address@hidden mailing list.

Cheers!



Cricket on your mind? Visit the ultimate cricket website. Enter now!
reply via email to

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