makefile generic version (c)

DIR_INC = ./include
DIR_SRC = ./src
DIR_OBJ = ./obj
DIR_BIN = ./bin

DIR_LIB = -Wl,-rpath=/home/exbot/shareWin/UnityCamera/TestCamera/lib \\
      -L/home/exbot/shareWin/UnityCamera/HKUnifyCamera_one/Debug \\
      -L/home/exbot/shareWin/UnityCamera/hk_one_camera LIBS = -lAudioRender -lHCCore -lhcnetsdk -lhpr -lPlayCtrl -lSuperRender -lcameraInterface -lpthread SRC = $(wildcard ${DIR_SRC}/*.cpp) OBJ = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC})) CC = g++ TARGET = Test BIN_TARGET=$(DIR_BIN)/$(TARGET) CFLAGS = -g -Wall -o -I${DIR_INC} ${BIN_TARGET}:${OBJ} $(CC) $(CFLAGS) $(OBJ) ${DIR_LIB} ${LIBS} -o $@ ${DIR_OBJ}/%.o:${DIR_SRC}/%.cpp $(CC) $(CFLAGS) -I${DIR_INC} -c $< -o $@ .PHONY:clean clean: rm -rf ${DIR_OBJ}/*

 

Description:

-rpath for dynamic link library specified program is running. If it is a relative path, the path of the file relative path to the role and the program is running, rather than where the program file path. 
-L: static library for program compilation phase links.

$$ PWD: Get the current path environment variable.
-rpath = $$ PWD /../ HKUnifyCamera_one Debug / 
the path specified dynamic library approach combines the advantages of both relative and absolute paths methods, need to modify the path to stop dependencies can be avoided when replacing environment, and run the program folder can be avoided when a relative path is defined only in a specific file.
And only need to program library depends to move together in a fixed order.

Guess you like

Origin www.cnblogs.com/wanghao-boke/p/11950121.html