]> gitweb @ CieloNegro.org - build-hc-pkg.git/commitdiff
build-hc-pkg seems to be mature now.
authorPHO <pho@cielonegro.org>
Thu, 9 Feb 2012 16:52:13 +0000 (01:52 +0900)
committerPHO <pho@cielonegro.org>
Thu, 9 Feb 2012 16:52:13 +0000 (01:52 +0900)
.gitignore
build-hc-pkg [new file with mode: 0755]
files/host-build.mk [new file with mode: 0644]
files/mkboot [new file with mode: 0755]
files/target-build.mk [new file with mode: 0644]
mk/canon-name.mk [new file with mode: 0644]
mk/main.mk [new file with mode: 0644]

index f470efe2cd9ed26fbd80f88932bdd6518197b072..e71ad643aa489639cb03207faa093fbb3288f07c 100644 (file)
@@ -17,3 +17,4 @@ depcomp
 install-sh
 missing
 stamp-h1
+work
diff --git a/build-hc-pkg b/build-hc-pkg
new file mode 100755 (executable)
index 0000000..81dcea4
--- /dev/null
@@ -0,0 +1,38 @@
+#!/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
+
+gmake -f mk/main.mk SRCPATH="$srcpath" PLATFORM="$platform" SHELL="$SHELL"
+
+echo "If you are done, run \"$0 clean\" to cleanup the working directory."
diff --git a/files/host-build.mk b/files/host-build.mk
new file mode 100644 (file)
index 0000000..3263302
--- /dev/null
@@ -0,0 +1,19 @@
+PORTING_HOST = YES
+GhcUnregisterised = YES
+GhcLibHcOpts = -O -fvia-C -keep-hc-files
+GhcRtsHcOpts = -keep-hc-files
+GhcLibWays = v
+GhcRTSWays =
+SplitObjs = NO
+GhcWithNativeCodeGen = NO
+GhcWithInterpreter = NO
+GhcStage1HcOpts = -O
+GhcStage2HcOpts = -O -fvia-C -keep-hc-files
+SRC_HC_OPTS += -H32m
+GhcWithSMP = NO
+utils/ghc-pkg_dist-install_v_HC_OPTS += -keep-hc-files
+
+INTEGER_LIBRARY = integer-simple
+libraries/terminfo_CONFIGURE_OPTS += \
+       --configure-option=--with-curses-includes=/usr/pkg/include \
+       --configure-option=--with-curses-libraries=/usr/pkg/lib
diff --git a/files/mkboot b/files/mkboot
new file mode 100755 (executable)
index 0000000..4692719
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -x
+rm -f list mkfiles boot.tar
+find . -name "*.hi" >> list
+find . -name "*.hc" >> list
+find . -name "*_stub.c" >> list
+find . -name "*_stub.h" >> list
+find . -name package-data.mk >> list
+find . -name package.conf.d >> list
+find . -name package.conf.inplace >> list
+ls compiler/stage?/build/Config.hs >> list
+echo compiler/prelude/primops.txt >> list
+ls compiler/primop-*.hs-incl >> list
+find . -name .depend | sed -e 's/^/mkdir -p `dirname /' -e 's/$/`/' >> mkfiles
+find . -name .depend | sed "s/^/touch /" >> mkfiles
+echo mkfiles >> list
+tar -cf boot.tar -T list
diff --git a/files/target-build.mk b/files/target-build.mk
new file mode 100644 (file)
index 0000000..ea12948
--- /dev/null
@@ -0,0 +1 @@
+INTEGER_LIBRARY = integer-simple
diff --git a/mk/canon-name.mk b/mk/canon-name.mk
new file mode 100644 (file)
index 0000000..266d5df
--- /dev/null
@@ -0,0 +1,10 @@
+all: canon-name/src/canon-name
+
+canon-name/src/canon-name: canon-name/Makefile
+       $(MAKE) -C canon-name
+
+canon-name/Makefile: canon-name/configure
+       cd canon-name && ./configure -C --enable-maintainer-mode
+
+canon-name/configure: canon-name/autogen.sh
+       cd canon-name && ./autogen.sh
diff --git a/mk/main.mk b/mk/main.mk
new file mode 100644 (file)
index 0000000..815f653
--- /dev/null
@@ -0,0 +1,85 @@
+DIRNAME    := $(patsubst %-src.tar.bz2,%,$(notdir $(SRCPATH)))
+GNUTAR     ?= gnutar
+HC_TARNAME ?= $(DIRNAME)-boot-$(PLATFORM).tar.bz2
+
+all: work/pack-hc-pkg.stamp
+
+work/extract-src.stamp:
+       $(GNUTAR) -jxf $(SRCPATH) -C work
+       touch $@
+
+work/patch-src.stamp: work/extract-src.stamp
+       @echo "Executing an inner shell."
+       @echo "Apply some patch to the source tree, then exit."
+       @echo "(pwd: `pwd`/$(DIRNAME))"
+       @cd "work/$(DIRNAME)" && "$(SHELL)"
+       touch $@
+
+work/duplicate-target.stamp: work/patch-src.stamp
+       cp -rp "work/$(DIRNAME)" "work/$(DIRNAME)-target"
+       touch $@
+
+work/rename-host.stamp: work/duplicate-target.stamp
+       mv "work/$(DIRNAME)" "work/$(DIRNAME)-host"
+       touch $@
+
+work/$(DIRNAME)-target/Makefile: work/rename-host.stamp
+       cd "work/$(DIRNAME)-target" && \
+               ./configure -C --enable-hc-boot
+       touch $@
+
+work/$(DIRNAME)-target/mk/build.mk: files/target-build.mk work/$(DIRNAME)-target/Makefile
+       cp -f $< $@
+
+work/build-boot-files.stamp: work/$(DIRNAME)-target/mk/build.mk
+       $(MAKE) -C "work/$(DIRNAME)-target" bootstrapping-files
+       touch $@
+
+work/$(DIRNAME)-host/Makefile: work/build-boot-files.stamp
+       cd "work/$(DIRNAME)-host" && \
+               ./configure \
+                       --with-iconv-includes=/usr/pkg/include \
+                       --with-iconv-libraries=/usr/pkg/lib
+       touch $@
+
+work/$(DIRNAME)-host/mk/build.mk: files/host-build.mk work/$(DIRNAME)-host/Makefile
+       cp -f $< $@
+
+work/copy-boot-files.stamp: work/$(DIRNAME)-host/mk/build.mk
+       for i in dist-ghcconstants dist-derivedconstants ghcautoconf.h; do \
+               rm -rf "work/$(DIRNAME)-host/includes/$$i" && \
+               cp -pr \
+                       "work/$(DIRNAME)-target/includes/$$i" \
+                       "work/$(DIRNAME)-host/includes"; \
+       done
+       touch $@
+
+work/build-hc.stamp: work/copy-boot-files.stamp
+       $(MAKE) -C "work/$(DIRNAME)-host"
+       touch $@
+
+work/build-boot-tarball.stamp: work/build-hc.stamp
+       cd "work/$(DIRNAME)-host" && ../../files/mkboot
+       touch $@
+
+work/extract-boot-tarball.stamp: work/build-boot-tarball.stamp
+       mkdir -p "work/$(DIRNAME)"
+       $(GNUTAR) -xf "work/$(DIRNAME)-host/boot.tar" -C "work/$(DIRNAME)"
+       touch $@
+
+work/replace-paths.stamp: work/extract-boot-tarball.stamp
+       cd "work/$(DIRNAME)" && \
+               gsed -i \
+                       -e 's#/usr/pkg#[[PREFIX]]#g' \
+                       -e 's#'`pwd`'-host#[[GHC_SOURCE_PATH]]#g' \
+                       inplace/lib/package.conf.d/*.conf \
+                       */package.conf.inplace \
+                       */*/package-data.mk \
+                       */*/*/package-data.mk \
+                       */*/*/*/package-data.mk
+       touch $@
+
+work/pack-hc-pkg.stamp: work/replace-paths.stamp
+       $(GNUTAR) -jcf "work/$(HC_TARNAME)" -C "work" $(DIRNAME)
+       touch $@
+       @echo "Done. Upload \"work/$(HC_TARNAME)\" to somewhere."