Board index » cppbuilder » Help appending to PATH with Makefile macros.

Help appending to PATH with Makefile macros.


2003-06-25 09:14:38 PM
cppbuilder34
Hello,
Sorry about the confusion in the last post. I can see why those
typos were sending you for a loop.
I hope somebody can help me. In a make file I have to edit my path
to get my program to run.
I have a var
JTC_DIR = $(top_dir)\..\jtc
!message $(PATH)
!message $(JTC_DIR)
!if "$(DLL)" == yes
PATH = $(JTC_DIR)\lib;$(PATH)
!endif
When I compile my program it complains that it can't find the file in
the jtc\lib directory. I know the file is there.
When I do the !message $(PATH) I see my current path.
When I do the !message $(JTC_DIR) I see the macro expanded correct.
If I do an echo %PATH% before the complaining I see $(JTC_DIR)\lib;
..... the rest of the path. The $(JTC_DIR) is not expanded and placed as
is in the PATH.
Does anybody know why this var is not expanding ? Does it have
something to do with the PATH command being in an !if directive ?
It would help me out a great deal if you could give me a solution.
Thanks
Matthew
 
 

Re:Help appending to PATH with Makefile macros.

Sorry,
but I found the description still a bit confusing :) Why not reduce
your makefile to a couple of lines showing the essentials (and the
failures) ?
Anyway, from what I think I understood I constructed the attached
makefile. I order for it to work, you need
- a directory c:\tmp\x and
- a file dummy.txt in this directory (which should contain some lines
of text)
Then if you copy the attached file as 'makefile' and run make, it
should print out the content of dummy.txt twice - it does for me.
HTH
Helmut Giese
PS: Using 'echo' did produce the result you described - but then, you
are not primarily interested in 'echo', are you?
------------- makefile ----------------
top_dir = c:\tmp
JTC_DIR = $(top_dir)\x
!message Path = $(PATH)
!message JTC_DIR = $(JTC_DIR)
PATH = $(JTC_DIR)
!message PATH has changed
!message Path = $(PATH)
# Let's define a file: Once just the name, then the full path
MyFile = dummy.txt
MyFileFP = $(PATH)\$(MyFile)
# Let's try to access MyFile (both versions)
target:
type $(PATH)\$(MyFile)
echo .
type $(MyFileFP)
 

Re:Help appending to PATH with Makefile macros.

Hello Helmut,
Thanks for the help. After I did some investigate I have discovered
that my problem is when I try to build a target I can't see the modify path.
This is the area of the make file that I am concerned with.
!message
!message before ECHO $(PATH)
!message
Types.cpp Types.h: Types.idl
-del Types.cpp Types.h
echo %PATH%
$(IDL) -I$(top_srcdir)/idl --no-skeletons Types.idl
This is the output when I run the make.
---------------------------------------------------------------------
D:\Borland-Path\cpp\ob\test\types>make -f Makefile.bcc
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
before ECHO
..\..\..\jtc\lib;..\..\..\ob\lib;C:\jdk1.3.1_05\bin;F:\Obe-tfp\OBEE_shared_d
ebug_install\OBE\2.2\c\lib;F:\Obe-2.2-rc4\OBEE_shared_debug_install\OBE\2.2\bin;
F:\trans-test\ftp\OBEE-2.2.0-bin-win32\OBE\2.2\bin;C:\texmf\miktex\bin;C:\Perl\b
in;c:\utils;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\vim\vim61
;C:\DevStudio\VC98\Bin;c:\vim\vim61;C:\Program
Files\Hummingbird\Connectivity\7.
10\Accessories\;C:\Program
Files\Hummingbird\Connectivity\7.10\NFSClient;C:\Prog
ram Files\Rational\Clearcase\bin;C:\Program
Files\Rational\common;F:\borland\bcc
55\bin;F:\Borland\BCC55\Include;
del Types.cpp Types.h
Could Not Find D:\Borland-Path\cpp\ob\test\types\Types.cpp
echo %PATH%
$(JTC_DIR)\lib;$(OB_DIR)\lib;C:\jdk1.3.1_05\bin;F:\Obe-tfp\OBEE_shared_debug_ins
tall\OBE\2.2\c\lib;F:\Obe-2.2-rc4\OBEE_shared_debug_install\OBE\2.2\bin;F:\trans
-test\ftp\OBEE-2.2.0-bin-win32\OBE\2.2\bin;C:\texmf\miktex\bin;C:\Perl\bin;c:\ut
ils;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\vim\vim61;C:\DevS
tudio\VC98\Bin;c:\vim\vim61;C:\Program
Files\Hummingbird\Connectivity\7.10\Acces
sories\;C:\Program
Files\Hummingbird\Connectivity\7.10\NFSClient;C:\Program File
s\Rational\Clearcase\bin;C:\Program
Files\Rational\common;F:\borland\bcc55\bin;F
:\Borland\BCC55\Include;
..\..\..\ob\bin\idl.exe -I..\../idl --no-skeletons Types.idl
---------------------------------------------------------------------------
As you can tell the PATH environment variable seems to be modified since
I can see it displayed correctly when I do the !message BEFORE ECHO
$(PATH). Then when I try to build my target it reverts to a state where
the PATH is still looking for the $(JTC_DIR) and $(OB_DIR). I can tell
that since the display from the ECHO %PATH%. The computer then sends me
a popup box saying that it can't locate a file which is in the jtc\lib
directory.
Does anybody know a way I fix this problem ?
Thanks
Matthew
Helmut Giese wrote:
Quote
Sorry,
but I found the description still a bit confusing :) Why not reduce
your makefile to a couple of lines showing the essentials (and the
failures) ?

