From 5765d608cc2fc602c038dd8aaf5e747986fac25b Mon Sep 17 00:00:00 2001 From: Peter Jin Date: Wed, 23 Nov 2016 20:29:39 -0800 Subject: [PATCH] Add a static library target "staticlib" to the Makefile. Rename the static library "libnccl_static.a" to disambiguate from the dynamic libraries. --- Makefile | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 64243e8..a706879 100644 --- a/Makefile +++ b/Makefile @@ -60,12 +60,13 @@ CUDA_MAJOR = $(shell echo $(CUDA_VERSION) | cut -d "." -f 1) CUDA_MINOR = $(shell echo $(CUDA_VERSION) | cut -d "." -f 2) CXXFLAGS += -DCUDA_MAJOR=$(CUDA_MAJOR) -DCUDA_MINOR=$(CUDA_MINOR) -.PHONY : lib clean test mpitest install deb debian debclean forlib fortest forclean -.DEFAULT : lib +.PHONY : all lib staticlib clean test mpitest install deb debian debclean forlib fortest forclean +.DEFAULT : all INCEXPORTS := nccl.h LIBSRCFILES := libwrap.cu core.cu all_gather.cu all_reduce.cu broadcast.cu reduce.cu reduce_scatter.cu LIBNAME := libnccl.so +STATICLIBNAME := libnccl_static.a INCDIR := $(BUILDDIR)/include LIBDIR := $(BUILDDIR)/lib @@ -74,12 +75,17 @@ OBJDIR := $(BUILDDIR)/obj INCTARGETS := $(patsubst %, $(INCDIR)/%, $(INCEXPORTS)) LIBSONAME := $(patsubst %,%.$(NCCL_MAJOR),$(LIBNAME)) LIBTARGET := $(patsubst %,%.$(NCCL_MAJOR).$(NCCL_MINOR).$(NCCL_PATCH),$(LIBNAME)) +STATICLIBTARGET := $(STATICLIBNAME) LIBLINK := $(patsubst lib%.so, -l%, $(LIBNAME)) LIBOBJ := $(patsubst %.cu, $(OBJDIR)/%.o, $(filter %.cu, $(LIBSRCFILES))) DEPFILES := $(patsubst %.o, %.d, $(LIBOBJ)) $(patsubst %, %.d, $(TESTBINS)) $(patsubst %, %.d, $(MPITESTBINS)) +all : lib staticlib + lib : $(INCTARGETS) $(LIBDIR)/$(LIBTARGET) +staticlib : $(INCTARGETS) $(LIBDIR)/$(STATICLIBTARGET) + -include $(DEPFILES) $(LIBDIR)/$(LIBTARGET) : $(LIBOBJ) @@ -89,6 +95,11 @@ $(LIBDIR)/$(LIBTARGET) : $(LIBOBJ) ln -sf $(LIBSONAME) $(LIBDIR)/$(LIBNAME) ln -sf $(LIBTARGET) $(LIBDIR)/$(LIBSONAME) +$(LIBDIR)/$(STATICLIBTARGET) : $(LIBOBJ) + @printf "Archiving %-35s > %s\n" $(STATICLIBTARGET) $@ + mkdir -p $(LIBDIR) + ar cr $@ $(LIBOBJ) + $(INCDIR)/%.h : src/%.h @printf "Grabbing %-35s > %s\n" $< $@ mkdir -p $(INCDIR)