[Top][All Lists]

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

Re: Help needed to check whether a directory exists

From: Paul Smith
Subject: Re: Help needed to check whether a directory exists
Date: Mon, 21 Nov 2011 12:13:42 -0500

On Mon, 2011-11-21 at 16:10 +0000, David Aldrich wrote:
> So I added the following code before the rules in my makefile:
> if test -d /usr/include/boost141; then \
>     echo Using Boost 1.41 directory; \
>     BOOST_INC := /usr/include/boost141; \
>     BOOST_LIB := boost141/boost_python-mt; \
> else \
>     echo Using default Boost location; \
>     BOOST_INC := /usr/include/boost; \
>     BOOST_LIB := boost_python-mt; \
> fi
> However, this code seems to do nothing. I get no messages from it on the 
> console.
> Please will someone explain where I am going wrong?

You are trying to write shell syntax in a makefile.  Makefiles must use
make syntax (except inside a recipe).  Make doesn't have an "if"
statement, or a "test" command, or anything like that.

The text above is resolving into a variable assignment (!!):

if test -d /usr/[...]tory; BOOST_INC := /usr/include/boost141; [...]

which is why you're not getting an error.  Believe it or not that's a
valid variable assignment statement in GNU make.

You'll want to do something like this instead:

ifneq (,$(wildcard /usr/include/boost141/.))
    $(info Using Boost 1.41 directory)
    BOOST_INC := /usr/include/boost141
    BOOST_LIB := boost141/boost_python-mt
    $(info Using default Boost location)
    BOOST_INC := /usr/include/boost
    BOOST_LIB := boost_python-mt

reply via email to

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