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 648293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:48:58+00:00 2026-05-13T21:48:58+00:00

I need to get some external data to form an output file name in

  • 0

I need to get some external data to form an output file name in a Makefile.

In GNU Make I can do something like this :

NAME=$(shell some_commands)
$(NAME).out: file.in
     compile "$<" -o "$@"

Some other rules have $(NAME).out as a prerequisite so I need $(NAME).out as a target. I can’t use substitution+quotes here as this is not interpreted by a shell.

I see from the BSD Make man page that on Mac OS X I should be able to do something like this (I could not test it yet, though) :

NAME!=some_commands
$(NAME).out: file.in
     compile "$<" -o "$@"

Is there a hack to do this kind of things in a portable way?

I do not want to generate the Makefile and clutter the build process. I though of includes, but they also have a different syntax across Make versions.

  • 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-13T21:48:58+00:00Added an answer on May 13, 2026 at 9:48 pm

    I can propose several tricks. All them are based on the outsourcing the execution of some_commands to a rule body, and ensuring that their result will be utilized properly.

    1. That’s my favourite. Include a makefile, which you create on your own, that contains the rule for $(NAME). At the beginning of processing it will be re-created and the proper target will appear. The thing is that the process of creation of this makefile is done within shell commands:

      include aux_makefile
      .PHONY aux_makefile
      aux_makefile:
          NAME=`some_commands` ; ( \
              echo $$NAME.out: file.in ; \
              echo "\t rm aux_makefile" ; \
              echo "\t compile ..."  ) >$@
      
    2. A variation of first one: make a wrapper makefile that first writes the auxilliary makefile and then recursively calls the original makefile, the auxilliary makefile being included into it. No special build target needed.

    3. Make a dummy target with a static name; it will represent $(NAME).out. I.e.:

      all: dummy    # Instead of all: $(NAME).out
      dummy: file.in
         NAME=`some_commands`; compile "$<" -o "$$NAME"
         touch $@
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From an external site, I need to present a form that POSTS data to
I need to get some information that is contained in the MFT on a
I need to get some AVI animations for use with the Borland VCL TAnimate
I have decided that I really need to get some flowcharts for reverse engineering
I need to optimize code to get room for some new code. I do
I need to get the default printer name. I'll be using C# but I
I need to get the name of the machine my .NET app is running
I am developing a web app that accesses some external JSON data. I'm currently
I'm working with C#.net developing applications for windows mobile 6, and i need get
I need to get a log of user access to our SQL Server so

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.