Saturday, 15 January 2011

shell - How can I pass and return a value from user defined function in MAKEFILE? -


I would like to create an action that takes a list in the form of an argument, performs some operations and lists (or A scalar value). I would like to define the function using 'define' function:

1) Performs an operation on the input list. 2) Checks that the resulting list is empty, if the list is empty Increase error 3) Neither return result list

It is easily possible in languages ​​such as C / C ++ When I try to do this in Macfil, then I am facing problems .

a) Can you point me to examples or post an example here?
b) What makes the MacFill function worth?

I checked the makefile documentation and some other places on the web but could not find anything useful. This will give me an idea on starting with the tasks Thanks for your help! Myfuntest fnames: $$ (filter% pattern, $ (1)) ifneq ($ (fnames)) $ (error is an error) endif endef

The caller function is something like this:

  ABC: = document downloads Return_value: = $ (mytestfun call, $ (ABC))  

To return to 'return_value', 'fnames' should be

post-text itemprop = "text">

User-defined macros should be a single "expression" Should return value is the result of expansion of expression. You can not use ifneq or variable assignment or other similar things in a user-defined macro.

You can create a makefile piece that is used with call , but is used only for eval , And this means that it is a separate section of the makefile, not really defined "function".

Therefore, if you can create your user-defined macro, the function is simply that if you get the result of the extension, you can do it as a macro; For example:

  myfuntest = $ (or $ (filter% pattern, $ (1)), $ (error is an error)) Results: = $ (call myfuntest, foo Barpattern biz  

If the result of filter will be a list of matching words and it will be assigned to result , or else it will be Error will run function.

However, if your function is more complex and can not be expressed in the expression format, then you eval , and you can Pass on the name of the variable to be shown, such as:

  define myfuntest ... $ (2) ... Calculate with $ (1) fnames: = $ $ (Fnames ) Endef  

You should be very careful with $ vs. $$ , as eval And then call it like this:

  $ (eval $ (myfuntest, return_value, $ (abc)))  < / Pre> 

No comments:

Post a Comment