From cperciva@xps.daemonology.net  Thu Feb 24 11:26:50 2011
Return-Path: <cperciva@xps.daemonology.net>
Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2001:4f8:fff6::35])
	by hub.freebsd.org (Postfix) with ESMTP id 85EE3106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 24 Feb 2011 11:26:50 +0000 (UTC)
	(envelope-from cperciva@xps.daemonology.net)
Received: from xps.daemonology.net (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by mx2.freebsd.org (Postfix) with SMTP id 7C0ED14E0AE
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 24 Feb 2011 11:26:49 +0000 (UTC)
Received: (qmail 38421 invoked by uid 1001); 24 Feb 2011 11:26:57 -0000
Message-Id: <20110224112657.38420.qmail@xps.daemonology.net>
Date: 24 Feb 2011 11:26:57 -0000
From: Colin Percival <cperciva@freebsd.org>
Reply-To: Colin Percival <cperciva@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: make(1) doesn't handle .POSIX: correctly
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         155000
>Category:       bin
>Synopsis:       make(1) doesn't handle .POSIX: correctly
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 24 11:30:07 UTC 2011
>Closed-Date:    
>Last-Modified:  Fri Feb 25 17:30:11 UTC 2011
>Originator:     Colin Percival
>Release:        all FreeBSD releases
>Organization:
>Environment:
>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".)

>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.
>Release-Note:
>Audit-Trail:

From: Colin Percival <cperciva@freebsd.org>
To: Bruce Evans <brde@optusnet.com.au>
Cc: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: bin/155000: make(1) doesn't handle .POSIX: correctly
Date: Thu, 24 Feb 2011 15:41:51 -0800

 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

From: Bruce Evans <brde@optusnet.com.au>
To: Colin Percival <cperciva@FreeBSD.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject: Re: bin/155000: make(1) doesn't handle .POSIX: correctly
Date: Fri, 25 Feb 2011 09:35:30 +1100 (EST)

 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

From: Bruce Evans <brde@optusnet.com.au>
To: Colin Percival <cperciva@FreeBSD.org>
Cc: Bruce Evans <brde@optusnet.com.au>, FreeBSD-gnats-submit@FreeBSD.org,
        freebsd-bugs@FreeBSD.org
Subject: Re: bin/155000: make(1) doesn't handle .POSIX: correctly
Date: Fri, 25 Feb 2011 13:13:09 +1100 (EST)

 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

From: Eitan Adler <eadler@freebsd.org>
To: bug-followup@freebsd.org, cperciva@freebsd.org
Cc:  
Subject: Re: bin/155000: make(1) doesn't handle .POSIX: correctly
Date: Fri, 25 Feb 2011 12:27:19 -0500

 This is just a pointer to bin/11114 filed on a similar issue
 
 -- 
 Eitan Adler
>Unformatted:
