delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/11/11/08:29:49

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dk AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: if construct doesn't work in makefile
Date: Thu, 11 Nov 2004 13:28:11 -0000
MIME-Version: 1.0
In-Reply-To: <7D5F213AF1EF264990B7C09ADD1B1CDDB8BF86@cheadle.ds.teradyne.com>
Message-ID: <NUTMEGG6OUDvkq81QtZ0000068d@NUTMEG.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 11 Nov 2004 13:28:11.0187 (UTC) FILETIME=[4A113030:01C4C7F2]

> -----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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019