Anyway, from what I think I understood I constructed the attached
makefile. I order for it to work, you need
- a directory c:\tmp\x and
- a file dummy.txt in this directory (which should contain some lines
of text)

Then if you copy the attached file as 'makefile' and run make, it
should print out the content of dummy.txt twice - it does for me.
HTH
Helmut Giese

PS: Using 'echo' did produce the result you described - but then, you
are not primarily interested in 'echo', are you?

------------- makefile ----------------
top_dir = c:\tmp
JTC_DIR = $(top_dir)\x

!message Path = $(PATH)
!message JTC_DIR = $(JTC_DIR)

PATH = $(JTC_DIR)
!message PATH has changed
!message Path = $(PATH)

# Let's define a file: Once just the name, then the full path
MyFile = dummy.txt
MyFileFP = $(PATH)\$(MyFile)

# Let's try to access MyFile (both versions)
target:
type $(PATH)\$(MyFile)
echo .
type $(MyFileFP)

 

{smallsort}

Re:Help appending to PATH with Makefile macros.

Matthew Pinhorn wrote:
Quote
!message
!message before ECHO $(PATH)
!message

Types.cpp Types.h: Types.idl
-del Types.cpp Types.h
echo %PATH%
As you can tell the PATH environment variable seems to be modified since
I can see it displayed correctly when I do the !message BEFORE ECHO
$(PATH).
You're slightly wrong in that conclusion: what you can see from that
!message
statement is that make's *internal* variable PATH has been modified as
desired.
But as long as you used make's internal commands to display it, you
don't necessarily get its actual value displayed.
From the combination of symptoms you show, it's quite clear that the
actual content of $(PATH) does not have the $(JTC_DIR) references
actually expanded. Those only got expanded by make when it prepared the
!message.
But this same expansion obviously doesn't happen to the exported version
of the internal variable that becomes the %PATH% environment variable
for executed commands.
What you would need is a way to tell make to expand $(JTC_DIR)
_immediately_ during the re-definition of PATH in the makefile, not only
when it evaluates internal commands. Somebody more experienced with
Borland knowing how that's done?
[If memory serves, GNU make uses the distinction between := and =
assignment syntax to set variables to do this.]
--
Hans-Bernhard Broeker ( XXXX@XXXXX.COM )
Even if all the snow were burnt, ashes would remain.
 

Re:Help appending to PATH with Makefile macros.

On Mon, 30 Jun 2003 17:20:47 +0200, Hans-Bernhard Broeker
< XXXX@XXXXX.COM >wrote:
Hi,
funny how the "experts" struggle to find better solutions for a
problem we don't really know that much about.
Quote
Helmut, I think you're oversimplifying the matter. As I showed in an
earlier reply, the real issue is that borland's make seems to fail to
expand references to make-internal or environment variables in the value
of exported environment variables.
If MAKE doesn't find a symbol's definition in the makefile itself, it
looks for a corresponding environment variable. I don't recall ever
having read in the docs that the inverse is true, too - that is, it is
exported automatically by MAKE.
Now, whatever MAKE is supposed / expected / wanted to do with a
modified value of PATH, it apparently doesn't make it into the
environment. So let's accept reality and see how to achieve what we're
after in a different way ("we" - metaphorically speaking).
I attempted to show, that often you don't need to modify PATH - if
*all* programs you want to activate are explicitely named in the
makefile, you can always call them with their full name - this full
name being constructed the way I (tried to) show.
If this is sufficient (and IMO it very often is) then this is the
simplest way and the OP should use it. Only if it is not sufficient
would we proceed to some more advanced "tricks" like the old "echo"
trick to construct a batch file and run this - but I prefer to keep
things as simple as possible.
I propose that we not pursue this topic, since it is well possible
that the OP has already found a satisfying solution.
Best regards
Helmut Giese