3

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))
arved
  • 4,401
  • 4
  • 30
  • 53
  • I'm uncertain about the Guile-specific details, but the way to produce an executable with the Autotools starts with naming the target in a `*_PROGRAMS` variable in your `Makefile.am`. For example, `bin_PROGRAMS = example'. You then name that target's corresponding source file in a matching `*_SOURCES` variable. I'm don't know how much of all that other stuff you need, if any. With the Autotools, you don't usually need to specify details for building intermediate files. – John Bollinger Dec 02 '18 at 13:48
  • Ouch, that needed a more careful eye. Correction: you name *all* of the target's source file***s*** in a corresponding `*_SOURCES` variable. – John Bollinger Dec 02 '18 at 17:39
  • @JohnBollinger, I added `bin_PROGRAMS = example` and changed `SOURCES` to `example_SOURCES`. I ran `autoreconf --verbose --install --force`, `./configure`, then finally `make` which resulted in an error complaining over a lack of input files. – Gareth Anthony Hulse Dec 08 '18 at 19:22
  • I'm afraid I don't know what else to tell you, for as I already said, I'm unfamiliar with the Guile-specific details and can speak only to general Autotools principles. – John Bollinger Dec 09 '18 at 04:01

1 Answers1

1

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 !

Jeko
  • 36
  • 4