build: Prepare for autoconfiscation.
Make build system more in alignment with how autotools work. This will make transition easier. * mes/module/mes/boot-0.scm.in: Update from module/mes/boot-0.scm. * scripts/mescc.in: Update from scripts/mescc. * build-aux/pre-inst-env.in: New file. * build-aux/cc-mes.sh: Use pre-inst-env. * configure: Substitute new .in files. * install.sh: Do not substitute mescc, boot-0.scm.
This commit is contained in:
parent
87269a16f6
commit
5d3fa50384
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -67,3 +67,7 @@
|
|||
/doc/mes.pdf
|
||||
/doc/mescc.1
|
||||
/doc/version.texi
|
||||
|
||||
/pre-inst-env
|
||||
/mes/module/mes/boot-0.scm
|
||||
/scripts/mescc
|
||||
|
|
|
@ -64,8 +64,7 @@ clean-go:
|
|||
check:
|
||||
./check.sh
|
||||
|
||||
|
||||
install:
|
||||
install: src/mes
|
||||
./install.sh
|
||||
|
||||
.config.make: ./configure
|
||||
|
|
|
@ -63,20 +63,20 @@ else
|
|||
fi
|
||||
|
||||
if [ -n "$PREPROCESS" ]; then
|
||||
bash $MESCC $MES_CPPFLAGS $MES_CFLAGS -E -o "$o.E" "$c".c
|
||||
bash $MESCC $MES_CFLAGS -S "$o".E
|
||||
bash $MESCC $MES_CFLAGS -c -o "$o".${p}o "$o".S
|
||||
./pre-inst-env bash $MESCC $MES_CPPFLAGS $MES_CFLAGS -E -o "$o.E" "$c".c
|
||||
./pre-inst-env bash $MESCC $MES_CFLAGS -S "$o".E
|
||||
./pre-inst-env bash $MESCC $MES_CFLAGS -c -o "$o".${p}o "$o".S
|
||||
if [ -z "$NOLINK" ]; then
|
||||
bash $MESCC $MES_CFLAGS -o "$o".${p}out "$o".${p}o $MES_LIBS
|
||||
./pre-inst-env bash $MESCC $MES_CFLAGS -o "$o".${p}out "$o".${p}o $MES_LIBS
|
||||
fi
|
||||
elif [ -n "$COMPILE" ]; then
|
||||
bash $MESCC $MES_CPPFLAGS $MES_CFLAGS -S -o "$o.S" "$c".c
|
||||
bash $MESCC $MES_CFLAGS -c -o "$o".${p}o "$o".S
|
||||
./pre-inst-env bash $MESCC $MES_CPPFLAGS $MES_CFLAGS -S -o "$o.S" "$c".c
|
||||
./pre-inst-env bash $MESCC $MES_CFLAGS -c -o "$o".${p}o "$o".S
|
||||
if [ -z "$NOLINK" ]; then
|
||||
bash $MESCC $MES_CFLAGS -o "$o".${p}out "$o".${p}o $MES_LIBS
|
||||
./pre-inst-env bash $MESCC $MES_CFLAGS -o "$o".${p}out "$o".${p}o $MES_LIBS
|
||||
fi
|
||||
elif [ -z "$NOLINK" ]; then
|
||||
bash $MESCC $MES_CPPFLAGS $MES_CFLAGS -o "$o".${p}out "$c".c $MES_LIBS
|
||||
./pre-inst-env bash $MESCC $MES_CPPFLAGS $MES_CFLAGS -o "$o".${p}out "$c".c $MES_LIBS
|
||||
else
|
||||
bash $MESCC $MES_CPPFLAGS $MES_CFLAGS -c -o "$o".${p}o "$c".c
|
||||
./pre-inst-env bash $MESCC $MES_CPPFLAGS $MES_CFLAGS -c -o "$o".${p}o "$c".c
|
||||
fi
|
||||
|
|
|
@ -73,7 +73,7 @@ for t in $tests; do
|
|||
echo $t: [SKIP];
|
||||
continue
|
||||
fi
|
||||
sh "$t" &> $t.${mes}log
|
||||
./pre-inst-env sh "$t" &> $t.${mes}log
|
||||
r=$?
|
||||
total=$((total+1))
|
||||
if [ $r = 0 ]; then
|
||||
|
|
37
build-aux/pre-inst-env.in
Normal file
37
build-aux/pre-inst-env.in
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of Mes.
|
||||
#
|
||||
# Mes 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.
|
||||
#
|
||||
# Mes 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 Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
abs_top_srcdir="$(cd "@abs_top_srcdir@" > /dev/null; pwd -P)"
|
||||
abs_top_builddir="$(cd "@abs_top_builddir@" > /dev/null; pwd -P)"
|
||||
|
||||
MES_PREFIX=mes
|
||||
export MES_PREFIX
|
||||
|
||||
GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/module${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
|
||||
GUILE_LOAD_PATH="$abs_top_srcdir/module${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
|
||||
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
|
||||
|
||||
PATH="$abs_top_builddir/scripts:$PATH"
|
||||
export PATH
|
||||
|
||||
LANG=
|
||||
LC_ALL=
|
||||
|
||||
exec "$@"
|
60
configure
vendored
60
configure
vendored
|
@ -46,6 +46,7 @@ exec ${GUILE-guile} -L . --no-auto-compile -e '(configure)' -s "$0" ${1+"$@"}
|
|||
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
(define-module (configure)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-26)
|
||||
#:use-module (ice-9 and-let-star)
|
||||
#:use-module (ice-9 curried-definitions)
|
||||
|
@ -54,12 +55,18 @@ exec ${GUILE-guile} -L . --no-auto-compile -e '(configure)' -s "$0" ${1+"$@"}
|
|||
#:use-module (ice-9 optargs)
|
||||
#:use-module (ice-9 popen)
|
||||
#:use-module (ice-9 rdelim)
|
||||
#:use-module (ice-9 regex)
|
||||
#:export (main))
|
||||
|
||||
(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)))
|
||||
|
||||
(define *shell* "sh")
|
||||
(define PACKAGE "mes")
|
||||
(define VERSION "0.16.1")
|
||||
(define GUILE (or (getenv "guile") "guile"))
|
||||
(define GUILE (PATH-search-path (or (getenv "guile") "guile")))
|
||||
(define GUILE_EFFECTIVE_VERSION (effective-version))
|
||||
|
||||
(define prefix "/usr/local")
|
||||
|
@ -128,11 +135,6 @@ exec ${GUILE-guile} -L . --no-auto-compile -e '(configure)' -s "$0" ${1+"$@"}
|
|||
(char-set-complement (char-set #\.)))))
|
||||
(map string->number version)))
|
||||
|
||||
(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)))
|
||||
|
||||
(define optional '())
|
||||
(define required '())
|
||||
(define* (check-version name expected
|
||||
|
@ -261,8 +263,22 @@ Some influential environment variables:
|
|||
TINYCC_SEED location of tinycc-seed
|
||||
" PACKAGE VERSION (getenv "prefix")))
|
||||
|
||||
(define* (substitute file-name pairs
|
||||
#:key (target (if (string-suffix? ".in" file-name)
|
||||
(string-drop-right file-name 3) 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)))))
|
||||
|
||||
(define (main args)
|
||||
(let* ((CC (or (getenv "CC") "gcc"))
|
||||
(srcdir (dirname (car (command-line))))
|
||||
(abs-top-srcdir (canonicalize-path srcdir))
|
||||
(builddir (getcwd))
|
||||
(abs-top-builddir (canonicalize-path builddir))
|
||||
(BUILD_TRIPLET %host-type)
|
||||
(ARCH (car (string-split BUILD_TRIPLET #\-)))
|
||||
(options (parse-opts args))
|
||||
|
@ -271,6 +287,13 @@ Some influential environment variables:
|
|||
(prefix (option-ref options 'prefix prefix))
|
||||
(infodir (option-ref options 'infodir infodir))
|
||||
(sysconfdir (option-ref options 'sysconfdir sysconfdir))
|
||||
(datadir (string-append prefix "/share/mes"))
|
||||
(moduledir (string-append datadir"module"))
|
||||
(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")))
|
||||
(verbose? (option-ref options 'verbose #f))
|
||||
(with-courage? (option-ref options 'with-courage #f))
|
||||
(disable-silent-rules? (option-ref options 'disable-silent-rules #f))
|
||||
|
@ -281,6 +304,7 @@ Some influential environment variables:
|
|||
(let ((CC32 (or (getenv "CC32")
|
||||
(if (member ARCH '("i686" "arm")) (string-append BUILD_TRIPLET "-" CC)
|
||||
"i686-unknown-linux-gnu-gcc")))
|
||||
(BASH (or (getenv "BASH") "bash"))
|
||||
(HELP2MAN (or (getenv "HELP2MAN") "help2man"))
|
||||
(TCC (or (getenv "TCC") "tcc"))
|
||||
(MAKEINFO (or (getenv "MAKEINFO") "makeinfo"))
|
||||
|
@ -319,6 +343,9 @@ Some influential environment variables:
|
|||
(when (and (not (member ARCH '("i686" "x86_64"))) (not with-courage?))
|
||||
(stderr "platform not supported: ~a, try --with-courage\n" ARCH)
|
||||
(exit 1))
|
||||
(if (check-version "bash" '(2))
|
||||
(set! BASH (PATH-search-path BASH))
|
||||
(set! BASH #f))
|
||||
(if (not (check-version CC '(4 8) #:optional? #t))
|
||||
(set! CC #f))
|
||||
(when CC
|
||||
|
@ -349,6 +376,8 @@ Some influential environment variables:
|
|||
(stdout "prefix:=~a\n" (gulp-pipe (string-append "echo " prefix)))
|
||||
(stdout "infodir:=~a\n" infodir)
|
||||
(stdout "mandir:=~a\n" mandir)
|
||||
(stdout "datadir:=~a\n" datadir)
|
||||
(stdout "moduledir:=~a\n" moduledir)
|
||||
(stdout "sysconfdir:=~a\n" sysconfdir)
|
||||
|
||||
(stdout "ARCH:=~a\n" ARCH)
|
||||
|
@ -378,6 +407,25 @@ Some influential environment variables:
|
|||
(when HEX2FLAGS (stdout "HEX2FLAGS:=~a\n" HEX2FLAGS))
|
||||
(when M1FLAGS (stdout "M1FLAGS:=~a\n" M1FLAGS))
|
||||
(when MES_CFLAGS (stdout "MES_CFLAGS:=~a\n" MES_CFLAGS))))
|
||||
(let ((pairs `(("@abs_top_srcdir@" . ,abs-top-srcdir)
|
||||
("@abs_top_builddir@" . ,abs-top-builddir)
|
||||
("@BASH@" . ,BASH)
|
||||
("@GUILE@" . ,GUILE)
|
||||
("@guile_site_dir@" . ,guile-site-dir)
|
||||
("@guile_site_ccache_dir@" . ,guile-site-ccache-dir)
|
||||
("@VERSION@" . ,VERSION)
|
||||
("mes/module/" . ,(string-append moduledir "/")))))
|
||||
(for-each (lambda (o)
|
||||
(substitute o pairs)
|
||||
(chmod (string-drop-right o 3) #o755))
|
||||
'(
|
||||
"build-aux/pre-inst-env.in"
|
||||
"mes/module/mes/boot-0.scm.in"
|
||||
"scripts/mescc.in"
|
||||
)))
|
||||
(chmod "build-aux/pre-inst-env" #o755)
|
||||
(rename-file "build-aux/pre-inst-env" "pre-inst-env")
|
||||
(chmod "scripts/mescc" #o755)
|
||||
(format (current-output-port)
|
||||
"\nRun:
|
||||
~a to build mes
|
||||
|
|
74
install.sh
74
install.sh
|
@ -15,24 +15,45 @@ MES_PREFIX=${MES_PREFIX-$prefix/share/mes}
|
|||
MES_SEED=${MES_SEED-../MES-SEED}
|
||||
TINYCC_SEED=${TINYCC_SEED-../TINYCC-SEED}
|
||||
|
||||
GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
|
||||
datadir=${moduledir-$prefix/share/mes}
|
||||
docdir=${moduledir-$prefix/share/doc/mes}
|
||||
GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
|
||||
bindir=${bindir-$prefix/bin}
|
||||
datadir=${datadir-$prefix/share/mes}
|
||||
docdir=${docdir-$prefix/share/doc/mes}
|
||||
infodir=${infodir-$prefix/share/info}
|
||||
mandir=${mandir-$prefix/share/man}
|
||||
moduledir=${moduledir-$datadir/module}
|
||||
guile_site_dir=${guile_site_dir-$prefix/share/guile/site/$GUILE_EFFECTIVE_VERSION}
|
||||
guile_site_ccache_dir=${guile_site_ccache_dir-$prefix/lib/guile/$GUILE_EFFECTIVE_VERSION/site-ccache}
|
||||
docdir=${moduledir-$prefix/share/doc/mes}
|
||||
|
||||
mkdir -p $DESTDIR$prefix/bin
|
||||
cp src/mes $DESTDIR$prefix/bin/mes
|
||||
mkdir -p $DESTDIR$bindir
|
||||
cp src/mes $DESTDIR$bindir/mes
|
||||
cp scripts/mescc $DESTDIR$bindir/mescc
|
||||
|
||||
mkdir -p $DESTDIR$prefix/lib
|
||||
mkdir -p $DESTDIR$MES_PREFIX/lib
|
||||
cp scripts/mescc $DESTDIR$prefix/bin/mescc
|
||||
sed \
|
||||
-e "s,^#! /bin/sh,#! $SHELL," \
|
||||
scripts/diff.scm > $DESTDIR$bindir/diff.scm
|
||||
chmod -w+x $DESTDIR$bindir/diff.scm
|
||||
|
||||
mkdir -p $DESTDIR$MES_PREFIX
|
||||
tar -cf- doc include lib scaffold | tar -xf- -C $DESTDIR$MES_PREFIX
|
||||
|
||||
mkdir -p $docdir
|
||||
cp\
|
||||
AUTHORS\
|
||||
BOOTSTRAP\
|
||||
COPYING\
|
||||
HACKING\
|
||||
INSTALL\
|
||||
NEWS\
|
||||
README\
|
||||
$DESTDIR$docdir
|
||||
|
||||
if [ -f ${top_builddest}ChangeLog ]; then
|
||||
cp ${top_builddest}ChangeLog $DESTDIR$docdir
|
||||
else
|
||||
cp ChangeLog $DESTDIR$docdir
|
||||
fi
|
||||
|
||||
tar -cf- include lib | tar -xf- -C $DESTDIR$MES_PREFIX
|
||||
tar -cf- scaffold --exclude='*.gcc*' --exclude='*.mes*' | tar -xf- -C $DESTDIR$MES_PREFIX
|
||||
tar -cf- --exclude='*.go' module | tar -xf- -C $DESTDIR$MES_PREFIX
|
||||
tar -cf- -C mes module | tar -xf- -C $DESTDIR$MES_PREFIX
|
||||
|
||||
|
@ -41,38 +62,9 @@ mkdir -p $DESTDIR$guile_site_ccache_dir
|
|||
tar -cf- -C module --exclude='*.go' . | tar -xf- -C $DESTDIR$guile_site_dir
|
||||
tar -cf- -C module --exclude='*.scm' . | tar -xf- -C $DESTDIR$guile_site_ccache_dir
|
||||
|
||||
chmod +w $DESTDIR$prefix/bin/mescc
|
||||
sed \
|
||||
-e "s,^#! /bin/sh,#! $SHELL," \
|
||||
-e "s,@datadir@,$datadir,g" \
|
||||
-e "s,@docdir@,$docdir,g" \
|
||||
-e "s,@guile_site_ccache_dir@,$guile_site_ccache_dir,g" \
|
||||
-e "s,@guile_site_dir@,$guile_site_dir,g" \
|
||||
-e "s,@moduledir@,$moduledir,g" \
|
||||
-e "s,@prefix@,$prefix,g" \
|
||||
-e "s,@VERSION@,$VERSION,g" \
|
||||
scripts/mescc > $DESTDIR$prefix/bin/mescc
|
||||
chmod +w $DESTDIR$moduledir/mes/boot-0.scm
|
||||
sed \
|
||||
-e "s,^#! /bin/sh,#! $SHELL," \
|
||||
-e "s,mes/module/,$moduledir/," \
|
||||
-e "s,@datadir@,$datadir,g" \
|
||||
-e "s,@docdir@,$docdir,g" \
|
||||
-e "s,@guile_site_ccache_dir@,$guile_site_ccache_dir,g" \
|
||||
-e "s,@guile_site_dir@,$guile_site_dir,g" \
|
||||
-e "s,@moduledir@,$moduledir,g" \
|
||||
-e "s,@prefix@,$prefix,g" \
|
||||
-e "s,@VERSION@,$VERSION,g" \
|
||||
mes/module/mes/boot-0.scm > $DESTDIR$moduledir/mes/boot-0.scm
|
||||
|
||||
sed \
|
||||
-e "s,^#! /bin/sh,#! $SHELL," \
|
||||
scripts/diff.scm > $DESTDIR$prefix/bin/diff.scm
|
||||
chmod -w+x $DESTDIR$prefix/bin/diff.scm
|
||||
|
||||
if [ -f doc/mes.info ]; then
|
||||
mkdir -p $DESTDIR$prefix/share/info
|
||||
tar -cf- doc/mes.info* doc/images | tar -xf- --strip-components=1 -C $DESTDIR$prefix/share/info
|
||||
tar -cf- doc/mes.info* doc/images | tar -xf- --strip-components=1 -C $DESTDIR$infodir
|
||||
install-info --info-dir=$DESTDIR$prefix/share/info doc/mes.info
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,25 +1,18 @@
|
|||
#! /bin/sh
|
||||
#! @BASH@
|
||||
# -*-scheme-*-
|
||||
if [ -n "$BUILD_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
prefix=${prefix-@prefix@}
|
||||
if [ "@prefix@" = @prefix""@ -o ! -d "$prefix/share/mes/module" ]
|
||||
then
|
||||
MES_PREFIX=${MES_PREFIX-$(cd $(dirname $0)/.. && pwd)/mes}
|
||||
else
|
||||
MES_PREFIX=${MES_PREFIX-$prefix/share/mes}
|
||||
fi
|
||||
export MES_PREFIX
|
||||
mes_p=$(command -v mes)
|
||||
|
||||
guile_site_dir=${guile_site_dir-@guile_site_dir@}
|
||||
[ "$guile_site_dir" = @"guile_site_dir"@ ] && guile_site_dir=$(dirname $0)/../module
|
||||
GUILE_LOAD_PATH=$guile_site_dir:$GUILE_LOAD_PATH
|
||||
|
||||
if [ '(' -z "$mes_p" -a -z "$MES" ')' -o "$MES" = "guile" -o "$MES" = "mes.guile" ]; then
|
||||
guile_site_ccache_dir=${guile_site_ccache_dir-@guile_site_ccache_dir@}
|
||||
[ "$guile_site_ccache_dir" = @"guile_site_ccache_dir"@ ] && guile_site_ccache_dir=$(dirname $0)/../module
|
||||
GUILE_LOAD_COMPILED_PATH=$guile_site_ccache_dir:$GUILE_LOAD_COMPILED_PATH
|
||||
GUILE_AUTO_COMPILE=${GUILE_AUTO_COMPILE-0}
|
||||
export GUILE_AUTO_COMPILE
|
Loading…
Reference in a new issue