$< 是什么意思?

cqxhhe 2003-06-05 07:05:36
< 是什么意思?
内核的Makefile文件中用到了这个符号,
差了查资料,知道是预定义的变量,但没找到是什么意思?
例如:

$(CPP) $(AFLAGS) $(AFLAGS_KERNEL) -traditional -o $*.s $<
...全文
40 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
AL_lew 2003-06-16
  • 打赏
  • 举报
回复
man bash ?
tryitagain 2003-06-16
  • 打赏
  • 举报
回复 1
这是一些设定好的内部变量,它们根据每一个规则内容定义。三个 比较有用的变量是 $@, $< 和 $^ (这些变量不需要括号括住)。 $@ 扩展成当前规则的目的文件名, $< 扩展成依靠列表中的第 一个依靠文件,而 $^ 扩展成整个依靠的列表(除掉了里面所有重 复的文件名)。举个例子:
=== makefile 开始 ===
OBJS = foo.o bar.o
CC = gcc
CFLAGS = -Wall -O -g

myprog : $(OBJS)
$(CC) $^ -o $@

foo.o : foo.c foo.h bar.h
$(CC) $(CFLAGS) -c $< -o $@

bar.o : bar.c bar.h
$(CC) $(CFLAGS) -c $< -o $@
=== makefile 结束 ===

把它扩展就是:
=== makefile 开始 ===
OBJS = foo.o bar.o
CC = gcc
CFLAGS = -Wall -O -g

myprog : $(OBJS)
$(CC) $(OBJS) -o myprog

foo.o : foo.c foo.h bar.h
$(CC) $(CFLAGS) -c foo.c -o foo.o

bar.o : bar.c bar.h
$(CC) $(CFLAGS) -c bar.c -o bar.o
=== makefile 结束 ===

cqxhhe 2003-06-12
  • 打赏
  • 举报
回复
我用
man make
怎么找不到相关的内容啊?
linaxing 2003-06-06
  • 打赏
  • 举报
回复
它们都是make的内建宏,一下内容来自HP-UNIX的man手册

$< In an inference rule, $< evaluates to the source file
name that corresponds to the implicit rule which
matches the suffix of the target being made. In other
words, it is the file that is out-of-date with respect
to the target. In the .DEFAULT rule, the $< macro
evaluates to the current target name. $< is evaluated
only for inference rules. Thus, in the .c.o rule, the
$< macro would evaluate to the .c file. An example for
making optimized .o files from .c files is:

.c.o:
cc -c -O $*.c

or:

.c.o:
cc -c -O $<

$* The macro $* is the current target name with the suffix
deleted. It is evaluated only for inference rules.
cqxhhe 2003-06-05
  • 打赏
  • 举报
回复
有没有详细的说明文档呢?
还有用法,

在Google里好像这些特殊字符都搜不出来。

是不是跟输入重定向有关?

$(CPP) $(AFLAGS) $(AFLAGS_KERNEL) -traditional -o $*.s $<
上面这个语句是什么含义呢?
vcppman 2003-06-05
  • 打赏
  • 举报
回复
让你输入东西

$<就代表是你输入的东东了呀

23,118

社区成员

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

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