Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Mar 2018 01:23:40 -0400
From:      Theron Tarigo <theron.tarigo@gmail.com>
To:        freebsd@dreamchaser.org, FreeBSD Mailing List <freebsd-ports@freebsd.org>
Subject:   Re: .if and Makefile issues
Message-ID:  <df255fd7-bdfb-7158-1c25-dc8260c434dd@gmail.com>
In-Reply-To: <85769c6d-a71a-f2c6-8a65-ac9b82f534ab@dreamchaser.org>
References:  <85769c6d-a71a-f2c6-8a65-ac9b82f534ab@dreamchaser.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 03/26/18 00:50, Gary Aitken wrote:
> 1. Why does the .if, .else, and .endif have to have no leading 
> whitespace?
The <ht> tells Make that the line contains a command to run in the shell 
when executing a rule.  ".if", etc. are statements understood only to 
Make itself.
> 2. Why does it require the <ht> on the stmt after the else but not
>    after the .if?  (Same behavior with tabs on the ones after .if)
The <ht> IS required before the "echo" after the ".if".  The "echo" you 
have written (with no preceding <ht>) wouldn't be run even if the ".if" 
were to succeed - without the <ht>, Make interprets it as a Make 
statement but it has no effect.
> 3. Why doesn't it find the file?
The ".if", etc. statements are evaluated when the Makefile is read, thus 
do not reflect the state of the files mid-build.
> 4. What's a right way to do this?
This can be done with the shell: (note the escapes)
<ht>test -f ${WRKSRC}/dcraw && \
<ht>  mv ${WRKSRC}/dcraw ${WRKSRC}/${PORTNAME}-dcraw || \
<ht>  echo "===== dcraw does not exist ====="

However, it may be better to simply try to move the file but return 
success even if it does not exist:
<ht>mv ${WRKSRC}/dcraw ${WRKSRC}/${PORTNAME}-dcraw || true




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?df255fd7-bdfb-7158-1c25-dc8260c434dd>