4 function detect_platform_type () {
5 local -r canon_name="canon-name/src/canon-name"
7 if [[ ! -x "$canon_name" ]]; then
8 gmake -f mk/canon-name.mk
14 function detect_number_of_cpus () {
15 case "$(detect_platform_type)" in
17 ioreg -r -c IOCPU | fgrep -c IOCPUNumber
20 echo "WARNING: I don't know how to detect the number of processors on this platform." >&2
21 echo "WARNING: GHC will be built using only 1 processor. Expect some slowdown." >&2
27 function say_hello () {
28 local -r platform=$(detect_platform_type)
29 local -r n_cpus=$(detect_number_of_cpus)
30 echo "This is build-hc-pkg, running on $platform with $n_cpus processors."
34 local -r archive="work/archive"
37 if [[ -e "$archive" ]]; then
38 srcpath=$(cat "$archive")
41 if [[ -z "$srcpath" || ! -e "$srcpath" ]]; then
43 read -e -p "Enter the file path to ghc-x.y.z-src.tar.bz2: " srcpath
44 if [[ -e "$srcpath" ]]; then
46 echo "$srcpath" > "$archive"
48 echo "$srcpath not found." >&2
56 function build_hc_pkg () {
57 local -r srcpath="$(srcpath)"
60 -j $(($(detect_number_of_cpus) + 1)) \
63 PLATFORM="$(detect_platform_type)" \
66 echo "If you are done, run \"$0 clean\" to cleanup the working directory."
82 echo "Usage: $0 [clean]" >&2