#
# Makefile for build world.
# Copyright <A9> 2000-2003 DVL Software Limited
#
# Available from http://www.freebsddiary.org/samples/makefile.for.build.world
#
# ******************************************************** #
# For information on how to use this Makefile, please read #
# http://freebsddiary.org/makeworld-script.php             #
# ******************************************************** #
#
# Do not copy/paste this file.  It contains tabs which will
# be replaced by spaces if you copy/paste.  Instead, use fetch
# to get this file.
#
# WARNING: this make file creates logs by default in /usr/tmp
# You may wish to clear these logs out from time to time with:
#
#      make cleanlogs
#
# e.g fetch <filename>
#
# Rename this file to Makefile.
#
# Thanks to Jim Mock for providing the script to me

#
# Thanks to gill for making the script easier to use by adding the variables
#

# start of configuration items ******************
#
# edit this variable to reflect your kernel name.
# this should be a file located at /usr/src/sys/i386/conf.
# see http://www.freebsd.org/handbook/kernelconfig-building.html 
# for more information.
#
MYKERNEL=XEON

# change this variable to your logging location
# (do not include a no trailing /):
LOGTO=/usr/tmp

#
# the suffix added to all log files
#
LOGTOSUFFIX=log

#
# end of configuration items ******************
# items below this line are not normally changed
#




DATE=`date "+%Y.%m.%d.%H.%M.%S"`

update:
	cd /usr/src; \
	make update 2>&1 | tee ${LOGTO}/update.${DATE}.${LOGTOSUFFIX};

build:
	cd /usr/src; \
	make buildworld 2>&1 | tee ${LOGTO}/bw.${DATE}.${LOGTOSUFFIX};

install:
	cd /usr/src; \
	make installworld 2>&1 | tee ${LOGTO}/iw.${DATE}.${LOGTOSUFFIX};

world:  
	cd /usr/src; \
	make world 2>&1 | tee ${LOGTO}/mw.${DATE}.${LOGTOSUFFIX};

kerneloldstyle:
#
# use this method only if you using FreeBSD pre 4.0
#
	(cd /sys/i386/conf && \
	config -r ${MYKERNEL} && \
	cd ../../compile/${MYKERNEL} && \
	make depend && \
	make && \
	make install && \
	make clean) 2>&1 | tee ${LOGTO}/kernel.${MYKERNEL}.${DATE}.${LOGTOSUFFIX};

#
# build and install the kernel
#
# if you are using FreeBSD 4 or later, use these instructions
# NOTE: this method should only be used when building world.
#       if you use it otherwise, you will get an error.
#       you should use "make kerneloldstyle" instead
#
kernel:
	(cd /usr/src && \
	make buildkernel   KERNCONF=${MYKERNEL} && \
	make installkernel KERNCONF=${MYKERNEL}) 2>&1 | tee ${LOGTO}/kernel.${MYKERNEL}.${DATE}.${LOGTOSUFFIX};
#
#
# build the kernel.  useful if building on one box and installing on another.
#
kernelbuild:
	(cd /usr/src && \
	make buildkernel   KERNCONF=${MYKERNEL}) 2>&1 | tee ${LOGTO}/kernelbuild.${MYKERNEL}.${DATE}.${LOGTOSUFFIX};

#
# install the kernel
# useful when the kernal has already been built.
# 
kernelinstall:
	(cd /usr/src && \
	make installkernel KERNCONF=${MYKERNEL}) 2>&1 | tee ${LOGTO}/kernelinstall.${MYKERNEL}.${DATE}.${LOGTOSUFFIX};

merge:
	/usr/sbin/mergemaster -w 120 -t ${LOGTO}/root.${DATE} 2>&1 | tee ${LOGTO}/merge.${DATE}.${LOGTOSUFFIX};

#
# deletes logs created in above steps
# use with caution.
#
cleanlogs:
	rm -rf ${LOGTO}/*.${LOGTOSUFFIX}

#
# clean out logs and obj
#
clean:
	chflags -R noschg /usr/obj/;
	rm -rf /usr/obj/*;
	cleanlogs

#
# WARNING: if you use this option, it will remove your kernel configuration files which 
# are [usually] located at /usr/src/sys/i386/conf/
# USE WITH EXTREME CAUTION.
# backup your kernel configuration files first!
#
#clobber:
#	clean
#	rm -rf /usr/src/*;
