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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:19:06+00:00 2026-05-29T06:19:06+00:00

To simplify my question, if I have a Makefile as below %: %.c gcc

  • 0

To simplify my question, if I have a Makefile as below

    %: %.c
           gcc -o $@ $<

    make foo

Make foo will build the executable foo from foo.c. No issues. If I were to change the Makefile as below, so that I can pass the target from Makefile command-line

    # To make things little complex
    TARG=$(EXE)
    $(TARG): %.c
            gcc -o $@ $<

    make EXE=foo

The above command make EXE=foo says:

"make: *** No rule to make target %.c, needed byfoo’. Stop.`

Why is $(TARG) not getting expanded in the target rule in Makefile?

  • 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-29T06:19:08+00:00Added an answer on May 29, 2026 at 6:19 am

    Just leave the code from your first example and add the following line:

    .DEFAULT_GOAL := $(EXE)
    

    Or (which is effectively the same) add $(EXE) : rule with no recipe before any other rules. By default Make picks the first target defined in the Makefile, if nothing is specified on the command line.

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

Sidebar

Related Questions

I'm developing a REST api. To simplify my question, I have an API that
Quick question/clarification required here. I have a DB table that will quite possibly have
I've tried to simplify for the purposes of asking this question. Hopefully, this will
From this question , a neat answer about using COALESCE to simplify complex logic
so i have 4 divs (i actually have many more but this will simplify
I have a question for a Javascript regex ninja: How could I simplify my
Rails 3.1 I'll simplify my application to get at my question. I have two
Short question: If I have class that impelemnts FactoryBean interface, how can I get
I have a strange build problem. I have a simple test program that sends
I have a question that has been viewed, but with no answers or comments

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.