From k@numeri.campus.luth.se  Tue Mar 21 14:56:56 2000
Return-Path: <k@numeri.campus.luth.se>
Received: from numeri.campus.luth.se (numeri.campus.luth.se [130.240.197.103])
	by hub.freebsd.org (Postfix) with ESMTP id 325EF37B632
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 21 Mar 2000 14:55:41 -0800 (PST)
	(envelope-from k@numeri.campus.luth.se)
Received: (from k@localhost)
	by numeri.campus.luth.se (8.9.3/8.9.3) id XAA15924;
	Tue, 21 Mar 2000 23:55:06 +0100 (CET)
	(envelope-from k)
Message-Id: <200003212255.XAA15924@numeri.campus.luth.se>
Date: Tue, 21 Mar 2000 23:55:06 +0100 (CET)
From: k@numeri.campus.luth.se
Reply-To: k@numeri.campus.luth.se
To: FreeBSD-gnats-submit@freebsd.org
Subject: KERNEL used both by Makefile.inc1 and Makefile.${MACHINE}
X-Send-Pr-Version: 3.2

>Number:         17536
>Category:       kern
>Synopsis:       KERNEL used both by Makefile.inc1 and Makefile.${MACHINE}
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    sheldonh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 21 15:00:01 PST 2000
>Closed-Date:    Thu Mar 30 05:09:26 PST 2000
>Last-Modified:  Thu Mar 30 05:11:56 PST 2000
>Originator:     Johan Karlsson
>Release:        FreeBSD 4.0-RELEASE i386
>Organization:
>Environment:

k@numeri /usr/src >ident Makefile.inc1
Makefile.inc1:
     $FreeBSD: src/Makefile.inc1,v 1.141 2000/03/09 06:28:19 kris Exp $


>Description:

	The variable KERNEL is used both by ${SRC}/Makefile.inc1 and
	${SRC}/sys/conf/Makefile.*

	When using the buildkernel/installkernel targets this 
	is a problem.

	By specifying two or more existing kernel config files to 
	these targets using the KERNEL variable (as suggested in 
	the makefile) the buildkernel target will link two (or more) 
	identical kernels with the given names.
 	The installkernel target will fail since 'install' do not know 
	how to handle this case.

	I propose to use KERNELS in Makefile.inc1 instead,
	see patch below.


	Also, since each config file generates a kernel with the 
	same name and the installed kernel get install under this 
	name, I suggest that all built kernels get install. 
	This way it will be easier to test them.
	For exampel I would like to get both GENERIC and my 
	custom kernel installed.
	However this is out of the scoop of this PR :-)

>How-To-Repeat:
	
	cd /usr/src; make KERNEL='GENERIC NEWCARD' buildkernel
	cd /usr/src; make KERNEL='GENERIC NEWCARD' installkernel
	
	on a x86 machine.
>Fix:

--- Makefile.inc1.orig	Thu Mar  9 07:28:19 2000
+++ Makefile.inc1	Tue Mar 21 22:54:33 2000
@@ -328,7 +328,7 @@
 # buildkernel and installkernel
 #
 # Which kernels to build and/or install is specified by setting
-# KERNEL. If not defined a GENERIC kernel is built/installed.
+# KERNELS. If not defined a GENERIC kernel is built/installed.
 # Only the existing (depending MACHINE) config files are used
 # for building kernels and only the first of these is designated
 # as the one being installed.
@@ -338,7 +338,7 @@
 # be set to cross-build, we have to make sure MACHINE is set
 # properly.
 
-KERNEL?=	GENERIC GENERIC98
+KERNELS?=	GENERIC GENERIC98
 
 # The only exotic MACHINE_ARCH/MACHINE combination valid at this
 # time is i386/pc98. In all other cases set MACHINE equal to
@@ -357,7 +357,7 @@
 
 BUILDKERNELS=
 INSTALLKERNEL=
-.for _kernel in ${KERNEL}
+.for _kernel in ${KERNELS}
 .if exists(${KRNLCONFDIR}/${_kernel})
 BUILDKERNELS+=	${_kernel}
 .if empty(INSTALLKERNEL)
@@ -384,8 +384,10 @@
 	cd ${KRNLOBJDIR}/${_kernel}; \
 		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx \
 		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/Makefile; \
-		${WMAKEENV} MACHINE=${MACHINE} ${MAKE} depend; \
-		${WMAKEENV} MACHINE=${MACHINE} ${MAKE} all
+		${WMAKEENV} MACHINE=${MACHINE} KERNEL=${_kernel} \
+		    ${MAKE} depend; \
+		${WMAKEENV} MACHINE=${MACHINE} KERNEL=${_kernel} \
+		    ${MAKE} all
 .endfor
 
 #
