Menu

Recursive make and the default target

Help
jontra
2009-11-24
2013-03-15
  • jontra

    jontra - 2009-11-24

    Hi,

    I am currently working on converting our old gnu make makefiles into makepp.

    One of the problems I am facing is the way makepp calculate the default target.

    We now use recursive gmake, and in each sub dir 'all' target is recalculated, and actions are performed accordingly.

    In makepp I don't use recursive make but use load_makefile to load the makefiles from the sub dirs (as needed).

    If I understood correctly, when using makepp I will have to specify the final linking targets (and any other targets I want) in the top makefile.

    for example:

    makefile1.mk

    $(phony all): bar

    load_makefile t/makefile2.mk

    bar:

        touch bar

    makefile2.mk

    $(phony all): foo

    foo:

        touch foo

    If I run makepp -f makefile1.mk only bat will be created and not foo.

    I don't want to specify all the targets in the top level makefile since:

    - I don't know in the top makefile all the targets from the sub dirs.
    - one could run makepp from a sub dir, and i want to make all default targets from that subdir and all the sub dirs below it.

    I hope i explained myself clearly.

    Is there any way to solve this problem?

    Thanks in advance,

    Yoni.

     
  • Nobody/Anonymous

    Hi 
    I used a global variable to solve this issue. 
    I defined it with $make::some_var and updated it in each makefile.

        $(phony all): $((perl $make::some_var ))

    Hope it will help anyone. 
    Yoni.

     
  • Daniel Pfeiffer

    Daniel Pfeiffer - 2009-12-12

    Hi Yoni,

    sorry for the late reply!  You could just have said in your top level:

    $(phony all): */**/all

    i.e. the all`s in all subdirs recursively.

    best regards
    Daniel

     
  • jontra

    jontra - 2009-12-24

    Hi Daniel, 
    Thanks for the answer. 
    I tried to use your approach, but it seem to work only on non phony rules. 
    For example: 

    Makefile1:

        load_makefile subdir/Makefile
        $(phony all): */**/all

    Makefile2: 

        some_target:
        touch $(target)
       
        $(phony all): some_target
       
    Give the Following result: 
    makepp: Loading makefile \`/home/yoni/test/Makefile' 
    makepp: Loading makefile \`/home/yoni/test/2/Makefile' 
    makepp: 0 files updated and 1 phony target built 

    But if i change all target (in Makefile2) to be non phony one: 

        all: some_target
                touch $(target)

    Then it works file. 
    I believe this is a small bug fix in makepp and hope you will find the time to fix it. 
    Best regards, 
    Yoni.

     
  • Daniel Pfeiffer

    Daniel Pfeiffer - 2009-12-27

    Sorry, that was off the top of my head, it should have been:

        $(phony all): $(only_phony_targets */**/all)

     

Log in to post a comment.