2016-10-15 22:34:23 +00:00
|
|
|
#! /bin/sh
|
|
|
|
# -*- scheme -*-
|
|
|
|
unset LANG LC_ALL
|
2018-07-21 19:20:48 +00:00
|
|
|
guile=$(command -v ${GUILE-guile})
|
2018-07-21 22:43:39 +00:00
|
|
|
guix=$(command -v ${GUIX-guix})
|
|
|
|
if [ -n "$guix" ] ; then
|
2018-07-22 06:41:48 +00:00
|
|
|
install="guix environment -l .guix.scm"
|
2018-05-06 06:46:32 +00:00
|
|
|
else
|
2018-07-21 19:20:48 +00:00
|
|
|
install="sudo apt-get install guile-2.2-dev"
|
|
|
|
fi
|
|
|
|
if [ -z "$guile" ]; then
|
|
|
|
cat <<EOF
|
2016-10-15 22:34:23 +00:00
|
|
|
|
2018-07-21 19:20:48 +00:00
|
|
|
Missing dependencies: ${GUILE-guile}, please install Guile 2.2 or later; run
|
|
|
|
$install
|
2016-10-15 22:34:23 +00:00
|
|
|
EOF
|
2018-07-21 19:20:48 +00:00
|
|
|
exit 1
|
2016-10-15 22:34:23 +00:00
|
|
|
fi
|
2018-07-21 19:20:48 +00:00
|
|
|
GUILE=$guile
|
|
|
|
export GUILE
|
|
|
|
exec ${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
|
2017-11-21 18:22:26 +00:00
|
|
|
;;; Copyright © 2016,2017,2018 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 and-let-star)
|
|
|
|
#:use-module (ice-9 curried-definitions)
|
|
|
|
#:use-module (ice-9 getopt-long)
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
#:use-module (ice-9 optargs)
|
|
|
|
#:use-module (ice-9 popen)
|
2018-05-20 22:06:39 +00:00
|
|
|
#:use-module (ice-9 rdelim)
|
2018-07-21 16:28:47 +00:00
|
|
|
#:use-module (ice-9 regex)
|
2018-05-20 22:06:39 +00:00
|
|
|
#:export (main))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
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
|
|
|
(define *shell* "sh")
|
|
|
|
(define PACKAGE "mes")
|
2018-07-09 14:44:06 +00:00
|
|
|
(define VERSION "0.16.1")
|
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
|
|
|
|
|
|
|
(define (gulp-pipe command)
|
|
|
|
(let* ((port (open-pipe* OPEN_READ *shell* "-c" command))
|
|
|
|
(output (read-string port))
|
|
|
|
(status (close-pipe port)))
|
|
|
|
(verbose "command[~a]: ~s => ~a\n" status command output)
|
|
|
|
(if (not (zero? status)) "" (string-trim-right output #\newline))))
|
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
(define* ((->string #:optional (infix "")) h . t)
|
|
|
|
(let ((o (if (pair? t) (cons h t) h)))
|
|
|
|
(match o
|
|
|
|
((? char?) (make-string 1 o))
|
|
|
|
((? number?) (number->string o))
|
|
|
|
((? string?) o)
|
|
|
|
((? symbol?) (symbol->string o))
|
|
|
|
((h ... t) (string-join (map (->string) o) ((->string) infix)))
|
|
|
|
(_ ""))))
|
|
|
|
|
|
|
|
(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))
|
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
;;; Configure
|
2018-07-21 19:20:48 +00:00
|
|
|
|
|
|
|
(define-immutable-record-type <dependency>
|
|
|
|
(make-depedency name version-expected optional? version-option commands file-name)
|
|
|
|
dependency?
|
|
|
|
(name dependency-name)
|
|
|
|
(version-expected dependency-version-expected)
|
|
|
|
(version-option dependency-version-option)
|
|
|
|
(optional? dependency-optional?)
|
|
|
|
(commands dependency-commands)
|
|
|
|
(file-name dependency-file-name)
|
|
|
|
(version-found dependency-version-found))
|
|
|
|
|
|
|
|
(define* (make-dep name #:optional (version '(0))
|
|
|
|
#:key optional? (version-option "--version") (commands (list name)) file-name)
|
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)))
|
|
|
|
(make-depedency name version optional? version-option commands file-name)))
|
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
|
|
|
|
2016-10-15 22:34:23 +00:00
|
|
|
(define (version->string version)
|
|
|
|
((->string '.) version))
|
|
|
|
|
|
|
|
(define (string->version string)
|
|
|
|
(and-let* ((version (string-tokenize string
|
|
|
|
(char-set-adjoin char-set:digit #\.)))
|
|
|
|
((pair? version))
|
2017-04-02 16:50:07 +00:00
|
|
|
(version (sort version (lambda (a b) (> (string-length a) (string-length b)))))
|
2016-10-15 22:34:23 +00:00
|
|
|
(version (car version))
|
|
|
|
(version (string-tokenize version
|
|
|
|
(char-set-complement (char-set #\.)))))
|
|
|
|
(map string->number version)))
|
|
|
|
|
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))
|
|
|
|
(if (null? commands) dependency
|
|
|
|
(let ((command (car commands)))
|
|
|
|
(stdout "checking for ~a~a... " command
|
|
|
|
(if (null? expected) ""
|
|
|
|
(format #f " [~a]" (version->string expected))))
|
|
|
|
(let* ((output (gulp-pipe (format #f "~a ~a 2>&1" command version-option)))
|
|
|
|
(actual (string->version output))
|
|
|
|
(pass? (and actual (tuple< expected actual)))
|
|
|
|
(dependency (set-field dependency (dependency-version-found) actual)))
|
|
|
|
(stdout "~a ~a\n" (if pass? (if (pair? actual) "" " yes")
|
|
|
|
(if actual " no, found" "no")) (version->string actual))
|
|
|
|
(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)))
|
|
|
|
|
|
|
|
(define* (check-header-c dependency #:optional (check check-compile-header-c))
|
|
|
|
(let ((name (dependency-name dependency)))
|
|
|
|
(stderr "checking for ~a..." name)
|
|
|
|
(let ((result (check name)))
|
|
|
|
(stderr " ~a\n" (if result "yes" "no"))
|
|
|
|
(if result (set-field dependency (dependency-file-name) name)
|
|
|
|
dependency-file-name))))
|
2016-10-15 22:34:23 +00:00
|
|
|
|
2017-05-14 07:03:06 +00:00
|
|
|
(define (check-compile-header-c header)
|
2018-07-21 19:20:48 +00:00
|
|
|
(zero? (system (format #f "echo '#include ~s' | gcc -E - > /dev/null 2>&1" header))))
|
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))
|
2016-10-15 22:34:23 +00:00
|
|
|
(help (single-char #\h))
|
|
|
|
(prefix (value #t))
|
2018-07-22 12:44:50 +00:00
|
|
|
(bindir (value #t))
|
|
|
|
(datadir (value #t))
|
|
|
|
(docdir (value #t))
|
|
|
|
(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))
|
2017-04-12 19:27:59 +00:00
|
|
|
(verbose (single-char #\v))
|
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))
|
|
|
|
(disable-silent-rules)
|
2018-07-25 06:14:13 +00:00
|
|
|
(enable-silent-rules)
|
2018-07-09 08:46:28 +00:00
|
|
|
|
|
|
|
(enable-fast-install) ; Ignored for Guix
|
|
|
|
(includedir (value #t)) ; Ignored for Debian
|
|
|
|
(mandir (value #t)) ; Ignored for Debian
|
|
|
|
(localstatedir (value #t)) ; Ignored for Debian
|
|
|
|
(libdir (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]
|
2018-07-09 08:46:28 +00:00
|
|
|
--disable-silent-rules
|
|
|
|
verbose build output [BUILD_DEBUG=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
|
2017-05-14 07:03:06 +00:00
|
|
|
--with-courage assert being courageous to configure for unsupported platform
|
2018-07-25 06:14:13 +00:00
|
|
|
--with-cheating cheat using Guile instead of Mes
|
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]
|
|
|
|
--infodir=DIR info documentation [PREFIX/share/info]
|
|
|
|
--mandir=DIR man pages [PREFIX/share/man]
|
|
|
|
|
|
|
|
Ignored for Guix:
|
|
|
|
--enable-fast-install
|
|
|
|
|
|
|
|
Ignored for Debian:
|
|
|
|
--disable-dependency-tracking
|
|
|
|
--disable-maintainer-mode
|
|
|
|
--includedir=DIR
|
|
|
|
--libdir=DIR
|
|
|
|
--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
|
|
|
|
CC32 x86 C compiler command
|
2018-07-09 09:49:49 +00:00
|
|
|
CC32_CFLAGS x86 C compiler flags
|
2018-06-16 04:37:20 +00:00
|
|
|
GUILE guile command
|
|
|
|
GUILE_TOOLS guile-tools command
|
2018-07-09 09:49:49 +00:00
|
|
|
MES_CFLAGS MesCC flags
|
2018-06-16 04:37:20 +00:00
|
|
|
MES_SEED location of mes-seed
|
|
|
|
MESCC_TOOLS_SEED location of mescc-tools-seed
|
2018-06-24 07:28:23 +00:00
|
|
|
TCC tcc C compiler command
|
2018-07-26 17:36:03 +00:00
|
|
|
TINYCC_PREFIX location of tinycc [for tests/test2]
|
2018-06-16 04:37:20 +00:00
|
|
|
TINYCC_SEED location of tinycc-seed
|
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))
|
|
|
|
|
|
|
|
(arch (car (string-split build-type #\-)))
|
|
|
|
(host-type (option-ref options 'host %host-type))(prefix "/usr/local")
|
|
|
|
|
|
|
|
(prefix "/usr/local")
|
|
|
|
(prefix (option-ref options 'prefix prefix))
|
|
|
|
(infodir (option-ref options 'infodir "${prefix}/share/info"))
|
|
|
|
(mandir (option-ref options 'infodir "${prefix}/share/man"))
|
|
|
|
(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"))
|
|
|
|
(docdir (option-ref options 'docdir "${datadir}/doc/mes-${VERSION}"))
|
|
|
|
(libdir (option-ref options 'libdir "${prefix}/lib"))
|
|
|
|
(moduledir "${datadir}/mes/module")
|
2018-08-09 09:00:10 +00:00
|
|
|
(moduledir/ (gulp-pipe (string-append "echo " prefix "/share/mes/module/")))
|
2018-07-22 12:44:50 +00:00
|
|
|
(guile-effective-version (effective-version))
|
|
|
|
(guile-site-dir (if (equal? prefix ".") (canonicalize-path ".")
|
|
|
|
(string-append "${prefix}/share/guile/site/" guile-effective-version)))
|
|
|
|
(guile-site-ccache-dir (if (equal? prefix ".") (canonicalize-path ".")
|
|
|
|
(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
|
|
|
|
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))
|
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))
|
2018-05-06 06:46:32 +00:00
|
|
|
(vars (filter (cut string-index <> #\=) (option-ref options '() '())))
|
|
|
|
(help? (option-ref options 'help #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)
|
2018-07-21 22:43:39 +00:00
|
|
|
(let* ((mes-seed (or (getenv "MES_SEED")
|
2018-07-25 06:14:13 +00:00
|
|
|
(string-append srcdest "../mes-seed")))
|
2018-07-26 17:36:03 +00:00
|
|
|
(tinycc-prefix (or (getenv "TINYCC_PREFIX")
|
|
|
|
(string-append srcdest "../tinycc-prefix")))
|
2018-07-21 22:43:39 +00:00
|
|
|
(tinycc-seed (or (getenv "TINYCC_SEED")
|
2018-07-25 06:14:13 +00:00
|
|
|
(string-append srcdest "../tinycc-seed")))
|
2018-07-21 22:43:39 +00:00
|
|
|
(mescc-tools-seed (or (getenv "MESCC_TOOLS_SEED")
|
2018-07-25 06:14:13 +00:00
|
|
|
(string-append srcdest "../mescc-tools-seed")))
|
2018-07-21 19:20:48 +00:00
|
|
|
(deps (fold (lambda (program results)
|
|
|
|
(cons (check-program-version program) results))
|
|
|
|
'()
|
|
|
|
(list (make-dep "guile" '(2 0) #:commands '("guile-2.2" "guile-2.0" "guile-2" "guile"))
|
2018-07-22 06:41:48 +00:00
|
|
|
(make-dep "guix" '(0 13) #:optional? #t)
|
2018-07-21 19:20:48 +00:00
|
|
|
(make-dep "bash" '(2 0) #:optional? #t)
|
|
|
|
(make-dep "guile-tools" '(2 0))
|
|
|
|
(make-dep "mes-seed" '(0 16 1) #:optional? #t
|
|
|
|
#:commands (list (string-append mes-seed "/refresh.sh"))
|
|
|
|
#:file-name mes-seed)
|
|
|
|
(make-dep "tinycc-seed" '(0 16) #:optional? #t
|
|
|
|
#:commands (list (string-append tinycc-seed "/refresh.sh"))
|
|
|
|
#:file-name tinycc-seed)
|
|
|
|
(make-dep "cc" '(2 95) #:commands '("gcc"))
|
|
|
|
(make-dep "make" '(4))
|
|
|
|
(make-dep "cc32" '(2 95)
|
|
|
|
#:optional? #t
|
|
|
|
#:commands '("i686-unknown-linux-gnu-gcc"))
|
|
|
|
(make-dep "M1" '(0 3))
|
|
|
|
(make-dep "blood-elf" '(0 1))
|
|
|
|
(make-dep "hex2" '(0 3))
|
2018-07-21 22:43:39 +00:00
|
|
|
(make-dep "tcc" '(0 9 26) #:optional? #t #:version-option "-v")
|
2018-07-21 19:20:48 +00:00
|
|
|
(make-dep "makeinfo" '(5) #:optional? #t)
|
2018-07-22 20:27:24 +00:00
|
|
|
(make-dep "dot" '(2) #:version-option "-V")
|
2018-07-21 19:20:48 +00:00
|
|
|
(make-dep "help2man" '(1 47) #:optional? #t)
|
|
|
|
(make-dep "perl" '(5) #:optional? #t)
|
|
|
|
(make-dep "git" '(2) #:optional? #t))))
|
|
|
|
(deps (cons (check-program-version (make-dep "nyacc" '(0 80 41) #:commands (list (string-append (file-name "guile" deps) " -c '(use-modules (nyacc lalr)) (display *nyacc-version*)'")) #:file-name #t))
|
|
|
|
deps))
|
|
|
|
(deps (if (file-name "cc" deps)
|
|
|
|
(cons* (check-header-c (make-dep "stdio.h"))
|
|
|
|
(check-header-c (make-dep "limits.h"))
|
|
|
|
deps)
|
|
|
|
deps))
|
|
|
|
(deps (cons (check-file (make-dep "mescc-tools-seed" '(0) #:optional? #t
|
|
|
|
#:file-name mescc-tools-seed))
|
|
|
|
deps))
|
2018-07-26 17:36:03 +00:00
|
|
|
(deps (cons (check-file (make-dep "tinycc-prefix" '(0) #:optional? #t
|
|
|
|
#:file-name tinycc-prefix))
|
|
|
|
deps))
|
2018-07-21 19:20:48 +00:00
|
|
|
(missing (filter (conjoin (negate dependency-file-name)
|
|
|
|
(negate dependency-optional?)) deps)))
|
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 _
|
|
|
|
(display
|
|
|
|
(fold (lambda (o result)
|
|
|
|
(regexp-substitute/global #f (car o) result 'pre (cdr o) 'post))
|
|
|
|
(with-input-from-file file-name read-string) pairs)))))
|
|
|
|
|
2018-07-21 19:20:48 +00:00
|
|
|
(when (and (not (member arch '("i686" "x86_64"))) (not with-courage?))
|
|
|
|
(stderr "platform not supported: ~a, try --with-courage\n" arch)
|
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-07-21 19:20:48 +00:00
|
|
|
(let ((git (find-dep "git" deps)))
|
|
|
|
(when (and git
|
|
|
|
(not (file-exists? ".git")))
|
|
|
|
;; Debian wants to run `make clean' from a tarball
|
|
|
|
(and (zero? (system* "git" "init"))
|
|
|
|
(zero? (system* "git" "add" "."))
|
2018-07-21 22:43:39 +00:00
|
|
|
(zero? (system* "git" "commit" "--allow-empty" "-m" "Import mes")))))
|
2018-05-06 06:46:32 +00:00
|
|
|
(with-output-to-file ".config.make"
|
2018-07-21 19:20:48 +00:00
|
|
|
(lambda _
|
|
|
|
(stdout "PACKAGE:=~a\n" PACKAGE)
|
|
|
|
(stdout "VERSION:=~a\n" VERSION)
|
|
|
|
|
2018-07-22 12:44:50 +00:00
|
|
|
(stdout "ARCH:=~a\n" arch)
|
2018-07-21 19:20:48 +00:00
|
|
|
(stdout "build:=~a\n" build-type)
|
|
|
|
(stdout "host:=~a\n" host-type)
|
2018-07-22 12:44:50 +00:00
|
|
|
|
2018-07-21 22:43:39 +00:00
|
|
|
(stdout "top_builddir:=~a\n" top-builddir)
|
|
|
|
(stdout "abs_top_builddir:=~a\n" abs-top-builddir)
|
|
|
|
(stdout "abs_top_srcdir:=~a\n" abs-top-srcdir)
|
2018-07-22 12:44:50 +00:00
|
|
|
|
2018-07-25 06:14:13 +00:00
|
|
|
(stdout "srcdest:=~a\n" srcdest)
|
2018-07-21 22:43:39 +00:00
|
|
|
(stdout "srcdir:=~a\n" srcdir)
|
2018-07-22 12:44:50 +00:00
|
|
|
|
2018-07-09 08:46:28 +00:00
|
|
|
(stdout "prefix:=~a\n" (gulp-pipe (string-append "echo " prefix)))
|
2018-07-22 12:44:50 +00:00
|
|
|
(stdout "datadir:=~a\n" datadir)
|
|
|
|
(stdout "docdir:=~a\n" docdir)
|
|
|
|
|
|
|
|
(stdout "bindir:=~a\n" bindir)
|
|
|
|
(stdout "guile_site_ccache_dir:=~a\n" guile-site-ccache-dir)
|
|
|
|
(stdout "guile_site_dir:=~a\n" guile-site-dir)
|
2018-07-09 08:46:28 +00:00
|
|
|
(stdout "infodir:=~a\n" infodir)
|
2018-07-22 12:44:50 +00:00
|
|
|
(stdout "libdir:=~a\n" libdir)
|
2018-07-09 08:46:28 +00:00
|
|
|
(stdout "mandir:=~a\n" mandir)
|
2018-07-21 16:28:47 +00:00
|
|
|
(stdout "moduledir:=~a\n" moduledir)
|
2018-07-09 08:46:28 +00:00
|
|
|
(stdout "sysconfdir:=~a\n" sysconfdir)
|
|
|
|
|
2018-07-21 19:20:48 +00:00
|
|
|
(for-each (lambda (o)
|
|
|
|
(stdout "~a:=~a\n" (variable-name o) (or (dependency-file-name o) "")))
|
|
|
|
deps)
|
|
|
|
(stdout "GUILE_EFFECTIVE_VERSION:=~a\n" (effective-version))
|
|
|
|
|
2018-07-09 08:46:28 +00:00
|
|
|
(when disable-silent-rules?
|
2018-07-25 06:14:13 +00:00
|
|
|
(stdout "V:=1\n"))
|
|
|
|
|
|
|
|
(when with-cheating?
|
|
|
|
(stdout "MES:=guile\n"))
|
2018-07-21 19:20:48 +00:00
|
|
|
|
|
|
|
(for-each (lambda (o)
|
|
|
|
(stdout "~a:=~a\n" o (or (getenv o) "")))
|
|
|
|
'(
|
|
|
|
"CFLAGS"
|
|
|
|
"CC32_CFLAGS"
|
|
|
|
"HEX2FLAGS"
|
|
|
|
"M1FLAGS"
|
|
|
|
"CC32_CFLAGS"
|
|
|
|
"MES_CFLAGS"
|
|
|
|
))))
|
|
|
|
|
2018-07-25 06:14:13 +00:00
|
|
|
(let ((pairs `(("@srcdest@" . ,srcdest)
|
|
|
|
("@srcdir@" . ,srcdir)
|
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-07-21 19:20:48 +00:00
|
|
|
("@BASH@" . ,(file-name "bash" deps))
|
|
|
|
("@GUILE@" . ,(file-name "guile" deps))
|
2018-07-25 06:14:13 +00:00
|
|
|
("@MES@" . ,(file-name "guile" deps))
|
2018-08-09 06:58:20 +00:00
|
|
|
("@prefix@" . ,prefix)
|
2018-07-21 16:28:47 +00:00
|
|
|
("@guile_site_dir@" . ,guile-site-dir)
|
|
|
|
("@guile_site_ccache_dir@" . ,guile-site-ccache-dir)
|
|
|
|
("@VERSION@" . ,VERSION)
|
2018-08-09 09:00:10 +00:00
|
|
|
("mes/module/" . ,(string-append moduledir/)))))
|
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"
|
|
|
|
"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"
|
2018-07-21 16:28:47 +00:00
|
|
|
"mes/module/mes/boot-0.scm.in"
|
|
|
|
"scripts/mescc.in"
|
2018-07-25 06:14:13 +00:00
|
|
|
)))
|
|
|
|
(chmod "build.sh" #o755)
|
|
|
|
(chmod "check.sh" #o755)
|
|
|
|
(chmod "install.sh" #o755)
|
2018-07-21 22:43:39 +00:00
|
|
|
(chmod "pre-inst-env" #o755)
|
2018-07-25 06:14:13 +00:00
|
|
|
(chmod "uninstall.sh" #o755)
|
2018-07-21 16:28:47 +00:00
|
|
|
(chmod "scripts/mescc" #o755)
|
2018-07-21 19:20:48 +00:00
|
|
|
(let ((make (and=> (file-name "make" deps) basename)))
|
|
|
|
(format (current-output-port)
|
2018-07-21 22:43:39 +00:00
|
|
|
"\nRun:
|
2017-07-02 14:25:14 +00:00
|
|
|
~a to build mes
|
|
|
|
~a help for help on other targets\n"
|
2018-07-21 22:43:39 +00:00
|
|
|
(or make "./build.sh")
|
|
|
|
(or make "./build.sh"))))))
|