#!/usr/local/bin/cbsd
CBSDMODULE=
MYARG=""
MYOPTARG="arch basename ccache clean destdir distcc maxjobs name nice notify stable target_arch target_cputype ver"
MYDESC="Run 'cbsd buildkernel' and 'cbsd installkernel' atomic"
ADDHELP="

${H3_COLOR}Description${N0_COLOR}:

Build/compile kernel from source tree. This is a wrapper script for 
build/installkernel: 'cbsd kernel' = 'cbsd buildkernel' + 'cbsd installkernel'.
To compile the kernel, you first need to get 'base', e.g.: 'cbsd world' or via 'cbsd repo'.

${H3_COLOR}Options${N0_COLOR}:

 ${N2_COLOR}arch=${N0_COLOR}         - <name>, use non-native architectures;
 ${N2_COLOR}basename=${N0_COLOR}     - Prefix for directory name, can be used for jail as alternative base;
 ${N2_COLOR}destdir${N0_COLOR}       - <path> - alternative DESTDIR= path instead of ~cbsd/basejail/;
 ${N2_COLOR}name=${N0_COLOR}         - name of the kernel, default: 'GENERIC';
 ${N2_COLOR}nice=${N0_COLOR}         - num: overwrite default nice: '19';
 ${N2_COLOR}target_arch=${N0_COLOR}  - <name>, build non-native target arch;
 ${N2_COLOR}ver=${N0_COLOR}          - set version: '13.0', '13.1';
                   when version without minor version: e.g:
                  '13' or '12' - you will receive RELENG (stable=1), not release.

${H3_COLOR}Examples${N0_COLOR}:

 # cbsd kernel
 # cbsd kernel destdir=/tmp/testkernel name=CBSD
 # cbsd kernel ver=13.0 arch=arm64 target_arch=aarch64
 # cbsd kernel ver=13.0 arch=riscv target_arch=riscv64

${H3_COLOR}See also${N0_COLOR}:

  cbsd buildkernel --help
  cbsd installkernel --help
  cbsd srcup --help
  cbsd kernels --help
  cbsd mkdistribution --help
  cbsd install-pkg-world --help

"

ARGS="${*}"
. ${subrdir}/nc.subr
. ${cbsdinit}

buildkernel ${ARGS} && installkernel ${ARGS}

exit $?
