7

Makefile defining a variable in the if statement in a target

 3 years ago
source link: https://www.codesd.com/item/makefile-defining-a-variable-in-the-if-statement-in-a-target.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Makefile defining a variable in the if statement in a target

advertisements

I have a Makefile with the following:

AVAR=""

all :
    if [ -d ../old ]; then \
    (echo "$@ Ping!"; AVAR="../old"; echo $(AVAR)) \
    fi
    @echo $(AVAR)

The idea is that depending on the presence of directory "../old" i will or not have information in AVAR (available for use later), however, the if is evaluating to true, and the Ping! is echoed, but nothing is assigned to AVAR, either inside or outside the if statement.

Output is as follows:

$ make all
if [ -d ../old ]; then \
        (echo "all Ping!"; AVAR="../old"; echo "") \
        fi
all Ping!

Any Insight appreciated.


(echo "$@ Ping!"; AVAR="../old"; echo $$AVAR) \

instead of

(echo "$@ Ping!"; AVAR="../old"; echo $(AVAR)) \

Related Articles

Define a variable in the SELECT statement - MySQL

I'm using this code which has an error: SET @rejects = ''; SELECT * FROM list WHERE maker = 1 AND by_ids IN ('10','11') AND country LIKE '%I%' AND ( src IS NULL || src NOT IN (@rejects) AND checkSrc(src) = 'yes' AND SET @rejects = CONCAT(@rejects,','

Pass the .each loop variable to the if statement in the function

I'm a novice at Jquery/Javascript programming so please be gentle ;) The function below checkes if a radiobutton from a specific group is selected. However I can't get the: var checkifonechecked = true; to be passed to the if statement. It returns a

Retrieves the variable of the if statement embedded in the .each function

I am trying to retrieve a variable from an if statement nested in a jquery .each function: var radioAmount; $('div.amount').each(function() { var input = $(this).find('input[type="radio"]'); if(input.is(':checked')) { radioAmount = input.attr('v

SSIS 2012 - Assigning variables to the SQL statement of an SQL task

I'm trying to map a parameter and variables to a SQL statement within a SQL Task I'm connecting to an oracle DB - the connection is working fine. My SQL Statement is: insert into ? values(?,?) I map package parameter: Param1 to (parametername) 0 in t

Define environment variables in the GAS control panel

I deploy my project to GAE over Github. There is some foreign API-key which I don't want to save in repository and make them public. Is it possible to set an environment variable for a project in GAE control panel so I can catch it in my application?

Comparing many variables in the if statement

I wrote a code for my homework which says do inputs create a magic square matrix or don't. In magic square matrix, all of the rows, columns and diagonals sum must be equal. I wrote some functions to calculate the sum of the rows, columns and diagonal

Define a variable on the data element

Setting up a Flickr script... In my ajax success function, how would I put a var in with the actual this element? I know this and $(this) represent different things. Hard to write out, so I'll use my code examples to explain better. I have my functio

Why the final java variable indicating the inaccessible state

class Temp { public static void main(String[] args) { int x=10,y=20; while (x<y) { System.out.println("Hello"); } System.out.println("Hi"); } } output it prints Hello infinity times but when i make local variable final int x=10,y=20

PHP: Affects Variables in the if Statement

I don't seem to be able to assign multiple variables in an "if" statement. The following code: <?php function a ($var) { if ($var == 1) { return 'foo'; } return false; } function b ($var) { if ($var == 1) { return 'bar'; } return false; } if

Specify the file name as a variable in the infiltration statement

I am tying to convert a comma delimited text file to a pipe delimited file but my input file name (comma delimited file) is a variable (flname1). I am using the code below suggested by a stackoverflow member. The code works fine as long as I specify

Javascript Variables in the if statement

I have a custom volume bar and mute button in my music player. Muting is very simple, but I want to return the previous volume when the button is clicked for the second time. Example: Let's say the current volume is at 50%. Clicking the mute button w

Must declare the scalar variable with the SELECT statement

I have the following statement: DECLARE @Nr_Karton int; SELECT @Nr_Karton = ISNULL(MAX(Nr), 1000) FROM W_Karton; SET @Nr_Karton = @Nr_Karton + 1; INSERT INTO W_Karton (Container_ID, Nr, Beschrieb, CreationDate, Location) VALUES ('1', @Nr_Karton, '',

Initialize the variable in the if statement (Java)

I'm assigning my variables in an if statement and trying to use them outside of it, but I can't figure out how. The error is in the very last if statement stating that "local variable may not have been initialized". int i,z; if (st1.nextToken()

Windows batch files: how to define a variable with the result of a command?

Under a bash environment I usually do: var=$(command -args) and the I use $var with its value setted as the result of the command. The same goes to a more conventional set var=`command -args` compatible in almost every unix shell. How could I define

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK