diff options
author | Arun Isaac | 2022-01-05 15:48:54 +0530 |
---|---|---|
committer | Arun Isaac | 2022-01-05 16:24:22 +0530 |
commit | 898e59dfa3db531542b556648d8ad029535886e3 (patch) | |
tree | 724bf13dc262264bdd52aa5158908463b7173970 | |
parent | 870ab7dba04afe86d8ff4a0b8434add416539ade (diff) | |
download | kolam-898e59dfa3db531542b556648d8ad029535886e3.tar.gz kolam-898e59dfa3db531542b556648d8ad029535886e3.tar.lz kolam-898e59dfa3db531542b556648d8ad029535886e3.zip |
configure: Output version.
* configure.scm: Import (rnrs io ports), (srfi srfi-26) and (ice-9
popen).
(call-with-input-pipe): New function.
(version): New variable.
Output version to Makefile.include.
-rw-r--r-- | configure.scm | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/configure.scm b/configure.scm index 07a822a..9c519fc 100644 --- a/configure.scm +++ b/configure.scm @@ -17,9 +17,24 @@ ;;; License along with kolam. If not, see ;;; <http://www.gnu.org/licenses/>. -(use-modules (srfi srfi-28) +(use-modules (rnrs io ports) + (srfi srfi-26) + (srfi srfi-28) (srfi srfi-37) - (ice-9 match)) + (ice-9 match) + (ice-9 popen)) + +(define (call-with-input-pipe command proc) + "Call PROC with input pipe to COMMAND. COMMAND is a list of program +arguments." + (match command + ((prog args ...) + (let ((port #f)) + (dynamic-wind + (lambda () + (set! port (apply open-pipe* OPEN_READ prog args))) + (cut proc port) + (cut close-pipe port)))))) (define (check-for-guile-3.0) (display "checking for guile 3.0... ") @@ -75,6 +90,16 @@ (libdir . ,libdir) (datarootdir . ,datarootdir)))))) +(define version + (call-with-input-pipe (list "git" "tag" "--sort=-taggerdate" + "--list" "v*") + (lambda (port) + (let ((line (get-line port))) + (if (eof-object? line) + ;; If there are no tags, assume first version. + "0.1.0" + (substring line (string-length "v"))))))) + (check-for-guile-3.0) (check-for-module '(json)) @@ -83,11 +108,13 @@ (display (format "# This file was automatically generated by configure. project = ~a +version = ~a libdir = ~a datarootdir = ~a guile_effective_version = ~a " (assq-ref processed-args 'project) + version (assq-ref processed-args 'libdir) (assq-ref processed-args 'datarootdir) (effective-version)) |