Linux通用Makefile

#------------------可执行程序通用makefile 开始-----------------------------------

CFLAGS = -g -D _DEBUG -I../Include -L/usr/local/lib -L/usr/local/  -lrt -ldl -Wall
CC=g++
SRC=$(wildcard *.cpp)
OBJ=$(addprefix ./, $(addsuffix .o, $(basename $(SRC))))
TARGET= ../bin/Test.bin

all: $(TARGET)

$(TARGET): $(SRC)
    $(CC)  -o $@  $^ $(CFLAGS)

clean:
    rm -f $(TARGET) $(OBJ)

#------------------可执行程序通用makefile 结束-----------------------------------



#------------------生成动态库文件通用makefile-----------------------------------

CFLAGS = -I../Include -I/usr/local/include -L../lib -L/usr/local/lib -g  -Wall
CC=g++
SRC=$(wildcard *.cpp)
OBJ=$(addprefix ./, $(addsuffix .o, $(basename $(SRC))))
TARGET=../bin/libTest.so

all: $(TARGET)
 
$(TARGET): $(OBJ)
    $(CC) -shared -fPCI -o $@ $^
    

%.o: %.cpp
    $(CC) $(CFLAGS) -o $@ -c $<

clean:
    rm -f $(TARGET) $(OBJ)

#------------------生成动态库文件通用makefile-----------------------------------



你可能感兴趣的:(Linux通用Makefile)