当前位置: 技术问答>linux和unix
有关于Makefile的问题。。。
来源: 互联网 发布时间:2016-06-27
本文导语: ALL:result CC=cc -DAIX_UNIX -DDEBUG_FUN_INFO_MSG path_alloc.o:path_alloc.c $(CC) -c $? getcwd.o : getcwd.c $(CC) -c $? result:path_alloc.o getcwd.o $(CC) -o result path_alloc.o getcwd.o clean: rm -r result *.o ...
ALL:result
CC=cc -DAIX_UNIX -DDEBUG_FUN_INFO_MSG
path_alloc.o:path_alloc.c
$(CC) -c $?
getcwd.o : getcwd.c
$(CC) -c $?
result:path_alloc.o getcwd.o
$(CC) -o result path_alloc.o getcwd.o
clean:
rm -r result *.o
~
上面这个是Makefile文件里保存的内容。但是当前目录下还有另外一个makefile。 怎样才能保证我make的是以大写开头Makefile文件 而不makefile这个文件呢??
本人也是刚学make。。 还望各位指教。 。 并帮忙看下我自己写的Makefile对不对啊?、
|
CFLAGS=-DAIX_UNIX -DDEBUG_FUN_INFO_MSG
TARGET=result
OBJS=path_alloc.o getcwd.o
$(TARGET): $(OBJS)
clean:
rm -rf $(TARGET) $(OBJS)
|
如果你实在觉得每次-f麻烦,你可以写个shell脚本把make -f xxx打个包,呵呵
|
直接用-f选项指定需要的Makefile文件名即可,你可以把Makefile文件编写为任意的文件名,然后用-f选项指定给make命令就可以了。
|
你可以这样处理 把你的Makefile 保存为 任意名 如 mymake
然后执行 make -f mymake 就会执行 mymake
若执行 make 就会执行目录下的makefile
然后执行 make -f mymake 就会执行 mymake
若执行 make 就会执行目录下的makefile
|
http://www.gnu.org/software/make/manual/make.html#Makefile-Names
3.2 What Name to Give Your Makefile
By default, when make looks for the makefile, it tries the following names, in order: GNUmakefile, makefile and Makefile. Normally you should call your makefile either makefile or Makefile. (We recommend Makefile because it appears prominently near the beginning of a directory listing, right near other important files such as README.) The first name checked, GNUmakefile, is not recommended for most makefiles. You should use this name if you have a makefile that is specific to GNU make, and will not be understood by other versions of make. Other make programs look for makefile and Makefile, but not GNUmakefile.
If make finds none of these names, it does not use any makefile. Then you must specify a goal with a command argument, and make will attempt to figure out how to remake it using only its built-in implicit rules. See Using Implicit Rules.
If you want to use a nonstandard name for your makefile, you can specify the makefile name with the `-f' or `--file' option. The arguments `-f name' or `--file=name' tell make to read the file name as the makefile. If you use more than one `-f' or `--file' option, you can specify several makefiles. All the makefiles are effectively concatenated in the order specified. The default makefile names GNUmakefile, makefile and Makefile are not checked automatically if you specify `-f' or `--file'.
3.2 What Name to Give Your Makefile
By default, when make looks for the makefile, it tries the following names, in order: GNUmakefile, makefile and Makefile. Normally you should call your makefile either makefile or Makefile. (We recommend Makefile because it appears prominently near the beginning of a directory listing, right near other important files such as README.) The first name checked, GNUmakefile, is not recommended for most makefiles. You should use this name if you have a makefile that is specific to GNU make, and will not be understood by other versions of make. Other make programs look for makefile and Makefile, but not GNUmakefile.
If make finds none of these names, it does not use any makefile. Then you must specify a goal with a command argument, and make will attempt to figure out how to remake it using only its built-in implicit rules. See Using Implicit Rules.
If you want to use a nonstandard name for your makefile, you can specify the makefile name with the `-f' or `--file' option. The arguments `-f name' or `--file=name' tell make to read the file name as the makefile. If you use more than one `-f' or `--file' option, you can specify several makefiles. All the makefiles are effectively concatenated in the order specified. The default makefile names GNUmakefile, makefile and Makefile are not checked automatically if you specify `-f' or `--file'.
|
make -f Makefile
或者mv makefile makefile.mk
或者mv makefile makefile.mk
|
学习了 帮顶~