summaryrefslogtreecommitdiff
path: root/scripts/build_grub.sh
blob: 764a908789e8b606ed4ab6f149f50937a305eca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash

# Originally from the Galileo port in contiki
# https://github.com/otcshare/contiki-x86

set -e

JOBS=5
HEAD="bac5d1a64ab4191058a8fd4c05f6b3b339e249e7"
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

prepare() {
  if [[ ! -d ./src ]]; then
    git clone http://git.savannah.gnu.org/r/grub.git src
  fi

  pushd src
  git checkout $HEAD
  git clean -fdx
  popd
}

build() {
  pushd src

  ./autogen.sh
  ./configure --with-platform=efi --target=i386

  make -j${JOBS}

  ./grub-mkimage -p /EFI/BOOT -d ./grub-core/ -O i386-efi -o grub.efi \
            boot efifwsetup efi_gop efinet efi_uga lsefimmap lsefi lsefisystab \
            exfat fat multiboot2 multiboot terminal part_msdos part_gpt normal \
            all_video aout configfile echo file fixvideo fshelp gfxterm gfxmenu \
            gfxterm_background gfxterm_menu legacycfg video_bochs video_cirrus \
            video_colors video_fb videoinfo video

  popd
}

setup() {
  mkdir -p bin
  cp src/grub.efi bin/
}

cleanup() {
  rm -rf ./src
  rm -rf ./bin
}

# This script will always run on its own basepath, no matter where you call it from.
mkdir -p ${SCRIPT_DIR}/grub
pushd ${SCRIPT_DIR}/grub

case $1 in
  -c | --cleanup)
    cleanup
    ;;
  *)
    prepare && build && setup
    ;;
esac

popd