bug-mcron
[Top][All Lists]
Advanced

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

[Bug-mcron] [PATCH 19/33] build: Compile and install '.go' files.


From: Mathieu Lirzin
Subject: [Bug-mcron] [PATCH 19/33] build: Compile and install '.go' files.
Date: Sun, 27 Sep 2015 23:00:30 +0200

Adapted from Guix build system.

* configure.ac: Set and substitute 'guilemoduledir'.  Check for 'guild'
  which requires Guile >= 2.0.7.  Use 'AC_CANONICAL_HOST'.
* scm/mcron/makefile.am (.scm.go): New target.
  (MODULES, GOBJECTS, CLEANFILES, AM_V_GUILEC, AM_V_GUILEC_)
  (AM_V_GUILEC_0, SUFFIXES, nobase_dist_guilemodule_DATA)
  (nobase_nodist_guilemodule_DATA): New variables.
  (pkgdata_DATA, EXTRA_DIST): Remove variables.
* .gitignore: Adjust accordingly.
---
 .gitignore            |  3 +++
 configure.ac          | 13 +++++++++++--
 scm/mcron/main.scm    |  2 ++
 scm/mcron/makefile.am | 43 ++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4505cc5..9748b8a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,12 @@
 *~
+*.go
 .deps
 INSTALL
 aclocal.m4
 autom4te.cache
 /build-aux/compile
+/build-aux/config.guess
+/build-aux/config.sub
 /build-aux/depcomp
 /build-aux/install-sh
 /build-aux/mdate-sh
diff --git a/configure.ac b/configure.ac
index 2149e9d..56914d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,6 +26,8 @@ AC_INIT([GNU Mcron], [1.0.8], address@hidden)
 AC_CONFIG_AUX_DIR([build-aux])
 AM_INIT_AUTOMAKE
 
+guilemoduledir="${datarootdir}/guile/site/2.0"
+AC_SUBST([guilemoduledir])
 
 AC_MSG_CHECKING([whether debugging is requested])
 AC_ARG_ENABLE(debug,
@@ -45,12 +47,19 @@ AC_SUBST(CONFIG_DEBUG)
 # We have no interest (hence a no-op), but Debian wants this.
 AC_ARG_ENABLE(maintainer-mode)
 
-
+AC_CANONICAL_HOST
 AC_PROG_AWK
 AC_PROG_EGREP
 AM_PROG_CC_C_O
 
-PKG_CHECK_MODULES(GUILE, guile-2.0)
+PKG_CHECK_MODULES([GUILE], [guile-2.0 >= 2.0.7])
+AC_PATH_PROG([GUILE], [guile])
+
+# search guild
+AC_PATH_PROG([GUILD], [guild])
+if test "x$GUILD" = "x"; then
+   AC_MSG_ERROR(['guild' binary not found; please check your guile-2.x 
installation.])
+fi
 
 # Checks for programs.
   
diff --git a/scm/mcron/main.scm b/scm/mcron/main.scm
index c03ccfc..44f8104 100644
--- a/scm/mcron/main.scm
+++ b/scm/mcron/main.scm
@@ -343,6 +343,8 @@ comes in on the above socket."
     (unless (option-ref options 'schedule #f)
       (with-output-to-file config-pid-file noop))
     (setenv "MAILTO" #f)
+    ;; XXX: At compile time, this yields a "possibly unbound variable"
+    ;; warning, but this is OK since it is bound in the C wrapper.
     (c-set-cron-signals))
 
   ;; Now we have the procedures in place for dealing with the contents of
diff --git a/scm/mcron/makefile.am b/scm/mcron/makefile.am
index 931b03b..a29af59 100644
--- a/scm/mcron/makefile.am
+++ b/scm/mcron/makefile.am
@@ -1,10 +1,43 @@
-EXTRA_DIST = main.scm mcron-core.scm vixie-specification.scm \
-             crontab.scm environment.scm job-specifier.scm redirect.scm \
-             vixie-time.scm
+MODULES =                                      \
+  core.scm                                     \
+  environment.scm                              \
+  job-specifier.scm                            \
+  main.scm                                     \
+  redirect.scm                                 \
+  vixie-specification.scm                      \
+  vixie-time.scm
 
-pkgdata_DATA = core.scm environment.scm job-specifier.scm redirect.scm \
-               vixie-time.scm vixie-specification.scm config.scm
+GOBJECTS = $(MODULES:%.scm=%.go) config.go
 
+nobase_dist_guilemodule_DATA = $(MODULES) crontab.scm
+nobase_nodist_guilemodule_DATA = $(GOBJECTS) config.scm
+
+CLEANFILES = $(GOBJECTS)
+
+AM_V_GUILEC = $(AM_V_GUILEC_$(V))
+AM_V_GUILEC_ = $(AM_V_GUILEC_$(AM_DEFAULT_VERBOSITY))
+AM_V_GUILEC_0 = @echo "  GUILEC" $@;
+
+# Unset 'GUILE_LOAD_COMPILED_PATH' altogether while compiling.  Otherwise, if
+# $GUILE_LOAD_COMPILED_PATH contains $(moduledir), we may find .go files in
+# there that are newer than the local .scm files (for instance because the
+# user ran 'make install' recently).  When that happens, we end up loading
+# those previously-installed .go files, which may be stale, thereby breaking
+# the whole thing.
+#
+# XXX: Use the C locale for when Guile lacks
+# 
<http://git.sv.gnu.org/cgit/guile.git/commit/?h=stable-2.0&id=e2c6bf3866d1186c60bacfbd4fe5037087ee5e3f>.
+.scm.go:
+       $(AM_V_GUILEC)$(MKDIR_P) `dirname "$@"` ;                       \
+       unset GUILE_LOAD_COMPILED_PATH ;                                \
+       LC_ALL=C                                                        \
+       $(GUILD) compile                                                \
+         -L "$(top_builddir)/scm" -L "$(top_srcdir)/scm"               \
+         -Wformat -Wunbound-variable -Warity-mismatch                  \
+         --target="$(host)"                                            \
+         -o "$@" "$<"
+
+SUFFIXES = .go
 
 # If you're wondering, the configure script keeps deleting all files with a 
name
 # like core.*, so we have to keep re-making it (I lost a good day's work 
because

reply via email to

[Prev in Thread] Current Thread [Next in Thread]