zoukankan      html  css  js  c++  java
  • Makefile模板

    Makefile模板:

    1.生成可执行程序的Makefile

     1 ########################################
     2 #
     3 # build exectable object Makefile
     4 ########################################
     5 SOURCE  := $(wildcard *.c) $(wildcard *.cpp)
     6 OBJS    := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
     7 
     8 # edit the following variables
     9 TARGET  := test
    10 CC      :=
    11 LIBS    :=
    12 LDFLAGS :=
    13 DEFINES :=
    14 INCLUDE :=
    15 
    16 CFLAGS  := -Wall $(DEFINES) $(INCLUDE)
    17 CXXFLAGS:= $(CFLAGS)
    18 
    19 
    20 # do not change the following objects below before you understand it's use
    21 .PHONY : everything objs rebuild clean veryclean
    22 
    23 everything : $(TARGET)
    24 
    25 objs : $(OBJS)
    26 
    27 rebuild: veryclean everything
    28 
    29 clean :
    30     rm -fr *.o
    31 
    32 veryclean : clean
    33     rm -fr $(TARGET)
    34 
    35 $(TARGET) : $(OBJS)
    36     $(CC) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS)

    2.生成静态链接库的Makefile

     1 ########################################
     2 #
     3 # build static library Makefile
     4 ########################################
     5 SOURCE  := $(wildcard *.c) $(wildcard *.cpp)
     6 OBJS    := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
     7 
     8 # edit the following variables
     9 TARGET  := libtest.a
    10 CC      :=
    11 AR      :=
    12 LIBS    :=
    13 LDFLAGS :=
    14 DEFINES :=
    15 INCLUDE :=
    16 
    17 RANLIB  := ranlib
    18 CFLAGS  := -Wall $(DEFINES) $(INCLUDE)
    19 CXXFLAGS:= $(CFLAGS)
    20 
    21 
    22 # do not change the following objects below before you understand it's use
    23 .PHONY : everything objs rebuild clean veryclean
    24 
    25 everything : $(TARGET)
    26 
    27 objs : $(OBJS)
    28 
    29 rebuild: veryclean everything
    30 
    31 clean :
    32     rm -fr *.o
    33 
    34 veryclean : clean
    35     rm -fr $(TARGET)
    36 
    37 $(TARGET) : $(OBJS)
    38     $(AR) cr $(TARGET) $(OBJS)
    39     $(RANLIB) $(TARGET)

    3.生成动态链接库的Makefile

     1 ########################################
     2 #
     3 # build dynamic library Makefile
     4 ########################################
     5 SOURCE  := $(wildcard *.c) $(wildcard *.cpp)
     6 OBJS    := $(SOURCE)
     7 
     8 # edit the following variables
     9 TARGET  := libtest.so
    10 CC      :=
    11 LIBS    :=
    12 LDFLAGS :=
    13 DEFINES :=
    14 INCLUDE :=
    15 
    16 CFLAGS  := -Wall $(DEFINES) $(INCLUDE)
    17 CXXFLAGS:= $(CFLAGS)
    18 SHARE   := -fPIC -shared -o
    19 
    20 
    21 # do not change the following objects below before you understand it's use
    22 .PHONY : everything objs rebuild clean veryclean
    23 
    24 everything : $(TARGET)
    25 
    26 objs : $(OBJS)
    27 
    28 rebuild: veryclean everything
    29 
    30 clean :
    31     rm -fr *.o
    32 
    33 veryclean : clean
    34     rm -fr $(TARGET)
    35 
    36 $(TARGET) : $(OBJS)
    37     $(CC) $(CXXFLAGS) $(SHARE) $@ $(OBJS) $(LDFLAGS) $(LIBS)
  • 相关阅读:
    JavaScript的作用域和块级作用域概念理解
    正则表达式中组的理解
    正则表达式的字符组取反(负值字符集合/范围)^必须出现在起始位置
    利用TortoiseGit(小乌龟)将项目上传至GitHub网站
    (.Net) NLog 记录日志功能
    关于网站中引用COM组件的部署问题
    备份与还原ORACLE数据库(通过CMD命令执行)
    C# Task中的Func, Action, Async与Await的使用
    ASP.NET WebAPI 项目示例(增删改查)
    .NET内存泄漏(之 静态事件)
  • 原文地址:https://www.cnblogs.com/live-program/p/11110243.html
Copyright © 2011-2022 走看看