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, 9 months ago) by misho
Branches: elwix2_8
Diff to: branchpoint 1.8: preferred, unified
update amd64 kernel and improve kernel script

    1: #!/bin/sh
    2: #
    3: # ELWIX build script for kernel
    4: #
    5: # (C) AITNET ltd - Sofia/Bulgaria <office@aitnet.org>
    6: #    by Michael Pounov <misho@elwix.org>
    7: #
    8: # $Id: build_kernel.sh,v 1.8.4.2 2021/09/14 12:00:33 misho Exp $
    9: #
   10: 
   11: [ -r ./config/rc.elwix ] && . ./config/rc.elwix
   12: if [ X"${ELWIX_IS_CONFIGURED}" != X"YES" ]; then
   13: 	echo
   14: 	echo "ELWIX project is not configured !?!"
   15: 	echo
   16: 	exit 1
   17: fi
   18: 
   19: if [ ! -d $BSDSRC -o ! -d ${BSDKERNCONF} ]; then
   20: 	echo
   21: 	echo "ELWIX project is not configured - missing BSD sources !?!"
   22: 	echo
   23: 	exit 1
   24: fi
   25: 
   26: if [ "${USER}" != "root" ]; then
   27: 	echo
   28: 	echo "ELWIX project is not configured - BSD kernel must compile under root !?!"
   29: 	echo
   30: 	exit 1
   31: fi
   32: 
   33: clean_kernel()
   34: {
   35: 	echo "+++ Clean ELWIX Kernel $2 ... $1"
   36: 	rm -rf $1
   37: 	mkdir -p $1
   38: 
   39: 	ln -sf ${CFGDIR}/$2 ${BSDKERNCONF}
   40: 	ln -sf ${CFGDIR}/${KERNHINT:=$KERNCONF.hints} ${BSDKERNCONF}
   41: }
   42: 
   43: build_kernel()
   44: {
   45: 	echo "+++ Build ELWIX Kernel $2 ... $1"
   46: 	cd $BSDSRC
   47: 	env MAKEOBJDIRPREFIX=${BSDOBJ} make TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
   48: 		${PARALLEL_BUILD} SRCCONF=${SRCCONF} __MAKE_CONF=${MAKECONF} \
   49: 		buildkernel KERNCONF=$2
   50: 	if [ $? -eq 0 ]; then
   51: 		cd -
   52: 	else
   53: 		exit 1
   54: 	fi
   55: }
   56: 
   57: install_kernel()
   58: {
   59: 	echo "+++ Install ELWIX Kernel $2 ... $1"
   60: 	cd $BSDSRC
   61: 	env MAKEOBJDIRPREFIX=${BSDOBJ} make TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
   62: 		SRCCONF=${SRCCONF} __MAKE_CONF=${MAKECONF} DESTDIR=$1 installkernel KERNCONF=$2
   63: 	cd -
   64: 
   65: 	if [ $? -eq 0 ]; then
   66: 		echo "ELWIX Platform:${PLATFORM} Version:${VERSION} TargetArch:${TARGET_ARCH}" >$1/elwix.ver
   67: 	fi
   68: 
   69: 	echo "+++ Completed ELWIX Kernel $2 ... $1"
   70: }
   71: 
   72: ### main()
   73: if [ -n "${1}" ]; then
   74: 	case "${1}" in
   75: 		rootfs)
   76: 			rm ${KERN_ROOTFS}/elwix.ver
   77: 			;;
   78: 		base)
   79: 			rm ${KERN}/elwix.ver
   80: 			;;
   81: 		both)
   82: 			rm ${KERN_ROOTFS}/elwix.ver
   83: 			rm ${KERN}/elwix.ver
   84: 			;;
   85: 		*)
   86: 			echo "Error:: unknown argument. Please, choose which kind of kernel [base|rootfs|both]?"
   87: 			exit 1
   88: 			;;
   89: 	esac
   90: else
   91: 	echo "Error:: missing argument. Please, choose which kind of kernel [base|rootfs|both]?"
   92: 	exit 1
   93: fi
   94: 
   95: if [ "${1}" = "base" -o "${1}" = "both" ]; then
   96: 	if ! SnitVer ${KERN}/elwix.ver; then
   97: 		clean_kernel ${KERN} ${KERNCONF}
   98: 		build_kernel ${KERN} ${KERNCONF}
   99: 		install_kernel ${KERN} ${KERNCONF}
  100: 	else
  101: 		echo "Skipped ELWIX Kernel build ..."
  102: 	fi
  103: fi
  104: 
  105: if [ "${1}" = "rootfs" -o "${1}" = "both" ]; then
  106: 	if ! SnitVer ${KERN_ROOTFS}/elwix.ver; then
  107: 		clean_kernel ${KERN_ROOTFS} ${KERNCONF_ROOTFS}
  108: 		build_kernel ${KERN_ROOTFS} ${KERNCONF_ROOTFS}
  109: 		install_kernel ${KERN_ROOTFS} ${KERNCONF_ROOTFS}
  110: 	else
  111: 		echo "Skipped ELWIX rootfs Kernel build ..."
  112: 	fi
  113: fi
  114: 
  115: echo "+++ Complete build ELWIX Kernels ${1}"

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