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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:01:43+00:00 2026-05-22T22:01:43+00:00

Note: using MinGW’s make (should be GNU make) i have a couple of -include

  • 0

Note: using MinGW’s make (should be GNU make)

i have a couple of -include statements in my makefile to import dependencies which were generated using g++ -MM. However I would like to only do this when necessary. I have several different build targets and I don’t want all of their respective dependency files to be included since this takes a while (suppose I’m running make clean: no need to include them in this case)

Here’s the format of my makefile.

DEPS_debug = $(patsubst %.cpp,build_debug/%.d,$(SRC))
OBJ_debug = $(patsubst %.cpp,build_debug/%.o,$(SRC))
all: program_debug
    -include $(DEPS_debug) #make: include: Command not found
program_debug: $(OBJ_debug)
    $(CC) $(CFLAGS) $(OBJ_debug) -o $@
  • 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-22T22:01:44+00:00Added an answer on May 22, 2026 at 10:01 pm

    If you really don’t want to include those files needlessly, you have a couple of options:

    You can put in a conditional as Diego Sevilla suggests (but I would recommend using MAKECMDGOALS so that you can write a more flexible version, specific to targets, e.g. you’ll include foo.d if and only if you’re making foo.o).

    You can use make recursively (heresy!), invoking $(MAKE) for each target object, using a makefile that includes that target’s dependencies.

    But actually including the file takes negligible time, it’s the rebuilding of the file (automatic for any included file that’s out of date) that takes time.
    If needless rebuilding is what you want to avoid, you can use a very clever trick. When must foo.d be rebuilt? Only when something about foo has changed. But in that case foo.o must also be rebuilt. So don’t have a seperate rule for foo.d, just rebuild it as a side effect of making foo.o. That way you can include all dependency files and not waste time rebuilding them if they aren’t needed.

    EDIT:
    I’m astounded that merely including these files can add 2-3 seconds to make clean. My last paragraph is off the mark, so let me expand on the first two options.

    If all is the only target for which these files should be included, and you make all from the command line (and not e.g. make all tests tarball install kitchenSink), then this will do it:

    ifeq ($(MAKECMDGOALS),all)
    -include $(DEPS_debug)
    endif
    

    Note that this will not include foo.d if you make foo.o. You can write a more sophisticated conditional, something like

    $(foreach targ,$(MAKECMDGOALS),$(eval $(call include_deps $(targ)))...
    

    but that’s pretty advanced, so let’s get a simple version working first.

    If you’d rather avoid the conditional and use recursive Make, the simplest way is to split the makefile in two:

    makefile:

    all:
        $(MAKE) -f makefile.all
    
    clean:
        rm whatever
    
    ...other rules
    

    makefile.all:

    DEPS_debug = $(patsubst %.cpp,build_debug/%.d,$(SRC))
    OBJ_debug = $(patsubst %.cpp,build_debug/%.o,$(SRC))
    -include $(DEPS_debug)
    
    all: program_debug
    program_debug: $(OBJ_debug)
        $(CC) $(CFLAGS) $(OBJ_debug) -o $@
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: Using MySQL 4.0, which means no subqueries (at present). I have 2 tables:
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
Note: Using raw Win32 CreateTheard() API No MFC An interface is simply a pointer
Note : No MFC No ATL Using Visual C++ While attempting a connection between
NOTE: I am not set on using VI, it is just the first thing
Note: while the use-case described is about using submodules within a project, the same
(NOTE: This question is not about escaping queries, it's about escaping results) I'm using
I'm building an application for Windows XP using the MinGW tool chain and it
I have a class using operator overloading, but there are some warnings. // base.h
I have a C# application and a C DLL both of which I wrote

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.