Subject: bug#7995: [PATCH 3/4] Guile macro AM_PATH_GUILE.

From: Ralf Wildenhues <[email-masked]>
Date: Sun, 20 Feb 2011 08:32:17 +0100

* m4/guile.m4 (AM_PATH_GUILE): New file, new macro.
* m4/Makefile.am (dist_m4data_DATA): Add guile.m4.
---
 ChangeLog      |    4 +++
 m4/Makefile.am |    3 +-
 m4/Makefile.in |    3 +-
 m4/guile.m4    |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 2 deletions(-)
 create mode 100644 m4/guile.m4

diff --git a/ChangeLog b/ChangeLog
index 5483ce4..bd27a05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-02-20  Ralf Wildenhues  <[email-masked]>
 
+	Guile macro AM_PATH_GUILE.
+	* m4/guile.m4 (AM_PATH_GUILE): New file, new macro.
+	* m4/Makefile.am (dist_m4data_DATA): Add guile.m4.
+
 	Testsuite coverage for Guile support.
 	* tests/guile1.test, tests/guile2.test, tests/guile3.test,
 	tests/guile4.test: New tests.
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 0cf074b..fe7a8d6 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -3,7 +3,7 @@
 ## Makefile for Automake m4.
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2006,
-# 2008, 2009 Free Software Foundation, Inc.
+# 2008, 2009, 2011 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -31,6 +31,7 @@ depend.m4 \
 depout.m4 \
 dmalloc.m4 \
 gcj.m4 \
+guile.m4 \
 header.m4 \
 init.m4 \
 install-sh.m4 \
diff --git a/m4/Makefile.in b/m4/Makefile.in
index e508848..49f46a7 100644
--- a/m4/Makefile.in
+++ b/m4/Makefile.in
@@ -16,7 +16,7 @@
 @SET_MAKE@
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2006,
-# 2008, 2009 Free Software Foundation, Inc.
+# 2008, 2009, 2011 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -201,6 +201,7 @@ depend.m4 \
 depout.m4 \
 dmalloc.m4 \
 gcj.m4 \
+guile.m4 \
 header.m4 \
 init.m4 \
 install-sh.m4 \
diff --git a/m4/guile.m4 b/m4/guile.m4
new file mode 100644
index 0000000..d16da79
--- /dev/null
+++ b/m4/guile.m4
@@ -0,0 +1,63 @@
+# Guile file handling                                      -*- Autoconf -*-
+
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PATH_GUILE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# --------------------------------------------------------------------------
+# Adds support for distributing Guile source files and compiled sources.
+# To install files, copy them to $(guiledir), using the guile_GUILE
+# automake variable.  To install a package with the same name as the
+# automake package, install to $(pkgguiledir), or use the
+# pkgguile_GUILE automake variable.
+#
+# The variables $(guileexecdir) and $(guileextensiondir) are provided as
+# locations to install Guile extension modules (shared libraries).
+# The XXX macro is required to find the appropriate flags to compile
+# extension modules.
+#
+# If the MINIMUM-VERSION argument is passed, AM_PATH_GUILE will
+# cause an error if the version of python installed on the system
+# doesn't meet the requirement.  MINIMUM-VERSION should consist of
+# numbers and dots only.
+AC_DEFUN([AM_PATH_GUILE],
+[AC_PATH_PROG([GUILE_TOOLS], [guile-tools], [:])
+am__guile_apiversion=1.6
+if test "$GUILE_TOOLS" != :; then
+  GUILE_VERSION=`$GUILE_TOOLS --version | sed '[s/.*\([1-9][0-9.]*\).*/\1/]'`
+  AS_VERSION_COMPARE([$GUILE_VERSION], [1.8],
+    [am__guile_apiversion=1.6],
+    [am__guile_apiversion=1.8],
+    [am__guile_apiversion=2.0])
+fi
+AC_SUBST([GUILE_VERSION])
+case $am__guile_apiversion in #(
+1.6) ;; #(
+1.8)
+  guiledir='${datarootdir}'/guile/site/$GUILE_VERSION
+  guileexecdir='${libdir}'/guile/$GUILE_VERSION/ccache
+  guileextdir='${libdir}'/guile/$GUILE_VERSION/extensions
+  ;; #(
+*)
+  guiledir='${datarootdir}'/guile/site/$GUILE_VERSION
+  guileexecdir='${libdir}'
+  guileextdir='${libdir}'
+  ;;
+esac
+case $am__guile_apiversion in #(
+1.6)
+  m4_default([$3], [AC_MSG_ERROR([no working Guile installation found])])
+  ;; #(
+*)
+  $2
+  ;;
+esac
+AC_SUBST([guiledir])dnl
+AC_SUBST([pkgguiledir], ['${guiledir}'/$PACKAGE])dnl
+AC_SUBST([guileexecdir])dnl
+AC_SUBST([guileextdir])dnl
+AC_ARG_VAR([GUILEFLAGS], [Flags for compilation of Guile source files])dnl
+])
-- 
1.7.4.1.48.g5673d