neuromancer
neuromancer

Reputation: 55469

How to fix this Makefile

Instead of executable code all it does is create files that don't do anything, even if the files are made executable.

TARGETS = load list show add delete btree
all: $(TARGETS)
%: %.cpp
    g++ $< -g -o $@ -MM -MF [email protected]
    sed "s/$@\.o:/$@:/" [email protected] > [email protected]
    -@rm [email protected]

DEPS=$(TARGETS:%=%.d)
-include $(DEPS)

Upvotes: 0

Views: 176

Answers (1)

Beta
Beta

Reputation: 99084

You are running g++ with the -MM option, to create the dependency file. But this option causes g++ to write a dependency file instead of a binary.

Try this:

TARGETS = load list show add delete btree
all: $(TARGETS)
%: %.cpp
    g++ $< -g -o $@
    g++ $< -g -MM -MF [email protected]
    sed "s/$@\.o:/$@:/" [email protected] > [email protected]
    -@rm [email protected]

DEPS=$(TARGETS:%=%.d)
-include $(DEPS)

Upvotes: 1

Related Questions