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

  • 相关阅读:
    LeetCode---Remove Duplicates from Sorted List II
    hackerrank---Sets
    hackerrank---Find a string
    push的时候隐藏底部的tabbar
    选择性编译代码:如 #ifdef __IPHONE_7_0
    客户端的文件存储文件夹代表意义
    设置非ARC
    KVC设置系统自带属性,不管是不是私有的属性
    一些关于队列,同步,异步的概念
    要求两个异步任务都完成后, 才能回到主线程:dispatch_group_t
  • 原文地址:https://www.cnblogs.com/cumtchw/p/13127060.html
Copyright © 2020-2023  润新知