make(1) doesn't handle .POSIX: correctly. It sucks in sys.mk before it reads the Makefile, and sys.mk has several instances of .if defined(%POSIX) to switch between POSIX and non-POSIX mode; because sys.mk is processed first, there is no opportunity for a .POSIX: directive to take effect. Fix: Before processing sys.mk, main() should "taste" the Makefile by looking for .POSIX. This is required to appear on the first non-comment line of the Makefile, so we don't need to actually parse the Makefile in order to check for this. How-To-Repeat: $ echo .POSIX: > Makefile $ make -V CC (prints "cc"; it should print "c89".)
On Thu, 24 Feb 2011, Colin Percival wrote: >> Description: > > make(1) doesn't handle .POSIX: correctly. It sucks in sys.mk before it > reads the Makefile, and sys.mk has several instances of > .if defined(%POSIX) > to switch between POSIX and non-POSIX mode; because sys.mk is processed > first, there is no opportunity for a .POSIX: directive to take effect. > >> How-To-Repeat: > $ echo .POSIX: > Makefile > $ make -V CC > (prints "cc"; it should print "c89".) Except that there is the opportunity to set %POSIX using make -D. This might be enough in practice. The namespace pollution avoidance is too perfect -- there seems to be no way to set %POSIX or .POSIX in the environment. Bruce
On 02/24/11 14:35, Bruce Evans wrote: > Except that there is the opportunity to set %POSIX using make -D. This > might be enough in practice. The namespace pollution avoidance is > too perfect -- there seems to be no way to set %POSIX or .POSIX in the > environment. Is this relevant? POSIX says that the Right Way to demand POSIX mode is to put .POSIX on the first non-comment line of the Makefile; our %POSIX variable is a red herring as far as POSIX is concerned. -- Colin Percival Security Officer, FreeBSD | freebsd.org | The power to serve Founder / author, Tarsnap | tarsnap.com | Online backups for the truly paranoid
On Thu, 24 Feb 2011, Colin Percival wrote: > On 02/24/11 14:35, Bruce Evans wrote: >> Except that there is the opportunity to set %POSIX using make -D. This >> might be enough in practice. The namespace pollution avoidance is >> too perfect -- there seems to be no way to set %POSIX or .POSIX in the >> environment. > > Is this relevant? POSIX says that the Right Way to demand POSIX mode is > to put .POSIX on the first non-comment line of the Makefile; our %POSIX > variable is a red herring as far as POSIX is concerned. It allows A Way. Of course you should fix make(1) to support the POSIX way if this is not too hard. If make can see .POSIX before including sys.mk, then it could alternatively include a POSIX-sys.mk instead. This would be cleaner than the ifdefs in sys.mk, and would inhibit breakage of the POSIX case by putting things like CTF in its rules. Bruce
This is just a pointer to bin/11114 filed on a similar issue -- Eitan Adler
Perhaps all the stuff in sys.mk which is %POSIX dependent should be moved somewhere that is read after Makefile. Of course no guarantee that a posix compliant makefile will include anything
The issue isn't make(1) but rather share/mk As noted share/mk/sys.mk does not know .POSIX is desired up front. Two workarounds would be simple enough 1/ make -DWITH_POSIX_MK and sys.mk could do .POSIX: itself. 2/ add a posix/sys.mk which could set .POSIX: and then include ../sys.mk for this one you'd need to make -m .../share/mk/posix
(In reply to Colin Percival from comment #2) If you really want to limit yourself to POSIX use make -r
You're missing the point. If the first line of Makefile is ".POSIX:" then make is supposed to operate in POSIX mode. The fact that you can get POSIX mode in other ways is irrelevant to whether we satisfy this requirement.
For bugs matching the following conditions: - Status == In Progress - Assignee == "bugs@FreeBSD.org" - Last Modified Year <= 2017 Do - Set Status to "Open"