aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-01-04 23:36:35 +0530
committerArun Isaac2022-01-04 23:40:35 +0530
commit910f7405950a0aef98e4c58594867675ba48213b (patch)
treea85adb65a6010034c4a85eca72c2561fd0d62b1d
parente2e437acebca2946df6978d902542fe845d8de1d (diff)
downloadkolam-910f7405950a0aef98e4c58594867675ba48213b.tar.gz
kolam-910f7405950a0aef98e4c58594867675ba48213b.tar.lz
kolam-910f7405950a0aef98e4c58594867675ba48213b.zip
configure: Generate Makefile.include.
* configure.scm (option-proc, unrecognized-option-proc, unrecognized-argument-proc): New functions. (processed-args): New variable. Generate Makefile.include. * Makefile: Include Makefile.include. (clean): Clean Makefile.include.
-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)))