使用自动工具制作可执行的Guile程序?

时间:2018-12-01 23:05:16

标签: scheme gnu autotools guile fhs

最近开始学习使用自动工具,并一直在尝试使用它制作一个简单的Guile程序。 Following this tutorial使程序成功编译,.go文件放在%site-ccache-dir中,而.scm文件放在%site-dir中。但是,本教程的目的是制作模块,而不是制作可执行文件。仅在%site-dir中创建指向.scm文件的链接并将其放置在/usr/bin中就足够了吗?用自动工具做到这一点的最佳方法是什么?以下是我目前的设置...

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 "$@" "$<"

引导程序:

#!/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))

1 个答案:

答案 0 :(得分:0)

这是一个非常老的问题,但仍然存在,因此它是否可以使某人受益...

要利用Guile项目的自动工具功能,可以使用Hall。最终,您可以调用诸如makemake checkmake distcheckmake clean等功能。

您可以找到一个演示here

希望有人会发现此信息有帮助...

干杯!