aboutsummaryrefslogtreecommitdiff
path: root/configure.scm
diff options
context:
space:
mode:
Diffstat (limited to 'configure.scm')
-rw-r--r--configure.scm31
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))