avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] __DATE__ constant, any way to format it differently


From: Steven Michalske
Subject: Re: [avr-gcc-list] __DATE__ constant, any way to format it differently ?
Date: Wed, 28 Jan 2009 12:59:17 -0800

great make snippet.

one suggestion, this doesn't check if the files were modified from the svn revision.

if you only compile code that is checked in this is fine, if you have changes in the working copy this poses problems.

I have used and seen scripts that add a single letter m to the revision number to indicate that the repository is modified.

Hardkrash

On Jan 28, 2009, at 12:10 PM, Dave Hylands wrote:

HI Vince,

...snip...
While I am at it, in the same vein, has anybody a trick to retrieve
the program revision number from subversion, so I can display that too
along with the compilation date ?

This is really a make question and not a gcc question.

I created the following Makefile (which I called svn-version.mk), and
then in my normal Makefile (I use handcoded Makefiles), I put this:

all: svn-version.h
include ${PATH_TO_SVN_VERSION}/svn-version.mk

and make my code have

#include "svn-version.h"

My makefiles also do dependency generation, which will automatically
add the svn-version.h file as a dependent.

--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/



###########################################################################
#
# svn-version.mk - Creates the svn-version.h file
#
###########################################################################

#--------------------------------------------------------------------------
#
# Rule to update svn-version.h file. If a C file includes this file then
# the dependcy generator will cause this file to be generated.
#
# To prevent unnecessary updates, a temporary file is created and compared
# to svn-version.h, so that svn-version.h is only touched if a change
# is detected.
#

svn-revision := $(subst Revision:,,$(shell svn info | grep Revision:))
ifeq ($(strip $(svn-revision)),)
svn-revision := 0
endif

svn-version.h: FORCE
        @echo "Creating svn-version.h ..."
        @echo "/*" > svn-version.tmp
        @echo " * Generated file - Do NOT edit" >> svn-version.tmp
        @echo " */" >> svn-version.tmp
        @echo >> svn-version.tmp
        @echo "#define     SVN_REVISION $(svn-revision)" >> svn-version.tmp
@cmp --quiet svn-version.tmp svn-version.h || cp svn-version.tmp svn-version.h
        @rm svn-version.tmp

ifneq ($(wildcard svn-version.h),)
clean: clean-svn-version

clean-svn-version:
        @echo "Removing svn-version.h ..."
        @rm svn-version.h
endif


_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list





reply via email to

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