有一个参考makefile,我正在慢慢编辑和使用它吐出这两个错误
Makefile:25: warning: overriding commands for target `build/semanticHash'
Makefile:21: warning: ignoring old commands for target `build/semanticHash'
make: Circular build/semanticHash <- build/semanticHash dependency dropped.
cc -g -ldl -lgsl -lgslcblas -lzmq -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG -fPIC -c -o src/semanticHash/rmb.o src/semanticHash/rmb.c
我是 makefile 语法和规则的新手,所以我谷歌搜索的任何常见错误,但在这种情况下我自己没有运气。
所以问题是,我在哪里导致这些错误,在我当前的 makefile 中是否有任何我应该避免的模式?
CFLAGS= -g $(LIBS) -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG $(OPTFLAGS)
LIBS= -ldl $(OPTLIBS)
PREFIX?=/usr/local
OPTLIBS= -lgsl -lgslcblas -lzmq
SOURCES=$(wildcard src/**/*.c src/*.c)
OBJECTS=$(patsubst %.c,%.o,$(SOURCES))
TEST_SRC=$(wildcard tests/*_tests.c)
TESTS=$(patsubst %.c,%,$(TEST_SRC))
TARGET=build/semanticHash # Rename to library !!!!!
SO_TARGET=$(patsubst %.a,%.so,$(TARGET))
# The Target Build
all: $(TARGET) tests
$(TARGET): CFLAGS += -fPIC
$(TARGET): build $(OBJECTS)
ar rcs $@ $(OBJECTS)
ranlib $@
$(SO_TARGET): $(TARGET) $(OBJECTS)
$(CC) -shared -o $@ $(OBJECTS)
build:
@mkdir -p build
@mkdir -p bin
# The Unit Tests
.PHONY: tests
tests: CFLAGS += $(TARGET)
tests: $(TESTS)
sh ./tests/runtests.sh
valgrind:
VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE)
# The Cleaner
clean:
rm -rf build $(OBJECTS) $(TESTS)
rm -f tests/tests.log
find . -name "*.gc*" -exec rm {} \;
rm -rf `find . -name "*.dSYM" -print`
# The Install
install: all
install -d $(DESTDIR)/$(PREFIX)/lib/
install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/