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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Yann E. MORIN
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 | Threaded
Open this post in threaded view
|

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

Yann E. MORIN
Update of bug #57866 (project make):

                  Status:                    None => Not A Bug              
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #1:

Hi: the behavior you're seeing is quite correct given the makefile you've
provided.

The bug tracker isn't the best place to ask for help with how to write
makefiles.

Please send an email to the [hidden email] or [hidden email] mailing
lists describing your problem just as you've done here and I'm sure someone
will be happy to help.

Thanks!

    _______________________________________________________

Reply to this item at:

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

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