You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Pedro Zorzenon Neto <pz...@terra.com.br> on 2006/02/19 23:04:59 UTC

Add a note to FAQ about #version-value-in-source

Hi,

  About the topic:
    http://subversion.tigris.org/faq.html#version-value-in-source

  I have a better option instead of using makefile to create a
svn_version.c file. Please put it in the FAQ if you think it will be
useful for other users.

  Below are the instructions.

  Please CC me the answers, I'm not a subscriber of this list. I'm using
svn for the 2nd day. It has many improvements compared to cvs.

  Thanks in advance,
    Pedro


Put the following 2 lines in Makefile:

SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
CFLAGS = $(SVNDEF) ... continue with your other flags ...

To use it, in yourfile.c do something similar to the example below:
  printf("this program was compiled from SVN revision %s\n",SVN_REV);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] note GNU-make-ism in FAQ

Posted by Peter Samuelson <pe...@p12n.org>.
[Philip Martin]
> > -SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
> > -CFLAGS = $(SVNDEF) ... continue with your other flags ...
> > +SVNDEF := -D'SVN_REV="$(shell svnversion -n .)"'
> > +CFLAGS := $(SVNDEF) ... continue with your other flags ...
> 
> I assume that := only needs to be used on the SVNDEF line and not on
> both lines.

Correct - but there's no reason *not* to use it on both lines.  It's
what you really should use by default.  = assignment should only be
used when you *know* you want delayed expansion semantics.  Usually you
don't.  (Or don't care.)

Re: [PATCH] note GNU-make-ism in FAQ

Posted by Philip Martin <ph...@codematters.co.uk>.
Peter Samuelson <pe...@p12n.org> writes:

> -SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
> -CFLAGS = $(SVNDEF) ... continue with your other flags ...
> +SVNDEF := -D'SVN_REV="$(shell svnversion -n .)"'
> +CFLAGS := $(SVNDEF) ... continue with your other flags ...

I assume that := only needs to be used on the SVNDEF line and not on
both lines.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] note GNU-make-ism in FAQ

Posted by kf...@collab.net.
Peter Samuelson <pe...@p12n.org> writes:
> [Philip Martin]
> > >> SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
> > >> CFLAGS = $(SVNDEF) ... continue with your other flags ...
> 
> > >>   printf("this program was compiled from SVN revision %s\n",SVN_REV);
> 
> > I don't think we should be recommending that because I think it
> > causes the svnversion command to get run each time the compiler is
> > invoked.
> 
> Also, we should warn readers that $(shell) is specific to GNU make.
> But while we're using features that may be GNU-specific, we can fix
> your objection by using := rather than = in the assignment.

Thanks, r18642.

-K

> [[[
> * www/faq.html (version-value-in-source): Use := in example Makefile
>   for efficiency.  Clarify use of GNU-make-ism.
> ]]]
> Index: faq.html
> ===================================================================
> --- faq.html	(revisione 18638)
> +++ faq.html	(copia locale)
> @@ -1526,9 +1526,9 @@
>  <p>
>  You can incorporate it into your build or release process to get the
>  information you need into the source itself.  For example, in a build
> -environment based on <tt>make</tt>, add <a
> +environment based on <tt>GNU&nbsp;make</tt>, add <a
>  href="http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=112564"
> ->something like this</a> to your <tt>Makefile</tt>:</p>
> +>something like this</a> to your <tt>Makefile</tt>:
>  
>  <pre>
>  ##
> @@ -1536,10 +1536,13 @@
>  ## printf("this program was compiled from SVN revision %s\n",SVN_REV);
>  ##
>  
> -SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
> -CFLAGS = $(SVNDEF) ... continue with your other flags ...
> +SVNDEF := -D'SVN_REV="$(shell svnversion -n .)"'
> +CFLAGS := $(SVNDEF) ... continue with your other flags ...
>  </pre>
>  
> +(Note that this will not work on non-GNU versions of <tt>make</tt>.
> +Don't use it if your build process needs to be portable.)</p>
> +
>  <p>Or try this recipe:</p>
>  
>  <pre>

-- 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

[PATCH] note GNU-make-ism in FAQ

Posted by Peter Samuelson <pe...@p12n.org>.
[Philip Martin]
> >> SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
> >> CFLAGS = $(SVNDEF) ... continue with your other flags ...

> >>   printf("this program was compiled from SVN revision %s\n",SVN_REV);

> I don't think we should be recommending that because I think it
> causes the svnversion command to get run each time the compiler is
> invoked.

Also, we should warn readers that $(shell) is specific to GNU make.
But while we're using features that may be GNU-specific, we can fix
your objection by using := rather than = in the assignment.

Peter

[[[
* www/faq.html (version-value-in-source): Use := in example Makefile
  for efficiency.  Clarify use of GNU-make-ism.
]]]
Index: faq.html
===================================================================
--- faq.html	(revisione 18638)
+++ faq.html	(copia locale)
@@ -1526,9 +1526,9 @@
 <p>
 You can incorporate it into your build or release process to get the
 information you need into the source itself.  For example, in a build
-environment based on <tt>make</tt>, add <a
+environment based on <tt>GNU&nbsp;make</tt>, add <a
 href="http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=112564"
->something like this</a> to your <tt>Makefile</tt>:</p>
+>something like this</a> to your <tt>Makefile</tt>:
 
 <pre>
 ##
@@ -1536,10 +1536,13 @@
 ## printf("this program was compiled from SVN revision %s\n",SVN_REV);
 ##
 
-SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
-CFLAGS = $(SVNDEF) ... continue with your other flags ...
+SVNDEF := -D'SVN_REV="$(shell svnversion -n .)"'
+CFLAGS := $(SVNDEF) ... continue with your other flags ...
 </pre>
 
+(Note that this will not work on non-GNU versions of <tt>make</tt>.
+Don't use it if your build process needs to be portable.)</p>
+
 <p>Or try this recipe:</p>
 
 <pre>

Re: Add a note to FAQ about #version-value-in-source

Posted by Philip Martin <ph...@codematters.co.uk>.
kfogel@collab.net writes:

> Pedro Zorzenon Neto <pz...@terra.com.br> writes:
>> SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
>> CFLAGS = $(SVNDEF) ... continue with your other flags ...
>> 
>> To use it, in yourfile.c do something similar to the example below:
>>   printf("this program was compiled from SVN revision %s\n",SVN_REV);
>
> Committed in r18636, thank you.

I don't think we should be recommending that because I think it causes
the svnversion command to get run each time the compiler is invoked.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Add a note to FAQ about #version-value-in-source

Posted by kf...@collab.net.
Pedro Zorzenon Neto <pz...@terra.com.br> writes:
>   About the topic:
>     http://subversion.tigris.org/faq.html#version-value-in-source
> 
>   I have a better option instead of using makefile to create a
> svn_version.c file. Please put it in the FAQ if you think it will be
> useful for other users.
> 
>   Below are the instructions.
> 
>   Please CC me the answers, I'm not a subscriber of this list. I'm using
> svn for the 2nd day. It has many improvements compared to cvs.
> 
>   Thanks in advance,
>     Pedro
> 
> 
> Put the following 2 lines in Makefile:
> 
> SVNDEF = -D'SVN_REV="$(shell svnversion -n .)"'
> CFLAGS = $(SVNDEF) ... continue with your other flags ...
> 
> To use it, in yourfile.c do something similar to the example below:
>   printf("this program was compiled from SVN revision %s\n",SVN_REV);

Committed in r18636, thank you.

-Karl

-- 
www.collab.net  <>  CollabNet  |  Distributed Development On Demand

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org