0

Why do i get dependency dropping error in this code?

There must be a problem inside it but I couldnt find this problem! Here I have automatic dependency generator. Here I have automatic dependency generator. Without the last line:

-include $(DEPFILES)

It runs ok. But when this code exists, it gives me error.

Please also avoid linking to another question just because of similar warning message. Their case is different.

Output:

bash ./scripts/outputs.bash
bash ./scripts/simulator_outputs.bash
make: Circular /usr/include/c++/4.8/iostream <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/ostream <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/ios <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/iosfwd <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/cwchar <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/exception <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/clocale <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/cctype <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/string <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/new <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/bits/basic_string.tcc <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/bits/locale_classes.tcc <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/streambuf <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/bits/streambuf.tcc <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/cwctype <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/bits/locale_facets.tcc <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/bits/basic_ios.tcc <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/bits/ostream.tcc <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/istream <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/bits/istream.tcc <- bin/sim dependency dropped.
make: Circular /usr/include/c++/4.8/cmath <- bin/sim dependency dropped.
make: `VARLISTS' is up to date.

Makefile:

SOURCES := test.cpp
OUTDIR:= ./out
BINDIR:= ./bin
OBJDIR:= ./bin/obj
OBJECTS := $(addprefix $(OBJDIR)/,$(SOURCES:.cpp=.o))
DEPFILES:= $(OBJECTS:.o=.d)
VARLISTS:= ./app/outputs.list
CXX := g++
CXXFLAGS := -c -g -MD -MP

# default
%: VARLISTS $(BINDIR)/sim
    @

VARLISTS:
    bash ./scripts/outputs.bash
    bash ./scripts/simulator_outputs.bash

$(BINDIR)/sim: $(OBJECTS)
    $(CXX) $(LDFLAGS) $^ -o $@

$(OBJDIR)/%.o: %.cpp
    @if [ ! -d "$(OBJDIR)" ]; then mkdir -p $(OBJDIR) && echo "$(OBJDIR) directory created: $(OBJDIR)";  fi
    $(CXX) $(CXXFLAGS) -MF $(OBJDIR)/$*.d -o $@  $<

-include $(DEPFILES)
ar2015
  • 5,558
  • 8
  • 53
  • 110
  • What is that `%:` rule doing there? It makes everything depend on `VARLISTS` and the `sim` binary. That's going to make anything that `sim` depends on circular. – Etan Reisner Mar 24 '15 at 20:31
  • `%:` is the default rule. It should run when `make` is called without argument. And it should require both `VARLISTS` and `sim` to be updated. – ar2015 Mar 24 '15 at 20:33
  • No, the default target is the first target listed in the makefile. Usually that's `all`. So you would put `all: VARLISTS sim` there. `%` is a [match-anything rule](http://www.gnu.org/software/make/manual/make.html#Match_002dAnything-Rules) and that is *quite* different. – Etan Reisner Mar 24 '15 at 20:36
  • One question: is all run for any rule or it runs only when `make` is called without argument? – ar2015 Mar 24 '15 at 20:38
  • The default target is run when no other targets are given and when that target it listed specifically. It does not run for other targets. If you want something run no matter what target is run that's slightly odd (though it can have reasons) and an included makefile that make knows how to build is your best option for that I think. – Etan Reisner Mar 24 '15 at 20:44
  • @EtanReisner you are right. If you put a one line answer, I can close this question. – ar2015 Mar 24 '15 at 23:02

1 Answers1

0

The problem is the %: VARLISTS $(BINDIR)/sim line.

That line is a match-anything rule and so matches all targets. So everything that $(BINDIR)/sim depends on (that doesn't have another target) will also (circularly) depend on the $(BINDIR)/sim file/target.

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148