muduo Makefile

muduo/base

VERSION     =
CC          =g++
DEBUG 	    =
CFLAGS	    =-Wall -std=c++11
AR  	    =ar
ARFLAGS     =rv
SOURCES	    =$(wildcard *.cc)
INCLUDES    =-I/home/cai/cai/workspace/E-muduo/muduo  
LIB_NAMES   =
LIB_PATH 	=
OBJ         =$(patsubst %.cc, %.o, $(SOURCES))
TARGET      =libbase

#link
$(TARGET):$(OBJ)
	@mkdir -p output
	$(AR) $(ARFLAGS) output/$(TARGET)$(VERSION).a $(OBJ)
	@rm -rf $(OBJ)

#compile
%.o: %.cc
	$(CC) $(INCLUDES) $(DEBUG) -c $(CFLAGS) $< -o $@
		
.PHONY:clean
clean:
	@echo "Remove linked and compiled files......"
	rm -rf $(OBJ) $(TARGET) output 

muduo/base/tests

VERSION 	=1.00
CC			=g++
DEBUG 		=-DUSE_DEBUG
CFLAGS		=-Wall -g 
SOURCES	 	=$(wildcard *.cc)
INCLUDES  	=-I/home/cai/cai/workspace/E-muduo/muduo
LIB_NAMES 	=-lbase -lpthread -lboost_unit_test_framework -lz
LIB_PATH 	=-L./
OBJ		=$(patsubst %.cc, %.o, $(SOURCES))
TARGET		=$(patsubst %.cc, %, $(SOURCES))
#TARGET		=app

#compile
%.o: %.cc
	$(CC) $(INCLUDES) $(DEBUG) -c $(CFLAGS) $< -o $@

.PHONY:clean all

all:$(TARGET)
	
$(TARGET):%:%.o
	@mkdir -p outputapp
	$(CC) $(CFLAGS)  $< $(LIB_PATH) $(LIB_NAMES) -o $@ 
#	@rm -rf $<

clean:
	@echo "Remove linked and compiled files......"
	rm -rf $(OBJ) $(TARGET) outputapp

muduo/net

VERSION     =
CC          =g++
DEBUG 	    =
CFLAGS	    =-Wall -std=c++11
AR  	    =ar
ARFLAGS     =rv
SOURCES	    =$(wildcard *.cc ./poller/*.cc)
INCLUDES    =-I/home/cai/cai/workspace/E-muduo/muduo  -I./poller/
LIB_NAMES   =-lpthread -lboost_unit_test_framework -lz
LIB_PATH    =
OBJ         =$(patsubst %.cc, %.o, $(SOURCES))
TARGET      =libnet

#link
$(TARGET):$(OBJ)
	@mkdir -p output
	$(AR) $(ARFLAGS) ../lib/$(TARGET)$(VERSION).a $(OBJ)
	@rm -rf $(OBJ)

#compile
%.o: %.cc
	$(CC) $(INCLUDES) $(DEBUG) -c $(CFLAGS) $< -o $@
		
.PHONY:clean
clean:
	@echo "Remove linked and compiled files......"
	rm -rf $(OBJ) $(TARGET) output 

muduo/net/test

VERSION     =
CC          =g++
DEBUG 	    =
CFLAGS	    =-Wall -std=c++11
AR  	    =ar
ARFLAGS     =rv
SOURCES	    =$(wildcard *.cc ./poller/*.cc)
INCLUDES    =-I/home/cai/cai/workspace/E-muduo/muduo  -I./poller/
LIB_NAMES   =-lpthread -lboost_unit_test_framework -lz
LIB_PATH    =
OBJ         =$(patsubst %.cc, %.o, $(SOURCES))
TARGET      =libnet

#link
$(TARGET):$(OBJ)
	@mkdir -p output
	$(AR) $(ARFLAGS) ../lib/$(TARGET)$(VERSION).a $(OBJ)
	@rm -rf $(OBJ)

#compile
%.o: %.cc
	$(CC) $(INCLUDES) $(DEBUG) -c $(CFLAGS) $< -o $@
		
.PHONY:clean
clean:
	@echo "Remove linked and compiled files......"
	rm -rf $(OBJ) $(TARGET) output 




如果是动态库 将生成的动态库。so文件添加到usr/local/bin中
然后sudo ldconfig下就可以了

muduo/base

VERSION   =
CC        =g++
DEBUG     =
CFLAGS    =-fPIC -shared 
LFLAGS	  =-fPIC -shared 
SOURCES   =$(wildcard *.cc)
INCLUDES  =-I. -I/home/cai/cai/workspace/E-muduo/muduo 
LIB_NAMES =
LIB_PATH  =
OBJ       =$(patsubst %.cc, %.o, $(SOURCES))
TARGET    =libbase

#link
$(TARGET):$(OBJ)
	#@mkdir -p output
	$(CC) $(OBJ) $(LIB_PATH) $(LIB_NAMES) $(LFLAGS) -o ../lib/$(TARGET)$(VERSION).so
	@rm -rf $(OBJ)
	
#compile
%.o: %.cc
	$(CC) $(INCLUDES) $(DEBUG) -c $(CFLAGS) $< -o $@

.PHONY:clean
clean:
	@echo "Remove linked and compiled files......"
	rm -rf $(OBJ) $(TARGET) output

muduo/base/tests

VERSION 	=1.00
CC			=g++
DEBUG 		=-DUSE_DEBUG
CFLAGS		=-Wall -g 
SOURCES	 	=$(wildcard *.cc)
INCLUDES  	=-I/home/cai/cai/workspace/E-muduo/muduo
LIB_NAMES 	=-lbase -lpthread -lboost_unit_test_framework -lz
LIB_PATH 	=-L../../lib
OBJ		=$(patsubst %.cc, %.o, $(SOURCES))
TARGET		=$(patsubst %.cc, %, $(SOURCES))
#TARGET		=app

	
	
	
	
#compile
%.o: %.cc
	$(CC) $(INCLUDES) $(DEBUG) -c $(CFLAGS) $< -o $@

.PHONY:clean all

all:$(TARGET)
	
$(TARGET):%:%.o
	@mkdir -p outputapp
	$(CC) $(CFLAGS)  $< $(LIB_PATH) $(LIB_NAMES) -o  outputapp/$@$(VERSION)
#	@rm -rf $<

clean:
	@echo "Remove linked and compiled files......"
	rm -rf $(OBJ) $(TARGET) outputapp 
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页