Micah Cowan wrote:
> I've improved the generation of version.c, removing the intermediate
> generation of an "hg-id" file and using a more portable replacement for
> "hg id | cut -d ' ' -f 1" (can be used on Windows and MS-DOS).
> 
> The relevant lines in src/Makefile.am are now:
> 
> version.c:  $(wget_SOURCES) $(LDADD)
>         printf '%s' 'const char *version_string = "@VERSION@' > $@
>         -hg log -r tip --template=' ({node|short})' >> $@
>         printf '%s\n' '";' >> $@
> 
> (The printf commands aren't portable to Windows AFAIK, but this should
> be easier to adapt, at any rate. Note that "echo -n" is not a portable
> method for suppressing newlines in echo's output.)

Gisle and Chris, you should be able to write this rule in your
Makefiles. Something like:

version.c: $(SOURCES)
        echo 'const char *version_string = "@VERSION@"' > $@
        -hg log -r tip --template='" ({node|short})"\n' >> $@
        echo ';' >> $@

This particular usage should actually be portable across all varying
implementations of Unix echo, as well (so maybe I'll use it too--though
printf is still probably a reasonable expectation, and I may well
require it in the future). It takes advantage of C's string-literal
concatenation. The results will be an eyesore, but will work.

Note that if version.c is in SOURCES, there is still a recursive
dependency; if this is a problem for your build system, you may want to
remove version.obj from OBJS, and add it directly to the command to link
wget.exe.

-- 
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to