2016-10-15 22:34:23 +00:00
|
|
|
#! /bin/sh
|
2018-11-11 09:38:02 +00:00
|
|
|
# -*-scheme-*-
|
|
|
|
MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)' -s "$0" ${1+"$@"}
|
2016-10-15 22:34:23 +00:00
|
|
|
!#
|
|
|
|
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; GNU Mes --- Maxwell Equations of Software
|
2020-10-06 11:43:11 +00:00
|
|
|
;;; Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2016-10-15 22:34:23 +00:00
|
|
|
;;;
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; configure: This file is part of GNU Mes.
|
2016-10-15 22:34:23 +00:00
|
|
|
;;;
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; GNU Mes is free software; you can redistribute it and/or modify it
|
2016-10-15 22:34:23 +00:00
|
|
|
;;; 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.
|
|
|
|
;;;
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; GNU Mes is distributed in the hope that it will be useful, but
|
2016-10-15 22:34:23 +00:00
|
|
|
;;; 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
|
2018-07-22 12:24:36 +00:00
|
|
|
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
2016-10-15 22:34:23 +00:00
|
|
|
|
|
|
|
(define-module (configure)
|
2018-07-21 16:28:47 +00:00
|
|
|
#:use-module (srfi srfi-1)
|
2018-07-21 19:20:48 +00:00
|
|
|
#:use-module (srfi srfi-9)
|
|
|
|
#:use-module (srfi srfi-9 gnu)
|
2018-05-06 06:46:32 +00:00
|
|
|
#:use-module (srfi srfi-26)
|
2016-10-15 22:34:23 +00:00
|
|
|
#:use-module (ice-9 getopt-long)
|
|
|
|
#:use-module (ice-9 optargs)
|
|
|
|
#:use-module (ice-9 popen)
|
2018-05-20 22:06:39 +00:00
|
|
|
#:use-module (ice-9 rdelim)
|
|
|
|
#:export (main))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
(define *shell* "sh")
|
|
|
|
(define PACKAGE "mes")
|
|
|
|
(define PACKAGE-NAME "GNU Mes")
|
|
|
|
(define PACKAGE-BUGREPORT "bug-mes@gnu.org")
|
2020-01-19 07:31:38 +00:00
|
|
|
(define VERSION "0.22")
|
2019-06-08 13:36:22 +00:00
|
|
|
|
2018-11-11 09:38:02 +00:00
|
|
|
(cond-expand
|
|
|
|
(guile)
|
|
|
|
(mes (mes-use-module (srfi srfi-1))
|
|
|
|
(mes-use-module (srfi srfi-9))
|
|
|
|
(mes-use-module (srfi srfi-9 gnu))
|
|
|
|
(mes-use-module (srfi srfi-26))
|
|
|
|
(mes-use-module (mes getopt-long))
|
|
|
|
(mes-use-module (mes guile))
|
|
|
|
(mes-use-module (mes misc))
|
|
|
|
(mes-use-module (mes optargs))
|
|
|
|
(define %host-type "x86_64-unknown-linux-gnu")
|
|
|
|
(define OPEN_READ "r")
|
|
|
|
(define (canonicalize-path o)
|
|
|
|
(if (string-prefix? "/" o) o
|
|
|
|
(string-append (getcwd) "/" o)))
|
|
|
|
(define (sort lst less)
|
|
|
|
lst)
|
|
|
|
(define (close-pipe o) 0)
|
|
|
|
(define (open-pipe* OPEN_READ . commands)
|
|
|
|
(let ((fake-pipe ".pipe"))
|
|
|
|
(with-output-to-file fake-pipe
|
|
|
|
(lambda _
|
|
|
|
(let ((status (apply system* (append commands))))
|
|
|
|
(set! close-pipe (lambda _ status)))))
|
|
|
|
(open-input-file fake-pipe)))))
|
|
|
|
|
2018-07-21 16:28:47 +00:00
|
|
|
(define* (PATH-search-path name #:key (default name) warn?)
|
|
|
|
(or (search-path (string-split (getenv "PATH") #\:) name)
|
|
|
|
(and (and warn? (format (current-error-port) "warning: not found: ~a\n" name))
|
|
|
|
default)))
|
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
;;; Utility
|
|
|
|
(define (logf port string . rest)
|
|
|
|
(apply format (cons* port string rest))
|
|
|
|
(force-output port)
|
|
|
|
#t)
|
|
|
|
|
|
|
|
(define (stderr string . rest)
|
|
|
|
(apply logf (cons* (current-error-port) string rest)))
|
|
|
|
|
|
|
|
(define (stdout string . rest)
|
|
|
|
(apply logf (cons* (current-output-port) string rest)))
|
|
|
|
|
2018-07-21 19:20:48 +00:00
|
|
|
(define %verbose? #f)
|
2017-04-12 19:27:59 +00:00
|
|
|
|
|
|
|
(define (verbose string . rest)
|
2018-07-21 19:20:48 +00:00
|
|
|
(if %verbose? (apply stderr (cons string rest))))
|
2017-04-12 19:27:59 +00:00
|
|
|
|
2019-12-04 20:18:45 +00:00
|
|
|
(define (gulp-pipe command)
|
2018-11-11 09:38:02 +00:00
|
|
|
(let* ((err (current-error-port))
|
|
|
|
(foo (set-current-error-port (open-output-file ".error")))
|
2019-12-04 20:18:45 +00:00
|
|
|
(port (open-pipe command "r"))
|
2017-04-12 19:27:59 +00:00
|
|
|
(output (read-string port))
|
2018-11-11 09:38:02 +00:00
|
|
|
(status (close-pipe port))
|
|
|
|
(error (with-input-from-file ".error" read-string)))
|
2019-02-18 06:22:50 +00:00
|
|
|
(when (file-exists? ".error")
|
|
|
|
(delete-file ".error"))
|
2018-11-11 09:38:02 +00:00
|
|
|
(set-current-error-port err)
|
|
|
|
(verbose "command[~a]: ~s => ~a [~a]\n" status command output error)
|
|
|
|
(if (not (zero? status)) ""
|
|
|
|
(string-trim-right (string-append output error)))))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
2019-12-04 20:18:45 +00:00
|
|
|
(define (gulp-pipe* . command)
|
|
|
|
(gulp-pipe (string-join command)))
|
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
(define (tuple< a b)
|
|
|
|
(cond
|
|
|
|
((and (null? a) (null? b)) #t)
|
|
|
|
((null? a) (not (null? b)))
|
|
|
|
((null? b) #f)
|
|
|
|
((and (not (< (car a) (car b)))
|
|
|
|
(not (< (car b) (car a))))
|
|
|
|
(tuple< (cdr a) (cdr b)))
|
|
|
|
(else (< (car a) (car b)))))
|
|
|
|
|
|
|
|
(define (tuple<= a b)
|
|
|
|
(or (equal? a b) (tuple< a b)))
|
|
|
|
|
2018-07-21 19:20:48 +00:00
|
|
|
(define (conjoin . predicates)
|
|
|
|
(lambda (. arguments)
|
|
|
|
(every (cut apply <> arguments) predicates)))
|
|
|
|
|
|
|
|
(define (char->char from to char)
|
|
|
|
(if (eq? char from) to char))
|
|
|
|
|
|
|
|
(define (string-replace-char string from to)
|
|
|
|
(string-map (cut char->char from to <>) string))
|
|
|
|
|
2018-11-11 09:38:02 +00:00
|
|
|
(define (string-replace-string string from to)
|
|
|
|
(cond ((string-contains string from)
|
|
|
|
=> (lambda (i) (string-replace string to i (+ i (string-length from)))))
|
|
|
|
(else string)))
|
|
|
|
|
|
|
|
(define (string-replace-string/all string from to)
|
|
|
|
(or (and=> (string-contains string from)
|
|
|
|
(lambda (i)
|
|
|
|
(string-append
|
|
|
|
(substring string 0 i)
|
|
|
|
to
|
|
|
|
(string-replace-string/all
|
|
|
|
(substring string (+ i (string-length from))) from to))))
|
|
|
|
string))
|
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
;;; Configure
|
2018-07-21 19:20:48 +00:00
|
|
|
|
|
|
|
(define-immutable-record-type <dependency>
|
2018-11-11 09:38:02 +00:00
|
|
|
(make-dependency name version-expected optional? version-option commands file-name data version-found)
|
2018-07-21 19:20:48 +00:00
|
|
|
dependency?
|
|
|
|
(name dependency-name)
|
|
|
|
(version-expected dependency-version-expected)
|
|
|
|
(optional? dependency-optional?)
|
2018-11-11 09:38:02 +00:00
|
|
|
(version-option dependency-version-option)
|
2018-07-21 19:20:48 +00:00
|
|
|
(commands dependency-commands)
|
|
|
|
(file-name dependency-file-name)
|
2018-11-11 09:38:02 +00:00
|
|
|
(data dependency-data)
|
|
|
|
(version-found dependency-version-found))
|
2018-07-21 19:20:48 +00:00
|
|
|
|
2019-12-13 16:21:53 +00:00
|
|
|
(define* (make-dep name #:key (version '()) optional? (version-option "--version") (commands (list name)) file-name data)
|
2018-07-21 22:43:39 +00:00
|
|
|
(let* ((env-var (getenv (name->shell-name name)))
|
|
|
|
(commands (if env-var (cons env-var commands) commands)))
|
2018-11-11 09:38:02 +00:00
|
|
|
(make-dependency name version optional? version-option commands file-name data #f)))
|
2018-07-21 19:20:48 +00:00
|
|
|
|
|
|
|
(define (find-dep name deps)
|
|
|
|
(find (compose (cut equal? <> name) dependency-name) deps))
|
|
|
|
|
|
|
|
(define (file-name name deps)
|
|
|
|
(and=> (find-dep name deps) dependency-file-name))
|
|
|
|
|
|
|
|
(define (variable-name dependency)
|
|
|
|
(and=>
|
|
|
|
(dependency-name dependency)
|
2018-07-21 22:43:39 +00:00
|
|
|
name->shell-name))
|
|
|
|
|
|
|
|
(define (name->shell-name name)
|
|
|
|
(string-upcase (string-replace-char name #\- #\_)))
|
2018-07-21 19:20:48 +00:00
|
|
|
|
2018-11-11 09:38:02 +00:00
|
|
|
(define (->string o)
|
|
|
|
(cond ((number? o) (number->string o))
|
|
|
|
((string? o) o)
|
|
|
|
(else (format #f "~a" o))))
|
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
(define (version->string version)
|
2018-11-11 09:38:02 +00:00
|
|
|
(and version (string-join (map ->string version) ".")))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
|
|
|
(define (string->version string)
|
2018-11-11 09:38:02 +00:00
|
|
|
(let ((split (string-tokenize string
|
|
|
|
(char-set-adjoin char-set:digit #\.))))
|
|
|
|
(and (pair? split)
|
2019-12-13 16:21:53 +00:00
|
|
|
(let* ((version (sort split (lambda (a b)
|
|
|
|
(let ((len-a (length (string-split a #\.)))
|
|
|
|
(len-b (length (string-split b #\.))))
|
|
|
|
(cond ((> len-a len-b) #t)
|
|
|
|
((< len-a len-b) #f)
|
|
|
|
(else (> (string-length a) (string-length b))))))))
|
2018-11-11 09:38:02 +00:00
|
|
|
(version (car version))
|
|
|
|
(version (string-tokenize version
|
|
|
|
(char-set-complement (char-set #\.)))))
|
|
|
|
(map string->number version)))))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
2018-07-21 19:20:48 +00:00
|
|
|
(define (check-program-version dependency)
|
|
|
|
(let ((name (dependency-name dependency))
|
|
|
|
(expected (dependency-version-expected dependency))
|
|
|
|
(version-option (dependency-version-option dependency))
|
|
|
|
(commands (dependency-commands dependency)))
|
|
|
|
(let loop ((commands commands))
|
2019-12-13 16:21:53 +00:00
|
|
|
(if (or (null? commands)
|
|
|
|
(not (car commands))) dependency
|
2018-07-21 19:20:48 +00:00
|
|
|
(let ((command (car commands)))
|
2019-12-13 16:21:53 +00:00
|
|
|
(stdout "checking for ~a~a... " (if (string-index command #\space) name command)
|
2018-07-21 19:20:48 +00:00
|
|
|
(if (null? expected) ""
|
|
|
|
(format #f " [~a]" (version->string expected))))
|
2019-12-04 20:18:45 +00:00
|
|
|
(let* ((output (gulp-pipe (string-append command " " (if version-option version-option ""))))
|
2018-07-21 19:20:48 +00:00
|
|
|
(actual (string->version output))
|
|
|
|
(pass? (and actual (tuple< expected actual)))
|
|
|
|
(dependency (set-field dependency (dependency-version-found) actual)))
|
2019-12-13 16:21:53 +00:00
|
|
|
(stdout "~a ~a\n" (if pass? (if (pair? actual) "" "yes")
|
2018-11-11 09:38:02 +00:00
|
|
|
(if actual " no, found" "no"))
|
|
|
|
(or (version->string actual) ""))
|
2018-07-21 19:20:48 +00:00
|
|
|
(if pass? (let ((file-name (or (PATH-search-path command)
|
|
|
|
(dependency-file-name dependency))))
|
|
|
|
(set-field dependency (dependency-file-name) file-name))
|
|
|
|
(loop (cdr commands)))))))))
|
|
|
|
|
|
|
|
(define (check-file dependency)
|
|
|
|
(stdout "checking for ~a... " (dependency-name dependency))
|
|
|
|
(let ((file-name (and (file-exists? (dependency-file-name dependency))
|
|
|
|
(dependency-file-name dependency))))
|
|
|
|
(stdout "~a\n" (or file-name ""))
|
|
|
|
(set-field dependency (dependency-file-name) file-name)))
|
|
|
|
|
2018-11-06 19:29:35 +00:00
|
|
|
(define* (check-header-c cc dependency #:optional (check check-preprocess-header-c))
|
2018-07-21 19:20:48 +00:00
|
|
|
(let ((name (dependency-name dependency)))
|
|
|
|
(stderr "checking for ~a..." name)
|
2018-11-06 19:29:35 +00:00
|
|
|
(let ((result (check cc name)))
|
2019-02-18 06:22:50 +00:00
|
|
|
(when (file-exists? ".config.c")
|
|
|
|
(delete-file ".config.c"))
|
2018-07-21 19:20:48 +00:00
|
|
|
(stderr " ~a\n" (if result "yes" "no"))
|
|
|
|
(if result (set-field dependency (dependency-file-name) name)
|
2018-11-06 19:29:35 +00:00
|
|
|
dependency))))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
2018-11-06 19:29:35 +00:00
|
|
|
(define* (check-compile-c cc dependency #:optional (check check-compile-string-c))
|
|
|
|
(let ((name (dependency-name dependency)))
|
|
|
|
(stderr "checking for ~a..." name)
|
|
|
|
(let ((result (check cc (dependency-data dependency))))
|
2019-02-18 06:22:50 +00:00
|
|
|
(when (file-exists? ".config.c")
|
|
|
|
(delete-file ".config.c"))
|
2018-11-06 19:29:35 +00:00
|
|
|
(stderr " ~a\n" (if result "yes" "no"))
|
|
|
|
(if result (set-field dependency (dependency-file-name) name)
|
|
|
|
dependency))))
|
|
|
|
|
|
|
|
(define* (check-link-c cc dependency #:optional (check check-link-string-c))
|
|
|
|
(let ((name (dependency-name dependency)))
|
|
|
|
(stderr "checking for ~a..." name)
|
|
|
|
(let ((result (check cc (dependency-data dependency))))
|
2019-02-18 06:22:50 +00:00
|
|
|
(when (file-exists? ".config.c")
|
|
|
|
(delete-file ".config.c"))
|
2018-11-06 19:29:35 +00:00
|
|
|
(stderr " ~a\n" (if result "yes" "no"))
|
|
|
|
(if result (set-field dependency (dependency-file-name) name)
|
|
|
|
dependency))))
|
|
|
|
|
2019-12-05 07:51:27 +00:00
|
|
|
(define (cflags-list)
|
|
|
|
(let ((cflags (getenv "CFLAGS")))
|
|
|
|
(if cflags (list cflags)
|
|
|
|
'())))
|
|
|
|
|
|
|
|
(define (ldflags-list)
|
|
|
|
(let ((ldflags (getenv "LDFLAGS")))
|
|
|
|
(if ldflags (list ldflags)
|
|
|
|
'())))
|
|
|
|
|
2018-11-06 19:29:35 +00:00
|
|
|
(define (check-preprocess-header-c cc header)
|
2018-11-11 09:38:02 +00:00
|
|
|
(with-output-to-file ".config.c"
|
|
|
|
(cut format #t "#include \"~a\"" header))
|
2019-12-05 07:51:27 +00:00
|
|
|
(let ((test (lambda _ (apply system* `(,cc "-E" "-o" ".config.E" ,@(cflags-list) ".config.c")))))
|
|
|
|
(zero? (if %verbose? (test)
|
|
|
|
(with-error-to-file "/dev/null"
|
|
|
|
test)))))
|
2018-11-06 19:29:35 +00:00
|
|
|
|
|
|
|
(define (check-compile-string-c cc string)
|
2018-11-11 09:38:02 +00:00
|
|
|
(with-output-to-file ".config.c"
|
|
|
|
(cut display string))
|
2019-12-12 05:55:43 +00:00
|
|
|
(let ((test (lambda _ (apply system* `(,cc "-std=gnu99" "-c" "-o" ".config.o" ,@(cflags-list) ".config.c")))))
|
2019-12-05 07:51:27 +00:00
|
|
|
(zero? (if %verbose? (test)
|
|
|
|
(with-error-to-file "/dev/null"
|
|
|
|
test)))))
|
2018-11-06 19:29:35 +00:00
|
|
|
|
|
|
|
(define (check-link-string-c cc string)
|
2018-11-11 09:38:02 +00:00
|
|
|
(with-output-to-file ".config.c"
|
|
|
|
(cut display string))
|
2019-12-12 05:55:43 +00:00
|
|
|
(let ((test (lambda _ (apply system* `(,cc "-std=gnu99" "-o" ".config" ,@(cflags-list) ,@(ldflags-list) ".config.c")))))
|
2019-12-05 07:51:27 +00:00
|
|
|
(zero? (if %verbose? (test)
|
|
|
|
(with-error-to-file "/dev/null"
|
|
|
|
test)))))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
|
|
|
(define (parse-opts args)
|
|
|
|
(let* ((option-spec
|
|
|
|
'((build (value #t))
|
2017-04-12 19:27:59 +00:00
|
|
|
(host (value #t))
|
2018-11-11 09:38:02 +00:00
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
(prefix (value #t))
|
2018-11-06 19:29:35 +00:00
|
|
|
(program-prefix (value #t))
|
2018-07-22 12:44:50 +00:00
|
|
|
(bindir (value #t))
|
|
|
|
(datadir (value #t))
|
|
|
|
(docdir (value #t))
|
2019-06-08 13:36:22 +00:00
|
|
|
(includedir (value #t))
|
2018-07-22 12:44:50 +00:00
|
|
|
(libdir (value #t))
|
2018-07-23 18:03:57 +00:00
|
|
|
(srcdir (value #t))
|
2016-10-15 22:34:23 +00:00
|
|
|
(sysconfdir (value #t))
|
2018-11-11 09:38:02 +00:00
|
|
|
|
|
|
|
(mes)
|
|
|
|
(help (single-char #\h))
|
2017-04-12 19:27:59 +00:00
|
|
|
(verbose (single-char #\v))
|
2019-12-08 14:32:51 +00:00
|
|
|
(with-bootstrap)
|
2018-07-25 06:14:13 +00:00
|
|
|
(with-cheating)
|
2017-05-14 07:03:06 +00:00
|
|
|
(with-courage)
|
2018-07-09 08:46:28 +00:00
|
|
|
(infodir (value #t))
|
|
|
|
(mandir (value #t))
|
2019-06-08 13:36:22 +00:00
|
|
|
(disable-colors)
|
|
|
|
(enable-colors)
|
2018-07-09 08:46:28 +00:00
|
|
|
(disable-silent-rules)
|
2018-07-25 06:14:13 +00:00
|
|
|
(enable-silent-rules)
|
2019-06-08 13:36:22 +00:00
|
|
|
(with-system-libc)
|
2018-07-09 08:46:28 +00:00
|
|
|
|
|
|
|
(enable-fast-install) ; Ignored for Guix
|
|
|
|
(mandir (value #t)) ; Ignored for Debian
|
|
|
|
(localstatedir (value #t)) ; Ignored for Debian
|
|
|
|
(libexecdir (value #t)) ; Ignored for Debian
|
|
|
|
(runstatedir (value #t)) ; Ignored for Debian
|
|
|
|
(disable-maintainer-mode) ; Ignored for Debian
|
|
|
|
(disable-dependency-tracking) ; Ignored for Debian
|
|
|
|
)))
|
|
|
|
|
2018-06-12 05:05:33 +00:00
|
|
|
(getopt-long args option-spec)))
|
2018-05-06 06:46:32 +00:00
|
|
|
|
|
|
|
(define* (print-help #:optional (port (current-output-port)))
|
|
|
|
(format port "\
|
|
|
|
`configure' configures ~a ~a to adapt to many kinds of systems.
|
|
|
|
|
|
|
|
Usage: ./configure [OPTION]... [VAR=VALUE]
|
|
|
|
|
|
|
|
To assign environment variables (e.g., CC, CFLAGS...), specify them as
|
|
|
|
VAR=VALUE. See below for descriptions of some of the useful variables.
|
|
|
|
|
|
|
|
Defaults for the options are specified in brackets.
|
|
|
|
|
|
|
|
Options:
|
2016-10-15 22:34:23 +00:00
|
|
|
-h, --help display this help
|
2017-04-12 19:27:59 +00:00
|
|
|
--build=BUILD configure for building on BUILD [guessed]
|
2019-06-08 13:36:22 +00:00
|
|
|
--colors no colorized output
|
2018-07-09 08:46:28 +00:00
|
|
|
--disable-silent-rules
|
2018-11-06 19:29:35 +00:00
|
|
|
verbose build output [V=1]
|
2017-04-12 19:27:59 +00:00
|
|
|
--host=HOST cross-compile to build programs to run on HOST [BUILD]
|
|
|
|
-v, --verbose be verbose
|
2019-12-08 14:32:51 +00:00
|
|
|
--with-bootstrap After building mes with CC, build mes with MesCC
|
2019-06-08 13:36:22 +00:00
|
|
|
--with-courage Assert that even if this platform is unsupported,
|
|
|
|
you will be courageous and port GNU Mes to it
|
|
|
|
(see \"Porting GNU Mes\" in the manual.)
|
2018-07-25 06:14:13 +00:00
|
|
|
--with-cheating cheat using Guile instead of Mes
|
2019-06-08 13:36:22 +00:00
|
|
|
--with-system-libc use system libc
|
2018-05-06 06:46:32 +00:00
|
|
|
|
|
|
|
Installation directories:
|
2018-07-09 08:46:28 +00:00
|
|
|
--prefix=DIR install in prefix DIR [~a]
|
2019-06-08 13:36:22 +00:00
|
|
|
|
|
|
|
--bindir=DIR user executables [PREFIX/bin]
|
|
|
|
--includedir=DIR C header files [PREFIX/include]
|
2018-07-09 08:46:28 +00:00
|
|
|
--infodir=DIR info documentation [PREFIX/share/info]
|
2019-06-08 13:36:22 +00:00
|
|
|
--libdir=DIR object code libraries [EPREFIX/lib]
|
2018-07-09 08:46:28 +00:00
|
|
|
--mandir=DIR man pages [PREFIX/share/man]
|
|
|
|
|
2018-11-06 19:29:35 +00:00
|
|
|
Program names:
|
|
|
|
--program-prefix=PREFIX prepend PREFIX to installed program names
|
|
|
|
--program-suffix=SUFFIX append SUFFIX to installed program names
|
|
|
|
|
2018-07-09 08:46:28 +00:00
|
|
|
Ignored for Guix:
|
|
|
|
--enable-fast-install
|
|
|
|
|
|
|
|
Ignored for Debian:
|
|
|
|
--disable-dependency-tracking
|
|
|
|
--disable-maintainer-mode
|
|
|
|
--libexecdir=DIR
|
|
|
|
--localstatedir=DIR
|
|
|
|
--runstatedir=DIR
|
2018-05-06 06:46:32 +00:00
|
|
|
|
|
|
|
Some influential environment variables:
|
2018-06-16 04:37:20 +00:00
|
|
|
CC C compiler command
|
|
|
|
CFLAGS C compiler flags
|
2019-11-03 21:15:11 +00:00
|
|
|
CPPFLAGS C preprocessor flags
|
|
|
|
LDFLAGS C linker flags
|
2018-06-16 04:37:20 +00:00
|
|
|
GUILE guile command
|
2018-11-06 19:29:35 +00:00
|
|
|
GUILD guild command
|
2020-10-07 11:55:06 +00:00
|
|
|
GUILD_OPTIMIZE guild compile optimization
|
2019-12-15 09:10:23 +00:00
|
|
|
GUILE_LOAD_PATH guile load path; where to find Nyacc
|
2018-11-06 19:29:35 +00:00
|
|
|
MES_FOR_BUILD build system MES [can be mes or guile]
|
2018-07-09 08:46:28 +00:00
|
|
|
" PACKAGE VERSION (getenv "prefix")))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
|
|
|
(define (main args)
|
2018-07-22 12:44:50 +00:00
|
|
|
(let* ((options (parse-opts args))
|
|
|
|
(build-type (option-ref options 'build %host-type))
|
2019-05-22 15:55:20 +00:00
|
|
|
(host-type (option-ref options 'host build-type))
|
2018-07-22 12:44:50 +00:00
|
|
|
|
|
|
|
(prefix "/usr/local")
|
|
|
|
(prefix (option-ref options 'prefix prefix))
|
2018-11-06 19:29:35 +00:00
|
|
|
(program-prefix (option-ref options 'program-prefix ""))
|
|
|
|
(program-suffix (option-ref options 'program-suffix ""))
|
2018-07-22 12:44:50 +00:00
|
|
|
(infodir (option-ref options 'infodir "${prefix}/share/info"))
|
2019-05-15 13:18:38 +00:00
|
|
|
(mandir (option-ref options 'mandir "${prefix}/share/man"))
|
2018-07-22 12:44:50 +00:00
|
|
|
(sysconfdir (option-ref options 'sysconfdir "${prefix}/etc"))
|
|
|
|
|
2018-08-09 09:00:10 +00:00
|
|
|
(bindir (option-ref options 'bindir "${prefix}/bin"))
|
2018-07-22 12:44:50 +00:00
|
|
|
(datadir (option-ref options 'datadir "${prefix}/share"))
|
2019-11-04 22:54:30 +00:00
|
|
|
(docdir (option-ref options 'docdir "${datadir}/doc/mes"))
|
2019-11-13 08:23:27 +00:00
|
|
|
(includedir (option-ref options 'includedir "${prefix}/include"))
|
2018-07-22 12:44:50 +00:00
|
|
|
(libdir (option-ref options 'libdir "${prefix}/lib"))
|
2019-06-08 13:36:22 +00:00
|
|
|
(pkgdatadir (string-append datadir "/mes"))
|
2019-12-15 09:10:23 +00:00
|
|
|
(guile-load-path (if (and (pair? %load-path) (equal? (car %load-path) ".")) (cdr %load-path)
|
|
|
|
%load-path))
|
2018-07-22 12:44:50 +00:00
|
|
|
(guile-effective-version (effective-version))
|
|
|
|
(guile-site-dir (if (equal? prefix ".") (canonicalize-path ".")
|
2018-11-25 12:21:03 +00:00
|
|
|
(string-append prefix "/share/guile/site/" guile-effective-version)))
|
2018-07-22 12:44:50 +00:00
|
|
|
(guile-site-ccache-dir (if (equal? prefix ".") (canonicalize-path ".")
|
2018-11-25 12:21:03 +00:00
|
|
|
(string-append prefix "/lib/guile/" guile-effective-version "/site-ccache")))
|
2018-07-21 19:20:48 +00:00
|
|
|
|
2018-07-21 16:28:47 +00:00
|
|
|
(srcdir (dirname (car (command-line))))
|
2018-07-25 06:14:13 +00:00
|
|
|
(srcdest (if (equal? srcdir ".") ""
|
|
|
|
(string-append srcdir "/")))
|
2018-07-21 16:28:47 +00:00
|
|
|
(abs-top-srcdir (canonicalize-path srcdir))
|
2018-07-21 22:43:39 +00:00
|
|
|
(abs-top-builddir (canonicalize-path (getcwd)))
|
|
|
|
(top-builddir (if (equal? srcdir ".") "."
|
|
|
|
abs-top-builddir))
|
2018-07-21 19:20:48 +00:00
|
|
|
|
2019-12-08 14:32:51 +00:00
|
|
|
(with-bootstrap? (option-ref options 'with-bootstrap #f))
|
2018-07-25 06:14:13 +00:00
|
|
|
(with-cheating? (option-ref options 'with-cheating #f))
|
2017-07-02 14:25:14 +00:00
|
|
|
(with-courage? (option-ref options 'with-courage #f))
|
2019-06-08 13:36:22 +00:00
|
|
|
(disable-colors? (option-ref options 'disable-colors #f))
|
|
|
|
(enable-colors? (option-ref options 'enable-colors #f))
|
2018-07-09 08:46:28 +00:00
|
|
|
(disable-silent-rules? (option-ref options 'disable-silent-rules #f))
|
2018-07-25 06:14:13 +00:00
|
|
|
(enable-silent-rules? (option-ref options 'enable-silent-rules #f))
|
2019-06-08 13:36:22 +00:00
|
|
|
(with-system-libc? (option-ref options 'with-system-libc #f))
|
2018-05-06 06:46:32 +00:00
|
|
|
(vars (filter (cut string-index <> #\=) (option-ref options '() '())))
|
2018-11-06 19:29:35 +00:00
|
|
|
(help? (option-ref options 'help #f))
|
|
|
|
(mes? (option-ref options 'mes #f)))
|
2018-07-21 19:20:48 +00:00
|
|
|
(when help?
|
|
|
|
(print-help)
|
|
|
|
(exit 0))
|
|
|
|
(set! %verbose? (option-ref options 'verbose #f))
|
2018-07-22 12:44:50 +00:00
|
|
|
(when %verbose?
|
|
|
|
(stderr "configure args=~s\n" args))
|
2018-05-06 06:46:32 +00:00
|
|
|
(for-each (lambda (v) (apply setenv (string-split v #\=))) vars)
|
2019-12-12 05:55:43 +00:00
|
|
|
(let* ((cross? (not (equal? host-type build-type)))
|
2019-12-13 16:21:53 +00:00
|
|
|
(gcc (if cross? (string-append host-type "-" "gcc") "gcc"))
|
|
|
|
(tcc (if cross? (string-append host-type "-" "tcc") "tcc"))
|
|
|
|
(mescc (if cross? (string-append host-type "-" "mescc") "mescc"))
|
2018-07-21 19:20:48 +00:00
|
|
|
(deps (fold (lambda (program results)
|
|
|
|
(cons (check-program-version program) results))
|
|
|
|
'()
|
2019-12-07 13:39:19 +00:00
|
|
|
(list (make-dep "hex2")
|
|
|
|
(make-dep "M1")
|
|
|
|
(make-dep "blood-elf")
|
2019-06-08 13:36:22 +00:00
|
|
|
(make-dep "diff" #:optional? #t)
|
2020-10-06 11:43:11 +00:00
|
|
|
(make-dep "guile" #:version '(2 0) #:commands '("guile-3.0" "guile-3" "guile-2.2" "guile-2.0" "guile-2" "guile") #:optional? #t)
|
2019-09-08 07:31:38 +00:00
|
|
|
(make-dep "mes" #:version '(0 20) #:optional? #t)
|
2020-01-19 10:27:53 +00:00
|
|
|
(make-dep "guix" #:version '() #:optional? #t)
|
2018-11-11 09:38:02 +00:00
|
|
|
(make-dep "ar" #:version '(2 10) #:optional? #t)
|
2019-12-13 16:21:53 +00:00
|
|
|
(make-dep "sh" #:optional? #t)
|
2018-11-11 09:38:02 +00:00
|
|
|
(make-dep "bash" #:version '(2 0) #:optional? #t)
|
2019-12-08 15:39:53 +00:00
|
|
|
(make-dep "guild" #:version '(2 0) #:commands '("guild" "guile-tools" "true"))
|
2019-12-13 16:21:53 +00:00
|
|
|
(make-dep "CC" #:commands `(,(getenv "CC")) #:optional? #t)
|
|
|
|
(make-dep "CC-v" #:commands `(,(getenv "CC")) #:optional? #t #:version-option "-v")
|
|
|
|
(make-dep "cc" #:commands '("cc") #:optional? #t)
|
|
|
|
(make-dep "gcc" #:commands `(,gcc "gcc") #:optional? #t)
|
|
|
|
(make-dep "mescc" #:commands `(,mescc "mescc") #:optional? #t)
|
|
|
|
(make-dep "tcc" #:commands `(,tcc "tcc") #:optional? #t #:version-option "-v")
|
|
|
|
(make-dep "cc-v" #:commands '("cc") #:optional? #t #:version-option "-v")
|
2019-12-11 00:10:22 +00:00
|
|
|
(make-dep "make" #:optional? #t #:commands '("gmake" "make"))
|
2019-12-13 16:21:53 +00:00
|
|
|
(make-dep "makeinfo" #:version '(6) #:optional? #t)
|
2018-11-11 09:38:02 +00:00
|
|
|
(make-dep "dot" #:version-option "-V" #:optional? #t)
|
|
|
|
(make-dep "help2man" #:version '(1 47) #:optional? #t)
|
2019-12-04 17:49:39 +00:00
|
|
|
(make-dep "perl" #:version '(5) #:optional? #t))))
|
2018-11-11 09:38:02 +00:00
|
|
|
(guile (file-name "guile" deps))
|
2020-10-07 11:55:06 +00:00
|
|
|
;; See https://bugs.gnu.org/43831; use -O1 with Guile-3
|
|
|
|
(guild-optimize (let ((guile-version (and=> (find-dep "guile" deps) dependency-version-found)))
|
|
|
|
(and guile-version (tuple< '(2) guile-version) "-O1")))
|
2019-12-04 20:18:45 +00:00
|
|
|
(deps (if guile (cons (check-program-version (make-dep "nyacc" #:version '(0 99 0) #:commands (list (string-append guile " -c '(use-modules (nyacc lalr)) (display *nyacc-version*)'")) #:file-name #t #:version-option #f))
|
2018-11-11 09:38:02 +00:00
|
|
|
deps)
|
|
|
|
deps))
|
|
|
|
(guile (or guile "guile"))
|
2019-12-13 16:21:53 +00:00
|
|
|
(cc (or (file-name "CC" deps)
|
|
|
|
(file-name "CC-v" deps)
|
2019-12-12 05:55:43 +00:00
|
|
|
(file-name "tcc" deps)
|
2019-12-13 16:21:53 +00:00
|
|
|
(file-name "gcc" deps)
|
|
|
|
(file-name "cc" deps)
|
|
|
|
(file-name "cc-v" deps)
|
2019-12-12 05:55:43 +00:00
|
|
|
(file-name "mescc" deps)))
|
2018-11-06 19:29:35 +00:00
|
|
|
(deps (if cc
|
|
|
|
(cons* (check-header-c cc (make-dep "limits.h"))
|
|
|
|
(check-header-c cc (make-dep "stdio.h" #:optional? #t))
|
2018-07-21 19:20:48 +00:00
|
|
|
deps)
|
|
|
|
deps))
|
|
|
|
(missing (filter (conjoin (negate dependency-file-name)
|
2018-11-06 19:29:35 +00:00
|
|
|
(negate dependency-optional?)) deps))
|
|
|
|
(deps (if cc
|
|
|
|
(cons (check-compile-c cc (make-dep "cc is GNU C" #:data "#if !defined (__GNUC__)
|
|
|
|
#error no gnuc
|
|
|
|
#endif
|
|
|
|
"))
|
|
|
|
deps)
|
|
|
|
deps))
|
|
|
|
(gcc? (file-name "cc is GNU C" deps))
|
|
|
|
(deps (if cc
|
|
|
|
(cons (check-compile-c cc (make-dep "cc is Mes C" #:data "#if !defined (__MESC__)
|
|
|
|
#error no mesc
|
|
|
|
#endif
|
|
|
|
"))
|
|
|
|
deps)
|
|
|
|
deps))
|
2019-12-12 05:55:43 +00:00
|
|
|
(mesc? (file-name "cc is MES C" deps))
|
2018-11-06 19:29:35 +00:00
|
|
|
(deps (if cc
|
2019-12-13 16:21:53 +00:00
|
|
|
(cons (check-compile-c cc (make-dep "cc is Tiny C" #:data "#if !defined (__TINYC__)
|
2018-11-06 19:29:35 +00:00
|
|
|
#error no tinycc
|
|
|
|
#endif
|
|
|
|
"))
|
|
|
|
deps)
|
|
|
|
deps))
|
2019-12-13 16:21:53 +00:00
|
|
|
(tcc? (file-name "cc is Tiny C" deps))
|
2018-11-06 19:29:35 +00:00
|
|
|
(deps (if cc
|
2019-12-13 16:21:53 +00:00
|
|
|
(cons (check-link-c cc (make-dep "whether cc can create executables" #:data "int main () {return 0;}"))
|
2018-11-06 19:29:35 +00:00
|
|
|
deps)
|
|
|
|
deps))
|
2019-06-08 13:36:22 +00:00
|
|
|
(system-libc? (and with-system-libc? (file-name "if cc can create executables" deps)))
|
2019-12-12 05:55:43 +00:00
|
|
|
(host-type (or (and cc (let ((dump (gulp-pipe* cc "-dumpmachine")))
|
|
|
|
(and (not (string-null? dump)) dump))) host-type))
|
2019-12-08 14:48:27 +00:00
|
|
|
(host-type-list (string-split host-type #\-))
|
|
|
|
(mes-cpu (car host-type-list))
|
2019-05-22 15:55:20 +00:00
|
|
|
(mes-cpu (cond ((member mes-cpu '("i386" "i486" "i586" "i686")) "x86")
|
|
|
|
((member mes-cpu '("arm" "armv4" "armv7l")) "arm")
|
|
|
|
(else mes-cpu)))
|
2019-06-08 13:36:22 +00:00
|
|
|
(mes-bits (if (member mes-cpu '("x86_64")) "64"
|
|
|
|
"32"))
|
|
|
|
(mes-libc (if system-libc? "system" "mes"))
|
2019-12-11 07:16:46 +00:00
|
|
|
(mes-kernel (car (filter
|
|
|
|
(compose not
|
|
|
|
(cut member <> '("pc" "portbld" "unknown")))
|
|
|
|
(cdr host-type-list))))
|
|
|
|
(mes-kernel (if (string-prefix? "freebsd" mes-kernel) "freebsd" mes-kernel))
|
2019-12-13 16:21:53 +00:00
|
|
|
(mes-compiler (cond (gcc? "gcc") (tcc? "gcc") (else "mescc")))
|
2019-11-09 09:59:01 +00:00
|
|
|
(mes-system (string-join (list mes-cpu mes-kernel "mes") "-"))
|
|
|
|
(bash (or (and (file-exists? "/bin/bash") "/bin/bash")
|
|
|
|
(file-name "bash" deps)
|
|
|
|
""))
|
|
|
|
(shell (or (and (file-exists? "/bin/bash") "/bin/bash")
|
|
|
|
(file-name "bash" deps)
|
|
|
|
(and (file-exists? "/bin/sh") "/bin/sh")
|
|
|
|
(file-name "sh" deps)
|
2019-12-07 13:39:19 +00:00
|
|
|
"sh"))
|
|
|
|
(hex2 (file-name "hex2" deps))
|
|
|
|
(numbered-arch? (begin
|
|
|
|
(stdout "checking for stage0 architecture flag... ")
|
|
|
|
(let ((numbered? (and hex2 (string-contains (gulp-pipe (string-append hex2 " --help 2>&1" )) "--Architecture 12345"))))
|
|
|
|
(stdout (if numbered? "numbered\n" "named\n"))
|
|
|
|
numbered?))))
|
2018-07-21 22:43:39 +00:00
|
|
|
|
|
|
|
(define* (substitute file-name pairs
|
|
|
|
#:key (target (if (string-suffix? ".in" file-name)
|
|
|
|
(string-drop-right file-name 3) file-name)))
|
|
|
|
(system* "mkdir" "-p" (dirname target))
|
|
|
|
(with-output-to-file target
|
|
|
|
(lambda _
|
2018-11-11 09:38:02 +00:00
|
|
|
(let ((in (open-input-file file-name)))
|
|
|
|
(let loop ((line (read-line in 'concat)))
|
|
|
|
(when (not (eof-object? line))
|
|
|
|
(display (fold (lambda (o result)
|
|
|
|
(string-replace-string/all result (car o) (cdr o)))
|
|
|
|
line pairs))
|
|
|
|
(loop (read-line in 'concat))))))))
|
2018-07-21 22:43:39 +00:00
|
|
|
|
2019-05-22 15:55:20 +00:00
|
|
|
(when (and (not (member mes-system '("arm-linux-mes"
|
|
|
|
"x86-linux-mes"
|
|
|
|
"x86_64-linux-mes")))
|
|
|
|
(not with-courage?))
|
|
|
|
(stderr "platform not supported: ~a
|
|
|
|
See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
|
2018-05-06 06:46:32 +00:00
|
|
|
(exit 1))
|
2018-07-21 19:20:48 +00:00
|
|
|
(when (pair? missing)
|
|
|
|
(stderr "\nMissing dependencies: ~a\n" (string-join (map dependency-name missing)))
|
2018-05-06 06:46:32 +00:00
|
|
|
(exit 1))
|
2018-11-06 19:29:35 +00:00
|
|
|
(let ((pairs `(("@PACKAGE@" . ,PACKAGE)
|
2019-06-08 13:36:22 +00:00
|
|
|
("@PACKAGE_NAME@" . ,PACKAGE-NAME)
|
|
|
|
("@PACKAGE_BUGREPORT@" . ,PACKAGE-BUGREPORT)
|
2018-11-06 19:29:35 +00:00
|
|
|
("@VERSION@" . ,VERSION)
|
|
|
|
|
|
|
|
("@build@" . ,build-type)
|
|
|
|
("@host@" . ,host-type)
|
|
|
|
|
2019-11-03 21:15:11 +00:00
|
|
|
("@bootstrap@" . ,(if with-bootstrap? "true" "false"))
|
2019-06-08 13:36:22 +00:00
|
|
|
("@courageous@" . ,(if with-courage? "true" "false"))
|
2019-12-13 16:21:53 +00:00
|
|
|
("@compiler@" . ,mes-compiler)
|
2019-06-08 13:36:22 +00:00
|
|
|
("@mes_bits@" . ,mes-bits)
|
|
|
|
("@mes_kernel@" . ,mes-kernel)
|
|
|
|
("@mes_cpu@" . ,mes-cpu)
|
|
|
|
("@mes_libc@" . ,mes-libc)
|
|
|
|
("@mes_system@" . ,mes-system)
|
2018-11-06 19:29:35 +00:00
|
|
|
|
2018-07-21 22:43:39 +00:00
|
|
|
("@abs_top_srcdir@" . ,abs-top-srcdir)
|
2018-07-21 16:28:47 +00:00
|
|
|
("@abs_top_builddir@" . ,abs-top-builddir)
|
2018-07-21 22:43:39 +00:00
|
|
|
("@top_builddir@" . ,top-builddir)
|
2018-11-06 19:29:35 +00:00
|
|
|
|
|
|
|
("@srcdest@" . ,srcdest)
|
|
|
|
("@srcdir@" . ,srcdir)
|
|
|
|
|
2018-08-09 06:58:20 +00:00
|
|
|
("@prefix@" . ,prefix)
|
2018-11-06 19:29:35 +00:00
|
|
|
("@program_prefix@" . ,program-prefix)
|
|
|
|
("@bindir@" . ,bindir)
|
|
|
|
("@datadir@" . ,datadir)
|
2019-06-08 13:36:22 +00:00
|
|
|
("@pkgdatadir@" . ,pkgdatadir)
|
2018-11-06 19:29:35 +00:00
|
|
|
("@docdir@" . ,docdir)
|
2018-07-21 16:28:47 +00:00
|
|
|
("@guile_site_ccache_dir@" . ,guile-site-ccache-dir)
|
2018-11-06 19:29:35 +00:00
|
|
|
("@guile_site_dir@" . ,guile-site-dir)
|
|
|
|
("@infodir@" . ,infodir)
|
2019-06-08 13:36:22 +00:00
|
|
|
("@includedir@" . ,includedir)
|
2018-11-06 19:29:35 +00:00
|
|
|
("@libdir@" . ,libdir)
|
|
|
|
("@mandir@" . ,mandir)
|
|
|
|
("@sysconfdir@" . ,sysconfdir)
|
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
("@colors@" . ,(if disable-colors? "no" "yes"))
|
2019-05-29 14:55:57 +00:00
|
|
|
("@V@" . ,(if disable-silent-rules? "1" "0"))
|
2018-11-06 19:29:35 +00:00
|
|
|
|
|
|
|
("@AR@" . ,(or (file-name "ar" deps) ""))
|
2019-11-09 09:59:01 +00:00
|
|
|
("@BASH@" . ,bash)
|
2019-12-13 16:21:53 +00:00
|
|
|
("@CC@" . ,cc)
|
2019-06-08 13:36:22 +00:00
|
|
|
("@DIFF@" . ,(or (file-name "diff" deps) (string-append abs-top-builddir "/pre-inst-env diff.scm")))
|
2018-11-11 09:38:02 +00:00
|
|
|
("@DOT@" . ,(or (file-name "dot" deps) ""))
|
2019-12-07 19:10:05 +00:00
|
|
|
("@GIT@" . ,(or (file-name "git" deps) ""))
|
2020-10-07 11:55:06 +00:00
|
|
|
("@GUILD_OPTIMIZE@" . ,(or (getenv "GUILD_OPTIMIZE") guild-optimize ""))
|
2018-11-11 09:38:02 +00:00
|
|
|
("@GUILE@" . ,guile)
|
2019-12-15 09:10:23 +00:00
|
|
|
("@GUILE_EFFECTIVE_VERSION@" . ,(effective-version))
|
|
|
|
("@GUILE_LOAD_PATH@" . ,(string-join guile-load-path ":"))
|
2018-11-06 19:29:35 +00:00
|
|
|
("@GUIX@" . ,(or (file-name "guix" deps) ""))
|
|
|
|
("@HELP2MAN@" . ,(or (file-name "help2man" deps) ""))
|
|
|
|
("@MAKEINFO@" . ,(or (file-name "makeinfo" deps) ""))
|
|
|
|
("@MES_FOR_BUILD@" . ,(or (file-name "mes" deps)
|
2018-11-11 09:38:02 +00:00
|
|
|
guile))
|
2018-11-06 19:29:35 +00:00
|
|
|
("@PERL@" . ,(or (file-name "perl" deps) ""))
|
2019-07-20 16:56:58 +00:00
|
|
|
("#SCHEME=\"@SCHEME@\"" . ,(if with-cheating? (string-append "\nSCHEME=\"" guile "\"") ""))
|
|
|
|
("@SCHEME@" . ,(if with-cheating? guile ""))
|
2019-11-09 09:59:01 +00:00
|
|
|
("@SHELL@" . ,shell)
|
2018-11-06 19:29:35 +00:00
|
|
|
|
2019-12-05 07:51:27 +00:00
|
|
|
("@CFLAGS@" . ,(or (getenv "CFLAGS") "-static -g"))
|
2019-12-02 17:26:08 +00:00
|
|
|
("@CPPFLAGS@" . ,(or (getenv "CPPFLAGS") ""))
|
2019-12-05 07:51:27 +00:00
|
|
|
("@LDFLAGS@" . ,(or (getenv "LDFLAGS") "-static -g"))
|
2018-11-06 19:29:35 +00:00
|
|
|
("@HEX2FLAGS@" . ,(or (getenv "HEX2FLAGS") ""))
|
|
|
|
("@M1FLAGS@" . ,(or (getenv "M1FLAGS") ""))
|
2019-12-07 13:39:19 +00:00
|
|
|
("@numbered_arch@" . ,(if numbered-arch? "true" "false"))
|
2018-11-06 19:29:35 +00:00
|
|
|
|
|
|
|
,@(map
|
|
|
|
(lambda (o)
|
|
|
|
(cons (string-append "@" (variable-name o) "@") (or (format #f "~a" (dependency-file-name o)) "")))
|
|
|
|
deps))))
|
|
|
|
|
2019-11-03 21:15:11 +00:00
|
|
|
(unless cc
|
|
|
|
(format (current-error-port) "must supply a C compiler")
|
2018-11-06 19:29:35 +00:00
|
|
|
(exit 2))
|
2018-07-21 16:28:47 +00:00
|
|
|
(for-each (lambda (o)
|
2018-07-25 06:14:13 +00:00
|
|
|
(let* ((src (string-append srcdest o))
|
2018-07-21 22:43:39 +00:00
|
|
|
(target (string-drop-right o 3))
|
|
|
|
(target (if (not (string-prefix? "build-aux/" target)) target
|
|
|
|
(string-drop target (string-length "build-aux/")))))
|
|
|
|
(substitute src pairs #:target target)))
|
2018-07-21 16:28:47 +00:00
|
|
|
'(
|
2018-07-25 06:14:13 +00:00
|
|
|
"build-aux/GNUmakefile.in"
|
2019-06-08 13:36:22 +00:00
|
|
|
"build-aux/config.sh.in"
|
2018-07-25 06:14:13 +00:00
|
|
|
"build-aux/build.sh.in"
|
|
|
|
"build-aux/check.sh.in"
|
|
|
|
"build-aux/install.sh.in"
|
2018-07-21 16:28:47 +00:00
|
|
|
"build-aux/pre-inst-env.in"
|
2018-07-25 06:14:13 +00:00
|
|
|
"build-aux/uninstall.sh.in"
|
2019-07-21 14:44:54 +00:00
|
|
|
"scripts/mesar.in"
|
2018-11-25 12:21:03 +00:00
|
|
|
"scripts/mescc.scm.in"
|
2018-07-21 16:28:47 +00:00
|
|
|
"scripts/mescc.in"
|
2018-11-06 19:29:35 +00:00
|
|
|
))
|
|
|
|
(chmod "pre-inst-env" #o755)
|
2019-07-21 14:44:54 +00:00
|
|
|
(chmod "scripts/mesar" #o755)
|
2018-11-06 19:29:35 +00:00
|
|
|
(chmod "scripts/mescc" #o755)
|
2018-11-25 12:21:03 +00:00
|
|
|
(chmod "scripts/mescc.scm" #o755)
|
2018-11-06 19:29:35 +00:00
|
|
|
(chmod "build.sh" #o755)
|
|
|
|
(chmod "check.sh" #o755)
|
|
|
|
(chmod "install.sh" #o755)
|
|
|
|
(chmod "uninstall.sh" #o755)
|
2019-06-08 13:36:22 +00:00
|
|
|
|
|
|
|
(system* "mkdir" "-p" "include/mes")
|
|
|
|
(let ((pkgdatadir (gulp-pipe* "sh" "-c" (string-append "prefix=" prefix
|
|
|
|
";datadir=" datadir
|
|
|
|
";echo ${datadir}/mes"))))
|
|
|
|
(with-output-to-file "include/mes/config.h"
|
|
|
|
(lambda _
|
|
|
|
(if system-libc?
|
|
|
|
(display "#define SYSTEM_LIBC 1
|
|
|
|
")
|
|
|
|
(display "#undef SYSTEM_LIBC
|
|
|
|
"))
|
|
|
|
(display (string-append "
|
2019-07-26 16:20:32 +00:00
|
|
|
#define MES_VERSION \"" VERSION "\"
|
2019-06-08 13:36:22 +00:00
|
|
|
")))))
|
2018-11-06 19:29:35 +00:00
|
|
|
(substitute (string-append srcdest "build-aux/config.make.in") pairs #:target ".config.make"))
|
|
|
|
|
2018-07-21 19:20:48 +00:00
|
|
|
(let ((make (and=> (file-name "make" deps) basename)))
|
2019-06-08 13:36:22 +00:00
|
|
|
(display (string-append "
|
|
|
|
GNU Mes is configured for
|
2019-12-13 16:21:53 +00:00
|
|
|
compiler: " mes-compiler "
|
2019-11-03 21:15:11 +00:00
|
|
|
cpu: " mes-cpu "
|
|
|
|
bits: " mes-bits "
|
|
|
|
libc: " mes-libc "
|
|
|
|
kernel: " mes-kernel "
|
|
|
|
system: " mes-system "
|
|
|
|
tools: " (if numbered-arch? "numbered" "named") " arch
|
|
|
|
bootstrap: " (if with-bootstrap? "yes" "no") "
|
|
|
|
courageous: " (if with-courage? "yes" "no") "
|
2018-11-06 19:29:35 +00:00
|
|
|
|
|
|
|
Run:
|
2019-06-08 13:36:22 +00:00
|
|
|
" (or make "./build.sh") " to build mes
|
|
|
|
" (or make "./build.sh") " help for help on other targets\n"))))))
|