[英]How can I write my own Makefile (.mak file)?
I want to know how to write a Makefile
( .mak
-file).我想知道如何编写Makefile
( .mak
-file)。
I have 4 files:我有4个文件:
myfunctions.h
: myfunctions.h
://myfunctions.h
#ifndef MYFUNCTIONS_H
#define MYFUNCTIONS_H
void show();
#endif
myfunctions.c
: myfunctions.c
://myfunctions.c
#include "myfunctions.h"
void show(){
printf("running!");
}
mymain.c
: mymain.c
://mymain.c
#include "myfunctions.h"
int main(int argc, char *argv[]) {
show();
}
mymake.mak
: mymake.mak
://mymake.mak
myprogramm: mymain.c myfunctions.c
gcc -o myprogramm mymain.c myfunctions.c -I.
I run the mymake.mak
with make mymakemak.mak
and I get this error:我运行mymake.mak
用make mymakemak.mak
和我得到这个错误:
make: Nothing to be done for `mymake.mak'.
What am I doing wrong?我究竟做错了什么?
You need to use the file as the Makefile itself, not as the target.您需要将该文件用作 Makefile 本身,而不是用作目标。 So you should be running所以你应该跑
make -f mymake.mak
You can also rename mymake.mak
to Makefile
or makefile
and re-run make
.您还可以将mymake.mak
重命名为Makefile
或makefile
并重新运行make
。
What make
is trying to do here is create a target called mymake.mak
. make
在这里试图做的是创建一个名为mymake.mak
的目标。 Since mymake.mak
already exists, make
thinks its job is done and it exits.由于mymake.mak
已经存在, make
认为它的工作已经完成并退出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.