help-make
[Top][All Lists]
Advanced

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

adding functions to function.c


From: Dill, John
Subject: adding functions to function.c
Date: Tue, 11 Jan 2005 12:42:19 -0600

A little while back someone mentioned that it would be possible to add the 
functions directly to the makefile source.  Is all I do is add the name of the 
function to the list using STRING_SIZE_TUPLE, and then define my own function?  
Are there any other files that need to be modified?  Can someone briefly 
explain the min, max, and exp fields (I think they deal with number of 
arguments)?  Is there some documentation on how the makefile system is coded 
together?  Is this the right mailing list for these types of questions?

For example, I have a little set of boolean functions and it would be nice to 
do $(or ...) instead of $(call or,...).

Here is my bool implementation.  $(space) is defined in another file, but it 
just represents a space.  Would something like this be something that would be 
desired to be implemented into the makefile system, or should it be a user 
supplied implementation like the following?

# The following parameterizes the boolean variables.  In the makefile
# $(if ...) function, empty text or whitespace represents false, while any
# text represents true.  For consistency, if the boolean operation is found
# to be true, the result is assigned the text 'true'.

# This variable represents the makefile boolean true construct.
true:=true

# This variable represents the makefile boolean false construct.
false:=

# A function which flips true to false and false to true.  Remember that
# false as a boolean is actually empty text.
# $(1) - The argument.
not=$(if $(strip $1),$(false),$(true))

# A function which performs the logical 'and' operation.  The spaces are
# substituted in the arguments so that if the argument contains spaces, it
# will not fake out the $(word ...) function.
# $(1) - The first argument.
# $(2) - The second argument.
and=$(if $(word 2,$(subst $(space),_,$(strip $1)) $(subst $(space),_,$(strip 
$2))),$(true),$(false))

# A function which performs the logical 'or' operation.
# $(1) - The first argument.
# $(2) - The second argument.
or=$(if $(strip $1 $2),$(true),$(false))

# A function which performs the exclusive 'or' operation.  The spaces are
# substituted in the arguments so that if the argument contains spaces, it
# will not fake out the $(word ...) function.
# $(1) - The first argument.
# $(2) - The second argument.
xor=$(if $(filter 1,$(words $(subst $(space),_,$(strip $1)) $(subst 
$(space),_,$(strip $2)))),$(true),$(false))

Any thoughts or recommendations?

Thanks,
John




reply via email to

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