title: How can I pass and return a value from user defined function in MAKEFILE?
body: <p>I would like create a function that takes a list as an argument, performs some operation and returns a list(or a scalar value). I would like to define the function using 'define'. The function:          </p>
  
  <p>1) Performs an operation on the input list<br>
  2) Checks if the resultant list is empty, if the list is empty raise an error.
  3) Otherwise return the resultant list</p>
  
  <p>This is easily possible in languages like C/C++. I am facing issues when I try to do this in MAKEFILE.</p>
  
  <p>a) Can you point me to examples or post an example here?.<br>
  b) How does the MAKEFILE function returns value?</p>
  
  <p>I checked the makefile documentation and few other places on the web but could not find anything useful. This would give me an idea on starting with functions. Thank you for your help!</p>
  
  <pre><code>define myfuntest
  fnames := $(filter %pattern, $(1))
  ifneq ($(fnames),)
  $(error this is an error)
  endif
  endef
  </code></pre>
  
  <p>Caller function is something like:</p>
  
  <pre><code>abc := Documents Downloads
  return_value := $(call mytestfun,$(abc))
  </code></pre>
  
  <p>I want 'fnames' to be returned in 'return_value'</p>