更新一个文件后,make不起作用。Makefile如何改?

526 views
Skip to first unread message

xx

unread,
Dec 6, 2011, 5:53:22 AM12/6/11
to sh...@googlegroups.com
各位英雄:

写了一个Makefile文件。但是遇到一个问题:

对项目的一个文件进行更新,运行make,会说“没有什么可以做的”。整个项目必须make clean,再make才行。

问题出在哪里?

Xiangfu Liu

unread,
Dec 6, 2011, 6:29:26 AM12/6/11
to sh...@googlegroups.com, xx

请贴 Makefile 出来。或者 make clean all.


Moore

unread,
Dec 6, 2011, 6:42:40 AM12/6/11
to Shanghai Linux User Group

这位壮士,先执行

find ./ -name "*.o" -exec rm -fr {} /;

就不会nothing to do 了。

Xiangfu Liu

unread,
Dec 6, 2011, 6:44:22 AM12/6/11
to sh...@googlegroups.com, Moore
On 12/06/2011 07:42 PM, Moore wrote:
> 这位壮士,先执行
>
> find ./ -name "*.o" -exec rm -fr {} /;
>
> 就不会nothing to do 了。

how did you know it's a C project? :D

xx

unread,
Dec 6, 2011, 6:52:10 AM12/6/11
to sh...@googlegroups.com, Moore, Xiangfu Liu
通常情况下在项目目录中,更改一个文件后,运行make会编译连接相关文件。

但是,现在出了问题,必须make clean,然后make,才能让改动的文件重新编译连接。

即:通常情况下:
$make
...编译改动的相关文件,然后链接生成新的目标文件

现在出了问题:
...修改文件....
$make
nothing to do
$make clean
$make
...编译整个项目的文件

如果每一次修改一个文件,都需要make clean然后把整个项目都完全编译连接一下,显然不好啊。

Dongkuo Ma

unread,
Dec 6, 2011, 8:37:04 AM12/6/11
to sh...@googlegroups.com
依赖关系没有配置好,这个得要你贴出代码来才能看问题在什么地方

2011/12/6 xx <xx.k...@gmail.com>

Zind

unread,
Dec 6, 2011, 8:41:57 AM12/6/11
to sh...@googlegroups.com
2011/12/6 xx <xx.k...@gmail.com>
如果每一次修改一个文件,都需要make clean然后把整个项目都完全编译连接一下,显然不好啊。

按理说是不需要的吧?
是不是你的 makefile 写的有问题呢?
不妨贴出来一瞅

xx

unread,
Dec 6, 2011, 8:53:11 AM12/6/11
to sh...@googlegroups.com
基本上确定是TARGET没有依赖的问题。 还没搞清楚,如何解决。 default: build
$(TARGET).gz: $(TARGET)
        gzip -f -9 < $< > $@.new
        mv $@.new $@

debug:
        objdump -D -S $(TARGET)-syms > $(TARGET).s

dist: install

build: $(TARGET).gz

install: $(TARGET).gz
ifeq (,$(strip $(PROJECT_DIR)))
$(error " $(PROJECT_DIR) is not defined. Please configure it in ./Config.mk!")
endif
        @if [ -d $(PROJECT_DIR) ] ; then \
                cp $(TARGET)-bin $(PROJECT_DIR) ; \
                echo "Installed successfully!" ; \
        else \
                echo  "ERROR. $(PROJECT_DIR) is invalid, Please check it in ./Config.mk!" ; \
        fi

clean:
        $(MAKE) -C common clean
        $(MAKE) -C drivers clean
        $(MAKE) -C fs clean
        $(MAKE) -C acm clean
        $(MAKE) -C arch/$(TARGET_ARCH) clean
        $(MAKE) -C security clean
        rm -f include/asm/arch
        rm -f include/asm *.o $(TARGET)* *~ core
        rm -f include/asm-*/asm-offsets.h
        rm -f include/xen/acm_policy.h

