diff options
author | Paul Smith <psmith@gnu.org> | 2012-01-16 03:32:49 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2012-01-16 03:32:49 +0000 |
commit | 49cc211819851b76c58fb37eeb579bd88a5ac65a (patch) | |
tree | 7846b379f1444f31458313bc97b2acf24c8a2a87 /guile.c | |
parent | 4e2e5eb199b5fbaf7cfdb203c64099b514fba5d0 (diff) | |
download | gunmake-49cc211819851b76c58fb37eeb579bd88a5ac65a.tar.gz |
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.
Diffstat (limited to 'guile.c')
-rw-r--r-- | guile.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -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; } |