#!/usr/bin/env bash set -e declare canon_name="canon-name/src/canon-name" declare archive="work/archive" if [[ ! -x "$canon_name" ]]; then gmake -f mk/canon-name.mk fi readonly platform=$("$canon_name") echo "This is build-hc-pkg, running on \"$platform\"." if [[ "$1" = "clean" ]]; then echo "Cleaning..." rm -rf work exit fi declare srcpath="" if [[ -e "$archive" ]]; then srcpath=$(cat "$archive") fi if [[ -z "$srcpath" || ! -e "$srcpath" ]]; then mkdir -p work read -e -p "Enter the file path to ghc-x.y.z-src.tar.bz2: " srcpath if [[ -e "$srcpath" ]]; then mkdir -p work echo "$srcpath" > "$archive" else echo "$srcpath not found." >&2 exit 1 fi fi # What's the name of our GNU tar? declare gnutar="" if which gnutar >/dev/null 2>&1; then gnutar="gnutar" elif which gtar >/dev/null 2>&1; then gnutar="gtar" else echo "We need GNU tar to be installed." >&2 exit 1 fi gmake -f mk/main.mk \ SRCPATH="$srcpath" \ PLATFORM="$platform" \ GNUTAR="$gnutar" \ SHELL="$SHELL" echo "If you are done, run \"$0 clean\" to cleanup the working directory."