chicken-git / git.setup

Full commit
(define *required-chicken* '("4.7.0"  . #(4 7 0)))
(define *required-libgit2* '("0.19.0" . #(0 19 0)))

;; Verify the CHICKEN version.
(when (string<? (chicken-version) (car *required-chicken*))
  (fprintf (current-error-port)
           "\n  git: This extension requires Chicken version ~a or later."
           (car *required-chicken*))
  (exit 1))

;; Verify the libgit2 version.
;; If pkg-config is available, consult it first.
(define pkg-config-version
   (with-input-from-pipe "pkg-config --modversion libgit2" read-string)))

(unless (or (string-null? pkg-config-version)
            (string=? pkg-config-version (car *required-libgit2*)))
  (fprintf (current-error-port)
           "\n  git: This extension requires libgit2 version ~a or later."
           (car *required-libgit2*))
  (exit 1))

;; Shared libraries.
(compile -sJ -O3 -d0 git-lolevel.scm -lgit2)
(compile -sJ -O3 -d0 git.scm)

;; Static libraries.
(compile -unit git-lolevel -cJ -O3 -d0 git-lolevel.scm -o git-lolevel.o)
(compile -unit git -uses git-lolevel -cJ -O3 -d0 git.scm -o git.o)
(run (ar -rc git.a git.o git-lolevel.o))

;; Import libraries.
(compile -s -O3 -d0 git-lolevel.import.scm)
(compile -s -O3 -d0 git.import.scm)

;; If we couldn't detect libgit2's version via pkg-config, check it
;; directly now.
(when (string-null? pkg-config-version)
  (load "./")
  (load "./")
  (import (only git-lolevel libgit2-version))
  (when (not (equal? (libgit2-version) (cdr *required-libgit2*)))
    (fprintf (current-error-port)
             "\n  git: This extension requires libgit2 ~a."
             (car *required-libgit2*))
    (exit 1)))

(install-extension 'git
  '("" ""
    "" ""
    "git.a" "git.o" "git-lolevel.o")
  '((version "0.0.23")))