Strange behavior of 'exists' function. Need help with Makefile.

Ulrich Spörlein uqs at spoerlein.net
Mon Dec 28 16:11:07 UTC 2009


On Mon, 28.12.2009 at 10:13:42 +0200, Yevgen Krapiva wrote:
> Hi guys, 
> 
> I'm trying to create my own port. I'm stucked with the following
> Makefile:
> 
> PORTNAME=      openjsip
> PORTVERSION=   0.0.4
> ...
> ...
> MY_FILE=       proxy.properties
> 
> do-check: 
> 
> 	#FIRST TEST
> .	if !exists(/usr/local/share/openjsip/conf/proxy.properties)
> 		@${ECHO_MSG} ">> /usr/local/share/openjsip/conf/proxy.properties
> doesn't exist"
> .	else
> 		@${ECHO_MSG} ">> /usr/local/share/openjsip/conf/proxy.properties
> exists"
> .	endif
> 	
> 	#SECOND TEST
> 	@${ECHO_MSG} ">> DATADIR=${DATADIR}"
> 
> .for f in ${MY_FILE}
> .	if !exists(${DATADIR}/conf/${f})
> 		@${ECHO_MSG} ">> File ${DATADIR}/conf/${f} doesn't exist"
> .	else
> 		@${ECHO_MSG} ">> File ${DATADIR}/conf/${f} exists"
> .	endif
> .endfor
> 
> 
> I'm trying to make script to check the existence of proxy.properties
> file.
> The first test works well while to other one (with the use of 'for')
> doesn't.
> Can you help me, I don't understand why the second test fails.

First of all, please do not use "empty" lines inside a Makefile, it is
not an imperative language and care must be taken so that the parser
gets things right.

Doing a minimal test, I cannot confirm your findings, perhaps you should
try to trim down your example and see where it breaks or starts to work.

Example:

FILES=/etc/rc.conf /etc/doener.conf

all:
.for f in ${FILES}
.if !exists(${f})
	@echo "${f} does not exist"
.else
	@echo "${f} does exist"
.endif
.endfor

% make all
/etc/rc.conf does exist
/etc/doener.conf does not exist

hth,
Uli



More information about the freebsd-ports mailing list