#!/bin/bash

function compile () {
    rm -rf $1-build;
    mkdir -p $1-build;
    rm -rf $1-install;
    mkdir -p $1-install;
    cd $1-build;
    ../source/configure $2;
    make
    DESTDIR=$PWD/../$1-install make install
    cd -;
    tar czf grub2-$1-`date --utc +%Y%m%d%H%M`.tar.gz --transform "s,$1-install/,," $1-install/*
}

cd source
./autogen.sh
cd -

tar czf grub2-src-`date --utc +%Y%m%d%H%M`.tar.gz --transform "s,source/,," source/*

compile i386-pc "--target=i386 --with-platform=pc"
compile i386-coreboot "--target=i386 --with-platform=coreboot"
compile i386-ieee1275 "--target=i386 --with-platform=ieee1275"
compile i386-efi "--target=i386 --with-platform=efi"
compile x86_64-efi "--target=x86_64 --with-platform=efi"



