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

  • Home
  • SEARCH
  • 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 6834085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:04:04+00:00 2026-05-26T23:04:04+00:00

I have a makefile such as : A : B echo made A B

  • 0

I have a makefile such as :

A : B
    echo "made A"
B : D
    echo "made B"

Here, B exists but D doesn’t (sometimes, it does, sometimes it doesn’t)

Now if I execute make, it shouts at me :

make: *** No rule to make target 'D', needed by 'B'.  Stop.

Is there any way to behave correctly i.e. :

  • B and D don’t exist : fail
  • B exists, D does and is newer than B , apply recipe
  • B exists, D exists but is older : don’t do anything
  • if B exists and D doesn’t : don’t rebuild B (you can’t) but you can use B to build A

Using an empty line with D as target would always execute recipe to build B, but without D it cannot, so it’s not wanted !

Is there any way ?

I found the solution of using an empty rule

D : 

at the end, so that missing D will not fail. So now all is OK except B is redone if D is missing, which can be tested in B recipe :

B : D
    if [ D ] ; then echo "doing B with D"; fi

But it really seems hackish …

  • 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-26T23:04:05+00:00Added an answer on May 26, 2026 at 11:04 pm

    You can get around the re-generation of B from an older D by marking B as intermediate:

     .INTERMEDIATE : B
    

    You can then remove the empty rule for D, and your four criteria for “correct” behaviour are matched.

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

Sidebar

Related Questions

I have made a makefile in order to compile my files: CFLAGS = -O3
I have a Makefile building many C files with long long command lines and
I have a makefile template to compile a single DLL (for a plugin system).
I have a Makefile where most of my targets are created generically through a
I have a makefile project that builds and links a DLL, using the command-line
We have a Makefile which runs on a Windows 2003 machine and we are
I have a makefile with something like the following targets: install: do a whole
I have a Makefile from which I want to call another external bash script
I have a Makefile that looks like this CXX = g++ -O2 -Wall all:
Let's say I have a makefile with the rule %.o: %.c gcc -Wall -Iinclude

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.