File:  [ELWIX - Embedded LightWeight unIX -] / elwix / build_kernel.sh
Revision 1.8.4.2: download - view: text, annotated - select for diffs - revision graph
Tue Sep 14 12:00:33 2021 UTC (2 years, 8 months ago) by misho
Branches: elwix2_8
Diff to: branchpoint 1.8: preferred, colored
update amd64 kernel and improve kernel script

#!/bin/sh
#
# ELWIX build script for kernel
#
# (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
#    by Michael Pounov <misho@elwix.org>
#
# $Id: build_kernel.sh,v 1.8.4.2 2021/09/14 12:00:33 misho Exp $
#

[ -r ./config/rc.elwix ] && . ./config/rc.elwix
if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
	echo
	echo "ELWIX project is not configured !?!"
	echo
	exit 1
fi

if [ ! -d $BSDSRC -o ! -d ${BSDKERNCONF} ]; then
	echo
	echo "ELWIX project is not configured - missing BSD sources !?!"
	echo
	exit 1
fi

if [ "${USER}" != "root" ]; then
	echo
	echo "ELWIX project is not configured - BSD kernel must compile under root !?!"
	echo
	exit 1
fi

clean_kernel()
{
	echo "+++ Clean ELWIX Kernel $2 ... $1"
	rm -rf $1
	mkdir -p $1

	ln -sf ${CFGDIR}/$2 ${BSDKERNCONF}
	ln -sf ${CFGDIR}/${KERNHINT:=$KERNCONF.hints} ${BSDKERNCONF}
}

build_kernel()
{
	echo "+++ Build ELWIX Kernel $2 ... $1"
	cd $BSDSRC
	env MAKEOBJDIRPREFIX=${BSDOBJ} make TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
		${PARALLEL_BUILD} SRCCONF=${SRCCONF} __MAKE_CONF=${MAKECONF} \
		buildkernel KERNCONF=$2
	if [ $? -eq 0 ]; then
		cd -
	else
		exit 1
	fi
}

install_kernel()
{
	echo "+++ Install ELWIX Kernel $2 ... $1"
	cd $BSDSRC
	env MAKEOBJDIRPREFIX=${BSDOBJ} make TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
		SRCCONF=${SRCCONF} __MAKE_CONF=${MAKECONF} DESTDIR=$1 installkernel KERNCONF=$2
	cd -

	if [ $? -eq 0 ]; then
		echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >$1/elwix.ver
	fi

	echo "+++ Completed ELWIX Kernel $2 ... $1"
}

### main()
if [ -n "${1}" ]; then
	case "${1}" in
		rootfs)
			rm ${KERN_ROOTFS}/elwix.ver
			;;
		base)
			rm ${KERN}/elwix.ver
			;;
		both)
			rm ${KERN_ROOTFS}/elwix.ver
			rm ${KERN}/elwix.ver
			;;
		*)
			echo "Error:: unknown argument. Please, choose which kind of kernel [base|rootfs|both]?"
			exit 1
			;;
	esac
else
	echo "Error:: missing argument. Please, choose which kind of kernel [base|rootfs|both]?"
	exit 1
fi

if [ "${1}" = "base" -o "${1}" = "both" ]; then
	if ! SnitVer ${KERN}/elwix.ver; then
		clean_kernel ${KERN} ${KERNCONF}
		build_kernel ${KERN} ${KERNCONF}
		install_kernel ${KERN} ${KERNCONF}
	else
		echo "Skipped ELWIX Kernel build ..."
	fi
fi

if [ "${1}" = "rootfs" -o "${1}" = "both" ]; then
	if ! SnitVer ${KERN_ROOTFS}/elwix.ver; then
		clean_kernel ${KERN_ROOTFS} ${KERNCONF_ROOTFS}
		build_kernel ${KERN_ROOTFS} ${KERNCONF_ROOTFS}
		install_kernel ${KERN_ROOTFS} ${KERNCONF_ROOTFS}
	else
		echo "Skipped ELWIX rootfs Kernel build ..."
	fi
fi

echo "+++ Complete build ELWIX Kernels ${1}"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>