Date: Fri, 9 Mar 2001 01:30:01 -0800 (PST) (10:30 CET) To: jhs@_ERASE_. From: gnats-admin@FreeBSD._ERASE_..org Subject: Re: bin/25627: Cannot append hash after .elif in Makefile, (but can after .if) Thank you very much for your problem report. It has the internal identification `bin/25627'. The individual assigned to look at your report is: freebsd-bugs. You can access the state of your problem report at any time via this link: http://www.freebsd.org/cgi/query-pr.cgi?pr=25627 SEND-PR: -*- send-pr -*- SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as SEND-PR: will all comments (text enclosed in `<' and `>'). SEND-PR: SEND-PR: Please consult the send-pr man page `send-pr(1)' or the Texinfo SEND-PR: manual if you are not sure how to fill out a problem report. SEND-PR: SEND-PR: Note that the Synopsis field is mandatory. The Subject (for SEND-PR: the mail) will be made the same as Synopsis unless explicitly SEND-PR: changed. SEND-PR: SEND-PR: Choose from the following categories: SEND-PR: SEND-PR: advocacy alpha bin conf docs gnu SEND-PR: i386 kern misc ports sparc SEND-PR: To: FreeBSD-gnats-submit@freebsd.._ERASE_.org Subject: Cannot append hash after .elif in Makefile, (but can after .if) From: jhs@._ERASE_. Reply-To: jhs@._ERASE_. X-send-pr-version: 3.2 >Submitter-Id: current-users >Originator: Julian Stacey jhs@._ERASE_. >Organization: FreeBSD >Confidential: no >Synopsis: Cannot append hash after .elif in Makefile, (but can after .if) >Severity: non-critical >Priority: low >Category: bin >Release: FreeBSD 4.2-RELEASE i386 >Class: sw-bug >Environment: `man make` says: Comments begin with a hash (`#') character, anywhere but in a shell com- mand line, and continue to the end of the line. To understand a complex Makefile like /usr/src/release/Makefile with nested .if .endif conditionals, it is useful to hang "#{" & "#}" at end of lines & use the "%" key in vi to bounce between matching braces. This fails on .elif >Description: The expansion of .elif uses everything up to '\n' & allows no '#' comment delimeter as available to simpler .if & .else & .endif commands. >How-To-Repeat: mkdir ~/tmp ; cd ~/tmp ; cat > Makefile << EOF break: .if defined(AA) #{AA @echo 11 .elif defined(BB) #}{!AA{BB @echo 22 .else #}{!BB @echo 33 .endif #}} ok: .if defined(AA) #{AA @echo 11 .else #}{!AA .if defined(BB) #{BB @echo 22 .else #}{!BB @echo 33 .endif #} .endif #} EOF make "Makefile", line 4: Malformed conditional (defined(BB) #}{!AA{BB) make: fatal errors encountered -- cannot continue >Fix: Document it - until a make guru fixes it sometime, maybe. *** 4.8-RELEASE/src/usr.bin/make/make.1 Thu Oct 19 06:23:49 2000 --- new/src/usr.bin/make/make.1 Thu Mar 8 16:53:43 2001 *************** *** 1238,1243 **** --- 1238,1273 ---- \&.endfor .Ed won't work, and should be rewritten the other way around. + .Pp + The expansion of .elif uses everything up to end of line, & allows no + # comment delimeter as available to simpler .if & .else & .endif commands. + .br + This thus fails; + .in +2 + .nf + .if defined(AA) #{AA + @echo 11 + .elif defined(BB) #}{!AA{BB + @echo 22 + .else #}{!BB + @echo 33 + .endif #}} + .fi + .in -2 + Whereas this works + .in +2 + .nf + .if defined(AA) #{AA + @echo 11 + .else #}{!AA + .if defined(BB) #{BB + @echo 22 + .else #}{!BB + @echo 33 + .endif #} + .endif #} + .fi + .in -2 .Sh SEE ALSO .Xr mkdep 1 .Rs