[英]What does this makefile do?
I have the following makefile (Makefile.certify) and when I execute: 我有以下makefile(Makefile.certify),执行时:
make -f Makefile.certify
It gives me a: 它给了我一个:
/bin/sh: line 23: -o: command not found
PROG=certify
TMP=/var/tmp
ARCH=x86_64
_CC=/bin/cc
all: ${PROG}
${PROG}: ${ARCH}
@for mode in $? ; do \
case $${mode} in \
i386) \
CC="${_CC} -g -D__x86"; \
;; \
i386-f64) \
CC="${_CC} -D_FILE_OFFSET_BITS=64 -g -D__x86";\
;; \
amd64) \
CC="${_CC} -m64 -g -D__x86 -D__ia64 -D__GNUC";\
;; \
*) \
;; \
esac; \
$${CC} -o ${TMP}/$${mode}/$@ ${TMP}/$@.c; \
done
I don't really use makefiles
or c
, but I have to deal with this one. 我不是真的使用
makefiles
或c
,但是我必须处理这个。
My questions are: 我的问题是:
- Why does for loop need a
@
prefix?为什么for循环需要
@
前缀?- What is the
$?
什么是
$?
in the for loop?在for循环中?
- What would be a possible execution of this makefile?
此makefile可能执行什么操作? Obviously it tries to compile my certify.
显然,它试图汇编我的证明。
c file
based on the architecture of the system executing or something like this, but I fail to see how it will choose eitheri386
oramd64
etc.基于执行或类似系统的体系结构的
c file
,但是我看不到它将如何选择i386
或amd64
等。
I am using an x86
system running RHEL
. 我正在使用运行
RHEL
的x86
系统。
@
prefix is used for suppressing command print by make
. @
前缀用于禁止make
打印命令。 If it is not present, make
will print command before execution to output. 如果不存在,
make
将在执行之前打印命令以输出。
You can remove it and see the difference. 您可以将其删除并查看区别。
$?
is the dependency list. 是依赖项列表。 In your particular case
ARCH
is defined as a single entry "x86_64". 在您的特定情况下,
ARCH
被定义为单个条目“ x86_64”。 So $?
那么
$?
will be expanded into that value. 将扩展为该值。 But you can try to modify
ARCH
value in the following way: 但是您可以尝试通过以下方式修改
ARCH
值:
ARCH=x86_64 i386
It tries to build certify
binary for a given architecture from cerfify.c
source file. 它尝试从
cerfify.c
源文件构建给定体系结构的certify
二进制文件。 Each binary will be located in own sub-directory: 每个二进制文件将位于自己的子目录中:
/var/tmp/{i386|x86_64|i386_f64}/certify
@
is used to suppress the normal 'echo' of the command that is executed. @
用于禁止执行的命令的正常“回显”。 Using it in the for loop is also new to me (does removing it change anything in the output?) 在for循环中使用它对我来说也是新的(删除它会更改输出中的任何内容吗?)
$?
is one of the makefile automatic variables , this one means "The names of all the prerequisites that are newer than the target, with spaces between them"
是makefile自动变量之一 ,它的意思是
"The names of all the prerequisites that are newer than the target, with spaces between them"
It will iterate through $?
它将遍历
$?
, read above , 阅读以上部分
Edit: 编辑:
Example of $?
$?
例子
targetfile : firstfile secondfile thirdfile
cat $? > $@
if targetfile
is older than all the other 3 files , the makefile will concatenate the contents of firstfile
, secondfile
and thirdfile
together in targetfile
. 如果
targetfile
是比其他3个文件年纪大了 ,makefile文件将拼接的内容firstfile
, secondfile
和thirdfile
在一起targetfile
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.