|
| 1 | +#!/usr/bin/bash |
| 2 | +# |
| 3 | +# {{{ CDDL HEADER |
| 4 | +# |
| 5 | +# This file and its contents are supplied under the terms of the |
| 6 | +# Common Development and Distribution License ("CDDL"), version 1.0. |
| 7 | +# You may only use this file in accordance with the terms of version |
| 8 | +# 1.0 of the CDDL. |
| 9 | +# |
| 10 | +# A full copy of the text of the CDDL should have accompanied this |
| 11 | +# source. A copy of the CDDL is also available via the Internet at |
| 12 | +# http://www.illumos.org/license/CDDL. |
| 13 | +# }}} |
| 14 | + |
| 15 | +# Copyright 2017 OmniOS Community Edition (OmniOSce) Association. |
| 16 | + |
| 17 | +# |
| 18 | +# Load support functions |
| 19 | +. ../../lib/functions.sh |
| 20 | + |
| 21 | +BUILD_DEPENDS_IPS=" |
| 22 | + developer/acpi/compiler |
| 23 | + developer/nasm |
| 24 | +" |
| 25 | + |
| 26 | +# XXX |
| 27 | +BUILD_DEPENDS_IPS= |
| 28 | + |
| 29 | +PROG=uefi-edk2 |
| 30 | +PKG=system/bhyve/firmware |
| 31 | +VER=20160525 |
| 32 | +VERHUMAN=$VER |
| 33 | +SUMMARY="UEFI-EDK2(+CSM) firmware for bhyve" |
| 34 | +DESC="$SUMMARY" |
| 35 | + |
| 36 | +# Respect environmental overrides for these to ease development. |
| 37 | +: ${PKG_SOURCE_REPO:=https://github.com/omniosorg/$PROG} |
| 38 | +: ${PKG_SOURCE_BRANCH:=bhyve/UDK2014.SP1} |
| 39 | + |
| 40 | +# Extend VER so that the temporary build directory is branch specific. |
| 41 | +# Branches can include '/' so remove them. |
| 42 | +VER+="-${PKG_SOURCE_BRANCH//\//_}" |
| 43 | + |
| 44 | +clone_source(){ |
| 45 | + logmsg "$PROG -> $TMPDIR/$BUILDDIR/$PROG" |
| 46 | + logcmd mkdir -p $TMPDIR/$BUILDDIR |
| 47 | + pushd $TMPDIR/$BUILDDIR > /dev/null |
| 48 | + if [ ! -d $PROG ]; then |
| 49 | + if [ -n "$EDK2_CLONE" -a -d "$EDK2_CLONE" ]; then |
| 50 | + logmsg "-- pulling $PROG from local clone" |
| 51 | + logcmd rsync -ar $EDK2_CLONE/ $PROG/ |
| 52 | + else |
| 53 | + logmsg "-- cloning $PKG_SOURCE_REPO" |
| 54 | + logcmd $GIT clone --depth 1 $PKG_SOURCE_REPO $PROG |
| 55 | + fi |
| 56 | + fi |
| 57 | + if [ -z "$EDK2_CLONE" ]; then |
| 58 | + logcmd $GIT -C $PROG pull || logerr "failed to pull" |
| 59 | + fi |
| 60 | + logmsg "-- Checking out $PKG_SOURCE_BRANCH branch" |
| 61 | + logcmd $GIT -C $PROG checkout $PKG_SOURCE_BRANCH \ |
| 62 | + || logerr "Could not check-out branch." |
| 63 | + popd > /dev/null |
| 64 | +} |
| 65 | + |
| 66 | +build() { |
| 67 | + pushd $TMPDIR/$BUILDDIR/$PROG >/dev/null || logerr "pushd" |
| 68 | + |
| 69 | + logmsg "-- Cleaning source tree..." |
| 70 | + |
| 71 | + logcmd gmake -C BaseTools clean |
| 72 | + rm -f Build Conf/{target,build_rule,tools_def}.txt Conf/.cache 2>/dev/null |
| 73 | + |
| 74 | + logmsg "-- Building tools..." |
| 75 | + |
| 76 | + # First build the tools. The code isn't able to detect the build |
| 77 | + # architecture - it doesn't expect `uname -m` to return `i86pc` |
| 78 | + logcmd gmake -C BaseTools ARCH=X64 || logerr "BaseTools build failed" |
| 79 | + |
| 80 | + BUILD_ARGS="-DDEBUG_ON_SERIAL_PORT=TRUE -DFD_SIZE_2MB -DCSM_ENABLE=TRUE" |
| 81 | + |
| 82 | + ( |
| 83 | + export GCCPATH=/opt/gcc-4.4.4 |
| 84 | + export OOGCC_BIN=$GCCPATH/bin/ |
| 85 | + export IASL_PREFIX=/usr/sbin/ |
| 86 | + export NASM_PREFIX=/usr/bin/i386/ |
| 87 | + source edksetup.sh |
| 88 | + |
| 89 | + logmsg "-- Building compatibility support module (CSM)..." |
| 90 | + logcmd gmake \ |
| 91 | + AS=/usr/bin/gas \ |
| 92 | + AR=/usr/bin/gar \ |
| 93 | + LD=/usr/bin/gld \ |
| 94 | + OBJCOPY=/usr/bin/gobjcopy \ |
| 95 | + CC=${OOGCC_BIN}gcc \ |
| 96 | + CXX=${OOGCC_BIN}g++ \ |
| 97 | + -C BhyvePkg/Csm/BhyveCsm16/ |
| 98 | + |
| 99 | + for mode in RELEASE DEBUG; do |
| 100 | + logmsg "-- Building $mode Firmware..." |
| 101 | + logcmd `which build` \ |
| 102 | + -t OOGCC -a X64 -b $mode \ |
| 103 | + -p BhyvePkg/BhyvePkgX64.dsc \ |
| 104 | + $BUILD_ARGS |
| 105 | + done |
| 106 | + ) || logerr "failed" |
| 107 | + |
| 108 | + popd >/dev/null |
| 109 | +} |
| 110 | + |
| 111 | +install() { |
| 112 | + pushd $TMPDIR/$BUILDDIR/$PROG >/dev/null || logerr "pushd" |
| 113 | + logcmd mkdir -p $DESTDIR/usr/share/bhyve/firmware |
| 114 | + for mode in RELEASE DEBUG; do |
| 115 | + logcmd cp Build/BhyveX64/${mode}_OOGCC/FV/BHYVE.fd \ |
| 116 | + $DESTDIR/usr/share/bhyve/firmware/BHYVE_$mode.fd |
| 117 | + done |
| 118 | + popd >/dev/null |
| 119 | +} |
| 120 | + |
| 121 | +init |
| 122 | +clone_source |
| 123 | +build |
| 124 | +install |
| 125 | +make_package |
| 126 | +clean_up |
| 127 | + |
| 128 | +# Vim hints |
| 129 | +# vim:ts=4:sw=4:et:fdm=marker |
0 commit comments