From c992c4d80f51540699f33fed067caf6b7c38df79 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 15 Jan 2012 22:41:53 +0000 Subject: Add GNU Guile as an optional embedded scripting language for make. On configure-enabled systems, configure will detect Guile installed (using pkg-config, which is how GNU Guile is distributed) and enable it if so. On all non-configure-enabled systems, currently, the default is for Guile support to be disabled. --- gmk-default.scm | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 gmk-default.scm (limited to 'gmk-default.scm') diff --git a/gmk-default.scm b/gmk-default.scm new file mode 100644 index 0000000..37db2f7 --- /dev/null +++ b/gmk-default.scm @@ -0,0 +1,57 @@ +;; Contents of the (gnu make) Guile module +;; Copyright (C) 2011 Free Software Foundation, Inc. +;; This file is part of GNU Make. +;; +;; GNU Make is free software; you can redistribute it and/or modify it under +;; the terms of the GNU General Public License as published by the Free +;; Software Foundation; either version 3 of the License, or (at your option) +;; any later version. +;; +;; GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY +;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +;; details. +;; +;; You should have received a copy of the GNU General Public License along +;; with this program. If not, see . + +(define (to-string-maybe x) + (cond + ;; In GNU make, "false" is the empty string + ((or (not x) + (unspecified? x) + (null? x) + (and (string? x) (string-null? x))) + #f) + ;; We want something not false... not sure about this + ((eq? x #t) "#t") + ;; Basics + ((or (symbol? x) (number? x)) + (object->string x)) + ((char? x) + (string x)) + ;; Printable string (no special characters) + ((and (string? x) + (eq? (string-length (string-delete x char-set:printing)) 0)) + x) + ;; No idea: fail + (else (error "Unknown object:" x)))) + +(define (obj-to-str x) + (let ((acc '())) + (define (walk x) + (cond ((pair? x) (walk (car x)) (walk (cdr x))) + ((to-string-maybe x) => (lambda (s) (set! acc (cons s acc)))))) + (walk x) + (string-join (reverse! acc)))) + +;; eval (GNU make eval) the input string S +(define (gmk-eval s) + (gmk-expand (format #f "$(eval ~a)" (obj-to-str s)))) + +;; Return the value of the GNU make variable V +(define (gmk-var v) + (gmk-expand (format #f "$(~a)" (obj-to-str v)))) + +;; Export the public interfaces +(export gmk-expand gmk-eval gmk-var) -- cgit v1.2.3