起初,我是makefile中的noobie ...
我的 Makefile 中有下一个目标:
$(BUILD_PATH)/%.o: %.c $(GEN_PATH)/%.c
$(CC) $(FLAGS) $(CFLAGS) $(HEADERS) -c $< -o $@
server: $(BUILD_PATH)/main.o $(BUILD_PATH)/socket.o $(BUILD_PATH)/settings.o $(BUILD_PATH)/options.o
$(CC) -L$(LIB_PATH) -Wl,-rpath=$(LIB_PATH) $(FLAGS) $(CFLAGS) -o $(DIST_PATH)/server $^ $(LDFLAGS)
我指定必须从当前文件夹和$(GEN_PATH)
编译目标文件,但是它不起作用,并且出现错误:
make: *** No rule to make target '../build/server/options.o', needed by 'server'. Stop.
如何正确编写此规则?
附言。这不是主要问题,但是我该如何缩短输入目标?我尝试了这种变体:
server: $(BUILD_PATH)/%.o
$(CC) -L$(LIB_PATH) -Wl,-rpath=$(LIB_PATH) $(FLAGS) $(CFLAGS) -o $(DIST_PATH)/server $^ $(LDFLAGS)
但这没用。