我试图编译一个示例代码,我在新目录下添加了一个新文件,但我一直遇到依赖问题。 我添加了一个文件" ipc.c"在" / interface"。 我已将源文件添加到" srcs"并且还使用" -I / interface"添加了目录。 Makefile如下所示:
#
# ======== Makefile ========
#
include ../products.mak
srcs = main_host.c interface/ipc.c
objs = $(addprefix bin/$(PROFILE)/obj/,$(patsubst %.c,%.o$(SUFFIX),$(srcs)))
libs = $(SYSLINK_INSTALL_DIR)/packages/ti/syslink/lib/syslink.a_$(PROFILE)
MAKEVARS = \
SYSLINK_INSTALL_DIR=$(SYSLINK_INSTALL_DIR) \
PKGPATH=$(PKGPATH)
all:
@$(ECHO) "!"
@$(ECHO) "! Making $@ ..."
$(MAKE) $(MAKEVARS) PROFILE=debug SUFFIX=v5T togs2_host
$(MAKE) $(MAKEVARS) PROFILE=release SUFFIX=v5T togs2_host
install:
@$(ECHO) "#"
@$(ECHO) "# Making $@ ..."
@$(MKDIR) $(INSTALL_DIR)/debug
$(CP) bin/debug/togs2_host $(INSTALL_DIR)/debug
@$(MKDIR) $(INSTALL_DIR)/release
$(CP) bin/release/togs2_host $(INSTALL_DIR)/release
clean::
$(RMDIR) bin
#
#
# ======== rules ========
#
togs2_host: bin/$(PROFILE)/togs2_host
bin/$(PROFILE)/togs2_host: $(objs) $(libs)
@$(ECHO) "##"
@$(ECHO) "## Making $@ ..."
$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
bin/$(PROFILE)/obj/%.o$(SUFFIX): %.h
bin/$(PROFILE)/obj/%.o$(SUFFIX): %.c
@$(ECHO) "###"
@$(ECHO) "### Making $@ ..."
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $<
# ======== create output directories ========
ifneq (clean,$(MAKECMDGOALS))
ifneq (,$(PROFILE))
ifeq (,$(wildcard bin/$(PROFILE)))
$(shell $(MKDIR) -p bin/$(PROFILE))
endif
ifeq (,$(wildcard bin/$(PROFILE)/obj))
$(shell $(MKDIR) -p bin/$(PROFILE)/obj)
endif
endif
endif
# ======== install validation ========
ifeq (install,$(MAKECMDGOALS))
ifeq (,$(INSTALL_DIR))
$(error must specify INSTALL_DIR)
endif
endif
# ======== toolchain macros ========
ifeq (v5T,$(SUFFIX))
CC = $(CS_ARM_INSTALL_DIR)gcc -c -MD -MF $@.dep -march=armv5t
AR = $(CS_ARM_INSTALL_DIR)ar cr
LD = $(CS_ARM_INSTALL_DIR)gcc
CPPFLAGS = -D_REENTRANT -Dxdc_target_name__=GCArmv5T \
-Dxdc_target_types__=gnu/targets/arm/std.h
CFLAGS = -Wall -ffloat-store -fPIC -Wunused -Dfar= $(CCPROFILE_$(PROFILE)) \
-I. -I/interface $(addprefix -I,$(subst +, ,$(PKGPATH)))
LDFLAGS = $(LDPROFILE_$(PROFILE)) -Wall -Wl,-Map=$@.map
LDLIBS = -lpthread -lc
CCPROFILE_debug = -ggdb -D DEBUG
CCPROFILE_release = -O3 -D NDEBUG
LDPROFILE_debug = -ggdb
LDPROFILE_release = -O3
endif
我一直收到这个错误: 致命错误:打开依赖文件bin / debug / obj / interface / ipc.ov5T.dep:没有这样的文件或目录
这就是products.mak的样子:
#
# ======== products.mak ========
#
DEPOT = /opt
BIOS_INSTALL_DIR = $(DEPOT)/bios_6_33_01_25
IPC_INSTALL_DIR = $(DEPOT)/ti/ipc_1_23_05_40
SYSLINK_INSTALL_DIR = $(DEPOT)/syslink_2_10_02_17
TI_C6X_INSTALL_DIR = $(DEPOT)/ti/ccsv5/tools/compiler/c6000
CS_ARM_INSTALL_DIR = $(DEPOT)/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-
XDC_INSTALL_DIR = $(DEPOT)/xdctools_3_23_00_32
PKGPATH := $(SYSLINK_INSTALL_DIR)/packages
PKGPATH := $(PKGPATH)+$(BIOS_INSTALL_DIR)/packages
PKGPATH := $(PKGPATH)+$(IPC_INSTALL_DIR)/packages
PKGPATH := $(PKGPATH)+$(XDC_INSTALL_DIR)/packages
PKGPATH := $(PKGPATH)+$
# Use this goal to print your product variables.
.show-products:
@echo "BIOS_INSTALL_DIR = $(BIOS_INSTALL_DIR)"
@echo "IPC_INSTALL_DIR = $(IPC_INSTALL_DIR)"
@echo "SYSLINK_INSTALL_DIR = $(SYSLINK_INSTALL_DIR)"
@echo "TI_ARM_INSTALL_DIR = $(TI_ARM_INSTALL_DIR)"
@echo "TI_C6X_INSTALL_DIR = $(TI_C6X_INSTALL_DIR)"
@echo "CS_ARM_INSTALL_DIR = $(CS_ARM_INSTALL_DIR)"
@echo "XDC_INSTALL_DIR = $(XDC_INSTALL_DIR)"
# ======== standard macros ========
ifneq (,$(wildcard $(XDC_INSTALL_DIR)/bin/echo.exe))
# use these on Windows
CP = $(XDC_INSTALL_DIR)/bin/cp
ECHO = $(XDC_INSTALL_DIR)/bin/echo
MKDIR = $(XDC_INSTALL_DIR)/bin/mkdir -p
RM = $(XDC_INSTALL_DIR)/bin/rm -f
RMDIR = $(XDC_INSTALL_DIR)/bin/rm -rf
else
# use these on Linux
CP = cp
ECHO = echo
MKDIR = mkdir -p
RM = rm -f
RMDIR = rm -rf
endif
我完全不理解Makefile,因为它是一个代码示例,我只是在扩展。
答案 0 :(得分:7)
对于记录:错误“致命错误:打开依赖文件[...]:没有这样的文件或目录”也可能由太长的路径引起。在Cygwin / Windows上发生了一个超过200个字符的路径(没有完全检查)。
答案 1 :(得分:6)
搞定了。
需要添加规则来创建输出目录。 所以我添加了
ifeq (,$(wildcard bin/$(PROFILE)/obj/interface))
$(shell $(MKDIR) -p bin/$(PROFILE)/obj/interface)
endif
答案 2 :(得分:0)
这个makefile非常复杂,所以需要进行一定程度的猜测,但我认为问题在于它不知道如何找到interface/ipc.c
。尝试在底部添加此行,看看是否有帮助:
vpath %.c interface
如果没有,我们可以尝试其他一些事情。 (如果确实如此,我可以建议一些简化makefile的方法。)