1. 程式人生 > >Makefile 標準寫法

Makefile 標準寫法

opencv.pc // 這個配置被Makefile 呼叫

# Package Information for pkg-config

prefix=/usr/local/thirdparty
exec_prefix=${prefix}
libdir=${exec_prefix}/lib64
includedir_old=${prefix}/include/opencv
includedir_new=${prefix}/include

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 3.4.0
Libs: -L${exec_prefix}/lib64 -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_imgproc -lopencv_core
Libs.private: -ldl -lm -lpthread -lrt
Cflags: -I${includedir_old} -I${includedir_new}

Makefile

thirdparty_root := /usr/local/thirdparty
facesdk_root := /usr/local/facesdk
export PKG_CONFIG_PATH := ${thirdparty_root}/lib64/pkgconfig:${PKG_CONFIG_PATH}

CC := g++
INCS += `pkg-config --cflags opencv`
INCS += -I${facesdk_root}/include
INCS += -I${thirdparty_root}/include
INCS += -I${thirdparty_root}/include/apr-1


LIBS += `pkg-config --libs opencv`
LIBS +=	-L${thirdparty_root}/lib -lglog -lactivemq-cpp -lapr-1
LIBS +=	-L${facesdk_root}/lib -lrr_faceverify_t -lrr_facedetect_t

AFLAGS := -Wall -c -fPIC -O2 -std=c++11 $(INCS)
LDFLAGS := -lpthread -lcurl
LDFLAGS += -Wl,-rpath,${thirdparty_root}/lib64:${thirdparty_root}/lib:${facesdk_root}/lib

OBJS := $(patsubst %.cpp,%.o,$(shell find . -name "*.cpp"))


FaceFilter: $(OBJS)
	$(CC) -o 
[email protected]
$^ $(LDFLAGS) $(LIBS) $(OBJS): %.o:%.cpp $(CC) $(AFLAGS) $^ -o [email protected] debugOBJS: @echo ${OBJS} .PHONY: clean FaceFilter setenv clean: rm -rf *.o FaceFilter baseutils/*.o factory/*.o message/*.o servicemodules/*.o