0

Consider the following makefile:

all : a.vo a.glob

a.gl%b a.v% : a.v
    touch a.glob a.vo

When I run make -j2, I get:

$ rm -f a.vo a.glob; make -j2
make: Circular a.v.o <- a.v dependency dropped.
touch a.glob a.vo

I see why a.v.o depends on a.v, but I don't see how a.v depends on a.v.o. Where does this dependency come from (and is there a way to disable it)?

Jason Gross
  • 5,928
  • 1
  • 26
  • 53

1 Answers1

1

GNU make uses Implicit Rules when no rule is defined. In particular,

n is made automatically from n.o by running the linker (usually called ld) via the C compiler. The precise recipe used is ‘$(CC) $(LDFLAGS) n.o $(LOADLIBES) $(LDLIBS)’.

As you can see:

~ $ cat Makefile
all: a.v
        echo "foo"
a.v.o:
        echo "bar"
~ $ make
echo "bar"
bar
cc   a.v.o   -o a.v
gcc: error: a.v.o: No such file or directory
gcc: fatal error: no input files
compilation terminated.
<builtin>: recipe for target 'a.v' failed
make: *** [a.v] Error 1

cc is executed.

llllvvuu
  • 286
  • 1
  • 9