• makefile备份-goods search project


    CC      = gcc
    CPP     = g++
    AR = ar
    RM      = rm -f
    
    #Define the resource compiler.
    RC = windres
    
    ## debug flag  
    DBG_ENABLE := 1
    
    OS = $(shell uname)
    
    ## source file path  
    SRC_PATH  := ./src/
    SRC_PATH_EXT := 
    DEMO :=./demo/main.cpp
    
    ## target file name  
    TARGET     := goodsSearch
    DEMO_TARGET := run
    
    ## get all source files  
    SRCS := $(foreach spath, $(SRC_PATH), $(wildcard $(spath)*.c) $(wildcard $(spath)*.cpp))
    
    ## all .o based on all .c/.cpp
    OBJS = $(SRCS:.c=.o)
    OBJS := $(OBJS:.cpp=.o) 
    
    ## macro define
    DEFS := __LINUX__ OS_LINUX _FILE_OFFSET_BITS=64
    
    #if freeimage is static-linked use this !
    #DEFS += FREEIMAGE_LIB
    
    ## need libs, add at here  
    LIBS := opencv_core opencv_highgui opencv_imgproc cafl boost_system boost_thread glog hdf5_serial_hl hdf5_serial boost_regex gflags leveldb  cublas curand sqlite3 cudnn cudart
    
    DEMO_LIBS = $(LIBS)
    DEMO_LIBS += goodsSearch
    
    ## used headers  file path  
    INCLUDE_PATH := ./include ./include/third /usr/local/cuda/include  ./src
    
    #$(warning $(INCLUDE_PATH))
    
    ## used include librarys file path  
    LIBRARY_PATH := ./  ./libs  /usr/include/tbb /usr/lib/python2.7/json /usr/local/cuda/lib64 ./opencvlibs /usr/lib/aarch64-linux-gnu /usr/local/cuda-10.0/targets/aarch64-linux/lib /home/software/gflags/build/lib
     
    ## debug for debug info, when use gdb to debug  
    ifeq (1, ${DBG_ENABLE})   
    CFLAGS += -D_DEBUG -g -DDEBUG=1 
    else
    CFLAGS += -O2 -DNDEBUG
    endif
    
    #for ENCYPT flags
    
    ifeq ($(OS), Linux)
    LIBS += dl rt
    CFLAGS += -fPIC
    TARGET_EXT := .so
    LIBRARY_PATH += 
    LDFLAGS += -Wl,--rpath=./libs 
    endif
    
    #CFLAGS += -msse4.2 -march=core2 -pipe $(foreach m, $(DEFS), -D$(m)) 
    #CFLAGS += -march=armv8.2-a -pipe $(foreach m, $(DEFS), -D$(m)) 
    
    CFLAGS += -march=armv8.2-a -pipe $(foreach m, $(DEFS), -D$(m)) 
      
    ## get all include path  
    CFLAGS  += $(foreach dir, $(INCLUDE_PATH), -I$(dir))  
    
    CXXFLAGS += $(CFLAGS) -std=c++11
    
    ## get all library path  
    LDFLAGS += -lpthread $(foreach lib, $(LIBRARY_PATH), -L$(lib))
    DEMO_LDFLAGS := $(LDFLAGS)
    ## get all librarys  
    LDFLAGS += $(foreach lib, $(LIBS), -l$(lib))
    
    DEMO_LDFLAGS += $(foreach lib, $(DEMO_LIBS), -l$(lib))
    
    RCFLAGS ?= -DNDEBUG
    
    
    default: all
    
    %.o: %.c
        $(CC) $(CFLAGS) -g -c $< -o $@
    
    %.o: %.cpp
        $(CPP) $(CXXFLAGS) -g -c $< -o $@
        
    all: $(OBJS) $(RESOURCE)
        #$(CPP) $(CXXFLAGS) -o $(TARGET) $(OBJS) $(RESOURCE) $(LDFLAGS)
        $(CPP) $(CXXFLAGS) -g -shared -o lib$(TARGET)$(TARGET_EXT) $(OBJS) $(RESOURCE) $(LDFLAGS)
        mv libgoodsSearch.so ./libs
        $(CPP) $(CXXFLAGS) -g -o $(DEMO_TARGET) $(DEMO) $(DEMO_LDFLAGS)
    
    clean:  
        $(RM) $(OBJS) $(DEMO_TARGET) $(TARGET).* $(RESOURCE)

    作者:cumtchw
    出处:http://www.cnblogs.com/cumtchw/
    我的博客就是我的学习笔记,学习过程中看到好的博客也会转载过来,若有侵权,与我联系,我会及时删除。

  • 相关阅读:
    web全栈第四讲:后端框架express.js初步体验。
    web全栈第三讲:Angular单页面应用
    Web第六讲:HTML基础
    关于命令模式的一点意见
    黑猫白猫读《大话设计模式》
    排序二叉树的实现和我的一个数据结构设计
    《算法与数据结构C语言描述》优先队列
    《算法与数据结构C语言描述》里的农夫过河
    读《算法与数据结构c语言描述》
    《算法与数据结构C语言描述》里的求多项达式值
  • 原文地址:https://www.cnblogs.com/cumtchw/p/13127060.html
Copyright © 2020-2023  润新知