bugmake - Bugs: bug #57866, make fails to recognize dependency...

 
 

bug #57866: make fails to recognize dependency and substitute variables

Submitted by:  None
Submitted on:  Thu 20 Feb 2020 09:00:41 AM UTC  
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.3 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 20 Feb 2020 01:53:47 PM UTC, 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 -email is unavailable- or -email is unavailable- mailing lists describing your problem just as you've done here and I'm sure someone will be happy to help.

Thanks!

Paul D. Smith <psmith>
Project Administrator
Thu 20 Feb 2020 09:00:41 AM UTC, original submission:  

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) && ./$@

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48455:  Makefile added by None (403B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-02-20 psmith StatusNone => Not A Bug
        Open/ClosedOpen => Closed
    2020-02-20 None Attached File- => Added Makefile, #48455

    Back to the top


    Powered by Savane 3.5