• 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/
    我的博客就是我的学习笔记,学习过程中看到好的博客也会转载过来,若有侵权,与我联系,我会及时删除。

  • 相关阅读:
    将excel中的sheet1导入到sqlserver中
    .net中 Timer定时器
    Exception异常处理机制
    算法
    八、上网行为管理
    获取网站路径绝对路径的方法汇总
    Window逆向基础之逆向工程介绍
    Java Web代码审计流程与漏洞函数
    创建一个Java Web项目,获取POST数据并显示
    七、虚拟专用网
  • 原文地址:https://www.cnblogs.com/cumtchw/p/13127060.html
Copyright © 2020-2023  润新知