免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3124 | 回复: 1
打印 上一主题 下一主题

求助!下面这个makefile是什么意思,特别是后面循环的那段,高手请指点 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-05 15:02 |只看该作者 |倒序浏览
# This is the Makefile for the client side device for npu-term.

include Defs.mk
export TOP_DIR
       
TARGET = npu-xscale.o
SRC = clientmain.c clientdma.c clientterm.c clientpci.c

all : .depend $(TARGET)

clean :
        rm -f $(TARGET) *.o *.c~ .depend ../common/header.h

$(TARGET): $(SRC:.c=.o)
        $(LD) -r $^ -o $@

# Special case for clientdma.c because it includes Grunt headers.
clientdma.o : clientdma.c
        $(CC) $(CFLAGS) -c -o $@ $<

../common/header.h : create_header.py
        ./create_header.py

# Clean up the code indenting before doing cvs commit.
# Unfortunately, the local .indent.pro uses --preserve-mtime which preserves
# the mtime for all files. The following hack runs indent on each file and
# touches the files which have changed.
indent:
        @for file in *.[ch] ;do \
                if [ -w "$$file" ]; then \
                        indent $$file ; \
                        x=`cmp $$file $$file~` ; \
                        if [ -n "$$x" ]; then \
                                echo "Indenting $$file" ; \
                                touch $$file ; \
                                fi ; \
                        fi ; \
                done
        @rm -f *~

depend .depend dep : ../common/header.h
        $(CC) $(CFLAGS) -M *.c > $@


ifeq (.depend,$(wildcard .depend))
include .depend
endif

文中加颜色的几行请大家帮我解释一下,谢谢!

论坛徽章:
0
2 [报告]
发表于 2007-03-06 10:02 |只看该作者
# This is the Makefile for the client side device for npu-term.

include Defs.mk
export TOP_DIR
        
TARGET = npu-xscale.o
SRC = clientmain.c clientdma.c clientterm.c clientpci.c

all : .depend $(TARGET)

clean :
        rm -f $(TARGET) *.o *.c~ .depend ../common/header.h
这是一个make Target,执行make clean时执行这一行指令。
$(TARGET): $(SRC:.c=.o)
        $(LD) -r $^ -o $@

# Special case for clientdma.c because it includes Grunt headers.
clientdma.o : clientdma.c
        $(CC) $(CFLAGS) -c -o $@ $<

../common/header.h : create_header.py
        ./create_header.py
#
当header.h不存在或比create_header.py脚本的
#时间更靠前,则执行该脚本。
# Clean up the code indenting before doing cvs commit.
# Unfortunately, the local .indent.pro uses --preserve-mtime which preserves
# the mtime for all files. The following hack runs indent on each file and
# touches the files which have changed.
indent:
        @for file in *.[ch] ;do \
                if [ -w "$$file" ]; then \
                        indent $$file ; \
                        x=`cmp $$file $$file~` ; \
                        if [ -n "$$x" ]; then \
                                echo "Indenting $$file" ; \
                                touch $$file ; \
                                fi ; \
                        fi ; \
                done
        @rm -f *~
# 这个循环明显是对所有.c 和 .h 文件进行 indent 操作。
# indent 我的理解是让c源文件更规范,比如缩进。
# man indent 可以获得详细解释
depend .depend dep : ../common/header.h
        $(CC) $(CFLAGS) -M *.c > $@


ifeq (.depend,$(wildcard .depend))
include .depend
endif

文中加颜色的几行请大家帮我解释一下,谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP