Subject: Re: Makefile targets and variables
To: Mike M. Volokhov <mishka@terabyte.com.ua>
From: Johnny C. Lam <jlam@netbsd.org>
List: tech-pkg
Date: 09/08/2003 19:53:07
On Mon, Sep 08, 2003 at 05:28:08PM +0300, Mike M. Volokhov wrote:
> 
> Lets follow some example:
> ---- cut ---
> post-extract:
> .if exists(${WRKSRC}/some-file)
>         echo "true"
>         ${LS} -l ${WRKSRC}/some-file
> .else
>         echo "false"
>         ${LS} -l ${WRKSRC}/some-file
> .endif
> ---- cut ---
> 
> % make extract
> ===> Checking for vulnerabilities in foo-1.0
> => Checksum OK for foo-1.0.tar.gz.
> ===> Extracting for foo-1.0
> echo "false"
> false
> /bin/ls -l /usr/pkgsrc/wip/foo/work/foo-1.0/some-file
> -rwxr-xr-x  1 mishka  users  647 Jan  6  2003 
> /usr/pkgsrc/wip/foo/work/foo-1.0/some-file
> %

You want:

post-extract:
	@if [ -f ${WRKSRC}/some-file ]; then	\
		# do stuff here
	fi

There's no need to do the file existence check at the Makefile level.

	Cheers,

	-- Johnny Lam <jlam@NetBSD.org>