bugmake - Bugs: bug #38437, cannot find the include file

 
 

bug #38437: cannot find the include file

Submitter:  Jian <skyshore>
Submitted:  Thu 28 Feb 2013 04:55:23 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  3.82 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 28 Feb 2013 08:35:30 AM UTC, comment #2: 

(just paste the mail with solution here for your reference)

Thanks Philip. It works for me, and now I can distribute my makefiles into different path.

However, I still hope it can be improved as the expreience of C/C++ tells us it shall be able to. When reading a makefile, the path of this file should be added into the search path automaticallly.



2013/2/28 Philip Guenther <guenther@gmail.com>
On Wed, Feb 27, 2013 at 8:55 PM, Jian <INVALID.NOREPLY@gnu.org> wrote:
...

> Supposing 2 makefiles in dir A: 1.mak, 2.mak, and 1.mak include 2.mak.
> Now in dir B, 3.mak includes 'A/1.mak' (will auto include 2.mak). But error
> shows that 2.mak cannot be found.
>
> The make option "-I" can be the workaround like:
>  cd B
>  make -f 3.mak -IA
>
> But it's not acceptable to tell user to uses "-I" to make every time. make
> shall be able to find 2.mak.


So have 1.mak look for 2.mak in the same directory, by doing something like:

# Get the directory part of the path by which 1.mak was included
# This should be before any other includes in 1.mak
dir_of_1 = $(dir $(lastword $(MAKEFILE_LIST)))

...and then later:

# pull in 2.mak in the same directory as this file
include ${dir_of_1}2.mak

Jian <skyshore>
Thu 28 Feb 2013 05:34:55 AM UTC, comment #1: 

This is how GNU make has always worked: the include file reference is always relative to the current working directory of the GNU make program, regardless of what directory the current makefile is in.  There are far too many makefiles out there relying on this behavior, to change it now.

Suggestions have been made to allow use of VPATH to find included makefiles; see bug #15224

Paul D. Smith <psmith>
Group administrator
Thu 28 Feb 2013 04:55:23 AM UTC, original submission:  

Supposing 2 makefiles in dir A: 1.mak, 2.mak, and 1.mak include 2.mak.
Now in dir B, 3.mak includes 'A/1.mak' (will auto include 2.mak). But error shows that 2.mak cannot be found.

The make option "-I" can be the workaround like:
 cd B
 make -f 3.mak -IA

But it's not acceptable to tell user to uses "-I" to make every time. make shall be able to find 2.mak.

Jian <skyshore>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

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)
  • -email is unavailable- added by skyshore (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-02-28 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code