Reputation: 81
Recently started learning to use auto-tools and have been trying make a simple Guile program with it. Following this tutorial I got the program successfully compiling, with the .go file placed in %site-ccache-dir
and the .scm file placed in %site-dir
. But, the tutorial is aimed at making modules rather than a making an executable. Would just creating a link to the .scm file in %site-dir
and placing it in /usr/bin
be enough? What is best way of doing that with auto-tools? Below is what I currently have setup...
guile.am:
moddir=$(datadir)/guile/site/$(GUILE_EFFECTIVE_VERSION)
godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache
GOBJECTS = $(SOURCES:%.scm=%.go)
nobase_dist_mod_DATA = $(SOURCES) $(NOCOMP_SOURCES)
nobase_go_DATA = $(GOBJECTS)
# Make sure source files are installed first, so that the mtime of
# installed compiled files is greater than that of installed source
# files. See
# <http://lists.gnu.org/archive/html/guile-devel/2010-07/msg00125.html>
# for details.
guile_install_go_files = install-nobase_goDATA
$(guile_install_go_files): install-nobase_dist_modDATA
CLEANFILES = $(GOBJECTS)
GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
SUFFIXES = .scm .go
.scm.go:
$(AM_V_GEN)$(top_builddir)/pre-inst-env $(GUILD) compile $(GUILE_WARNINGS) -o "$@" "$<"
bootstrap:
#!/usr/bin/env sh
autoreconf --verbose --install --force
Makefile.am:
include guile.am
SOURCES = \
example-program.scm
EXTRA_DIST = \
bootstrap \
pre-inst-env.in
configure.ac:
AC_INIT([example-program], [0.1])
AC_CONFIG_SRCDIR([example-program.scm])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
GUILE_PKG([2.2])
GUILE_PROGS
if test "x$GUILD" = "x"; then
AC_MSG_ERROR(['guild' binary not found; please check your guile-2.x installation.])
fi
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
AC_OUTPUT
pre-inst-env.in:
#!/bin/sh
abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd`"
abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd`"
GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir${GUILE_LOAD_PATH:+:}:$GUILE_LOAD_PATH"
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
PATH="$abs_top_builddir:$PATH"
export PATH
exec "$@"
example-program.scm:
#!/usr/bin/guile \
-e main -s
!#
;;; Functions.
(define count-to-100
(lambda ()
(define my-num 1)
(while (<= my-num 100)
(display my-num)
(newline)
(set! my-num (+ my-num 1)))))
;;; Main.
(define (main args)
(count-to-100))
Upvotes: 3
Views: 1548
Reputation: 36
This is a really old question but still open so if it can benefit to someone...
To take advantage of the autotools features for your Guile projects, you can use Hall. It takes care of a lot of stuff for you to end up with the ability to call things like make
, make check
, make distcheck
, make clean
, etc...
You can find a demo here
Hope someone will find this information helpful...
Cheers !
Upvotes: 1