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)

 

原文链接: https://www.cnblogs.com/cumtchw/p/13127060.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;

也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬

    makefile备份-goods search project

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/355118

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年3月2日 上午9:03
下一篇 2023年3月2日 上午9:04

相关推荐