views:

24

answers:

1

I'm using mercurial as a SCM, and an output from the hg parents command in my makefile to store build number and version information in my program. However, mercurial is not always present on machines where I try to build the program. Thus, hg parent fails.
I'd like to use a substitute string (hard-coded or output from other program) when mercurial is not available. But I'm no good in makefile scripting.
Can you provide a hint how to compose a makefile-command that would store the output from a hg parents if it's available, or output from date if hg is not available, in the internal variable.

+1  A: 

This is bit cranky but it works for me:

X=$(shell hg parent || date)
hluk
Cranky how? This is how I'd do it, with the possible exception of making a small shell script to do a test for `hg` first, then `hg parents` or `date`. That way, you don't have command not found messages.
Jack Kelly