#25 $CURDIR incompatible with gnumake

来源:互联网 发布:淘宝模块是什么 编辑:程序博客网 时间:2024/05/20 23:31

#25 $CURDIR incompatible with gnumake

closed-invalid
nobody
None
5
2012-02-16
2011-12-13
Credzba
No

I noticed that the release notes for 1.14 says that CURDIR is now compatible, but in my testing with 1.15 and 2.0rc makepp returns the current file directory (if its included, then the directory of the include) while gnumake always returns the original makefile location.

gnu documentation at http://www.gnu.org/s/hello/manual/make/Recursion.html states:
For your convenience, when GNU make starts (after it has processed any -C options) it sets the variable CURDIR to the pathname of the current working directory. This value is never touched by make again: in particular note that if you include files from other directories the value of CURDIR does not change. The value has the same precedence it would have if it were set in the makefile (by default, an environment variable CURDIR will not override this value). Note that setting this variable has no impact on the operation of make (it does not cause make to change its working directory, for example).

makepp documentation at http://makepp.sourceforge.net/2.0/makepp_variables.html#curdir states:
CURDIR
The directory in which the current Makefile resides.

Discussion

  • Daniel Pfeiffer
    Daniel Pfeiffer
    2011-12-13

    I can't reproduce this. Given /tmp/abc/Makeppfile with:

    &echo bef $(CURDIR)
    include toto
    &echo aft $(CURDIR)

    and /tmp/toto with:

    &echo inc $(CURDIR)

    mpp prints:

    bef /tmp/abc
    inc /tmp/abc
    aft /tmp/abc

    Can you please attach some simple files that reproduce your case?

    regards -- Daniel

     

  • Credzba
    Credzba
    2011-12-14

    I tried your test, and it worked just as it did for you, then I retried my production code, and it had the same problem ! So.. just need to shrink the problem.

    Here is what I found ..

    setup your files slightly different:
    abc/Makefile (will include ../toto/Makefile.inc)

    move your toto to
    ../toto/Makefile.inc (so it will get included properly)
    create a ../toto/Makefile (this is the root problem)

    Now when you makepp in abc directory, you will see it loads the Makefile in toto directory just before it loads toto/Makefile.inc, and Makefile.inc will now have the CURDIR of ITS toto/Makefile, not the original Makefile.

    Perhaps this is a feature of makepp, and I can turn it off ?

     

  • Daniel Pfeiffer
    Daniel Pfeiffer
    2011-12-14

    I still don't get it. I set it up as you write, with an echo in the new file too, and I get:

    makepp: Loading makefile `/tmp/abc/Makefile'
    bef /tmp/abc
    makepp: Loading makefile `/tmp/toto/Makefile'
    toto/mf /tmp/toto
    inc /tmp/abc <-- still right
    aft /tmp/abc

    The way you describe it, loading the extra makefile doesn't seem to be your problem. But just in case, be aware that makepp will check if it needs to (re)create an include file. As it does not have a rule for toto/Makefile.inc yet, it will try to load a makefile in its directory to see if that produces a rule. It does not here, so loading the makefile has no effect (at least in my setup, where it does nothing except echo).

    So please try to narrow down your problem to a small tarball that reproduces what you mean!

    regards -- Daniel

     

  • Credzba
    Credzba
    2011-12-15

    tar of example

     
    Attachments
    makeTest.tar

  • Credzba
    Credzba
    2011-12-15

    The problem is the Makefile in toto has an include for Makefile.inc as well, and since it gets loaded Makefile.inc gets loaded with an invalid directory (in my case).

    I think I can work around the problem by moving Makefile out of the include directory or tell it not to try to find a rule for Makefile.inc (if that is possible).

    here are sample executions with make and makepp:
    % makepp
    makepp: Loading makefile `/c/users/desktop/maketest/main/makefile'
    CURDIR in main is /c/users/desktop/maketest/main
    makepp: Loading makefile `/c/users/desktop/maketest/secondary/makefile'
    Makefile from secondary loaded
    CURDIR in secondary is /c/users/desktop/maketest/secondary
    CURDIR in secondary is /c/users/desktop/maketest/main
    CURDIR in main after include is /c/users/desktop/maketest/main
    makepp: Entering directory `/c/users/desktop/maketest/main'
    Main Target all
    makepp: 0 files updated and 1 phony target built

    09:22 PM ~/makeTest/main
    % make
    CURDIR in main is /c/Users/desktop/makeTest/main
    CURDIR in secondary is /c/Users/desktop/makeTest/main
    CURDIR in main after include is /c/Users/desktop/makeTest/main
    Main Target all

     

  • Daniel Pfeiffer
    Daniel Pfeiffer
    2011-12-16

    Ok, now it's clear: you have a misconception here. Makefile.inc is not a makefile in its own right. It does not have its own value of CURDIR. Instead you must think of it, as though it were copy pasted literally instead of the include statements, just like #include in C.

    The difference to gmake is that mpp is more thorough in that it loads secondary/Makefile too. This gives you an extra output, which is correct from that makefile. You can verify this with mpp --dont-build ../secondary which is essentially like gmake.

     

  • Daniel Pfeiffer
    Daniel Pfeiffer
    2012-02-16

    • status: open --> closed-invalid
     


0 0
原创粉丝点击