help-make
[Top][All Lists]
Advanced

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

Re: adding functions to function.c


From: Dill, John
Subject: Re: adding functions to function.c
Date: Wed, 12 Jan 2005 10:23:31 -0600

>I was the one that suggested you do that.  For example, suppose you were
>me and you egotistically wanted to add the $(jgc TEXT) function which
>printed out John Graham-Cumming followed by the expanded TEXT argument
>you would do this:
>
>1. Add a function that does the work:
>
>static char *
>func_jgc (o, argv, funcname)
>     char *o;
>     char **argv;
>     const char *funcname;
>{
>  char f[256];
>  sprintf( f, "John Graham-Cumming %s", argv[0] );
>  return variable_buffer_output (o, f, strlen(f));
>}
>
>2. Add an entry in the function table:
>
>  { STRING_SIZE_TUPLE("jgc"),           0,  1,  1,  func_jgc},
>
>which states that the $(jgc) function has maximum one argument which
>should be expanded before the value is passed to func_jgc.
>
>
>Now consider this Makefile:
>
>FOO := is nuts
>
>all: ; @echo $(jgc $(FOO))
>
>When using the augmented GNU Make with the $(jgc) function this prints
>
>John Graham-Cumming is nuts
>
>$(FOO) is expanded before func_jgc is called because expanding was set
>to 1 and the func_jgc just returns that appropriate string in o.

That is cool.  I was able to get a couple of functions working, but what about 
global variables.  Is expand only 1 or 0?  If I wanted to define semantics for 
$(true) and $(false) to expand to "true" and "" for example, is that a easy 
task as well?  Also, what is the rule of thumb if encoding functions which 
expect a certain format, like numbers for instance.

Do you maintain your own special version of make with your own additions?

You've kind of put me at a crossroads.  I have done some work on adding 
functionality to make through creating functions and using them with $(call 
...), which is all well and good, but I don't know if it may be better to learn 
the make source and implement some of the missing functionality I need in that, 
like the boolean functions for example.  I looked in the mingw32 source for 
make 3.80 and found that there was an EXPERIMENTAL with not and eq functions.  
I also have a little numerical library which does some simple add, sub, and 
numerical comparisons '< > == != <= >=', but it has limitations since it's 
based on list manipulation (using a number list) using make functions (no 
negative integers and max limit of 1000 which was my arbitrary limit), but 
working with the source code may allow a more robust implementation.

I'm not really sure which way to go.  I don't know which things are in the 
spirit of make, and whether or not some other development effort is being done 
to address some of these types of things.  Also, where would I find the current 
source of make if I want to make contributions?  Does anyone know how the 
mingw32 is maintained also, since I use that quite a bit?

Thanks for the help,
John Dill




reply via email to

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