Mail Archives: cygwin/2004/11/11/08:29:49
> -----Original Message-----
> From: cygwin-owner On Behalf Of Prasad, Kanuparthi
> Sent: 11 November 2004 11:16
> In my make file I am trying to check whether a directory
> exists or not
> then set a path differently if doesn't exist.
> I am using cygwin installed on windows 2000.
> The if construct I have is as follows.
>
> if test [-dc:/tools]; then DRIVE = c:/tools; else DRIVE =
> c:/altTools; fi
Oh, and by the way, another way you can do this, using only makefile syntax so
it doesn't involve the shell at all, is to use the $(wildcard ...) function with
a full filename to see if it exists, and then use that in a $(if ...) test.
Like so:
DRIVE=$(if $(wildcard c:/tools), c:/tools, c:/altTools)
This technique has the advantage of working whether you're using make in --win32
or --unix mode:
dk AT mace /tmp/bgcc> ls -la C:/tools
ls: C:/tools: No such file or directory
dk AT mace /tmp/bgcc> cat makefoo
DRIVE=$(if $(wildcard c:/tools), c:/tools, c:/altTools)
all:
echo drive is ${DRIVE}
dk AT mace /tmp/bgcc> make -f makefoo
echo drive is c:/altTools
drive is c:/altTools
dk AT mace /tmp/bgcc> make --win32 -f makefoo
echo drive is c:/altTools
drive is c:/altTools
dk AT mace /tmp/bgcc> mkdir C:/tools
dk AT mace /tmp/bgcc> make -f makefoo
echo drive is c:/tools
drive is c:/tools
dk AT mace /tmp/bgcc> make --win32 -f makefoo
echo drive is c:/tools
drive is c:/tools
dk AT mace /tmp/bgcc>
since it depends only on the cygwin dll's path-handling abilities, and not on
the nature of the shell that is being used to execute the commands.
cheers,
DaveK
--
Can't think of a witty .sigline today....
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -