Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jun 2006 12:34:13 +0200
From:      Jeremie Le Hen <jeremie@le-hen.org>
To:        Darren Pilgrim <freebsd@bitfreak.org>
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
Message-ID:  <20060611103413.GJ1273@obiwan.tataz.chchile.org>
In-Reply-To: <4489FA7C.7080207@bitfreak.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>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <darren.pilgrim@bitfreak.org> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060611103413.GJ1273>