Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6706877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:34:19+00:00 2026-05-26T07:34:19+00:00

I need to export a user-defined GNU make function (i.e. a recursively expanded makefile

  • 0

I need to export a user-defined GNU make function (i.e. a recursively expanded makefile variable) to a sub-make. However, make seems to expand all such variables into simply expanded variables, which makes them useless.

Here is an example:

Contents of “parent.make”:

export myfunc = my arg is $1
$(info parent testing myfunc: $(call myfunc,parent))
all: ; $(MAKE) -f child.make

Contents of “child.make”:

$(info child testing myfunc: $(call myfunc,child))
nullrule: ; @true

Running “make -f parent.make” produces the following output:

parent testing myfunc: my arg is parent
make -f child.make
child testing myfunc: my arg is 

Parent exports myfunc as a simple expanded variable containing “my arg is” to the sub-make, making it useless as a function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:34:20+00:00Added an answer on May 26, 2026 at 7:34 am

    I’m not sure if this will satisfy your requirements, but here goes:

    parent.make:

    export myfunc1 = my arg is $1
    export myfunc2 = $(value myfunc1)
    $(info parent testing myfunc1: $(call myfunc1,parent))
    all: ; $(MAKE) -f child.make
    

    child.make:

    $(info child testing myfunc2: $(call myfunc2,child))
    nullrule: ; @true
    

    EDIT:
    All right, how about this:

    child.make:

    myfunc1=$(myfunc2)
    
    $(info child testing myfunc1: $(call myfunc1,child))
    nullrule: ; @true
    

    EDIT:

    Not so fast. Take a look at this:

    parent.make:

    myfunc_base = my arg is $1
    
    export myfunc = $(value myfunc_base)
    
    $(info parent testing myfunc: $(call myfunc_base,parent))
    all: ; @$(MAKE) -f child.make
    

    child.make:

    $(info child testing myfunc: $(call myfunc,child))
    nullrule: ;  @$(MAKE) -f grandchild.make
    

    grandchild.make:

    $(info grandchild testing myfunc: $(call myfunc,grandchild))
    nullrule: ; @true
    

    This works with no modification at all to child.make or grandchild.make. It does require that parent.make call myfunc_base rather than myfunc; if that’s a problem there’s a way around it, maybe more than one.

    One possibility, we move the definition up into whatever calls parent, where it won’t actually be called at all:

    grandparent.make:

    myfunc_base = my arg is $1
    
    export myfunc = $(value myfunc_base)
    
    all: ; @$(MAKE) -f child.make
    

    parent.make:

    $(info parent testing myfunc: $(call myfunc,parent))
    all: ; @$(MAKE) -f child.make
    

    I realize this might not be workable, since the definition of myfunc might require other things defined in parent.make. See if this will suit your situation; there may be another way…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to export multiple data tables to Excel on the clients machine, each
I need to export a report to Excel file using PHP i.e. on the
I need to export a gridview to excel, I put the return html code
being in need to export a DOC file to TXT and then reimport it
In a web page button click event we need to export 2,00,000 to 5,00,000
I am working on an ASP.NET MVC application where I need to export data
I need a solution to export a dataset to an excel file without any
I need a way to easily export and then import data in a MySQL
I have received a content export of a MOSS 2007 site which I need
I have realised after making about 20 tables that I need to user utf8_unicode

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.