1 CXX = g++ 2 LIBS +=`pkg-config --libs opencv` 3 INC +=`pkg-config --cflags opencv` 4 CPPFLAGS += -g -std=c++11 -Wall 5 6 SRCS = detect.cpp 7 TARGET = detect 8 OBJS = detect.o 9 10 $(TARGET):$(OBJS) 11 $(CXX) $(INC) $(CPPFLAGS) $(OBJS) -o $(TARGET) $(LIBS) 12 $(OBJS):%.o:%.cpp 13 $(CXX) $(INC) $(CPPFLAGS) -c $< -o $@ 14 15 .PHONY:clean 16 clean: 17 rm -r *.o $(TARGET)
1 CXX = g++ 2 LDLIBS += `pkg-config --libs opencv` 3 INC += `pkg-config --cflags opencv` 4 CPPFLAGS += -g -std=c++11 -Wall -I./ 5 6 TARGET = edges 7 OBJS = edges.o label.o 8 SRCS = edges.cpp label.cpp 9 HEAD = label.hpp 10 11 $(TARGET):$(OBJS) 12 $(CXX) -o $(TARGET) $(OBJS) $(LDLIBS) 13 14 %.o:%.c $(HEAD) 15 $(CXX) $(INC) $(CPPFLAGS) -c $> -o $@ 16 17 .PHONY:clean 18 clean: 19 rm -r *.o
1 CXX = g++ 2 INC += `pkg-config --cflags opencv` 3 LIBS += `pkg-config --libs opencv` 4 5 6 #dir 7 DIR_INC = ./include 8 DIR_SRC = ./src 9 DIR_OBJ = ./obj 10 DIR_BIN = ./bin 11 12 CPPFLAGS += -g -std=c++11 -Wall -I${DIR_INC} 13 14 #SRC = $(wildcard ${DIR_SRC}/*.cpp) 15 SRC1 = ${DIR_SRC}/detect.cpp ${DIR_SRC}/tools.cpp 16 OBJ1 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC1})) 17 BIN_TARGET1 = ${DIR_BIN}/detect 18 19 SRC2 = ${DIR_SRC}/detect2.cpp ${DIR_SRC}/tools.cpp 20 OBJ2 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC2})) 21 BIN_TARGET2 = ${DIR_BIN}/detect2 22 23 SRC3 = ${DIR_SRC}/detect_circle.cpp ${DIR_SRC}/tools.cpp 24 OBJ3 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC3})) 25 BIN_TARGET3 = ${DIR_BIN}/detect_circle 26 27 SRC4 = ${DIR_SRC}/detect_circle2.cpp ${DIR_SRC}/tools.cpp 28 OBJ4 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC4})) 29 BIN_TARGET4 = ${DIR_BIN}/detect_circle2 30 31 SRC5 = ${DIR_SRC}/hog_svm_test.cpp ${DIR_SRC}/tools.cpp 32 OBJ5 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC5})) 33 BIN_TARGET5 = ${DIR_BIN}/hog_svm_test 34 35 SRC6 = ${DIR_SRC}/hog_svm_test2.cpp ${DIR_SRC}/tools.cpp 36 OBJ6 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC6})) 37 BIN_TARGET6 = ${DIR_BIN}/hog_svm_test2 38 39 SRC7 = ${DIR_SRC}/hog_svm_test2.cpp ${DIR_SRC}/tools.cpp 40 OBJ7 = $(patsubst %.cpp,${DIR_OBJ}/%.o,$(notdir ${SRC7})) 41 BIN_TARGET7 = ${DIR_BIN}/hog_svm_test3 42 43 detect:${BIN_TARGET1} 44 45 detect2:${BIN_TARGET2} 46 47 detect_circle:${BIN_TARGET3} 48 49 detect_circle2:${BIN_TARGET4} 50 51 hog_svm_test:${BIN_TARGET5} 52 53 hog_svm_test2:${BIN_TARGET6} 54 55 hog_svm_test3:${BIN_TARGET7} 56 57 # echo: 58 # echo $(OBJ1) 59 # echo $(BIN_TARGET) 60 # echo $(notdir ${SRC1}) 61 62 ${BIN_TARGET1}:${OBJ1} 63 $(CXX) -o $@ $(OBJ1) $(LIBS) 64 65 ${BIN_TARGET2}:${OBJ2} 66 $(CXX) -o $@ $(OBJ2) $(LIBS) 67 68 ${BIN_TARGET3}:${OBJ3} 69 $(CXX) -o $@ $(OBJ3) $(LIBS) 70 71 ${BIN_TARGET4}:${OBJ4} 72 $(CXX) -o $@ $(OBJ4) $(LIBS) 73 74 ${BIN_TARGET5}:${OBJ5} 75 $(CXX) -o $@ $(OBJ5) $(LIBS) 76 77 ${BIN_TARGET6}:${OBJ6} 78 $(CXX) -o $@ $(OBJ6) $(LIBS) 79 80 ${BIN_TARGET7}:${OBJ7} 81 $(CXX) -o $@ $(OBJ7) $(LIBS) 82 83 84 ${DIR_OBJ}/%.o:${DIR_SRC}/%.cpp 85 $(CXX) $(CPPFLAGS) -c $< -o $@ 86 87 88 .PHONY:clean 89 clean: 90 find ${DIR_OBJ} -name *.o -exec rm -rf {} ;