Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6689123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:28:57+00:00 2026-05-26T05:28:57+00:00

i am trying to set a variable’s value to use during the compilation. I

  • 0

i am trying to set a variable’s value to use during the compilation.
I try to do that in a separate makefile target

svnversion:
    SVN_REV=$(shell svnversion -cn | sed -e 's/.*://' -e 's/\([0-9]*\).*/\1/' | grep '[0-9]')
    $(info svn_rev = $(SVN_REV))

I have read that this is the way to set the value of a variable.
Yet when i run ‘make’ I see :

SVN_REV=613
svn_rev = 

so the variable seems to be empty. Afterwards I expect that this variable will be present while the compilation takes place (in other targets). Is this the case? or should I add an ‘export’ command in the svnversion target? and how to I address the SVN_REV variable? $(SVN_REV) or $$(SVN_REV).

thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:28:58+00:00Added an answer on May 26, 2026 at 5:28 am

    You are actually assigning the value SVN_REV in the subshell that is concluded at the end of the line,

    what you probably want is:

    svnversion:: SVN_REV=$(shell svnversion -cn | sed -e 's/.*://' -e 's/\([0-9]*\).*/\1/' | grep '[0-9]')
    
    svnversion:
            $(info svn_rev = $(SVN_REV))
    

    This sets the variable when the target is set.

    If this isn’t what was intended, say you want to do some processing with the variable, then you need to make each line a continuation of the previous one using the horrible ; \ at the end of line semantics. If you are then referencing shell variables (like the one evaluated in your first line), then you need to use the $$ syntax before the variable name

    e.g.

    svnversion:
            SVN_REV=$(shell svnversion -cn | sed -e 's/.*://' -e 's/\([0-9]*\).*/\1/' | grep '[0-9]'); \
            echo svn_rev = $$SVN_REV
    

    but because it’s in a shell, you can’t use the variable in the $(info command, as that takes place outside of the evaluation of the target.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set the CLASSPATH variable so that my java programs can
I'm trying to use the PYTHONSTARTUP environmental variable. I set it to be c:\python25\pythonstartup.py
I have a makefile with the following code. I'm trying to set a variable
I'm trying to set up Excel so that the cell's value that is selected
I am trying to set a new variable to the same value as an
I'm trying to set a variable that should be accessible from outside PHP. Ideally
I am trying to set a variable name and variable value in the environment
I am trying to set a variable that I will refer to in a
I'm trying to set a variable to the value of the selected item in
I'm trying to set a default value in an instance variable. I'm doing: module

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.