[aisleriot] guile: Install the compiled files not the sources



commit 11656d96cef37552da10125f3969793ca43ceb2f
Author: Christian Persch <chpe gnome org>
Date:   Sat Dec 3 17:05:14 2011 +0100

    guile: Install the compiled files not the sources
    
    On guile 2.x, install the compiled .go files instead of the source .scm files.
    
    Remove the check for guile-tools in configure, and instead check for guile.
    guile-tools however aborts the compile because it doesn't know about our internal
    (aisleriot interface) module. So we copy it into our repo (the licence is LGPL3+
    which is compatible with ours), and add a dummy module definition to it.

 configure.ac        |    8 ++--
 games/Makefile.am   |   41 ++++++++++++++++++++----
 games/guile-compile |   84 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4586b5a..e6557ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -572,10 +572,10 @@ AM_CONDITIONAL([HAVE_GUILE_2_X],[test "$with_guile" != "1.8"])
 
 AC_SUBST([GUILE_EFFECTIVE_VERSION],[$with_guile])
 
-AC_ARG_VAR([GUILE_TOOLS])
-AC_PATH_PROG([GUILE_TOOLS],[guile-tools],[false])
-if test "$GUILE_TOOLS" = "false"; then
-  AC_MSG_ERROR([guile-tools not found])
+AC_ARG_VAR([GUILE],[the guile programme])
+AC_PATH_PROG([GUILE],[guile],[false])
+if test "$GUILE" = "false"; then
+  AC_MSG_ERROR([guile not found])
 fi
 
 # *************
diff --git a/games/Makefile.am b/games/Makefile.am
index 4c424f5..db5feda 100644
--- a/games/Makefile.am
+++ b/games/Makefile.am
@@ -1,13 +1,10 @@
 NULL = 
 
-pkgguiledir = $(pkgdatadir)/guile/$(GUILE_EFFECTIVE_VERSION)
-
-moduledir = $(pkgguiledir)/aisleriot
-module_DATA = \
+module_GUILE = \
 	api.scm \
 	$(NULL)
 
-pkgguile_DATA  = \
+games_GUILE = \
 	accordion.scm \
 	agnes.scm \
 	athena.scm \
@@ -98,9 +95,39 @@ pkgguile_DATA  = \
 	zebra.scm \
 	$(NULL)
 
+if HAVE_GUILE_2_X
+
+pkglibguiledir = $(pkglibdir)/guile/$(GUILE_EFFECTIVE_VERSION)
+compiledmoduledir = $(pkglibguiledir)/aisleriot
+
+nodist_pkglibguile_DATA = $(games_GUILE:.scm=.go)
+nodist_compiledmodule_DATA = $(module_GUILE:.scm=.go)
+
+CLEANFILES = $(nodist_pkglibguile_DATA) $(nodist_compiledmodule_DATA)
+
+AM_V_GUILEC = $(AM_V_GUILEC_$(V))
+AM_V_GUILEC_ = $(AM_V_GUILEC_$(AM_DEFAULT_VERBOSITY))
+AM_V_GUILEC_0 = @echo "  GUILEC" $@;
+
+GUILE_FLAGS =
+# GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
+
+%.go: %.scm
+	$(AM_V_GUILEC) GUILE=$(GUILE) GUILE_FLAGS=$(GUILE_FLAGS) GUILE_AUTO_COMPILE=0 GUILE_LOAD_PATH=. GUILE_LOAD_COMPILED_PATH=. $(srcdir)/guile-compile compile $(GUILE_WARNINGS) -o "$@" "$<"
+
+else # !HAVE_GUILE_2_X
+
+pkgdataguiledir = $(pkgdatadir)/guile/$(GUILE_EFFECTIVE_VERSION)
+moduledir = $(pkgdataguiledir)/aisleriot
+
+nodist_pkgdataguile_DATA = $(games_GUILE)
+nodist_module_DATA = $(module_GUILE)
+
+endif # HAVE_GUILE_2_X
+
 EXTRA_DIST = \
-	$(pkgguile_DATA) \
-	$(module_DATA) \
+	$(games_GUILE) \
+	$(module_GUILE) \
 	template.scm \
 	Rules.HOWTO \
 	$(NULL)
diff --git a/games/guile-compile b/games/guile-compile
new file mode 100755
index 0000000..195e324
--- /dev/null
+++ b/games/guile-compile
@@ -0,0 +1,84 @@
+#!/bin/sh
+# -*- scheme -*-
+exec $GUILE $GUILE_FLAGS -e '(@@ (guild) main)' -s "$0" "$@"
+!#
+
+;;;; guild --- running scripts bundled with Guile
+;;;; Andy Wingo <wingo pobox com> --- April 2009
+;;;; 
+;;;; 	Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+;;;; 
+;;;; This library is free software; you can redistribute it and/or
+;;;; modify it under the terms of the GNU Lesser General Public
+;;;; License as published by the Free Software Foundation; either
+;;;; version 3 of the License, or (at your option) any later version.
+;;;; 
+;;;; This library 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
+;;;; Lesser General Public License for more details.
+;;;; 
+;;;; You should have received a copy of the GNU Lesser General Public
+;;;; License along with this library; if not, write to the Free
+;;;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;;;; Boston, MA 02110-1301 USA
+
+;; We need to provide a dummy module for our internal API
+
+(define-module (aisleriot interface))
+
+;; empty
+
+(define-module (aisleriot api))
+
+;; empty
+
+(define-module (guild)
+  #:use-module (ice-9 getopt-long)
+  #:use-module (ice-9 command-line)
+  #:autoload (ice-9 format) (format))
+
+;; Hack to provide scripts with the bug-report address.
+(module-define! the-scm-module
+                '%guile-bug-report-address
+                "bug-guile gnu org")
+
+
+(define *option-grammar*
+  '((help (single-char #\h))
+    (version (single-char #\v))))
+
+(define (display-version)
+  (version-etc "GNU Guile"
+               (version)
+               #:command-name "guild"
+               #:license *LGPLv3+*))
+
+(define (find-script s)
+  (resolve-module (list 'scripts (string->symbol s)) #:ensure #f))
+
+(define (main args)
+  (if (defined? 'setlocale)
+      (setlocale LC_ALL ""))
+
+  (let* ((options (getopt-long args *option-grammar*
+                               #:stop-at-first-non-option #t))
+         (args (option-ref options '() '())))
+    (cond
+     ((option-ref options 'help #f)
+      (apply (module-ref (resolve-module '(scripts help)) 'main) args)
+      (exit 0))
+     ((option-ref options 'version #f)
+      (display-version)
+      (exit 0))
+     ((find-script (if (null? args) "help" (car args)))
+      => (lambda (mod)
+           (exit (apply (module-ref mod 'main) (if (null? args)
+                                                   '()
+                                                   (cdr args))))))
+     (else
+      (format (current-error-port)
+              "guild: unknown script ~s~%" (car args))
+      (format (current-error-port)
+              "Try `guild help' for more information.~%")
+      (exit 1)))))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]