zoukankan      html  css  js  c++  java
  • 分享一个Makefile

    又回到了Linux的编程环境中,不再折腾了,没有意义。把编程技术学好吧。 分享了一个Makefile,这个Makefile,是从TinyXML的工程文件中提取出来的。自己按照自己的需求修改了下。感觉还不错。

    #****************************************************************************
    # This is a GNU make (gmake) makefile
    #****************************************************************************

    # DEBUG can be set to YES to include debugging info, or NO otherwise
    DEBUG := NO

    # PROFILE can be set to YES to include profiling info, or NO otherwise
    PROFILE :
    = NO

    # TINYXML_USE_STL can be used to turn on STL support. NO, then STL
    # will not be used. YES will include the STL files.
    TINYXML_USE_STL :
    = NO

    #****************************************************************************

    DEBUG_CFLAGS :
    = -Wall -Wno-format -g -DDEBUG
    RELEASE_CFLAGS :
    = -Wall -Wno-unknown-pragmas -Wno-format -O3

    DEBUG_CXXFLAGS :
    = ${DEBUG_CFLAGS}
    RELEASE_CXXFLAGS :
    = ${RELEASE_CFLAGS}

    DEBUG_LDFLAGS :
    = -g
    RELEASE_LDFLAGS :
    =

    ifeq
    (YES, ${DEBUG})
    CFLAGS :
    = ${DEBUG_CFLAGS}
    CXXFLAGS :
    = ${DEBUG_CXXFLAGS}
    LDFLAGS :
    = ${DEBUG_LDFLAGS}
    else
    CFLAGS :
    = ${RELEASE_CFLAGS}
    CXXFLAGS :
    = ${RELEASE_CXXFLAGS}
    LDFLAGS :
    = ${RELEASE_LDFLAGS}
    endif

    ifeq
    (YES, ${PROFILE})
    CFLAGS :
    = ${CFLAGS} -pg -O3
    CXXFLAGS :
    = ${CXXFLAGS} -pg -O3
    LDFLAGS :
    = ${LDFLAGS} -pg
    endif


    #****************************************************************************
    # 编译器设置
    #****************************************************************************

    CC :
    = gcc
    CXX :
    = g++
    LD :
    = g++
    AR :
    = ar rc
    RANLIB :
    = ranlib
    #CFLAGS := -Wall -Wno-format -g

    #****************************************************************************
    # Preprocessor directives
    #****************************************************************************

    ifeq
    (YES, ${TINYXML_USE_STL})
    DEFS :
    = -DTIXML_USE_STL
    else
    DEFS :
    =
    endif
    #****************************************************************************
    # Makefile code common to all platforms
    #****************************************************************************

    CFLAGS :
    = ${CFLAGS} ${DEFS}
    CXXFLAGS :
    = ${CXXFLAGS} ${DEFS}

    #****************************************************************************
    # Include paths &&& Lib path
    # 在此次添加搜索的路径和库
    #****************************************************************************

    #INCS := -I/usr/include/g++-2 -I/usr/local/include
    CINCLUDE :
    = -I ../include
    CXXINCLUDE :
    = -I ../include
    LD_LIBRARY_PATH:
    = -L./ \
    -L
    ../lib
    LDFLAGS :
    = ${LD_LIBRARY_PATH} \
    -lgtest
    \
    -lpthread

    #****************************************************************************
    # Targets of the build
    #****************************************************************************
    TARGET :
    = algo
    all:
    $(TARGET)

    #****************************************************************************
    # Source files
    #****************************************************************************
    SRCDIRS :
    = ./
    CSRCS :
    = $(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.c))
    CXXSRCS :
    = $(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.cpp))
    SRCS :
    = ${CSRCS} ${CXXSRCS}

    OBJS :
    = $(addsuffix .o,$(basename ${SRCS}))

    #****************************************************************************
    # Output
    #****************************************************************************
    $(TARGET): $(OBJS)
    ${LD} -o $@ ${OBJS} ${LDFLAGS} ${LIBS} ${EXTRA_LIBS}
    @echo $@ Build Success!
    # Rules for compiling source files to object files
    %
    .o : %.cpp
    ${CXX} -c ${CXXFLAGS} ${CXXINCLUDE} $< ${LDFLAGS} -o $@

    %
    .o : %.c
    ${CC} -c ${CFLAGS} ${CINCLUDE} -c $< -o $@

    dist:
    bash makedistlinux
    clean:
    -rm -f core
    ${OBJS} ${TARGET}

  • 相关阅读:
    dom4j 解析 xml文件1
    java 简单的动态代理例子
    标识接口的作用 (转)
    JAVA servlet输出IE6下乱码
    java时间操作函数汇总
    IE支持getElementsByClassName方法
    女朋友问我 LB 是谁?
    人类高质量 Java 学习路线【一条龙版】
    程序员作图工具和技巧,你 get 了么?
    3 分钟了解 JSON Schema
  • 原文地址:https://www.cnblogs.com/westfly/p/1897678.html
Copyright © 2011-2022 走看看