bug-make
[Top][All Lists]
Advanced

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

[bug #51434] Document that variables are treated differently in prerequi


From: anonymous
Subject: [bug #51434] Document that variables are treated differently in prerequisite lists and recipes
Date: Mon, 10 Jul 2017 10:11:06 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux i686; rv:22.0) Gecko/20100101 Firefox/22.0

URL:
  <http://savannah.gnu.org/bugs/?51434>

                 Summary: Document that variables are treated differently in
prerequisite lists and recipes
                 Project: make
            Submitted by: None
            Submitted on: Mon 10 Jul 2017 02:11:04 PM UTC
                Severity: 3 - Normal
              Item Group: Documentation
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: None
        Operating System: POSIX-Based
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

The same variable is expanded at different times depending on whether it is
used in a pre-requisites list or a recipe but this counter-intuitive
difference is not documented anywhere.  It is the same for both "flavors" of
variables.

Consider the following example

VARS=a.c b.c

p: $(VARS)
        echo i am using  $(VARS) to build
        echo $(VARS) > p

VARS=x.c y.c

Here $(VARS) in the prerequisite list is expanded when make reads that line of
the file (to "a.c b.c") but the $(VARS) in the recipe on the next line is
expanded to its value at the end of the makefile (here "x.c y.c")

A demonstration of the effect using the above example follows. In summary it
builds p using x.c and y.c but build is triggered when a.c and b.c are
touched

address@hidden temp/make.vars]$ make
echo i am using  x.c y.c to build
i am using x.c y.c to build
echo x.c y.c > p
address@hidden temp/make.vars]$ touch x.c
address@hidden temp/make.vars]$ make
make: `p' is up to date.
address@hidden temp/make.vars]$ touch b.c
address@hidden temp/make.vars]$ make
echo i am using  x.c y.c to build
i am using x.c y.c to build
echo x.c y.c > p
address@hidden temp/make.vars]$ vi
address@hidden temp/make.vars]$ make --version
GNU Make 3.82
Built for i386-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
address@hidden temp/make.vars]$






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51434>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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