#| Copyright (C) 2025 Peter McGoron | | This program 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. | | This program 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-module (mcgoron guix gauche-build-system) #:use-module (guix build utils)) (define-public gauche-configure (lambda* (#:key build target outputs (configure-flags '()) out-of-source? (configure-file-name "configure") #:allow-other-keys) ;; Copied from gnu-build-system.scm, rev. f0c0769189d11debf7b237a02695c44c9773d52a ;; modified for Gauche. ;; Allows for the configure file to have a different name (not tested). (define (package-name) (let* ((out (assoc-ref outputs "out")) (base (basename out)) (dash (string-rindex base #\-))) ;; XXX: We'd rather use `package-name->name+version' or similar. (string-drop (if dash (substring base 0 dash) base) (+ 1 (string-index base #\-))))) (let* ((prefix (assoc-ref outputs "out")) (bindir (assoc-ref outputs "bin")) (libdir (assoc-ref outputs "lib")) (includedir (assoc-ref outputs "include")) (docdir (assoc-ref outputs "doc")) (flags `(,@(if target ; cross building '("CC_FOR_BUILD=gcc") '()) ,(string-append "--prefix=" prefix) ;; Produce multiple outputs when specific output names ;; are recognized. ,@(if bindir (list (string-append "--bindir=" bindir "/bin")) '()) ,@(if libdir (cons (string-append "--libdir=" libdir "/lib") (if includedir '() (list (string-append "--includedir=" libdir "/include")))) '()) ,@(if includedir (list (string-append "--includedir=" includedir "/include")) '()) ,@(if docdir (list (string-append "--docdir=" docdir "/share/doc/" (package-name))) '()) ,@(if build (list (string-append "--build=" build)) '()) ,@(if target ; cross building (list (string-append "--host=" target)) '()) ,@configure-flags)) (abs-srcdir (getcwd)) (srcdir (if out-of-source? (string-append "../" (basename abs-srcdir)) "."))) (format #t "source directory: ~s (relative from build: ~s)~%" abs-srcdir srcdir) (if out-of-source? (begin (mkdir "../build") (chdir "../build"))) (format #t "build directory: ~s~%" (getcwd)) (format #t "configure flags: ~s~%" flags) ;; Gauche configure scripts are written in Gauche. ;; ;; Call `configure' with a relative path. Otherwise, GCC's build system ;; (for instance) records absolute source file names, which typically ;; contain the hash part of the `.drv' file, leading to a reference leak. (apply invoke "gosh" (string-append srcdir "/" configure-file-name) flags))))