# # Makefile for common library. # ROOT=.. # 开源工具包路径 LDDIR +=-L$(ROOT)/lib/nng # 开源工具包 LDLIBS += -lnng -lpthread PLATFORM=$(shell $(ROOT)/systype.sh) include $(ROOT)/Make.defines.$(PLATFORM) LIBBIPC = libbipc.a DLIBBIPC = libbipc.so SOURCES := $(wildcard *.c) OBJS = $(patsubst %.c, %.o, $(SOURCES)) all: libs libs: $(LIBBIPC) $(DLIBBIPC) #static lib $(LIBBIPC): $(OBJS) $(AR) rv $@ $? $(RANLIB) $@ #dynamic lib $(DLIBBIPC): $(SOURCES) rm -f *.o $(CC) -fPIC -shared $(CFLAGS) $^ -o $@ $(LDFLAGS) #PREFIX is environment variable, but if it is not set, then set default value ifeq ($(PREFIX),) PREFIX := /usr/local endif # 使用方式: g++ test1.c -lcommon install: $(DLIBBIPC) sudo install -d $(PREFIX)/lib/ sudo install -m 644 $^ $(PREFIX)/lib/ sudo install -d $(PREFIX)/include/ sudo install -m 644 include/* $(PREFIX)/include/ clean: rm -f *.o a.out core temp.* *.a *.so # include $(ROOT)/Make.libapue.inc