# # Makefile for common library. # ROOT=.. LDLIBS+=-Wl,-rpath=../hclib:../hclib/HCNetSDKCom:../common LDDIR += -L$(ROOT)/hcnetdisk_wrapper -L../hclib -L../hclib/HCNetSDKCom LDLIBS += -lhcnetsdk -lhpr -lHCCore $(EXTRALIBS) LIB_NETDISK = libnetdisk.a DLIB_NETDISK = libnetdisk.so PLATFORM=$(shell $(ROOT)/systype.sh) include $(ROOT)/Make.defines.$(PLATFORM) SOURCES := $(wildcard *.c) OBJS = $(patsubst %.c, %.o, $(SOURCES)) all: $(LIB_NETDISK) $(DLIB_NETDISK) test: hcnetdisk.c #static lib $(LIB_NETDISK): $(OBJS) $(AR) rv $@ $? $(RANLIB) $@ #dynamic lib $(DLIB_NETDISK): $(SOURCES) rm -f *.o # $(CC) -fPIC $(CFLAGS) $(filter-out $(DLIBCOMMON), $^) -o $@ $(LDFLAGS) $(LDLIBS) $(CC) -fPIC -shared $(CFLAGS) -o $@ $(filter-out $(DLIBCOMMON), $^) #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: $(DLIB_NETDISK) 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 test *.o a.out core temp.* *.a *.so include $(ROOT)/Make.common.inc