From owner-freebsd-ports@freebsd.org Mon Mar 26 04:51:08 2018 Return-Path: Delivered-To: freebsd-ports@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEBD3F6AD83 for ; Mon, 26 Mar 2018 04:51:07 +0000 (UTC) (envelope-from freebsd@dreamchaser.org) Received: from nightmare.dreamchaser.org (ns.dreamchaser.org [66.109.141.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "nightmare.dreamchaser.org", Issuer "nightmare.dreamchaser.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 55F6B6A332 for ; Mon, 26 Mar 2018 04:51:06 +0000 (UTC) (envelope-from freebsd@dreamchaser.org) Received: from breakaway.dreamchaser.org (breakaway [192.168.151.122]) by nightmare.dreamchaser.org (8.15.2/8.15.2) with ESMTP id w2Q4owF2082319 for ; Sun, 25 Mar 2018 22:50:59 -0600 (MDT) (envelope-from freebsd@dreamchaser.org) To: FreeBSD Mailing List Reply-To: freebsd@dreamchaser.org From: Gary Aitken Subject: .if and Makefile issues Message-ID: <85769c6d-a71a-f2c6-8a65-ac9b82f534ab@dreamchaser.org> Date: Sun, 25 Mar 2018 22:50:18 -0600 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2018 04:51:08 -0000 Bewildered and frustrated, looking for some guidance on a seemingly simple task: check the existence of a file and rename it. Looking at a number of examples in the Porter's guide, I should be able to do something like this: post-build: echo "***** post-build *****" #Avoid executable name conflict with dcraw port .if exists ${WRKSRC}/dcraw echo ===== dcraw exists ===== mv ${WRKSRC}/dcraw ${WRKSRC}/${PORTNAME}-dcraw .else echo ===== dcraw does not exist ===== .endif That causes: echo "***** post-build *****" ***** post-build ***** .if exists /usr/ports/graphics/ufraw-devel/work/ufraw-6d3259a/dcraw make[1]: exec(.if) failed (No such file or directory) *** Error code 1 I then tried adding parens: post-build: echo "***** post-build *****" #Avoid executable name conflict with dcraw port .if exists(${WRKSRC}/dcraw) echo "===== dcraw exists =====" mv ${WRKSRC}/dcraw ${WRKSRC}/${PORTNAME}-dcraw .else echo "===== dcraw does not exist =====" .endif echo "***** post-build *****" ***** post-build ***** .if exists(/usr/ports/graphics/ufraw-devel/work/ufraw-6d3259a/dcraw) Syntax error: "(" unexpected *** Error code 2 I finally got this to do *something*: post-build: echo "***** post-build *****" # Avoid executable name conflict with dcraw port .if exists ${WRKSRC}/dcraw echo ===== dcraw exists ===== mv ${WRKSRC}/dcraw ${WRKSRC}/${PORTNAME}-dcraw .else echo ===== dcraw does not exist ===== .endif echo "***** post-build *****" ***** post-build ***** echo "===== dcraw does not exist =====" ===== dcraw does not exist ===== Unfortunately, the file *does* exist. Can someone enlighten me as to what is going on in the above three situations, to further my education? Any hints / pointers would be much appreciated: 1. Why does the .if, .else, and .endif have to have no leading whitespace? 2. Why does it require the on the stmt after the else but not after the .if? (Same behavior with tabs on the ones after .if) 3. Why doesn't it find the file? 4. What's a right way to do this? # ls /usr/ports/graphics/ufraw-devel/work/ufraw-6d3259a/dcraw /usr/ports/graphics/ufraw-devel/work/ufraw-6d3259a/dcraw Thanks, off to sleep to try to save what little hair is left. Gary