On 3/30/13 7:17 AM, oborchert wrote:
Hi,
I created a Makefile.in where I read the content out of a file and pass it
to CFLAGS. Calling ./configure ... the Makefile will be generated an all
works well.

Makefile.in:
...
MY_REVISION_FILE=my-revision.txt
MY_REVISION=$(shell cat $(top_srcdir)/$(MY_REVISION_FILE))
AM_CFLAGS = -I$(EXTRAS_INCLUDE_DIR) -I$(top_srcdir)
-DMY_REVISION=$(MY_REVISION)
...
Rather than carry this information via cmdline, I store create a header file that I can include when needed. In that way dependencies become correct too. I have the following rule in my Makefile.am:

BUILT_SOURCES += $(builddir)/svn_revision.h
$(builddir)/svn_revision.h: $(srcdir)/svn_revision.h.in $(srcdir)/.revision
    $(AM_V_at)revision=$$(cat $(srcdir)/.revision) \
&& sed "s|@SVN_REVISION@|$$revision|g" < $(srcdir)/svn_revision.h.in \
> $@-t && mv $@-t $@

and then my svn_revision.h.in looks like

#ifndef SVN_REVISION
#define SVN_REVISION "@SVN_REVISION@"
#endif


Cheers,
Peter


--
Peter Johansson


_______________________________________________
Autoconf mailing list
Autoconf@gnu.org
https://lists.gnu.org/mailman/listinfo/autoconf

Reply via email to