zoukankan      html  css  js  c++  java
  • Makefile 使用方法

    我们在平时的日常运维中, 经常会遇到要源码安装一些软件,在安装的过程中, 总会遇到 make &&make install 等类似的make的命令,之前一直没有对这个进行过深入的了解。其实make命令是依赖于一个Makefile的文件的, 在文件中定义make的使用方法,用以告诉make怎么去执行命令,怎么去编译。

    今天自己做了一个小的实验:

    [root@yangdong tmp]# cat Makefile 
    
    usage:
        @echo "Usage: "
        @echo " make test"
    
    test:
        date
        echo "this is a test!"

    这是我自己写的一个简单的Makefile 的文本文件。用以输出当前的时间同时打印出字符串:this is a test!

    运行结果:

    [root@yangdong tmp]# make         #获取make的一些信息。类似--help
    Makefile:13: warning: overriding recipe for target `usage'
    Makefile:2: warning: ignoring old recipe for target `usage'
    Usage: 
     make test   #使用方法
    [root@yangdong tmp]# make test  #调用make的test方法date
    Tue Jul 23 21:47:06 EDT 2019
    echo "this is a test!"
    this is a test!

    在了解了Makefile的使用方法后,我们可以在以后的运维中使用上。比如我在安装tomcat的时候,我完全可以在当前目录下写一个Makefile。来方便后期的一些操作

    root@dev-java001:~/projects$ cat Makefile 
    
    usage:
        @echo "Usage: "
        @echo "    APP_NAME=<appName> make init"
    
    
    init:
        cp -R appname $(APP_NAME) && 
            mkdir -p /home/souchelogs/applogs/$(APP_NAME) && 
            rm -rf $(APP_NAME)/logs && 
            ln -s /home/souchelogs/applogs/$(APP_NAME) $(APP_NAME)/logs

    比如这个文件,我在使用的时候就可以 很方便我做后面的一些频繁的操作。

  • 相关阅读:
    无旋转Treap简介
    bzoj 4318 OSU!
    bzoj 1419 Red is good
    bzoj 4008 亚瑟王
    bzoj 1014 火星人prefix
    更多的莫队
    bzoj 3489 A simple rmq problem
    洛谷 2056 采花
    NOIP 2017 游(划水)记
    UVa 11997 K Smallest Sums
  • 原文地址:https://www.cnblogs.com/yangxiaochu/p/11251313.html
Copyright © 2011-2022 走看看