当前位置 主页 > 服务器问题 > Linux/apache问题 >

    详解linux下make命令的使用方法(2)

    栏目:Linux/apache问题 时间:2018-11-16 14:00

    $ make -d | moreGNU Make 3.81Copyright (C) 2006 Free Software Foundation, Inc.This is free software; see the source for copying conditions.There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR APARTICULAR PURPOSE.This program built for x86_64-pc-linux-gnuReading makefiles…Reading makefile `Makefile'…Updating makefiles….Considering target file `Makefile'.Looking for an implicit rule for `Makefile'.Trying pattern rule with stem `Makefile'.Trying implicit prerequisite `Makefile.o'.Trying pattern rule with stem `Makefile'.Trying implicit prerequisite `Makefile.c'.Trying pattern rule with stem `Makefile'.Trying implicit prerequisite `Makefile.cc'.Trying pattern rule with stem `Makefile'.Trying implicit prerequisite `Makefile.C'.Trying pattern rule with stem `Makefile'.Trying implicit prerequisite `Makefile.cpp'.Trying pattern rule with stem `Makefile'.--More--

    这是很长的输出,你也看到我使用了 more 命令来一页一页显示输出。

    4. 使用 -C 选项改变目录

    你可以为 make 命令提供不同的目录路径,在寻找 Makefile 之前会切换目录的。

    这是一个目录,假设你就在当前目录下:

    $ ls file file2 frnd frnd1.cpp log1.txt log3.txt log5.txtfile1 file name with spaces frnd1 frnd.cpp log2.txt log4.txt

    但是你想运行的 make 命令的 Makefile 文件保存在 ../make-dir/ 目录下,你可以这样做:

    $ make -C ../make-dir/ make: Entering directory `/home/himanshu/practice/make-dir' make: Nothing to be done for `all'. make: Leaving directory `/home/himanshu/practice/make-dir

    你能看到 make 命令首先切到特定的目录下,在那执行,然后再切换回来。

    5. 通过 -f 选项将其它文件看作 Makefile

    如果你想将重命名 Makefile 文件,比如取名为 my_makefile 或者其它的名字,我们想让 make 将它也当成 Makefile,可以使用 -f 选项。

    make -f my_makefile

    通过这种方法,make 命令会选择扫描 my_makefile 来代替 Makefile。

    以上就是本文的详细内容,希望对大家的学习有所帮助。