On Thu, Nov 4, 2010 at 13:46 UTC, Valentin David <valentin.da...@gmail.com> wrote: > You probably want to have one object that has symbols for the date and > the time, and this object to be depending on other objects.
The NTP reference implementation does something along these lines. Every time any consituent libraries or objects change for a binary, an updated version.c is generated containing the build timestamp as well as a generation counter for repeated builds in the same directory. version.c contains a line like: char * Version = "ntpd 4.2.7...@1.2247-o Nov 03 19:17:08.92 (UTC-00:00) 2010 (1)" ; (1) is the generation counter. This is wired into the Makefile.am by omitting version.c from program_SOURCES, adding version.o to program_LDADD, and adding a rule to build it like: version.o: $(ntpq_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpq $(COMPILE) -c version.c mkver is a shell script which uses the version number from packageinfo.sh, the repository revision from $CSET, and the current date/time to produce version.c. The dependency of version.o on Makefile, combined with the practice of the NTP build shell script of invoking config.status (which unconditionally regenerates Makefile) before make, means that a run of the "build" script always generates updated version.c files with the current timestamp, even if nothing else has changed. I am not responsible for inventing this scheme, and I may have missed an important part. Cheers, Dave Hart