Subject: patch to have 'make snapshot' avoid rebuilding kernels.
To: None <tech-install@netbsd.org>
From: Todd Whitesel <toddpw@best.com>
List: tech-install
Date: 12/26/1999 04:23:55
Below is the first cut patch I came up with tonight. I use a single loop to
generate all the rules that are common to all kernels, so the order of things
changes a little but if you don't set UPDATE then that is the only change you
should see. If you do set UPDATE, then it avoids redoing the config, depend,
and make for each kernel, if they've already been done.

As tested on my 110 mhz sparcbook, it does a good job saving time lost due to
the previously unconditional config and depend steps. config would force a
dozen or so files to be recompiled by make, and depend would take 15 minutes
all by itself. This helps me re-test failures in distrib a lot faster.

(Some of these failures only happen when run from 'make snapshot', because
of environment variable settings that get 'picked up' along the way through
the recursive makefiles. For example, leaving DESTDIR set as we go into
distrib to build the install stuff causes extra options like CPPFLAGS to be
set and seen by, say, installboot, which then complains that it can't find
some header. But when you cd/make to installboot yourself, even with DESTDIR
set as you had it with 'make snapshot', it works fine. Observed on i386.)

Ideally this would use .depend instead of .last-depend-stamp, and the list of
GETKERNELAWK kernels instead of .last-build-stamp, and so on. But I just
wanted to do a proof-of-concept and post something for discussion.

Plus I'm still trying to decide how best to improve the config dependencies.
What file in the compile/KERN directory is the "primary" output from config?
And do we care about having the config target depend on the relevant include
files in the conf/ directory?

Sometimes I think the dumb time stamp file method really is better, simply
because it _is_ dumb, easy to explain, and easy to tweak when it screws up.

Index: Makefile
===================================================================
RCS file: /usr/toddpw/anoncvs/main/basesrc/etc/Makefile,v
retrieving revision 1.129
diff -c -r1.129 Makefile
*** Makefile	1999/12/13 10:19:32	1.129
--- Makefile	1999/12/26 10:27:06
***************
*** 282,320 ****
  		END{ if (found == 0) print "netbsd"; }'
  #
  .if !target(snap_kern)
! snap_kern:
! 	cd ${KERNCONFDIR} && ${CONFIG} \
! 		-b ${KERNOBJDIR}/GENERIC -s ${KERNSRCDIR} GENERIC
  .ifndef UPDATE
! 	cd ${KERNOBJDIR}/GENERIC && ${MAKE} clean 
  .endif
! 	cd ${KERNOBJDIR}/GENERIC && ${MAKE} depend && ${MAKE} ${_J}
  	cd ${KERNOBJDIR}/GENERIC &&	\
  		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
  		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
- # XXX use same loop for ${EXTRA_KERNELS} and ${BUILD_KERNELS} but
- # XXX only install ${EXTRA_KERNELS} in binary/kernel???
  .for configfile in ${EXTRA_KERNELS}
- 	cd ${KERNCONFDIR} && ${CONFIG} \
- 		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
- .ifndef UPDATE
- 	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
- .endif
- 	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
  	cd ${KERNOBJDIR}/${configfile} &&	\
  		for kernel in `${GETKERNELAWK} \
  			${KERNCONFDIR}/${configfile}` ; {   \
  		gzip -c -9 < $${kernel} > \
  			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
  .endfor # EXTRA_KERNELS
- .for configfile in ${BUILD_KERNELS}
- 	cd ${KERNCONFDIR} && ${CONFIG} \
- 		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
- .ifndef UPDATE
- 	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
- .endif
- 	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend && ${MAKE} ${_J}
- .endfor # BUILD_KERNELS
  .endif # no target(snap_kern)
  
  .endif # RELEASEDIR check
--- 282,326 ----
  		END{ if (found == 0) print "netbsd"; }'
  #
  .if !target(snap_kern)
! 
! .for configfile in GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
! 
  .ifndef UPDATE
! ${KERNOBJDIR}/${configfile}/.last-clean-stamp:
! 	cd ${KERNOBJDIR}/${configfile} && ${MAKE} clean 
! 	rm -f $@
! 
! ${KERNOBJDIR}/${configfile}/.last-config-stamp: ${KERNOBJDIR}/${configfile}/.last-clean-stamp
  .endif
! 
! ${KERNOBJDIR}/${configfile}/.last-config-stamp:
! 	cd ${KERNCONFDIR} && ${CONFIG} \
! 		-b ${KERNOBJDIR}/${configfile} -s ${KERNSRCDIR} ${configfile}
! 	touch $@
! 
! ${KERNOBJDIR}/${configfile}/.last-depend-stamp: ${KERNOBJDIR}/${configfile}/.last-config-stamp
! 	cd ${KERNOBJDIR}/${configfile} && ${MAKE} depend
! 	touch $@
! 
! ${KERNOBJDIR}/${configfile}/.last-build-stamp: ${KERNOBJDIR}/${configfile}/.last-depend-stamp
! 	cd ${KERNOBJDIR}/${configfile} && ${MAKE} ${_J}
! 	touch $@
! 
! snap_kern: ${KERNOBJDIR}/${configfile}/.last-build-stamp
! 
! .endfor # GENERIC ${EXTRA_KERNELS} ${BUILD_KERNELS}
! 
! snap_kern:
  	cd ${KERNOBJDIR}/GENERIC &&	\
  		tar cf - `${GETKERNELAWK} ${KERNCONFDIR}/GENERIC` |\
  		gzip -c -9 > ${RELEASEDIR}/binary/sets/kern.tgz
  .for configfile in ${EXTRA_KERNELS}
  	cd ${KERNOBJDIR}/${configfile} &&	\
  		for kernel in `${GETKERNELAWK} \
  			${KERNCONFDIR}/${configfile}` ; {   \
  		gzip -c -9 < $${kernel} > \
  			${RELEASEDIR}/binary/kernel/$${kernel}.${configfile}.gz ; }
  .endfor # EXTRA_KERNELS
  .endif # no target(snap_kern)
  
  .endif # RELEASEDIR check
# eof

Todd Whitesel
toddpw @ best.com