Re: [fbsd] Re: How to disable a src.conf on command-line

2006-06-11 Thread Jeremie Le Hen
Hi, Darren, Warner,

On Fri, Jun 09, 2006 at 03:47:24PM -0700, Darren Pilgrim wrote:
 M. Warner Losh wrote:
 In message: [EMAIL PROTECTED]
 Darren Pilgrim [EMAIL PROTECTED] 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 
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 -  1.54
+++ bsd.own.mk  11 Jun 2006 10:25:43 -
@@ -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.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL 

How to disable a src.conf on command-line

2006-06-09 Thread Jeremie Le Hen
Hi list !

I wonder what's the trick to enable (resp. disable) a feature that has
been switched with a WITH_FOO/WITHOUT_FOO knob in src.conf(5) or
make.conf(5).

I can't find one myself because bsd.own.mk only check if the knob is
defined, it doesn't care of its value.  Furthermore it is an error to
define both WITH_FOO and WITHOUT_FOO.

My thought on this is WITH_FOO/WITHOUT_FOO knob are to be used for
software inclusion/exclusion in the base system, but not to
enable/disable compilation flags, since you can't disable it without
editing src.conf(5).

(My concern is about activation of stack-smashing protection compiler
options.  I'd like the user to be able to use -DWITHOUT_SSP to
compile something, even if he has WITH_SSP=YES in src.conf(5).
Should I turn the name of this options into ENABLE_SSP and pull it
out the bsd.own.mk magic ?)

Thank you.i
Regards,
-- 
Jeremie Le Hen
 jeremie at le-hen dot org  ttz at chchile dot org 
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to disable a src.conf on command-line

2006-06-09 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Jeremie Le Hen [EMAIL PROTECTED] writes:
: (My concern is about activation of stack-smashing protection compiler
: options.  I'd like the user to be able to use -DWITHOUT_SSP to
: compile something, even if he has WITH_SSP=YES in src.conf(5).
: Should I turn the name of this options into ENABLE_SSP and pull it
: out the bsd.own.mk magic ?)

First, there's the trick:
make -V MK_FOO
if you are unsure of the results.

For make options that default to enabled, turning them off in one
place (command line or src.conf) will turn them off.  Likewise for
on.

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.

Finally, please don't invent another way to configure the system.
Many code reviewers will not like you much for doing that, since we've
recently worked hard to make them all regular.  If you need to do
something the current scheme doesn't allow, we need to expand the
current scheme somehow.

Warner
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to disable a src.conf on command-line

2006-06-09 Thread Darren Pilgrim

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

--
Darren Pilgrim
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to disable a src.conf on command-line

2006-06-09 Thread M. Warner Losh
In message: [EMAIL PROTECTED]
Darren Pilgrim [EMAIL PROTECTED] 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.

Warner
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: How to disable a src.conf on command-line

2006-06-09 Thread Darren Pilgrim

M. Warner Losh wrote:

In message: [EMAIL PROTECTED]
Darren Pilgrim [EMAIL PROTECTED] 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

--
Darren Pilgrim
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to [EMAIL PROTECTED]