help-gplusplus
[Top][All Lists]
Advanced

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

Re: Question on Makefile


From: James Kanze
Subject: Re: Question on Makefile
Date: Sat, 19 Mar 2005 17:14:18 +0100
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Paul D. Smith wrote:
> %% Christian Christmann <plfriko@yahoo.de> writes:

>   cc> I want to use some binaries in the Makefile
>   cc> which are located in the same directory as
>   cc> the source code. When I want to call these
>   cc> files just with their name, make is complaining
>   cc> about not finding the files. When I add "./" to the
>   cc> file name everthing works fine.

>   cc> Are there any options for the Makefile to let
>   cc> make search for files also in the current directory?

> Make doesn't run programs: it runs /bin/sh and passes it the
> rule you've written, and it's _/bin/sh_ that runs programs.
> The shell, of course, looks in the PATH variable to find
> binaries, so if "." is in your PATH then they will be found in
> the current directory; if it's not, they won't be.

> Personally I _strongly_ recommend that you NOT rely on PATH,
> but rather do exactly what you've done and invoke your
> programs using "./foo" if they exist in the current directory.
> Not only does this make it quite obvious to people reading the
> makefile exactly what you intend, but it solves issues with
> finding unintended versions of programs on PATH; these can be
> quite confusing.

I'd go one step further, and recommend using a makefile
variable, e.g.:
    toolsDir = .
and in the rule:
    $(toolsDir)/myprog ...

That way, the day you have to support several platforms, you can
replace toolsDir with something platform specific.

--
James Kanze                                      home: www.gabi-soft.fr
Conseils en informatique orientée objet/
                       Beratung in objektorientierter Datenverarbeitung
9 pl. Pierre Sémard, 78210 St.-Cyr-l'École, France +33 (0)1 30 23 00 34


reply via email to

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