help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help: makefile: directory rules


From: Greg Chicares
Subject: Re: help: makefile: directory rules
Date: Mon, 20 Mar 2006 16:51:08 +0000
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

On 2006-3-17 4:12 UTC, Paul Li wrote:
>
> On 3/17/06, Greg Chicares <address@hidden> wrote:
>
>>On 2006-3-17 2:41 UTC, paulur wrote:
>>
>>>There are two directories /src1 and /src2 where the soruce codes are, and
>>>another directory /headers for head files.
>>>
>>>How should the makefile set variables ( not to hard code all the
>>>directories) so that the complier can find these files?
>>
>>Let's say those are all subdirectories of /somepath/ and
>>assume you're using C. If you write
>>
>>vpath %.c /somepath/src1 /somepath/src2
>>vpath %.h /somepath/headers
>>
>>then you can run 'make' in a completely different directory
>>and it will find those files.
>
> * where to put the makefile?

Anywhere you like. Given
  /somepath/src1
  /somepath/src2
  /somepath/headers
it would seem logical to put it in /somepath/ or even in
/somepath/makefiles/ if you want.

> * since head files are under different directories from .c files, how
> to declare #include ".h"?

As long as you use vpath, it doesn't matter--it's just your
personal preference.

The 'make' sources just say, for instance,
  #include "make.h"
but headers like that aren't designed to be used by other
programs. If you're writing a library and other programs
need to include its headers, then it's common to put them
in my_library-2.3.4/include/my_library/ and write
  vpath %.h /wherever/my_library-2.3.4/include
in the makefile
  #include <my_library/my_header.h>
in any source file that needs it. I like angle brackets
here, while others may prefer double quotes, but the
language standard doesn't clearly say that one is better
than the other.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]