help-make
[Top][All Lists]
Advanced

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

Re: multiple condition in test


From: Paul Smith
Subject: Re: multiple condition in test
Date: Wed, 19 Sep 2007 19:21:49 -0400

On Wed, 2007-09-19 at 15:25 +0200, Paolo MARTINELLI wrote:
> export FILE_GEN_NAME = ${TLM_BOTTOM}/tlm_ncsc_${TLM_TEST_NAME}.so
> export LIB_GEN_NAME = ${TLM_BOTTOM}/lib${TLM_PLT_NAME}.so
> FileExists = $(strip $(wildcard ${FILE_GEN_NAME}))
> LibExists = $(strip $(wildcard ${LIB_GEN_NAME}))
> display:
>     if [  $(or (! -f $(LibExists)), (! -f $(FileExists))  ]  ; [...]

This cannot work.  Whoa, there's so much here I can't really explain all
the problems.

Let's just say, you cannot mix and match shell and make constructs in
any order you like, as you are doing here.  Make will evaluate the
ENTIRE line, replacing ALL make constructs first.  Then it will send the
results to the shell.  The shell will do what it does, and stop with an
exit code; that exit code is the ONLY communication back from the shell
to make.


You need to either do the entire thing using shell syntax:

        FILE_GEN_NAME = ${TLM_BOTTOM}/tlm_ncsc_${TLM_TEST_NAME}.so
        LIB_GEN_NAME = ${TLM_BOTTOM}/lib${TLM_PLT_NAME}.so
        display:
                if [ -f $(LIB_GEN_NAME) -a -f $(FILE_GEN_NAME) ]; then \
                    echo "library building SUCCEEDED!!!"; \
                else \
                    echo "library building FAILED!!!"; \
                fi

Or do the whole thing with make:

        FILE_GEN_NAME = ${TLM_BOTTOM}/tlm_ncsc_${TLM_TEST_NAME}.so
        LIB_GEN_NAME = ${TLM_BOTTOM}/lib${TLM_PLT_NAME}.so
        FileExists = $(strip $(wildcard ${FILE_GEN_NAME}))
        LibExists = $(strip $(wildcard ${LIB_GEN_NAME}))
        display:
                echo "library building $(if $(and $(LibExists), 
$(FileExists)),SUCCEEDED,FAILED)!!!"

Which you use is up to you.

Note this whole thing seems wrong to me, though: if you want to know if
a file was built or not you should make it a prerequisite, then if it
fails the rule won't be run in the first place.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.us
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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