zoukankan      html  css  js  c++  java
  • linux: 几个常用makefile模板

    不才,总结个人常用makefile模板,以备后用。

    1、编译动态库

    1. #############################################################   
    2. # Makefile for shared library.  
    3. # 编译动态链接库  
    4. #############################################################  
    5. #set your own environment option  
    6. CC = g++  
    7. CC_FLAG = -D_NOMNG -D_FILELINE  
    8.   
    9. #set your inc and lib  
    10. INC =   
    11. LIB = -lpthread -L./ -lsvrtool  
    12.   
    13. #make target lib and relevant obj   
    14. PRG = libsvrtool.so  
    15. OBJ = Log.o  
    16.   
    17. #all target  
    18. all:$(PRG)  
    19.   
    20. $(PRG):$(OBJ)  
    21.     $(CC) -shared -o $@ $(OBJ) $(LIB)  
    22.   
    23. .SUFFIXES: .c .o .cpp  
    24. .cpp.o:  
    25.     $(CC) $(CC_FLAG) $(INC) -c $*.cpp -o $*.o  
    26.   
    27. .PRONY:clean  
    28. clean:  
    29.     @echo "Removing linked and compiled files......;  
    30.     rm -f $(OBJ) $(PRG)  

    2、编译静态库

    1. #############################################################  
    2. # Makefile for static library.  
    3. # 编译静态链接库  
    4. #############################################################  
    5. #set your own environment option  
    6. CC = g++  
    7. CC_FLAG = -D_NOMNG -D_FILELINE  
    8.   
    9. #static library use 'ar' command   
    10. AR = ar  
    11.   
    12. #set your inc and lib  
    13. INC =   
    14. LIB = -lpthread -L./ -lsvrtool  
    15.   
    16. #make target lib and relevant obj   
    17. PRG = libsvrtool.a  
    18. OBJ = Log.o  
    19.   
    20. #all target  
    21. all:$(PRG)  
    22. $(PRG):$(OBJ)  
    23.     ${AR} rv ${PRG} $?  
    24.   
    25. .SUFFIXES: .c .o .cpp  
    26. .cpp.o:  
    27.     $(CC) $(CC_FLAG) $(INC) -c $*.cpp -o $*.o  
    28.   
    29. .PRONY:clean  
    30. clean:  
    31.     @echo "Removing linked and compiled files......"  
    32.     rm -f $(OBJ) $(PRG)  

    3、可执行程序

    1. ###########################################  
    2. #Makefile for simple programs  
    3. ###########################################  
    4. INC=  
    5. LIB= -lpthread  
    6.   
    7. CC=CC  
    8. CC_FLAG=-Wall  
    9.   
    10. PRG=threadpooltest  
    11. OBJ=CThreadManage.o CThreadPool.o CThread.o CWorkerThread.o threadpooltest.o  
    12.   
    13. $(PRG):$(OBJ)  
    14.     $(CC) $(INC) $(LIB) -o $@ $(OBJ)  
    15.       
    16. .SUFFIXES: .c .o .cpp  
    17. .cpp.o:  
    18.     $(CC) $(CC_FLAG) $(INC) -c $*.cpp -o $*.o  
    19.   
    20. .PRONY:clean  
    21. clean:  
    22.     @echo "Removing linked and compiled files......"  
    23.     rm -f $(OBJ) $(PRG)  


    随机组合、举一反三会写出适合项目的makefile

  • 相关阅读:
    如何使用谷歌的自定义搜索引擎来搜寻一个ASP.NET网站
    [导入][FMS开发笔记]理解应用程序实例(聊天室房间的划分)
    WEB页面自打开的响应顺序
    Windows下SVN配置管理员指南
    [导入]Ajax基本过程
    [导入]FMS 中文帮助 (下载)
    [导入][Flash开发笔记] 系列
    [导入]mootools框架【三】Array篇: 方法完全解析
    [导入]mootools框架【七】Common篇: mootools的构造应用的基础设施类Common.js
    [导入]mootools框架【十】mootools深层探讨
  • 原文地址:https://www.cnblogs.com/subo_peng/p/5157376.html
Copyright © 2011-2022 走看看