#!/usr/bin/env bash # # Copyright (c) 2018 Intel Corporation # # SPDX-License-Identifier: Apache-2.0 #--------------------------------------------------------------------- # Description: This script is the *ONLY* place where "qemu*" build options # should be defined. # # Note to maintainers: # # XXX: Every option group *MUST* be documented explaining why it has # been specified. #--------------------------------------------------------------------- script_name=${0##*/} arch="${3:-$(uname -m)}" # Array of configure options. # # Each element is comprised of two parts in the form: # # tags:option # # Where, # # - 'tags' is a comma-separated list of values which denote why # the option is being specified. # # - 'option' is the hypervisor configuration option. typeset -a qemu_options typeset -A recognised_tags # Prefix were kata will be installed prefix=${PREFIX:-/usr} # The QEMU version on "major.minor" format. qemu_version="" recognised_tags=( [arch]="architecture-specific" [functionality]="required functionality" [minimal]="specified to avoid building unnecessary elements" [misc]="miscellaneous" [security]="specified for security reasons" [size]="minimise binary size" [speed]="maximise startup speed" ) # Given $1 and $2 as version strings with 'x.y.z' format; if $1 >= $2 then # return 0. Otherwise return 1. # Use this function on conditionals to compare versions. # gt_eq() { format='^[0-9]+(\.[0-9]+)*$' if [[ ! ("$1" =~ $format && "$2" =~ $format) ]]; then echo "ERROR: Malformed version string" fi echo -e "$1\n$2" | sort -V -r -C } # Display message to stderr and exit indicating script failed. die() { local msg="$*" echo >&2 "$script_name: ERROR: $msg" exit 1 } # Display usage to stdout. usage() { cat < Options: -d : Dump all options along with the tags explaining why each option is specified. -h : Display this help. -m : Display options one per line (includes continuation characters). -s : Generate options to build static Example: $ $script_name qemu EOF } show_tags_header() { local keys local key local value cat <= 6.1.0" fi local gcc_version_major=$(gcc -dumpversion | cut -f1 -d.) [ -n "${gcc_version_major}" ] || die "cannot determine gcc major version, please ensure it is installed" # -dumpversion only returns the major version since GCC 7.0 if gt_eq "${gcc_version_major}" "7.0.0" ; then local gcc_version_minor=$(gcc -dumpfullversion | cut -f2 -d.) else local gcc_version_minor=$(gcc -dumpversion | cut -f2 -d.) fi [ -n "${gcc_version_minor}" ] || die "cannot determine gcc minor version, please ensure it is installed" local gcc_version="${gcc_version_major}.${gcc_version_minor}" # Generate qemu options generate_qemu_options show_array "$action" "${qemu_options[@]}" exit 0 } main $@