summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hare.scm193
1 files changed, 193 insertions, 0 deletions
diff --git a/hare.scm b/hare.scm
new file mode 100644
index 0000000..a51da1a
--- /dev/null
+++ b/hare.scm
@@ -0,0 +1,193 @@
+(define-module (hare)
+ #:use-module (guix packages)
+ #:use-module (guix utils)
+ #:use-module (guix gexp)
+ #:use-module (guix git-download)
+ #:use-module (guix download)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system gnu)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages base)
+ #:use-module (gnu packages c)
+ #:use-module (gnu packages man)
+ #:use-module (ice-9 match))
+
+(define tzdata-list
+ (package
+ (inherit tzdata)
+ (name "tzdata-list")
+ (arguments
+ (list #:tests? #f
+ ;; This consists purely of (architecture-independent) data, so
+ ;; ‘cross-compilation’ is pointless here! (The binaries zic,
+ ;; dump, and tzselect are deleted in the post-install phase.)
+ #:target #f
+ #:make-flags
+ #~(let ((out #$output)
+ (tmp (getenv "TMPDIR")))
+ (list (string-append "TOPDIR=" out)
+ (string-append "TZDIR=" out "/share/zoneinfo")
+ (string-append "TZDEFAULT=" out
+ "/share/zoneinfo/localtime")
+
+ ;; Likewise for the C library routines.
+ (string-append "LIBDIR=" tmp "/lib")
+ (string-append "MANDIR=" tmp "/man")
+
+ ;; XXX: tzdata 2020b changed the on-disk format
+ ;; of the time zone files from 'fat' to 'slim'.
+ ;; Many packages (particularly evolution-data-server)
+ ;; can not yet handle the latter, so we stick with
+ ;; 'fat' for now.
+ #$@(if (version>=? (package-version this-package)
+ "2020b")
+ '("CPPFLAGS=-DZIC_BLOAT_DEFAULT='\"fat\"'")
+ '())
+
+ "AWK=awk"
+ "CC=gcc"))
+ #:modules '((guix build utils)
+ (guix build gnu-build-system)
+ (srfi srfi-1))
+ #:phases
+ #~(modify-phases %standard-phases
+ (replace 'unpack
+ (lambda* (#:key source inputs #:allow-other-keys)
+ (invoke "tar" "xvf" source)
+ (invoke "tar" "xvf"
+ #$(match (package-inputs this-package)
+ (((_ tzcode)) tzcode)))))
+ (add-after 'install 'post-install
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; Move data in the right place.
+ (let ((out (assoc-ref outputs "out")))
+ (copy-file "leap-seconds.list"
+ (string-append out "/share/zoneinfo/leap-seconds.list"))
+ (symlink (string-append out "/share/zoneinfo")
+ (string-append out "/share/zoneinfo/posix"))
+ (copy-recursively (string-append out "/share/zoneinfo-leaps")
+ (string-append out "/share/zoneinfo/right")))))
+ (delete 'configure))))))
+
+(define qbe-master
+ (let ((commit "d023bdaa6b493686f7e9be7ac200ee4ac37d351f")
+ (revision "1"))
+ (package
+ (inherit qbe)
+ (name "qbe")
+ (version (git-version "1.1" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "git://c9x.me/qbe")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "11flr6mmxglidp4fr7whfzhwr1bjkiz0rcvpy541xmwm2isj5znm")))))))
+
+(define-public harec
+ (let ((revision "1")
+ (commit "b4dd4275b24513d14e999bc35ea7d61ed02d1e08"))
+ (package
+ (name "harec")
+ (version (git-version "0.0.1" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.sr.ht/~sircmpwn/harec")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1brb0qr6fsi2hx724rprkkwi6qs6ymqglng78gm9m8k6z7c61j8b"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'setenv
+ (lambda _
+ (setenv "CC" ,(cc-for-target))))
+ (add-after 'configure 'configure-better
+ (lambda* (#:key outputs #:allow-other-keys)
+ (invoke "./configure"
+ (string-append "--prefix=" (assoc-ref outputs "out")))))
+ (delete 'configure))))
+ (inputs (list qbe-master scdoc))
+ (synopsis "Bootstrapping compiler for Hare")
+ (description "Hare is a systems programming language designed to be
+simple, stable, and robust. Hare uses a static type system, manual memory
+management, and a minimal runtime. It is well-suited to writing operating
+systems, system tools, compilers, networking software, and other low-level,
+high performance tasks. If you want to code in Hare, you probably prefer to
+install @code{hare}")
+ (home-page "https://git.sr.ht/~sircmpwn/harec")
+ (license license:gpl3))))
+
+
+(define-public hare
+ (let ((revision "1")
+ (commit "b35f4bc1551bf561de2e0e1fcd7367c20fa21216"))
+ (package
+ (name "hare")
+ (version (git-version "0.0.1" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://git.sr.ht/~sircmpwn/hare")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0v5r7007dyy75qagffkhag1pqigdsv2qgbgwrn44d51ws695phzi"))))
+ (inputs (list scdoc qbe-master harec tzdata-list))
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ #:make-flags #~(list "HARECACHE=./cache" (string-append "PREFIX=" #$output))
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-before 'configure 'configure-make
+ (lambda _
+ (substitute*
+ "time/chrono/+linux.ha"
+ (("/usr/share/zoneinfo/leap-seconds.list")
+ (string-append #$tzdata-list "/share/zoneinfo/leap-seconds.list"))
+ (("/usr/share/zoneinfo/")
+ (string-append #$tzdata-list "/share/zoneinfo/")))
+ (copy-file "config.example.mk" "config.mk")
+ (substitute*
+ "config.mk"
+ (("AS = as")
+ (string-append "AS = "
+ #$binutils "/bin/" #$(as-for-target)))
+ (("LD = ld")
+ (string-append "LD = "
+ #$binutils "/bin/" #$(ld-for-target)))
+ (("QBE = qbe")
+ (string-append "QBE = "
+ #$qbe-master "/bin/qbe"))
+ (("SCDOC = scdoc")
+ (string-append "SD ="
+ #$scdoc "/bin/scdoc"))
+ (("HAREC = harec")
+ (string-append "HAREC =" #$harec "/bin/harec")))
+ (substitute*
+ "cmd/hare/build.ha"
+ (("\"qbe\"")
+ (string-append "\"" #$qbe-master "/bin/qbe" "\""))
+ (("\"harec\"")
+ (string-append "\"" #$harec "/bin/harec" "\""))
+ (("arch.as_cmd")
+ (string-append "\"" #$binutils "/bin/" #$(as-for-target) "\""))
+ (("arch.ld_cmd")
+ (string-append "\"" #$binutils "/bin/" #$(ld-for-target) "\"")))))
+ (delete 'configure))))
+ (synopsis "Hare build driver")
+ (description "Hare is a systems programming language designed to be
+simple, stable, and robust. Hare uses a static type system, manual memory
+management, and a minimal runtime. It is well-suited to writing operating
+systems, system tools, compilers, networking software, and other low-level,
+high performance tasks.")
+ (home-page "https://git.sr.ht/~sircmpwn/hare")
+ (license license:gpl3))))