summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--configure.scm50
2 files changed, 53 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index be43eb1..5fa3c06 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,8 @@
 # License along with kolam.  If not, see
 # <http://www.gnu.org/licenses/>.
 
+include Makefile.include
+
 GUILE = guile
 GUILD = guild
 EMACS = emacs
@@ -40,4 +42,4 @@ website/index.html: README.org build-aux/build-home-page.el
 
 .PHONY: clean
 clean:
-	rm -f website/index.html
+	rm -f Makefile.include website/index.html
diff --git a/configure.scm b/configure.scm
index 1a6fdde..6681f17 100644
--- a/configure.scm
+++ b/configure.scm
@@ -37,5 +37,55 @@
         (display (format "no~%error: no ~a found~%"))
         (exit #f))))
 
+(define (option-proc opt name arg result)
+  (cons (cons (string->symbol name) arg)
+        result))
+
+(define (unrecognized-option-proc opt name arg result)
+  (display (if arg
+               (format "Ignoring unrecognized option --~a=~a~%"
+                       name arg)
+               (format "Ignoring unrecognized option --~a~%"
+                       name)))
+  result)
+
+(define (unrecognized-argument-proc arg result)
+  (display (format "Ignoring unrecognized argument ~a~%"
+                   arg))
+  result)
+
+(define processed-args
+  (match (program-arguments)
+    ((_ args ...)
+     (let* ((args (args-fold args
+                             (list (option '("prefix") #t #f
+                                           option-proc))
+                             unrecognized-option-proc
+                             unrecognized-argument-proc
+                             '()))
+            (prefix (or (assq-ref args 'prefix)
+                        "/usr/local"))
+            (exec-prefix (or (assq-ref args 'exec-prefix)
+                             prefix))
+            (libdir (or (assq-ref args 'libdir)
+                        (string-append exec-prefix "/lib")))
+            (datarootdir (or (assq-ref args 'datarootdir)
+                             (string-append prefix "/share"))))
+       `((libdir . ,libdir)
+         (datarootdir . ,datarootdir))))))
+
 (check-for-guile-3.0)
 (check-for-module '(json))
+
+(call-with-output-file "Makefile.include"
+  (lambda (port)
+    (display (format "# This file was automatically generated by configure.
+
+libdir = ~a
+datarootdir = ~a
+guile_effective_version = ~a
+"
+                     (assq-ref processed-args 'libdir)
+                     (assq-ref processed-args 'datarootdir)
+                     (effective-version))
+             port)))