Hi,
In a project of mine, I generate a header file which contains the GIT commit
sha1. It's generated using these rules:
FORCE:
$(top_srcdir)/revision: FORCE
@if (test -d $(top_srcdir)/.git && cd $(top_srcdir) \
&& git rev-parse --verify HEAD) > revision-t 2>/dev/null \
&& ! cmp -s revision-t $@; then \
mv -f revision-t $@; \
else \
rm -f revision-t; \
if ! test -f $@; then touch $@; fi; \
fi
revision.h: $(top_srcdir)/revision Makefile.am
$(AM_V_GEN) echo "#define DC_VERSION_REVISION \""`cat
$(top_srcdir)/revision`"\"" > $@
BUILT_SOURCES = revision.h
EXTRA_DIST = $(top_srcdir)/revision
CLEANFILES = revision.h revision-t
This works very well, but I also have a windows resource file to include a
version resource in the dll. I build the resource file with libtool using these
rules.
libdivecomputer_la_SOURCES += libdivecomputer.rc
.rc.lo:
$(AM_V_GEN) $(LIBTOOL) --silent --tag=RC --mode=compile $(RC) $< -o $@
The libdivecomputer.rc file is generated from a libdivecomputer.rc.in from
configure.ac, and it also includes the revision.h file for the GIT commit.
This also works well, except that resource file doesn't get recompiled when the
revision.h file is changed. How can I fix this? I tried adding the revision.h
file as a dependency to the the .rc.lo rule, but that doesn't seem to have any
effect.
Note the full Makefile.am file can be viewed here:
http://libdivecomputer.git.sourceforge.net/git/gitweb.cgi?p=libdivecomputer/libdivecomputer;a=blob;f=src/Makefile.am;hb=HEAD
Jef