Unix Programming - make and PATH

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2007 > make and PATH





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author make and PATH
Anders Christensen

2007-09-12, 1:19 pm

Hi NG,

I have a problem with paths together with make.

I'd like my Makefile to execute a program in a specific working
directory.
My rule looks something like this
%.in %.out:
cd $(dir $*.in) && \
myprogram.exe $(notdir $*.in)

My test target looks something like this
test: wanted\path\mytarget.out wanted2\path2\mytarget2.out
wanted3\path3\mytarget3.out

For some reason myprogram.exe is unknown and I get this output when
running make:
cd wanted\path\ && \
myprogram.exe mytarget.in
'myprogram.exe' is not recognized as an internal or external command,
operable program or batch file.
make: *** [wanted\path\mytarget.out] Error 1

The path to myprogram.exe is in my PATH variable and I have no problem
running it if I manually navigate to wanted\path\ to execute it.

The strange thing is that there's no error if I change the Makefile to
%.IN %.OUT:
cd $(dir $*.IN)
myprogram.exe $(notdir $*.IN)

....but then the working directory for myprogram.exe is not wanted\path
\ as I want it to be.

What could be the problem? I'd appreciate any hint!

../Anders.

Gianni Mariani

2007-09-12, 7:20 pm

Anders Christensen wrote:
> Hi NG,
>
> I have a problem with paths together with make.
>
> I'd like my Makefile to execute a program in a specific working
> directory.
> My rule looks something like this
> %.in %.out:
> cd $(dir $*.in) && \
> myprogram.exe $(notdir $*.in)
>
> My test target looks something like this
> test: wanted\path\mytarget.out wanted2\path2\mytarget2.out
> wanted3\path3\mytarget3.out
>
> For some reason myprogram.exe is unknown and I get this output when
> running make:
> cd wanted\path\ && \
> myprogram.exe mytarget.in
> 'myprogram.exe' is not recognized as an internal or external command,
> operable program or batch file.
> make: *** [wanted\path\mytarget.out] Error 1
>
> The path to myprogram.exe is in my PATH variable and I have no problem
> running it if I manually navigate to wanted\path\ to execute it.
>
> The strange thing is that there's no error if I change the Makefile to
> %.IN %.OUT:
> cd $(dir $*.IN)
> myprogram.exe $(notdir $*.IN)
>
> ...but then the working directory for myprogram.exe is not wanted\path
> \ as I want it to be.
>
> What could be the problem? I'd appreciate any hint!


change the rule temporarily to run bash and check to see what is going on:

%.out : %.in
cd $(dir $*.in) && \
echo myprogram.exe $(notdir $*.in) ; bash

This will print the command and start a shell. You can then examine why
it's not finding your exe.

What I normally do is put the entire path to the executable

MYPROGRAM=/usr/bin/myprogram

and then I use $(MYPROGRAM)



Anders Christensen

2007-09-14, 1:30 am

On 12 Sep., 22:23, Gianni Mariani <gi3nos...@mariani.ws> wrote:
> Anders Christensen wrote:
>
>
>
>
>
>
>
>
>
> change the rule temporarily to run bash and check to see what is going on:
>
> %.out : %.in
> cd $(dir $*.in) && \
> echo myprogram.exe $(notdir $*.in) ; bash
>
> This will print the command and start a shell. You can then examine why
> it's not finding your exe.
>
> What I normally do is put the entire path to the executable
>
> MYPROGRAM=3D/usr/bin/myprogram
>
> and then I use $(MYPROGRAM)- Skjul tekst i anf=F8rselstegn -
>
> - Vis tekst i anf=F8rselstegn -


Hi and thank you for your quick answer!

I followed your advise and started a prompt (cmd.exe). I found out
that some of the entries of my path (eg. the path to myprogram.exe)
were missin in this prompt. Only some of them, I don't really get
it...

I solved the problem in the following way, since $(PATH) contains
_all_ entries of my path:
%=2Eout : %.in
cd $(dir $*.in) && \
set PATH=3D$(PATH) && \
myprogram.exe $(notdir $*.in)

Thanks again ^_^
../Anders.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com