bug-make
[Top][All Lists]
Advanced

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

[bug #57866] make fails to recognize dependency and substitute variables


From: anonymous
Subject: [bug #57866] make fails to recognize dependency and substitute variables
Date: Thu, 20 Feb 2020 04:00:43 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0

URL:
  <https://savannah.gnu.org/bugs/?57866>

                 Summary: make fails to recognize dependency and substitute
variables
                 Project: make
            Submitted by: None
            Submitted on: Thu 20 Feb 2020 09:00:41 AM UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.3
        Operating System: POSIX-Based
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

I have a typical C++ project with inc, src and test directories.
In test, I have 3 tests: utils.cpp exception.cpp object.cpp and the Makefile
at the bottom (also attached).

I have encountered two problems:

- If I put definition of BR and src variables above the rule they are used,
they are not properly substituted and Makefile does not work at all. I thought
make variables are recursive and this should not make a difference.

- The below Makefile works as expected, but for example when I change
utils.cpp, make does not recognize the change and does not rebuild utils
executable.


targets = utils exception object

# required sources
utils_req     = ../src/Util.cpp
exception_req = ../src/Exception.cpp ../src/InvalidObject.cpp $(utils_req)
object_req    = ../src/Object.cpp $(exception_req)

all: $(targets)

clean:
        @rm -f *.o $(targets)

$(targets): $(src)
        $(BR)

# build & run. To be used in a rule
src = $@.cpp $($@_req)
BR  = @clang++ -I.. -Wall -DMY_TEST -o $@ $(src) && ./$@



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 20 Feb 2020 09:00:41 AM UTC  Name: Makefile  Size: 403B   By: None

<http://savannah.gnu.org/bugs/download.php?file_id=48455>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57866>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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