From 49cc211819851b76c58fb37eeb579bd88a5ac65a Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 16 Jan 2012 03:32:49 +0000 Subject: Create a new internal interface for defining new make functions. This allows us to create new functions without changing function.c. You still have to modify the GNU make code (for now) though: this is simply a preliminary step to possibly allowing make to load modules. Modify the Guile integration to use this method rather than ifdefs in function.c. --- guile.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'guile.c') diff --git a/guile.c b/guile.c index 060c6d6..c32821a 100644 --- a/guile.c +++ b/guile.c @@ -85,20 +85,33 @@ internal_guile_eval (void *arg) return cvt_scm_to_str (scm_c_eval_string (arg)); } -/* ----- Public interface ----- */ - -/* This is the make interface for passing programs to Guile. */ -char * -guile_eval_string (char *str) +/* This is the function registered with make */ +static char * +func_guile (char *o, char **argv, const char *funcname UNUSED) { - return scm_with_guile (internal_guile_eval, str); + if (argv[0] && argv[0][0] != '\0') + { + char *str = scm_with_guile (internal_guile_eval, argv[0]); + o = variable_buffer_output (o, str, strlen (str)); + free (str); + } + + return o; } -void +/* ----- Public interface ----- */ + +int setup_guile () { + /* Initialize the Guile interpreter. */ scm_with_guile (guile_init, NULL); + /* Create a make function "guile". */ + define_new_function (NILF, "guile", 0, 1, 1, func_guile); + /* Add 'guile' to the list of features. */ do_variable_definition (NILF, ".FEATURES", "guile", o_default, f_append, 0); + + return 1; } -- cgit v1.2.3