@@ -395,7 +397,8 @@
 #
 installkernel:
 	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
-		${IMAKEENV} MACHINE=${MACHINE} ${MAKE} install
+		${IMAKEENV} MACHINE=${MACHINE} KERNEL=${INSTALLKERNEL} \
+		    ${MAKE} install
 
 #
 # update
	

>Release-Note:
>Audit-Trail:

From: Johan Karlsson <k@numeri.campus.luth.se>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/17536: KERNEL used both by Makefile.inc1 and 
 Makefile.${MACHINE}
Date: Wed, 29 Mar 2000 11:34:08 +0200

 Hi
 
 I was asked to describe how the 'How-to-repeat' case bahaivs with my patch 
 aplied.
 
 I have run the build/install-kernel target w/o and w/ the patch.
 I have also run both targets with a new version of the patch that also alows 
 one to install multiple kernels (see patch below).
  
 
 And as one can see below:
 
 w/o the patch the two kernels are linked twice, one time for each name in 
 $KERNEL and the install fails.
 
 w/ the patch each kernel is linked only once with its proper name and the 
 first kernel is installed.
 
 w/ the new patch each kernel is linked only once and _both_ kernels are 
 installed.
 
 /Johan K
 
 
 w/o the patch
 ================
 numeri# make KERNEL='GENERIC NEWCARD' buildkernel > & org.build
 numeri# ls /GENERIC /NEWCARD
 ls: /GENERIC: No such file or directory
 ls: /NEWCARD: No such file or directory
 numeri# make KERNEL='GENERIC NEWCARD' installkernel > & org.inst
 numeri# ls /GENERIC /NEWCARD
 ls: /GENERIC: No such file or directory
 ls: /NEWCARD: No such file or directory
 numeri# cat org.build
 --------------------------------------------------------------
 >>> Rebuilding kernel(s)
 --------------------------------------------------------------
 ===> GENERIC
 
 [ CUT ]
 
 sh /usr/src/sys/conf/newvers.sh GENERIC 
 cc -c -O -pipe -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  
 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions 
 -ansi  -nostdinc -I- -I. -I/usr/src/sys -I/usr/src/sys/../include  -D_KERNEL 
 -include opt_global.h -elf  -mpreferred-stack-boundary=2  vers.c
 linking GENERIC
    text	   data	    bss	    dec	    hex	filename
 2197157	 161496	 126200	2484853	 25ea75	GENERIC
 linking NEWCARD
    text	   data	    bss	    dec	    hex	filename
 2197157	 161496	 126200	2484853	 25ea75	NEWCARD
 ===> NEWCARD
 
 [ CUT ]
 
 sh /usr/src/sys/conf/newvers.sh NEWCARD 
 cc -c -O -pipe -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  
 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions 
 -ansi  -nostdinc -I- -I. -I/usr/src/sys -I/usr/src/sys/../include  -D_KERNEL 
 -include opt_global.h -elf  -mpreferred-stack-boundary=2  vers.c
 linking GENERIC
    text	   data	    bss	    dec	    hex	filename
 2040750	 155408	 118776	2314934	 2352b6	GENERIC
 linking NEWCARD
    text	   data	    bss	    dec	    hex	filename
 2040750	 155408	 118776	2314934	 2352b6	NEWCARD
 numeri# cat org.inst 
 cd /usr/obj/usr/src/sys/GENERIC;  MAKEOBJDIRPREFIX=/usr/obj  
 COMPILER_PATH=/usr/obj/usr/src/i386/usr/libexec:/usr/obj/usr/src/i386/usr/bin  
 LIBRARY_PATH=/usr/obj/usr/src/i386/usr/lib:/usr/obj/usr/src/i386/usr/lib  
 OBJFORMAT_PATH=/usr/obj/usr/src/i386/usr/libexec  PERL5LIB=/usr/obj/usr/src/i38
 6/usr/libdata/perl/5.00503 MACHINE=i386 make install
 [: NEWCARD: unexpected operator
 install -c -m 555 -o root -g wheel -fschg  GENERIC NEWCARD /GENERIC NEWCARD
 usage: install [-CcDpsv] [-f flags] [-g group] [-m mode] [-o owner] file1 file2
        install [-CcDpsv] [-f flags] [-g group] [-m mode] [-o owner] file1 ...
              fileN directory
        install -d [-v] [-g group] [-m mode] [-o owner] directory ...
 *** Error code 64
 
 Stop in /usr/obj/usr/src/sys/GENERIC.
 *** Error code 1
 
 Stop in /usr/src.
 *** Error code 1
 
 Stop in /usr/src.
 numeri#
 ================
 
 w/ the patch
 ================
 numeri# make KERNELS=GENERIC NEWCARD buildkernel >& new.build
 numeri# ls /GENERIC /NEWCARD
 ls: /GENERIC: No such file or directory
 ls: /NEWCARD: No such file or directory
 numeri# make KERNELS='GENERIC NEWCARD' installkernel > & new.inst
 numeri# ls /GENERIC /NEWCARD
 ls: /NEWCARD: No such file or directory
 /GENERIC
 numeri# cat new.build
 --------------------------------------------------------------
 >>> Rebuilding kernel(s)
 --------------------------------------------------------------
 ===> GENERIC
 
 [ CUT ]
 
 sh /usr/src/sys/conf/newvers.sh GENERIC 
 cc -c -O -pipe -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  
 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions 
 -ansi  -nostdinc -I- -I. -I/usr/src/sys -I/usr/src/sys/../include  -D_KERNEL 
 -include opt_global.h -elf  -mpreferred-stack-boundary=2  vers.c
 linking GENERIC
    text	   data	    bss	    dec	    hex	filename
 2197157	 161496	 126200	2484853	 25ea75	GENERIC
 ===> NEWCARD
 
 [ CUT ]
 
 sh /usr/src/sys/conf/newvers.sh NEWCARD 
 cc -c -O -pipe -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  
 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions 
 -ansi  -nostdinc -I- -I. -I/usr/src/sys -I/usr/src/sys/../include  -D_KERNEL 
 -include opt_global.h -elf  -mpreferred-stack-boundary=2  vers.c
 linking NEWCARD
    text	   data	    bss	    dec	    hex	filename
 2040750	 155408	 118776	2314934	 2352b6	NEWCARD
 numeri# cat new.inst
 cd /usr/obj/usr/src/sys/GENERIC;  MAKEOBJDIRPREFIX=/usr/obj  
 COMPILER_PATH=/usr/obj/usr/src/i386/usr/libexec:/usr/obj/usr/src/i386/usr/bin  
 LIBRARY_PATH=/usr/obj/usr/src/i386/usr/lib:/usr/obj/usr/src/i386/usr/lib  
 OBJFORMAT_PATH=/usr/obj/usr/src/i386/usr/libexec  PERL5LIB=/usr/obj/usr/src/i38
 6/usr/libdata/perl/5.00503 MACHINE=i386 KERNEL=GENERIC  make install
 install -c -m 555 -o root -g wheel -fschg  GENERIC /GENERIC
 numeri#
 ================
 
 
 
 
 w/ new patch below
 ==================
 numeri# make KERNELS=GENERIC NEWCARD buildkernel >& new2.build
 numeri# ls /GENERIC /NEWCARD
 ls: /GENERIC: No such file or directory
 ls: /NEWCARD: No such file or directory
 numeri# make KERNELS='GENERIC NEWCARD' installkernel > & new2.inst
 numeri# ls /GENERIC /NEWCARD
 /GENERIC        /NEWCARD
 numeri# cat new2.build
 --------------------------------------------------------------
 >>> Rebuilding kernel(s)
 --------------------------------------------------------------
 ===> GENERIC
 
 [ CUT ]
 
 sh /usr/src/sys/conf/newvers.sh GENERIC 
 cc -c -O -pipe -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  
 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions 
 -ansi  -nostdinc -I- -I. -I/usr/src/sys -I/usr/src/sys/../include  -D_KERNEL 
 -include opt_global.h -elf  -mpreferred-stack-boundary=2  vers.c
 linking GENERIC
    text	   data	    bss	    dec	    hex	filename
 2197157	 161496	 126200	2484853	 25ea75	GENERIC
 ===> NEWCARD
 
 [ CUT ]
 
 sh /usr/src/sys/conf/newvers.sh NEWCARD 
 cc -c -O -pipe -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  
 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -fformat-extensions 
 -ansi  -nostdinc -I- -I. -I/usr/src/sys -I/usr/src/sys/../include  -D_KERNEL 
 -include opt_global.h -elf  -mpreferred-stack-boundary=2  vers.c
 linking NEWCARD
    text	   data	    bss	    dec	    hex	filename
 2040750	 155408	 118776	2314934	 2352b6	NEWCARD
 numeri# cat new2.inst
 --------------------------------------------------------------
 >>> Installing kernel(s)
 --------------------------------------------------------------
 ===> GENERIC
 cd /usr/obj/usr/src/sys/GENERIC ; MAKEOBJDIRPREFIX=/usr/obj  
 COMPILER_PATH=/usr/obj/usr/src/i386/usr/libexec:/usr/obj/usr/src/i386/usr/bin  
 LIBRARY_PATH=/usr/obj/usr/src/i386/usr/lib:/usr/obj/usr/src/i386/usr/lib  
 OBJFORMAT_PATH=/usr/obj/usr/src/i386/usr/libexec  PERL5LIB=/usr/obj/usr/src/i38
 6/usr/libdata/perl/5.00503 MACHINE=i386 KERNEL=GENERIC  make install
 install -c -m 555 -o root -g wheel -fschg  GENERIC /GENERIC
 ===> NEWCARD
 cd /usr/obj/usr/src/sys/NEWCARD ; MAKEOBJDIRPREFIX=/usr/obj  
 COMPILER_PATH=/usr/obj/usr/src/i386/usr/libexec:/usr/obj/usr/src/i386/usr/bin  
 LIBRARY_PATH=/usr/obj/usr/src/i386/usr/lib:/usr/obj/usr/src/i386/usr/lib  
 OBJFORMAT_PATH=/usr/obj/usr/src/i386/usr/libexec  PERL5LIB=/usr/obj/usr/src/i38
 6/usr/libdata/perl/5.00503 MACHINE=i386 KERNEL=NEWCARD  make install
 install -c -m 555 -o root -g wheel -fschg  NEWCARD /NEWCARD
 numeri #
 ==================
 
 
 
 New patch
 ==================
 --- Makefile.inc1.orig	Thu Mar  9 07:28:19 2000
 +++ Makefile.inc1	Tue Mar 28 20:09:57 2000
 @@ -328,7 +328,7 @@
  # buildkernel and installkernel
  #
  # Which kernels to build and/or install is specified by setting
 -# KERNEL. If not defined a GENERIC kernel is built/installed.
 +# KERNELS. If not defined a GENERIC kernel is built/installed.
  # Only the existing (depending MACHINE) config files are used
  # for building kernels and only the first of these is designated
  # as the one being installed.
 @@ -338,7 +338,7 @@
  # be set to cross-build, we have to make sure MACHINE is set
  # properly.
  
 -KERNEL?=	GENERIC GENERIC98
 +KERNELS?=	GENERIC GENERIC98
  
  # The only exotic MACHINE_ARCH/MACHINE combination valid at this
  # time is i386/pc98. In all other cases set MACHINE equal to
 @@ -356,13 +356,11 @@
  .endif
  
  BUILDKERNELS=
 -INSTALLKERNEL=
 -.for _kernel in ${KERNEL}
 +INSTALLKERNELS=
 +.for _kernel in ${KERNELS}
  .if exists(${KRNLCONFDIR}/${_kernel})
  BUILDKERNELS+=	${_kernel}
 -.if empty(INSTALLKERNEL)
 -INSTALLKERNEL= ${_kernel}
 -.endif
 +INSTALLKERNELS+= ${_kernel}
  .endif
  .endfor
  
 @@ -384,8 +382,10 @@
  	cd ${KRNLOBJDIR}/${_kernel}; \
  		MAKESRCPATH=${KRNLSRCDIR}/dev/aic7xxx \
  		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/Makefile; \
 -		${WMAKEENV} MACHINE=${MACHINE} ${MAKE} depend; \
 -		${WMAKEENV} MACHINE=${MACHINE} ${MAKE} all
 +		${WMAKEENV} MACHINE=${MACHINE} KERNEL=${_kernel} \
 +		    ${MAKE} depend; \
 +		${WMAKEENV} MACHINE=${MACHINE} KERNEL=${_kernel} \
 +		    ${MAKE} all
  .endfor
  
  #
 @@ -394,8 +394,16 @@
  # Install the kernel defined by INSTALLKERNEL
  #
  installkernel:
 -	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
 -		${IMAKEENV} MACHINE=${MACHINE} ${MAKE} install
 +	@echo
 +	@echo "--------------------------------------------------------------"
 +	@echo ">>> Installing kernel(s)"
 +	@echo "--------------------------------------------------------------"
 +.for _kernel in ${INSTALLKERNELS}
 +	@echo "===> ${_kernel}"
 +	cd ${KRNLOBJDIR}/${_kernel} ;\
 +		${IMAKEENV} MACHINE=${MACHINE} KERNEL=${_kernel} \
 +		    ${MAKE} install
 +.endfor
  
  #
  # update
 ==================
 
 
 
 
 
 
 
 
Responsible-Changed-From-To: freebsd-bugs->sheldonh 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Wed Mar 29 02:17:19 PST 2000 
Responsible-Changed-Why:  
I'll take this one, although I'll probably want to consult with marcel. 
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Thu Mar 30 05:09:26 PST 2000 
State-Changed-Why:  
A simplified version of your patch (in which variables were not 
renamed) has been committed as rev 1.143 of src/Makefile.inc1 
and merged onto the RELENG_4 branch.  Thanks! 
>Unformatted:
