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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:02:54+00:00 2026-06-10T18:02:54+00:00

I use the following Makefile section: .PHONY: all all: _MyModule.so _%.so: %.pb.cc %.pb.h python

  • 0

I use the following Makefile section:

.PHONY: all
all: _MyModule.so

_%.so: %.pb.cc %.pb.h
    python setup.py build

%.pb.cc %.pb.h: %.proto
    protoc --cpp_out=. $^  # Generate these two files together

I would expect make to create the _MyModule.so file and remove the intermediates MyModule.pb.cc and MyModule.pb.h. What happens in practice is that only one of the files is deleted(.h or .cpp). I also noticed that it depends on the order of their appearance in the _%.so dependencies list.

Could anyone explain this behavior?

How could I elegantly remove all the intermediates?

  • 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-06-10T18:02:55+00:00Added an answer on June 10, 2026 at 6:02 pm

    How peculiar. I’ll go out on a limb and say this looks like a bug in GNUMake. A pattern rule with multiple targets has special behavior, and it seems that this behavior doesn’t dovetail correctly with the treatment of intermediate files (and .INTERMEDIATE doesn’t help).

    I wouldn’t call this an elegant solution, but it works:

    %.pb.cc: %.pb.h
        @:
    
    %.pb.h: %.proto
        ...
    

    P.S. Turns out this is a known bug.

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

Sidebar

Related Questions

The following is the Makefile i use. All is well, except for .o should
I have the following makefile that I use to build a program (a kernel,
I would like to use a single Makefile to generate targets in hundreds of
I am trying to use autogen and configure to generate a Makefile in a
I use following find command to find and show all files having the input
I have a Makefile with the following: AVAR= all : if [ -d ../old
I want use waf to trigger a makefile to build an other library. For
I use following style attribute so when i will start typing in text box
I use following code: Create a retry policy, when error, retry after 1 second,
I just use following code to add an image to my project, var paper

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.