======================================================================== How to hook it into automake-based builds: ======================================================================== ---[ BEGIN top-level Makefile.am ]--- EXTRA_DIST += git-buildmsg ---[ END top-level Makefile.am ]--- ---[ BEGIN Makefile.am where information is needed ]--- BUILT_SOURCES += git-buildmsg.stamp GIT_BUILDMSG_CMD = $(SHELL) "$(top_srcdir)/git-buildmsg" GIT_BUILDMSG_H = git-buildmsg.h CLEANFILES += $(GIT_BUILDMSG_H) git-buildmsg.stamp: env GIT_DIR="$(top_srcdir)/.git" $(GIT_BUILDMSG_CMD) -s "$(top_srcdir)" -o "$(GIT_BUILDMSG_H)" @if test -s "$(srcdir)/$(GIT_BUILDMSG_H)"; then \ if cmp "$(srcdir)/$(GIT_BUILDMSG_H)" "$(GIT_BUILDMSG_H)"; then :; \ else \ echo "Error: $(srcdir)/$(GIT_BUILDMSG_H) and $(GIT_BUILDMSG_H) differ."; \ echo " You probably want to remove the former."; \ exit 1; \ fi; \ fi bin_PROGRAMS += foo foo_SOURCES = foo.c nodist_foo_SOURCES = $(GIT_BUILDMSG_H) ---[ END Makefile.am where information is needed ]--- ======================================================================== How to hook it into imake-based builds: ======================================================================== ---[ BEGIN Imakefile ]--- GIT_VERSION_CMD = $(SHELL) $(TOP)/git-buildmsg GIT_DEFINES = `env GIT_DIR="$(TOP)/.git" $(GIT_VERSION_CMD) -s $(TOP) -o git-buildmsg.h` clean:: RemoveFile(git-buildmsg.h) ---[ END Imakefile ]--- Then make sure that the DEFINES the C compiler is run with includes $(GIT_DEFINES).