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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:28:54+00:00 2026-05-31T08:28:54+00:00

Consider the following makefile: .SUFFIXES: SRC:=../Src OBJ:=../Obj # Sources SOURCES := $(SRC)/App/a.c $(SRC)/App/b.c $(SRC)/App/c.c

  • 0

Consider the following makefile:

.SUFFIXES:

SRC:=../Src
OBJ:=../Obj

# Sources
SOURCES := $(SRC)/App/a.c $(SRC)/App/b.c $(SRC)/App/c.c
HEADERS := $(wildcard $(SRC)/App/*.h)

# Directories
INC_DIRS := $(SRC)/App
OBJ_INC_DIRS := $(INC_DIRS:$(SRC)/%=$(OBJ)/%)

# Objects
OBJECTS := $(SOURCES:$(SRC)%=$(OBJ)%.obj)

# Dependencies
DEPS := $(SOURCES:$(SRC)%.c=$(OBJ)%.d)
-include $(DEPS)

GCC_INCLUDES := $(foreach directory, $(INC_DIRS), -I$(directory))

all: target

target: $(OBJECTS)
    touch target

#Objects
$(OBJ)%.c.obj: $(SRC)%.c
    @echo Compiling $@
    @touch $@

# Dependencies 
$(OBJ)%.d: $(SRC)%.c
    @echo Checking dependencies for $<
    @gcc -MM $< $(GCC_INCLUDES) -MT '$(patsubst %.d,%.c.obj,$@)' -MT '$@' -MF '$@'
    @[ ! -s $@ ] && rm -f $@

# Creating directory tree before checking dependencies    
$(DEPS):|$(OBJ_INC_DIRS)

$(OBJ_INC_DIRS):
    @mkdir $@

clean:
    echo clean
    @rm $(OBJ_INC_DIRS)

When running the first time, I get:

Checking dependencies for ../Src/App/a.c
Checking dependencies for ../Src/App/b.c
Checking dependencies for ../Src/App/c.c
clean
Compiling ../Obj/App/a.c.obj
Compiling ../Obj/App/b.c.obj
Compiling ../Obj/App/c.c.obj
touch target

It’s ok, but now, make again (without modifying any file):

make: `../Obj/App/a.c.obj' is up to date.

Now if I modify the file a.c

Checking dependencies for ../Src/App/a.c
Compiling ../Obj/App/a.c.obj

target isn’t remade !

It’s like my file a.c is the target but it isn’t… Can someone explain me what’s wrong here?

If I remove the include to the DEPS, I observe the expected behavior…

Thanks


EDIT

By putting the include at the end as mentioned by @Beta works but now I added the target clean and show the result…

  • 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-31T08:28:56+00:00Added an answer on May 31, 2026 at 8:28 am

    I’ll have to do some experiments to be sure, but I think the problem is:

    -include $(DEPS)
    ...
    all: target
    

    You include $(DEPS) before the first target. So if you modify a.c, Make sees that it must rebuild a.d, then since it includes that file it must start over, and now a.c.obj is an earlier target than all.

    Try moving -include $(DEPS) to the end of the makefile.

    EDIT:
    (Two small points: your clean rule is incorrect, since it tries to rm a directory, and I would do make clean; make all rather than make all, since I am not certain that Make promises to build targets in the given order in all cases.)

    Yes, this makefile will rebuild the DEPS even when running clean. The makefile includes those files and has a rule for them, so if they are missing or out of date it must rebuild them and restart, no matter what the target is. The best way to deal with this is by Advanced Auto-Dependency Generation; basically, the commands that build dependency files go in the %.obj rule, so that a.d is a side effect of building a.c.obj. It’s a sophisticated technique, not obvious, but it works beautifully. (Let us know if you try this and have trouble setting it up.)

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

Sidebar

Related Questions

Consider following code for an android app; private String GetDistance(String src, String dest) {
Consider following SWT code example: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet151.java?view=co How can I separate the inline defined class?
Consider the following makefile: # various settings, lots of them # (supposed to be
Consider the following Makefile: # <include global configuration Makefile> INCL = -I../include \ -I<whatever>
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
Consider following class class test { public: test(int x){ cout<< test \n; } };
Consider following scenario: I have RESTful URL /articles that returns list of articles user
Consider following program: static void Main (string[] args) { int i; uint ui; i
Consider following script: SET LANGUAGE 'German' GO SET DATEFIRST 1 GO DECLARE @FullDate DATETIME
Consider following: $(#myform).attr({ action: @Url.Action(MVC.Thing.Delete().AddRouteValue(id, myJsModel.Id )) }); I'm trying to set the action

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.