谁能帮我把下列makefile作一下注释?万分感谢

qizhan2008 2008-12-19 04:13:15
INCLUDES = -I /home/nie/mysrc/inclulde\
-I /home/nie/mysrc/extern/include\
-I /home/nie/mysrc/src\
-I /home/nie/mysrc/libsrc\
-I. \
-I..
EXT_CC_OPTS = -DEXT_MODE
CPP_REQ_DEFINES = -DMODEL=tunel -DRT -DNUMST=2 \
-DTID01EQ=1 -DNCSTATES=0 \
-DMT=0 -DHAVESTDIO
RTM_CC_OPTS=-DUSE_RTMODEL

CFLAGS=-O-g
CFLAGS+=$(CPP_REQ_DEFINES)
CFLAGS+=$(EXT_CC_OPTS)
CFLAGS+=$(RTM_CC_OPTS)
SRCS=tunel.c rt_sim.c rt_nonfinite.c grt_main.c rt_logging.c \
ext_svr.c updown.c ext_svr_transport.c ext_work.c
OBJS=$(SRCS:.c=.o)
RM=rm -f
CC=gcc
LD=gcc
all:tunel
%.o:%.c
%(CC)-c -o %@$(CFLAGS)$(INCLUDES)$<
tunel : $@$(OBJS) -lm
clean :
$(RM) $(OBJS)
...全文
305 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangb2014# 2008-12-21
  • 打赏
  • 举报
回复
先看看make的入门资料吧。。。
malone1 2008-12-21
  • 打赏
  • 举报
回复
这种忙最好别帮,不人道啊.以后不用听课了
qizhan2008 2008-12-21
  • 打赏
  • 举报
回复
希望某位大侠帮我注释一下,小弟是菜鸟,要交作业,没去听课~~
honesy 2008-12-20
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 joyself 的回复:]
怪怪龙地洞,这里面错误还真是太多了,。。。。

这里说个简化版,每行开头如果有缩进,都是Table,而不是空行。


C/C++ codeOBJS=$(SRCS:.c=.o)



C/C++ code
%.o:%.c
%(CC)-c -o %@ $(CFLAGS) $(INCLUDES)$< #








C/C++ codeINCLUDES = -I/home/nie/mysrc/include
EXT_CC_OPTS = -DEXT_MODE
CPP_REQ_DEFINES = -DMODEL=tunel -DRT -DNUMST=2
RTM_CC_OPTS=-DUSE_RTMODEL

CFLAGS=-O -g
C…
[/Quote]
下面的书下载地址给个....
我怎么搜不到
joyself 2008-12-19
  • 打赏
  • 举报
回复
怪怪龙地洞,这里面错误还真是太多了,。。。。

这里说个简化版,每行开头如果有缩进,都是Table,而不是空行。

OBJS=$(SRCS:.c=.o)   


%.o:%.c
%(CC)-c -o %@ $(CFLAGS) $(INCLUDES)$< #



INCLUDES = -I/home/nie/mysrc/include
EXT_CC_OPTS = -DEXT_MODE
CPP_REQ_DEFINES = -DMODEL=tunel -DRT -DNUMST=2
RTM_CC_OPTS=-DUSE_RTMODEL

CFLAGS=-O -g
CFLAGS+=$(CPP_REQ_DEFINES)
CFLAGS+=$(EXT_CC_OPTS)
CFLAGS+=$(RTM_CC_OPTS)
SRCS=tunel.c rt_sim.c rt_nonfinite.c grt_main.c rt_logging.c

OBJS=$(SRCS:.c=.o) # 把SRCS中以 .c 结尾的 全部换成 .o
RM=rm -f
CC=gcc
LD=gcc

all:tunel
%.o:%.c
$(CC) -c -o $@ $(CFLAGS) $(INCLUDES) $< # $@ 就是指的是 %.o, $<指的是 %.c ;你的 %(CC)和%@都不对的
tunel : $(OBJS) -lm # 由 .o 生成 可执行文件 tunel
clean :
$(RM) $(OBJS)


其余的都是设置变量什么的,没什么可说的。


下面从managing project with GNU make 3d拷贝过来的
2.2.1 Automatic Variables
Automatic variables are set by make after a rule is matched. They provide access to elements from the target and prerequisite lists so you don't have to explicitly specify any filenames. They are very useful for avoiding code duplication, but are critical when defining more general pattern rules (discussed later).

There are six "core" automatic variables:

$@

The filename representing the target.


$%

The filename element of an archive member specification.


$<

The filename of the first prerequisite.


$?

The names of all prerequisites that are newer than the target, separated by spaces.


$^

The filenames of all the prerequisites, separated by spaces. This list has duplicate filenames removed since for most uses, such as compiling, copying, etc., duplicates are not wanted.


$+

Similar to $^, this is the names of all the prerequisites separated by spaces, except that $+ includes duplicates. This variable was created for specific situations such as arguments to linkers where duplicate values have meaning.


$*

The stem of the target filename. A stem is typically a filename without its suffix. (We'll discuss how stems are computed later in Section 2.4.) Its use outside of pattern rules is discouraged.

linaxing 2008-12-19
  • 打赏
  • 举报
回复
还是自己找点makefile/gcc的资料看看吧,要弄明白这个make文件不难。

23,130

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