我有以下我试图从教程中构建的makefile。然后我(以为)我添加了必要的源以使其适合我的代码..但它没有找到目标。我认为这可能与来源的文件夹结构有关,但我无法弄清楚。
SVN_REV=(svnversion -cn | sed -e 's/.*://' -e 's/\([0-9]*\).*/\1/' | grep '[0-9]')
DEBUG_OPTS:=-g -DSVN_REV \
-DDEBUG_MODE \
-UTIME_MODE \
-UREADFROMFILE
CFLAGS:=$(DEBUG_OPTS) -c -Wall
LDFLAGS:=$(DEBUG_OPTS) -lpthread
EXECUTABLE:=fw_board
COMPILER:=arm-linux-gcc
(makefile 在下面继续,有从 TOPDIR 看到的 src 文件位置)
SOURCES:=main_process/main.c \
ezxml/ezxml.c \
info_file_parser/info_file_parser.c \
info_file_parser/array_management.c \
info_file_parser/protocol_file_parser.c \
info_file_parser/sequence_file_parser.c \
info_file_parser/topology_file_parser.c \
seq_exec_module/seq_execution.c \
i2c_device_drivers/pca950x.c \
i2c_device_drivers/ltc2495.c \
i2c_device_drivers/ltc2609.c \
i2c_device_drivers/temperature_uc.c \
i2c_device_drivers/pcf8574.c \
i2c_device_drivers/stepper_motor_control.c \
i2c_device_drivers/test_functions.c \
i2c_device_drivers/stepper_pca.c \
i2c_device_drivers/stepper_atmega.c \
i2c_device_drivers/general_i2c.c \
i2c_device_drivers/zx_mbd_pwr.c \
i2c_device_drivers/virtual_switch_handler.c \
i2c_device_drivers/pressure_sensor_ASDXAV030PG7A5.c \
hashing/ConfigData.c \
hashing/Hash.c \
hashing/LinkedList.c \
init_file_parser/init_file_parser.c \
usb_communication/serial_comm.c \
protocol_parser/protocol_parser.c
BINDIR:=bin
OBJDIR:=.obj
OBJECTS:=$(addprefix $(OBJDIR)/,$(SOURCES:%.c=%.o))
.PHONY: all
all: $(SOURCES) $(EXECUTABLE)
@echo all_start
这是链接阶段
$(EXECUTABLE): $(OBJECTS) | $(BINDIR)
@echo link
$(COMPILER) $(LDFLAGS) $(OBJECTS) -o $(BINDIR)/$@
和编译阶段。但如您所见,无法找到 main.c
$(OBJECTS): $(OBJDIR)/%.o : %.c | $(OBJDIR)
@echo compile
$(COMPILER) $(CFLAGS) $< -o $@
$(OBJDIR):
mkdir $(OBJDIR)
$(BINDIR):
mkdir $(BINDIR)
.PHONY: clean
clean:
@echo removing_files
rm -rf $(OBJECTS) $(BINDIR)/$(EXECUTABLE)
运行 make 返回以下内容:
make: *** No rule to make target `main_process/main.c', needed by `all'. Stop.