.if and Makefile issues
Theron Tarigo
theron.tarigo at gmail.com
Mon Mar 26 05:23:42 UTC 2018
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
More information about the freebsd-ports
mailing list