From owner-freebsd-hackers@FreeBSD.ORG Sun Jun 11 10:34:04 2006 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.ORG Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DFCA516A41A; Sun, 11 Jun 2006 10:34:04 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from smtp6-g19.free.fr (smtp6-g19.free.fr [212.27.42.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 320B243D45; Sun, 11 Jun 2006 10:34:04 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp6-g19.free.fr (Postfix) with ESMTP id F14382258C; Sun, 11 Jun 2006 12:34:02 +0200 (CEST) Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25]) by tatooine.tataz.chchile.org (Postfix) with ESMTP id C945E9C3F9; Sun, 11 Jun 2006 10:34:17 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id AE25540A5; Sun, 11 Jun 2006 12:34:13 +0200 (CEST) Date: Sun, 11 Jun 2006 12:34:13 +0200 From: Jeremie Le Hen To: Darren Pilgrim Message-ID: <20060611103413.GJ1273@obiwan.tataz.chchile.org> References: <20060609094052.GH1273@obiwan.tataz.chchile.org> <20060609.074844.1324583587.imp@bsdimp.com> <4489E354.5070201@bitfreak.org> <20060609.153340.-432838362.imp@bsdimp.com> <4489FA7C.7080207@bitfreak.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline In-Reply-To: <4489FA7C.7080207@bitfreak.org> User-Agent: Mutt/1.5.11 Cc: freebsd-hackers@FreeBSD.ORG, ru@FreeBSD.org, jeremie@le-hen.org Subject: Re: [fbsd] Re: How to disable a src.conf on command-line X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jun 2006 10:34:05 -0000 --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Darren, Warner, On Fri, Jun 09, 2006 at 03:47:24PM -0700, Darren Pilgrim wrote: > M. Warner Losh wrote: > >In message: <4489E354.5070201@bitfreak.org> > > Darren Pilgrim writes: > >: M. Warner Losh wrote: > >: > So if you make WITH_SSP off by default, then having WITH_SSP in the > >: > src.conf can't be overridden. If you have it on by default, having > >: > WITHOUT_SSP in the src.conf file can't be overriden. this appears to > >: > be an unintended flaw with the with/without stuff. I'm not sure the > >: > right way to compensate. > >: > >: I can't speak for the "right" way, but if you specify the variable in > >: src.conf/make.conf with ?= instead of =, you can override it on the > >: command-line: > >: > >: # grep KERNCONF /etc/make.conf > >: KERNCONF?=TTPWEB > >: # make -V KERNCONF > >: TTPWEB > >: # env KERNCONF=SOMETHING_ELSE make -V KERNCONF > >: SOMETHING_ELSE > > > >?= doesn't mesh well with WITH/WITHOUT because then it will always be > >defined, thus defeating its purpose. > > Use .ifndef to define WITH/WITHOUT iff its counterpart is undef: > > .ifndef WITHOUT_FOO > WITH_FOO=def > .endif Yes, this is indeed the way to go but actually I would prefer to this this wrapped in share/mk/bsd.own.mk, so that src.conf(5) would only handle variable assignments (in a rc.conf(5) fashion) without using make(1) magic. This would be pretty less puzzling for users. IMHO, the attached patch makes things better in case both WITH_FOO and WITHOUT_FOO are defined. Variables defined on command-line are read-only, therefore I take advantage of this to give the priority to the knob that has been defined on command-line. % jarjarbinks# head -n 1 /etc/src.conf % WITH_SSP=YES % % jarjarbinks# make echo.o % cc -O2 -fno-strict-aliasing -pipe -march=pentium-m -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow-Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -fstack-protector -c /usr/src/bin/echo/echo.c % ^^^^^^^^^^^^^^^^^ % jarjarbinks# make clean % rm -f echo echo.o echo.1.gz echo.1.cat.gz % % jarjarbinks# make WITHOUT_SSP=yes echo.o % cc -O2 -fno-strict-aliasing -pipe -march=pentium-m -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow-Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -c /usr/src/bin/echo/echo.c % ^^^^^^^^^^^^^^^^^ % jarjarbinks# make clean % rm -f echo echo.o echo.1.gz echo.1.cat.gz % % jarjarbinks# echo "WITHOUT_SSP=YES" >> /etc/src.conf % jarjarbinks# make echo.o % "/usr/share/mk/bsd.own.mk", line 394: WITH_SSP and WITHOUT_SSP can't both be set from the same place. % Best regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org > --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="bsd.own.mk.patch" Index: bsd.own.mk =================================================================== RCS file: /home/ncvs/src/share/mk/bsd.own.mk,v retrieving revision 1.54 diff -u -r1.54 bsd.own.mk --- bsd.own.mk 28 Apr 2006 12:03:36 -0000 1.54 +++ bsd.own.mk 11 Jun 2006 10:25:43 -0000 @@ -352,7 +352,20 @@ USB \ WPA_SUPPLICANT_EAPOL .if defined(WITH_${var}) && defined(WITHOUT_${var}) -.error WITH_${var} and WITHOUT_${var} can't both be set. +# Check the user didn't define both variables from the same place. +WITH_${var}:= bsd.own.mk +WITHOUT_${var}:= bsd.own.mk +.if (${WITH_${var}} == "bsd.own.mk" && ${WITHOUT_${var}} == "bsd.own.mk") || \ + (${WITH_${var}} != "bsd.own.mk" && ${WITHOUT_${var}} != "bsd.own.mk") +.error WITH_${var} and WITHOUT_${var} can't both be set from the same place. +.endif +.if ${WITH_${var}} != "bsd.own.mk" +# WITH_${var} is defined on comand-line +.undef WITHOUT_${var} +.else +# WITHOUT_${var} is defined on comand-line +.undef WITH_${var} +.endif .endif .if defined(MK_${var}) .error MK_${var} can't be set by a user. @@ -372,7 +385,20 @@ HESIOD \ IDEA .if defined(WITH_${var}) && defined(WITHOUT_${var}) -.error WITH_${var} and WITHOUT_${var} can't both be set. +# Check the user didn't define both variables from the same place. +WITH_${var}:= bsd.own.mk +WITHOUT_${var}:= bsd.own.mk +.if (${WITH_${var}} == "bsd.own.mk" && ${WITHOUT_${var}} == "bsd.own.mk") || \ + (${WITH_${var}} != "bsd.own.mk" && ${WITHOUT_${var}} != "bsd.own.mk") +.error WITH_${var} and WITHOUT_${var} can't both be set from the same place. +.endif +.if ${WITH_${var}} != "bsd.own.mk" +# WITH_${var} is defined on comand-line +.undef WITHOUT_${var} +.else +# WITHOUT_${var} is defined on comand-line +.undef WITH_${var} +.endif .endif .if defined(MK_${var}) .error MK_${var} can't be set by a user. --Q68bSM7Ycu6FN28Q--