Makefile(二)

VERSION = 1.0.0

SOURCE = $(wildcard ./*.cpp)
OBJ = $(patsubst %.cpp,%.o,$(SOURCE))

INCLUDE = -I /usr/include/mysql/

LIBS = -lmysqlclient
LIB_PATH = -L /usr/lib/mysql/

CFALGS = -g

TARGET = test

$(TARGET): $(OBJ)
        @mkdir -p output/
        g++ $(OBJ) $(LIB_PATH) $(LIBS) -o output/$(TARGET).$(VERSION)

%.o : %.cpp
        g++ $(INCLUDE) $(CFALGS) -c $< -o $@

.PHONY: clean
clean:
        rm -rf $(OBJ) output/

 

posted @ 2019-09-25 08:54  王清河  阅读(101)  评论(0编辑  收藏  举报