$(TARGET):
        $(MAKE) include/xen/compile.h
        $(MAKE) include/xen/acm_policy.h
        $(MAKE) include/xen/autoconf.h
        [ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm
        [ -e include/asm/arch ] || ln -sf arch-$(TARGET_SUBARCH) include/asm/arch
        $(MAKE) -C arch/$(TARGET_ARCH) asm-offsets.s
        $(MAKE) include/asm-$(TARGET_ARCH)/asm-offsets.h
        $(MAKE) -C arch/$(TARGET_ARCH) $(TARGET)

2011/12/6 Zind <wzmi...@gmail.com>

Xiangfu Liu

unread,
Dec 6, 2011, 10:11:40 AM12/6/11
to sh...@googlegroups.com, xx
On 12/06/2011 09:53 PM, xx wrote:
> 基本上确定是TARGET没有依赖的问题。 还没搞清楚,如何解决。

你修改了哪个文件?

Xunzhen Quan

unread,
Dec 6, 2011, 10:21:07 AM12/6/11
to sh...@googlegroups.com
你的 $(TARGET) 根本没有设置依赖任何文件,当然不会自动更新咯

2011/12/6 Xiangfu Liu <xia...@openmobilefree.net>

Jeova Sanctus Unus

unread,
Dec 6, 2011, 7:05:20 PM12/6/11
to sh...@googlegroups.com

说了这么久,才贴出来。建议去看,提问的智慧。然后去把make的入门文档看下。

xx

unread,
Dec 6, 2011, 7:52:38 PM12/6/11
to sh...@googlegroups.com


2011/12/7 Jeova Sanctus Unus <jeova.san...@gmail.com>

说了这么久,才贴出来。建议去看,提问的智慧。然后去把make的入门文档看下。

这位大侠,我有功夫去看make文档,还用在这里问吗?

Chaos Eternal

unread,
Dec 6, 2011, 7:57:18 PM12/6/11
to sh...@googlegroups.com
小朋友,你没有时间去看make文档就可以浪费别人的时间么?

如果连看文档的时间都没有,别吃这口饭了。

2011/12/7 xx <xx.k...@gmail.com>:

xx

unread,
Dec 6, 2011, 8:08:10 PM12/6/11
to sh...@googlegroups.com


2011/12/7 Chaos Eternal <chaose...@shlug.org>
小朋友,你没有时间去看make文档就可以浪费别人的时间么?

如果连看文档的时间都没有,别吃这口饭了。
 
好吧,看来您是吃这口饭的,并且我浪费您时间了,非常抱歉,以后遇到新手帖子,注意绕道哦。

xxmplus

unread,
Dec 6, 2011, 8:08:33 PM12/6/11
to sh...@googlegroups.com
把你工资给我,我帮你搞定

2011/12/7 xx <xx.k...@gmail.com>:


>
>
> 2011/12/7 Jeova Sanctus Unus <jeova.san...@gmail.com>
>>
>> 说了这么久,才贴出来。建议去看,提问的智慧。然后去把make的入门文档看下。
>
> 这位大侠,我有功夫去看make文档,还用在这里问吗?

--
Any complex technology which doesn’t come with documentation must be the best
available.

Xunzhen Quan

unread,
Dec 6, 2011, 8:10:11 PM12/6/11
to sh...@googlegroups.com
大家不要在这里互相攻击了。
xx 你去找个 makefile 的入门教程好好看看吧,这个真的是非常低级的错误。

2011/12/7 xx <xx.k...@gmail.com>

xx

unread,
Dec 6, 2011, 8:11:34 PM12/6/11
to sh...@googlegroups.com


2011/12/7 xxmplus <xxm...@gmail.com>
把你工资给我,我帮你搞定
 
哈哈,我木有工资,一苦逼学僧。正在摸索。

Chaos Eternal

unread,
Dec 6, 2011, 8:11:56 PM12/6/11
to sh...@googlegroups.com
别人可以绕道,我不能。

所以请你闭嘴。

2011/12/7 xx <xx.k...@gmail.com>:

Xunzhen Quan

unread,
Dec 6, 2011, 8:12:52 PM12/6/11
to sh...@googlegroups.com
别吵了别吵了啦 > <

2011/12/7 Chaos Eternal <chaose...@shlug.org>

xx

unread,
Dec 6, 2011, 8:14:55 PM12/6/11
to sh...@googlegroups.com
2011/12/7 Chaos Eternal <chaose...@shlug.org>
别人可以绕道,我不能。

所以请你闭嘴。

弱弱问您一下,这个ML是您的么?

ghosTM55

unread,
Dec 6, 2011, 8:26:08 PM12/6/11
to sh...@googlegroups.com
2011/12/7 xx <xx.k...@gmail.com>:
> 弱弱问您一下,这个ML是您的么?

不是
但是他有权因为你对给到你忠言逆耳的建议不好好感激思考,反而以这样的态度回敬的人直接踢出我们SHLUG

再出现这样请教问题和回复邮件的态度我直接ban掉

--
Thomas
Shanghai Linux User Group

http://ghosTunix.org
Twitter: @ghosTM55

Chaos Eternal

unread,
Dec 6, 2011, 8:30:04 PM12/6/11
to sh...@googlegroups.com

此人:xx.k...@gmail.com已ban。

Chaos Eternal

unread,
Dec 6, 2011, 8:33:49 PM12/6/11
to sh...@googlegroups.com

注:期限三天。

jojo

unread,
Dec 6, 2011, 9:18:30 PM12/6/11
to sh...@googlegroups.com
这种问题肯定是makfile的depends不是很好。你懂的。

B.R
-- jojo

firedtoad

unread,
Dec 6, 2011, 9:35:47 PM12/6/11
to sh...@googlegroups.com
�� 2011/12/7 10:18, jojo �:
��������϶���makfile��depends���Ǻܺá��㶮�ġ�

B.R
-- jojo

�� 2011-12-6������6:53�� xx ���

��λӢ�ۣ�

д��һ��Makefile�ļ�����������һ�����⣺

����Ŀ��һ���ļ����и��£�����make����˵��û��ʲô�������ġ��������Ŀ����make clean����make���С�

����������
���ALL Ŀ��

Xunzhen Quan

unread,
Dec 6, 2011, 11:19:37 PM12/6/11
to sh...@googlegroups.com
跟 all 目标一点关系都没有……

2011/12/7 firedtoad <fire...@gmail.com>
这种问题肯定是makfile的depends不是很好。你懂的。
添加ALL 目标


George.Qiao

unread,
Dec 12, 2011, 1:19:40 AM12/12/11
to sh...@googlegroups.com
Hi xx,

我是想帮你,可是确实我不知道你在写什么。。。
貌似你写的太不靠谱了,给你的建议是去看看文档,或者看看成功的开源项目的 Makefile,你的Makefile我真是看不懂。。。



Xiangfu Liu

unread,
Dec 12, 2011, 1:24:17 AM12/12/11
to sh...@googlegroups.com
On 12/06/2011 09:53 PM, xx wrote:
> 基本上确定是TARGET没有依赖的问题。 还没搞清楚,如何解决。

加这一行到你的makefile:

.PHONE: $(TARGET) clean


:D

Xiangfu Liu

unread,
Dec 12, 2011, 1:24:54 AM12/12/11
to sh...@googlegroups.com, xx
On 12/06/2011 09:53 PM, xx wrote:
> 基本上确定是TARGET没有依赖的问题。 还没搞清楚,如何解决。

加这两行更好:

.PHONE: clean
$(TARGET): clean


:D

Moore

unread,
Dec 12, 2011, 2:46:12 AM12/12/11
to Shanghai Linux User Group
埋了这么久,终于看到有人这么说了。

1. 事情是这样的,如果比如是其他语言,python ruby erlang schema java 或者等等,都多少有点基本常识和基础的,而
有基本常识的人是不会这么傻傻地问这么低级的问题的。

只有像C , 有很高的概率,什么都还不懂的情况下就作为入门的语言使用,用的还不熟,也不愿意看文档,到处问低级问题,只能说明还是像我一样的低级
用户。

2. 我其他的都不会,只会写 fprintf 的人,所以就当他和我一样了。

Xiangfu Liu

unread,
Dec 12, 2011, 3:23:52 AM12/12/11
to xx, sh...@googlegroups.com
On 12/12/2011 04:17 PM, xx wrote:
> .PHONE: clean
> $(TARGET): clean
>
>
> 谢谢


this is a workaround. :) you need fix the root-cause.

there are two way you can fix the root-cause:
1. learn more about Make system. fix it by youself
2. paste all the source code somewhere. include all the makefiles under sub-folder
like:


$(MAKE) include/xen/compile.h
$(MAKE) include/xen/acm_policy.h
$(MAKE) include/xen/autoconf.h

$(MAKE) -C arch/$(TARGET_ARCH) asm-offsets.s
$(MAKE) include/asm-$(TARGET_ARCH)/asm-offsets.h
$(MAKE) -C arch/$(TARGET_ARCH) $(TARGET)

then the sh linux user fix that for you. :D

xx

unread,
Dec 12, 2011, 3:37:31 AM12/12/11
to sh...@googlegroups.com, Xiangfu Liu
呵呵,非常感谢!

这几天,啃了Makefile文档。因为,平时不用写Makefile,所以,只掌握基本的Makefile语法。而不愿意去读枯燥的文档,可能也有对英文的文档读起来还有些障碍的原因。

问题目前还没有解决,不过,我决定自己搞定它了。
Reply all
Reply to author
Forward
0 new messages