automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

compiling in the build time


From: David Byron
Subject: compiling in the build time
Date: Thu, 3 Nov 2005 10:40:35 -0800

This feels like a faq, but I couldn't find anything related so here
goes.

I'd like to compile in the build time into my application.  I have a
recipe like this:

BUILDTIME   = $(shell TZ=UTC date --utc)
builddate.c:
        echo "#include <builddate.h>" >$@
        echo >>$@
        echo "const char *BuildDate = \"$(BUILDTIME)\";" >>$@

What I'm having trouble with is getting the builddate.c recipe to happen
at the right time.  I don't want to make it .PHONY since I don't want to
re-generate, re-compile, and re-link unless something else has actually
changed.

In Makefile.am I have the above, preceded by:

bin_PROGRAMS = geoidx
geoidx_SOURCES = geoidx.c
nodist_geoidx_SOURCES = builddate.c

This happily gets me builddate.c generated and compiled once, but never
updated.

If I was writing my own makefile, I'd have a recipe like this:

geoidx: $(OBJS)
  <generate builddate.c -- the three echo lines from above>
  <compile buliddate.c>
  <link geoidx with $(OBJS) and builddate.o>

But I'm not sure how to get automake to generate a Makefile like this.
Can someone point me in the right direction, or suggest another approach
to get this done?

Thanks much.

-DB




reply via email to

[Prev in Thread] Current Thread [Next in Thread]