【发布时间】:2014-12-21 23:55:04
【问题描述】:
该项目是关于一个包含 src 目录的根目录。我创建了两个 makefile,一个在顶层目录,另一个在 src 目录。这是src目录的makefile:
## Process this file with automake to produce Makefile.in
## Created by Netbeans
AM_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"
bin_PROGRAMS = scratchautotool
program_INCLUDE_DIRS := /usr/bin/PR__bin
program_LIBRARY_DIRS := /usr/lib/PR__lib
CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
scratchautotool_SOURCES = \
main.c \
Task.c \
SeedVP.c
depend :
makedepend --$(CFLAGS) --$(scratchautotool_SOURCES)
根目录的makefile如下图:
## Process this file with automake to produce Makefile.in
## Created by Netbeans
SUBDIRS = src
scratchautotooldocdir = ${prefix}/doc/scratchautotool
scratchautotooldoc_DATA = \
README\
COPYING\
AUTHORS\
ChangeLog\
INSTALL\
NEWS
INTLTOOL_FILES = intltool-extract.in \
intltool-merge.in \
intltool-update.in
EXTRA_DIST = $(scratchautotooldoc_DATA) \
$(INTLTOOL_FILES)
DISTCLEANFILES = intltool-extract \
intltool-merge \
intltool-update \
po/.intltool-merge-cache
# Remove doc directory on uninstall
uninstall-local:
-rm -r $(scratchautotooldocdir)
但是当我从终端调用 make 时,它给了我以下错误:
Making all in src
make[2]: Entering directory `../src'
make[2]: *** No rule to make target `all'. Stop.
make[2]: Leaving directory `../src'
【问题讨论】:
-
--$(scratchautotool_SOURCES)将扩展到--main.c Task.c SeedVP.c,这很可能不是您想要或想要的。同样,--$(CFLAGS)将扩展到---I/usr/bin/PR__bin(或者可能是-- -I/usr/bin/PR__bin,我必须对其进行测试才能确定),但在任何一种情况下都不太可能是您想要的。 -
@Etan 我的源目录包含 3 个文件和两个头文件,我使用 makedepend 自动生成依赖规则并避免任何错误我可以这样做你的意思是这是错误的,关于 cflags,我有一个文件夹,里面有很多main.c、seedvp.c等在代码中用到的头文件
-
我的意思是在 makedepend 行上使用这些变量几乎肯定是不正确的,因为你有太多的破折号(除非 makedepend 有一些奇怪的参数要求)。只需查看当您运行
make depend时make 指示它正在运行的命令即可了解我的意思。为简单起见,那些foreach循环也可以替换为CFLAGS += $(addprefix -I,$(program_INCLUDE_DIRS))和AM_LDFLAGS += $(addprefix -L,$(program_LIBRARY_DIRS))。 -
我运行 makedepend 它给了我这个错误 No rule to make target `depend'。停止。
-
depend目标很可能只在src目录中有效。