tags:

views:

19

answers:

1

how to express this logic in Makefile?

if $(XORG_VERSION) > "7.7"
   <do some thing>
fi

Conditional Parts of Makefiles only provides ifeq or ifneq.

+1  A: 

You're not restricted to using the make conditional statements - each command is a shell command which may be as complex as you need (including a shell conditional statement):

Consider the following makefile:

dummy:
    if [ ${xyz} -gt 8 ] ; then \
        echo urk!! ${xyz} ;\
    fi

When you use xyz=7 make --silent, there is no output. When you use xyz=9 make --silent, it outputs urk!! 9 as expected.

paxdiablo
just curious, then why they make the conditional ifdef, etc?
Dyno Fu
`Make` doesn't (and probably shouldn't) assume anything about the underlying shell. For example, if you're running it under Windows, it may only have `cmd.exe` which isn't as powerful as `bash`. The real question would be why didn't gnu make provide more powerful comparison operators? To which my answer is "I have no idea" :-)
paxdiablo