From 910f7405950a0aef98e4c58594867675ba48213b Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 4 Jan 2022 23:36:35 +0530 Subject: 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. --- Makefile | 4 +++- configure.scm | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) 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 # . +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))) -- cgit v1.2.3