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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:28:13+00:00 2026-05-14T19:28:13+00:00

I have several C and C++ projects that all follow a basic structure I’ve

  • 0

I have several C and C++ projects that all follow a basic structure I’ve been using for a while now. My source files go in src/*.c, intermediate files in obj/*.[do], and the actual executable in the top level directory.

My makefiles follow roughly this template:

# The final executable
TARGET := something
# Source files (without src/)
INPUTS := foo.c bar.c baz.c

# OBJECTS will contain: obj/foo.o obj/bar.o obj/baz.o
OBJECTS := $(INPUTS:%.cpp=obj/%.o)
# DEPFILES will contain: obj/foo.d obj/bar.d obj/baz.d
DEPFILES := $(OBJECTS:%.o=%.d)

all: $(TARGET)

obj/%.o: src/%.cpp
    $(CC) $(CFLAGS) -c -o $@ $<

obj/%.d: src/%.cpp
    $(CC) $(CFLAGS) -M -MF $@ -MT $(@:%.d=%.o) $<

$(TARGET): $(OBJECTS)
    $(LD) $(LDFLAGS) -o $@ $(OBJECTS)

.PHONY: clean
clean:
    -rm -f $(OBJECTS) $(DEPFILES) $(RPOFILES) $(TARGET)

-include $(DEPFILES)

Now I’m at the point where I’m packaging this for a Debian system. I’m using debuild to build the Debian source package, and pbuilder to build the binary package. The debuild step only has to execute the clean target, but even this causes the dependency files to be generated and included.

In short, my question is really: Can I somehow prevent make from generating dependencies when all I want is to run the clean target?

  • 1 1 Answer
  • 5 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-14T19:28:13+00:00Added an answer on May 14, 2026 at 7:28 pm

    The solution is easy, don’t -include generated files under clean:

    ifneq ($(MAKECMDGOALS),clean)
        -include $(DEPFILES)
    endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several projects that build reusable libraries. All these projects are under source
I have several small open-source projects that I wrote. All my attempts to find
In my limited experience, I've been on several projects that have had some sort
We have an svn project that also has several plugins in vendor/plugins - all
Like many people, I have several SVN repositories that contains several projects. I've decided
I have created several DLL (.NET) libraries that are used in several projects. In
i have multiple Elipse plugin projects that depend on each other. Several questions concerning
In one of my projects, I have an application that manages several clients (or
I have several projects on my development system - some projects are open source,
I have several projects that I just upgraded from Visual Studio 2003 and ASP.NET

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.