From 8952d2dc442913f0ecf1fa896d97c882a5daa664 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 17 Oct 2015 20:05:08 +0200 Subject: build: Support VPATH builds. This allows using 'mcron' before it is installed without hardcoding the local build environment in the executable. * build-aux/pre-inst-env.in: New script. * configure.ac (AC_CONFIG_FILES): Create it. (AC_CONFIG_HEADER): Add 'config.h'. (moduledir): New variable. (PACKAGE_LOAD_PATH): new C preprocessor macro. * mcron.c: Include "config.h". (main): Don't overwrite Guile load paths. (inner_main): Prepend Mcron modules load paths. * Makefile.am (.scm.go, doc/mcron.1): Use 'pre-inst-env'. (mcron_CFLAGS): Remove GUILE_LOAD_PATH macro. (noinst_SCRIPTS): New variable. * .gitignore: Update. --- mcron.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'mcron.c') diff --git a/mcron.c b/mcron.c index 0c62ec8..92e1a37 100644 --- a/mcron.c +++ b/mcron.c @@ -22,6 +22,7 @@ is needed because the crontab personality requires SUID which is not permitted for executable scripts. */ +#include "config.h" #include #include #include @@ -35,7 +36,6 @@ static SCM set_cron_signals (void); int main (int argc, char **argv) { - setenv ("GUILE_LOAD_PATH", GUILE_LOAD_PATH, 1); scm_boot_guile (argc, argv, inner_main, 0); return EXIT_SUCCESS; @@ -45,6 +45,14 @@ main (int argc, char **argv) static void inner_main (void *closure, int argc, char **argv) { + /* Set Guile load paths to ensure that Mcron modules will be found. */ + if (getenv ("MCRON_UNINSTALLED") == NULL) + { + scm_c_eval_string ("(set! %load-path (cons \"" + PACKAGE_LOAD_PATH "\" %load-path))"); + scm_c_eval_string ("(set! %load-compiled-path (cons \"" + PACKAGE_LOAD_PATH "\" %load-compiled-path))"); + } scm_set_current_module (scm_c_resolve_module ("mcron main")); /* Register set_cron_signals to be called from Guile. */ scm_c_define_gsubr ("c-set-cron-signals", 0, 0, 0, set_cron_signals); -- cgit v1.2.3