zoukankan      html  css  js  c++  java
  • linux 一个超简单的makefile

    makefile 自动化变量:
     
    $@ : 规则的目标文件名
     例如:main:main.o test.o
                       g++ -Wall -g  main.o test.o -o main 
     可以写成:
               main:main.o test.o
                       g++ -Wall -g  main.o test.o -o $@ 
     
    $< : 规则的第一个依赖文件名
      例如:main.o: main.cpp 
                       g++ -Wall -g -c main.cpp -o main.o
      可以写成:
                 main.o: main.cpp 
                       g++ -Wall -g -c $< -o main.o
     
    $^ : 规则的所有依赖文件列表。
      例如:test.o:test.cpp test.h
                        g++ -Wall -g -c test.cpp test.h -o test.o
      可以写成:
                 test.o:test.cpp test.h
                        g++ -Wall -g -c $^ -o test.o
     
     //程序文件包括main.cpp test.cpp test.h
      .PHONY:clean
      XX=g++
      exe=dididididididididi
      obj=main.o test.o
      $(exe):$(obj)
              $(XX) -pthread -Wall -g -o $(exe) $(obj)
      main.o:main.cpp test.h
              $(XX) -c main.cpp -o main.o
      test.o:test.cpp test.h
             $(XX) -c test.cpp -o test.o
     clean:
             rm -f *.o $(exe)
  • 相关阅读:
    51nod乘积之和
    Dell服务器安装OpenManage(OMSA)
    Nginx反向代理PHP
    搭建haproxy
    108. Convert Sorted Array to Binary Search Tree
    60. Permutation Sequence
    142. Linked List Cycle II
    129. Sum Root to Leaf Numbers
    118. Pascal's Triangle
    26. Remove Duplicates from Sorted Array
  • 原文地址:https://www.cnblogs.com/Ph-one/p/6764916.html
Copyright © 2011-2022 走看看