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)
  • 相关阅读:
    所谓guard进程不能启动
    文件拒绝访问
    (转)Android 自定义 spinner (背景、字体颜色)
    (转)安装Android SDK时遇到Failed to rename directory
    (转)Download interrupted: Connection to https://dl-ssl.google.com refused
    安卓中Activity的onStart()和onResume()的区别是什么
    Could not find class 'org.ksoap2.serialization.SoapObject
    Android三种左右滑动效果 手势识别(转)
    The method of type must override a superclass method解决方式(转)
    MySQL插入中文时出现ERROR 1406 (22001): Data too long for column 'name' at row 1 (转)
  • 原文地址:https://www.cnblogs.com/live-program/p/11110243.html
Copyright © 2011-2022 走看看