我想編譯一個示例代碼,其中我在一個新目錄下添加了一個新文件,但我不斷收到依賴關係問題。 我在「/ interface」下添加了一個「ipc.c」文件。 我已經將源文件添加到「srcs」,並且還添加了「-I/interface」目錄。 Makefile文件如下所示: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 [email protected] ..."
$(MAKE) $(MAKEVARS) PROFILE=debug SUFFIX=v5T togs2_host
$(MAKE) $(MAKEVARS) PROFILE=release SUFFIX=v5T togs2_host
install:
@$(ECHO) "#"
@$(ECHO) "# Making [email protected] ..."
@$(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 [email protected] ..."
$(LD) $(LDFLAGS) -o [email protected] $^ $(LDLIBS)
bin/$(PROFILE)/obj/%.o$(SUFFIX): %.h
bin/$(PROFILE)/obj/%.o$(SUFFIX): %.c
@$(ECHO) "###"
@$(ECHO) "### Making [email protected] ..."
$(CC) $(CPPFLAGS) $(CFLAGS) -o [email protected] $<
# ======== 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 [email protected] -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,[email protected]
LDLIBS = -lpthread -lc
CCPROFILE_debug = -ggdb -D DEBUG
CCPROFILE_release = -O3 -D NDEBUG
LDPROFILE_debug = -ggdb
LDPROFILE_release = -O3
endif
我不斷收到此錯誤: 致命錯誤:打開依賴文件斌/調試/ OBJ /接口/ 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,因爲它是一個代碼示例,我只是擴展。
任何幫助將是最有幫助的。
羅爾夫 Cdltd
你沒有向我們展示整個問題。在頂部,這個makefile包含文件'../products.mak'。該文件中可能有一行包含每個目標文件的'.dep'文件,但它沒有在您添加的文件的正確目錄中查看(或者您可能認爲您將該文件添加到了錯誤的目錄中)) 。 – eriktous 2012-03-07 13:48:01
StackO阿伯丁Meetup 2012:請參閱[SO聚會鏈接](http://www.meetup.com/stackoverflow/Aberdeen-GB/653922/#comment1228022)瞭解更多信息。看到你在阿伯丁,請嘗試參加。明天我會刪除這條評論。道歉,但沒有其他方式聯繫SO。 – bPratik 2012-04-27 02:21:58