Build Gash with Autotools.

This commit allows most of Gash to be built with Autotools.  It also
removes some of the Gash build scripts.

* configure.ac: Add checks for compress, gzip, bzip2, and xz;
configure gash/config.scm.
* Makefile.am: Add Gash modules and the 'gash' script.
* scripts/gash.in: Rename 'guile_site_dir' to 'MODDIR' and
'guile_site_ccache_dir' to 'GODIR'.
* configure: Delete file.
* makefile: Delete file.
* build-aux/build-guile.sh: Delete file.
* build-aux/pre-inst-env.in: Delete file.
* build-aux/trace.sh: Delete file.
* .gitignore: Add configure; remove exceptions for the deleted
build-aux files.
This commit is contained in:
Timothy Sample 2018-12-15 21:38:48 -05:00
parent c5e5a34fc0
commit 7e8caba055
9 changed files with 74 additions and 451 deletions

8
.gitignore vendored
View File

@ -35,17 +35,11 @@ Makefile.in
aclocal.m4
autom4te.cache/*
build-aux/*
!build-aux/build-guile.sh
!build-aux/git-version-gen
!build-aux/gitlab-ci.yml
!build-aux/pre-inst-env.in
!build-aux/trace.sh
config.log
config.status
# Preserve this Gash file for now.
# configure
configure
coverage/*
lcov.info
pre-inst-env

View File

@ -44,10 +44,59 @@ check-spec:
check-bootstrap:
guix build -f tests/bootstrap/bash-without-bash.scm
.PHONY: check-gash
check-gash:
SHELL=gash $(top_builddir)/pre-inst-env $(top_builddir)/check.sh
dist-hook:
echo $(VERSION) > $(distdir)/.tarball-version
MODULES = \
gash/bournish-commands.scm \
gash/builtins.scm \
gash/commands/basename.scm \
gash/commands/cat.scm \
gash/commands/chmod.scm \
gash/commands/compress.scm \
gash/commands/cp.scm \
gash/commands/dirname.scm \
gash/commands/find.scm \
gash/commands/grep.scm \
gash/commands/ls.scm \
gash/commands/mkdir.scm \
gash/commands/mv.scm \
gash/commands/reboot.scm \
gash/commands/rm.scm \
gash/commands/rmdir.scm \
gash/commands/sed.scm \
gash/commands/sed/reader.scm \
gash/commands/tar.scm \
gash/commands/touch.scm \
gash/commands/tr.scm \
gash/commands/wc.scm \
gash/commands/which.scm \
gash/compress.scm \
gash/config.scm \
gash/environment.scm \
gash/gash.scm \
gash/geesh.scm \
gash/grammar.scm \
gash/guix-utils.scm \
gash/io.scm \
gash/job.scm \
gash/lzw.scm \
gash/peg.scm \
gash/peg/cache.scm \
gash/peg/codegen.scm \
gash/peg/simplify-tree.scm \
gash/peg/string-peg.scm \
gash/peg/using-parsers.scm \
gash/pipe.scm \
gash/readline.scm \
gash/script.scm \
gash/shell-utils.scm \
gash/ustar.scm \
gash/util.scm \
geesh/built-ins/break.scm \
geesh/built-ins/cd.scm \
geesh/built-ins/colon.scm \
@ -81,6 +130,7 @@ MODULES = \
geesh/word.scm
bin_SCRIPTS = \
scripts/gash \
scripts/geesh
do_subst = sed \
@ -88,6 +138,10 @@ do_subst = sed \
-e 's,[@]MODDIR[@],$(moddir),g' \
-e 's,[@]GODIR[@],$(godir),g'
scripts/gash: scripts/gash.in Makefile
$(do_subst) < $(srcdir)/scripts/gash.in > scripts/gash
chmod a+x scripts/gash
scripts/geesh: scripts/geesh.in Makefile
$(do_subst) < $(srcdir)/scripts/geesh.in > scripts/geesh
chmod a+x scripts/geesh

View File

@ -1,134 +0,0 @@
#! /bin/sh
# Gash --- Guile As SHell
# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of Gash.
#
# Gash 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.
#
# Gash 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 Gash. If not, see <http://www.gnu.org/licenses/>.
srcdir=${srcdir-.}
. ${srcdest}build-aux/trace.sh
export GUILE
export GUILE_AUTO_COMPILE
GUILE=${GUILE-$(command -v guile)}
GUILD=${GUILD-$(command -v guild || command -v guile-tools)}
GUILE_AUTO_COMPILE=0
set -e
SCM_FILES="
${srcdest}gash/bournish-commands.scm
${srcdest}gash/guix-utils.scm
${srcdest}gash/builtins.scm
${srcdest}gash/compress.scm
${srcdest}gash/config.scm
${srcdest}gash/environment.scm
${srcdest}gash/gash.scm
${srcdest}gash/geesh.scm
${srcdest}gash/grammar.scm
${srcdest}gash/io.scm
${srcdest}gash/job.scm
${srcdest}gash/lzw.scm
${srcdest}gash/pipe.scm
${srcdest}gash/readline.scm
${srcdest}gash/script.scm
${srcdest}gash/shell-utils.scm
${srcdest}gash/ustar.scm
${srcdest}gash/util.scm
${srcdest}gash/peg.scm
${srcdest}gash/peg/cache.scm
${srcdest}gash/peg/codegen.scm
${srcdest}gash/peg/simplify-tree.scm
${srcdest}gash/peg/string-peg.scm
${srcdest}gash/peg/using-parsers.scm
${srcdest}gash/commands/basename.scm
${srcdest}gash/commands/cat.scm
${srcdest}gash/commands/chmod.scm
${srcdest}gash/commands/compress.scm
${srcdest}gash/commands/cp.scm
${srcdest}gash/commands/dirname.scm
${srcdest}gash/commands/find.scm
${srcdest}gash/commands/grep.scm
${srcdest}gash/commands/ls.scm
${srcdest}gash/commands/mkdir.scm
${srcdest}gash/commands/mv.scm
${srcdest}gash/commands/reboot.scm
${srcdest}gash/commands/rm.scm
${srcdest}gash/commands/rmdir.scm
${srcdest}gash/commands/sed.scm
${srcdest}gash/commands/tar.scm
${srcdest}gash/commands/touch.scm
${srcdest}gash/commands/tr.scm
${srcdest}gash/commands/wc.scm
${srcdest}gash/commands/which.scm
${srcdest}gash/commands/sed/reader.scm
"
SCRIPTS="
${srcdest}bin/basename
${srcdest}bin/cat
${srcdest}bin/chmod
${srcdest}bin/compress
${srcdest}bin/cp
${srcdest}bin/dirname
${srcdest}bin/find
${srcdest}bin/grep
${srcdest}bin/ls
${srcdest}bin/mkdir
${srcdest}bin/mv
${srcdest}bin/reboot
${srcdest}bin/rm
${srcdest}bin/rmdir
${srcdest}bin/sed
${srcdest}bin/tar
${srcdest}bin/touch
${srcdest}bin/tr
${srcdest}bin/wc
${srcdest}bin/which
${srcdest}scripts/gash
"
export host=$($GUILE -c "(display %host-type)")
abs=$srcdest
if [ "$GUILE_EFFECTIVE_VERSION" = "2.0" ]; then
srcdest=$abs_top_srcdir/
fi
GUILE_AUTO_COMPILE=0
WARNINGS="
--warn=unsupported-warning
--warn=unused-variable
--warn=unused-toplevel
--warn=unbound-variable
--warn=macro-use-before-definition
--warn=arity-mismatch
--warn=duplicate-case-datum
--warn=bad-case-datum
--warn=format
"
for i in $SCM_FILES $SCRIPTS; do
b=$(basename $i)
go=${i%%.scm}.go
if [ $i -nt $go ]; then
trace "GUILEC $b" $GUILD compile -L ${srcdir} $WARNINGS -o $go $i
fi
done

View File

@ -1,45 +0,0 @@
#! @BASH@
# Gash --- Guile As SHell
# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of Gash.
#
# Gash 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.
#
# Gash 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 Gash. If not, see <http://www.gnu.org/licenses/>.
srcdir="@srcdir@"
abs_top_srcdir="@abs_top_srcdir@"
abs_top_builddir="@abs_top_builddir@"
prefix=${prefix-@prefix@}
MES_PREFIX=${MES_PREFIX-${srcdest}mes}
export MES_PREFIX
GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/bin:$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="$abs_top_srcdir${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
if [ -n "$srcdest" ]; then
GUILE_LOAD_PATH="${srcdest}module:${srcdest}mes:$GUILE_LOAD_PATH"
fi
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
PATH="$abs_top_builddir/bin:$PATH"
export PATH
COMMANDS="$abs_top_builddir/gash/commands"
export COMMANDS
LANG=
LC_ALL=
exec "$@"

View File

@ -1,41 +0,0 @@
# Gash --- Guile As SHell
# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of Gash.
#
# Gash 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.
#
# Gash 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 Gash. If not, see <http://www.gnu.org/licenses/>.
if [ -z "$V" -o "$V0" = 0 ]; then
trace () {
echo " $1"
shift
eval "$@" $LOG
}
LOG=" >>build.log 2>&1"
fi
if [ "$V" = 1 ]; then
trace () {
shift
echo "$@"
eval "$@ $LOG"
}
LOG=" >>build.log 2>&1"
fi
if [ "$V" = 2 ]; then
set -x
trace () {
shift
eval "$@"
}
fi

129
configure vendored
View File

@ -1,129 +0,0 @@
#! /bin/sh
VERSION=0.1
# parse --prefix=PREFIX, mainly for GuixSD/Debian
cmdline=$(echo "$@")
PREFIX=${cmdline##*--prefix=}
PREFIX=${PREFIX% *}
PREFIX=${PREFIX% -*}
if [ -z "$PREFIX" ]; then
PREFIX=/usr/local
fi
BASH=$(command -v bash)
GUILE=${GUILE-$(command -v guile)}
GUILD=${GUILD-$(command -v guild || command -v guile-tools)}
guile_site_dir=$PREFIX/share/guile/site/$guile_effective_version
guile_site_ccache_dir=$PREFIX/lib/guile/$guile_effective_version/site-ccache
guile_effective_version=$(guile -c '(display (effective-version))')
MAKEINFO=$(command -v makeinfo)
GEESH_PREFIX=${GEESH_PREFIX-$HOME/src/geesh}
if [ -d $GEESH_PREFIX ]; then
GUILE_LOAD_PATH=$GEESH_PREFIX:$GUILE_LOAD_PATH
GUILE_LOAD_COMPILED_PATH=$GEESH_PREFIX:$GUILE_LOAD_COMPILED_PATH
if ! $GUILE -c '(use-modules (geesh parser)) (exit (defined? '"'"'read-sh-all))'; then
echo "warning: building without Geesh"
fi
fi
if [ "$srcdir" = . ]; then
top_builddir=.
else
srcdest=${srcdest}
top_builddir=$PWD
fi
abs_top_srcdir=${abs_top_srcdir-$(cd ${srcdir} && pwd)}
abs_top_builddir=$PWD
cat > .config.make <<EOF
BASH=$BASH
GUILE=$GUILE
GUILD=$GUILD
prefix=$PREFIX
bindir=$PREFIX/bin
docdir=$PREFIX/share/doc/gash
guile_effective_version=$guile_effective_version
guile_site_dir=$guile_site_dir
guile_site_ccache_dir=$guile_site_ccache_dir
MAKEINFO=$MAKEINFO
SHELL=$BASH
VERSION=$VERSION
EOF
BZIP2=$(command -v bzip2)
COMPRESS=$(command -v compress)
[ -z "$COMPRESS" ] && COMPRESS=$PWD/bin/compress
GZIP=$(command -v gzip)
XZ=$(command -v xz)
subst () {
sed \
-e s,"@srcdest@,$srcdest,"\
-e s,"@srcdir@,$srcdir,"\
-e s,"@abs_top_srcdir@,$abs_top_srcdir,"\
-e s,"@abs_top_builddir@,$abs_top_builddir,"\
-e s,"@top_builddir@,$top_builddir,"\
-e s",@BASH@,$BASH,"\
-e s",@GUILE@,$GUILE,"\
-e s,"@prefix@,$prefix,"\
-e s",@guile_site_dir@,$guile_site_dir,"\
-e s",@guile_site_ccache_dir@,$guile_site_ccache_dir,"\
-e s",@BZIP2@,$BZIP2,"\
-e s",@COMPRESS@,$COMPRESS,"\
-e s",@GZIP@,$GZIP,"\
-e s",@XZ@,$XZ,"\
-e s",@VERSION@,$VERSION,"\
-e s",@guile_site_dir@,$guile_site_dir,"\
-e s",@guile_site_ccache_dir@,$guile_site_ccache_dir,"\
-e s",@builtin@,$builtin,"\
$1 > $2
}
SHELLS="
bash
gash
sh
"
for shell in $SHELLS; do
subst ${srcdest}scripts/gash.in scripts/$shell
chmod +x scripts/$shell
done
BUILTINS="
basename
cat
chmod
compress
cp
dirname
find
grep
ls
mkdir
mv
reboot
rm
rmdir
sed
tar
touch
tr
wc
which
"
for builtin in $BUILTINS; do
subst ${srcdest}bin/builtin.in bin/$builtin
chmod +x bin/$builtin
done
subst ${srcdest}gash/config.scm.in gash/config.scm
subst ${srcdest}build-aux/pre-inst-env.in pre-inst-env
chmod +x pre-inst-env
cat <<EOF
Run:
make to build gash
make help for help on other targets
EOF

View File

@ -8,10 +8,28 @@ AM_SILENT_RULES([yes])
GUILE_PKG([2.2])
GUILE_PROGS
AC_PATH_PROG([COMPRESS], [compress])
AC_PATH_PROG([GZIP], [gzip])
if test x"$GZIP" = x ; then
AC_MSG_ERROR([could not find gzip])
fi
AC_PATH_PROG([BZIP2], [bzip2])
if test x"$BZIP2" = x ; then
AC_MSG_ERROR([could not find bzip2])
fi
AC_PATH_PROG([XZ], [xz])
if test x"$XZ" = x ; then
AC_MSG_ERROR([could not find xz])
fi
AC_PATH_PROG([GENHTML], [genhtml])
AM_CONDITIONAL([HAVE_GENHTML], [test -n $GENHTML])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([gash/config.scm])
AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
AC_CONFIG_FILES([tests/unit/config.scm])
AC_CONFIG_FILES([tests/spec/Makefile])

View File

@ -1,94 +0,0 @@
.PHONY: all all-go check clean install
-include .config.make
default: all
.config.make: makefile
scripts/gash: scripts/gash.in
$(MAKE) do-configure
gash/config.scm:
$(MAKE) do-configure
do-configure:
./configure --prefix=$(prefix)
all: all-go
all-go: | gash/config.scm
build-aux/build-guile.sh
clean:
git clean -fdx
clean-go:
rm -f $(shell find . -name '*.go')
check: all check-bash check-gash
check-bash: all
ifneq ($(BASH),)
PATH=$(PATH):bin SHELL=$(BASH) ./check.sh
endif
check-gash: all
SHELL=scripts/gash ./check.sh
check-parse: all
SHELL='scripts/gash -p' PARSE=1 ./check.sh
check-geesh: all
SHELL='scripts/gash --geesh' ./check.sh
install: all
mkdir -p $(DESTDIR)$(bindir)
cp scripts/gash $(DESTDIR)$(bindir)/gash
mkdir -p $(DESTDIR)$(guile_site_dir)
tar -cf- gash/*.scm | tar -C $(DESTDIR)$(guile_site_dir) -xf-
mkdir -p $(DESTDIR)$(guile_site_ccache_dir)
cp scripts/gash.go $(DESTDIR)$(guile_site_ccache_dir)
tar -cf- gash/*.go | tar -C $(DESTDIR)$(guile_site_ccache_dir) -xf-
mkdir -p $(DESTDIR)$(docdir)
cp -f COPYING README TODO $(docdir)
$(MAKE) install-info
install-info: info
mkdir -p $(DESTDIR)$(prefix)/share/info
tar -cf- doc/gash.info* | tar -xf- --strip-components=1 -C $(DESTDIR)$(prefix)/share/info
install-info --info-dir=$(DESTDIR)$(prefix)/share/info doc/gash.info
doc/version.texi: doc/gash.texi makefile
(set `LANG= date -r $< +'%d %B %Y'`;\
echo "@set UPDATED $$1 $$2 $$3"; \
echo "@set UPDATED-MONTH $$2 $$3"; \
echo "@set EDITION $(VERSION)"; \
echo "@set VERSION $(VERSION)") > $@
info: doc/gash.info
doc/gash.info: doc/gash.texi doc/version.texi makefile
$(MAKEINFO) -o $@ -I doc $<
define HELP_TOP
Usage: make [OPTION]... [TARGET]...
Targets:
all update everything
all-go update .go files
check run ./test.sh
clean run git clean -dfx
clean-go clean .go files
install install in $(PREFIX)
endef
export HELP_TOP
help:
@echo "$$HELP_TOP"
export BUILD_DEBUG
export GUILE
export GUILE_TOOLS
export guile_load_path
export guile_load_compiled_path

View File

@ -1,5 +1,5 @@
#! @GUILE@ \
--no-auto-compile -e main -L @guile_site_dir@ -C @guile_site_ccache_dir@ -L . -C . -s
--no-auto-compile -e main -L @MODDIR@ -C @GODIR@ -L . -C . -s
!#
;;; Gash --- Guile As SHell
;;; Copyright © 2016,2017,2018 R.E.W. van Beusekom <rutger.van.beusekom@gmail.com>