Commit de794a4c authored by Gerard Ryan's avatar Gerard Ryan

Merge branch 'v1.1-candidate' into 'master'

v1.1 release See merge request !1
parents 5993bfbe 86d3d83d
# Ignore everything in this directory
*~
*.o
*.gcov
bin/
build/
test/build
......@@ -10,11 +11,13 @@ apidoc_warning_logfile.txt
third-party/distros/gmp-6.1.1
third-party/distros/gmp-6.1.2
third-party/distros/ntl-10.3.0
third-party/distros/ntl-10.5.0
third-party/include
third-party/lib
third-party/share
timing/
gmon.out
.gitattributes
## .gitattributes
# Except this file
!.gitignore
output.txt
......
......@@ -23,13 +23,18 @@
#POSSIBILITY OF SUCH DAMAGE.
#
# this defines the source, build (obj) and binary directories
BMARK_SRC := benchmark/src
BMARK_BIN := $(BINDIR)/benchmark
BMARK_BUILD := $(BINDIR)/build/benchmark
BMLIB_SRCDIR := google/benchmark-master/src
BMLIB_IFLAG := -I$(BMLIB_SRCDIR)/../include
BMLIB_SRC := $(wildcard $(BMLIB_SRCDIR)/*.cc)
BMLIB_OBJ := $(BMLIB_SRC:.cc=.o)
BMLIB_OBJ := $(patsubst $(BMLIB_SRCDIR)/%,$(BMARK_BUILD)/%,$(BMLIB_SRC:.cc=.o))
#this defines the benchmark library archive
BMLIB_LIB := $(BMLIB_SRCDIR)/libbenchmark.a
BMLIB_LIB := $(BMARK_BIN)/libbenchmark.a
REGEX_FLAG := -DHAVE_STD_REGEX #note does not work for g++ <version 4.9
......@@ -42,11 +47,6 @@ WARNING_FLAG := -Wno-unused-but-set-variable
LIBBENCHMARK_FLAGS := $(REGEX_FLAG) -DHAVE_STEADY_CLOCK -DNDEBUG $(WARNING_FLAG) -Wno-unused-variable ##-Wextra -Wshadow -pedantic -pedantic-errors -Wfloat-equal -Wzero-as-null-pointer-constant -fstrict-aliasing -Wstrict-aliasing -Wno-nested-anon-types
# this defines the source, build (obj) and binary directories
BMARK_SRC := benchmark/src
BMARK_BIN := benchmark/bin
BMARK_BUILD := benchmark/build
#define list of source files (all files with .cc in the BMARK_SRC
BM_SOURCES := $(wildcard $(BMARK_SRC)/*.cpp)
......@@ -60,11 +60,13 @@ benchmark: $(BMLIB_LIB) $(BMARKS)
# this builds objects from sources for benchmark library
.PRECIOUS: $(BMLIB_SRCDIR)/%.o
$(BMLIB_SRCDIR)/%.o: $(BMLIB_SRCDIR)/%.cc
$(BMARK_BUILD)/%.o: $(BMLIB_SRCDIR)/%.cc
@mkdir -p $(BMARK_BUILD)
$(CC) $(CPPFLAGS) $(LIBBENCHMARK_FLAGS) $(BMLIB_IFLAG) -o $@ -c $<
.PRECIOUS: $(BMLIB_LIB)
$(BMLIB_LIB): $(BMLIB_OBJ)
@mkdir -p $(BMARK_BIN)
ar cr $(BMLIB_LIB) $(BMLIB_OBJ)
ranlib $(BMLIB_LIB)
......@@ -76,17 +78,18 @@ BMLIB_LIBSRCDIR := google/benchmark-master/include
#this is is the Include directive for the palisade code being benchmarked
BM_IFLAG := -Isrc/core/lib -Isrc/pke/lib $(BMLIB_IFLAG) $(NTLINCLUDE) $(GMPINCLUDE)
PLIBS := $(EXTLIBDIR)/$(PALISADEPKELIB) $(EXTLIBDIR)/$(PALISADECORELIB)
PLIBS := $(EXTLIBDIR)/$(PALISADEPKELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
# this builds executables from objects for benchmarks
benchmark/bin/%$(EXESUFFIX): benchmark/build/%.o $(BMLIB_LIB) $(PLIBS)
$(BMARK_BIN)/%$(EXESUFFIX): $(BMARK_BUILD)/%.o $(BMLIB_LIB) $(PLIBS)
@mkdir -p $(BMARK_BIN)
$(CC) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS) $< -o $@ $(PLIBS) $(RDYNAMIC) $(BMLIB_LIB) $(EXTLIB) $(MINGWREGEX)
$(CC) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS) $(BMLIB_IFLAG) $< -o $@ $(LOADTHREADFLAG) $(RDYNAMIC) $(BMLIB_LIB) -L$(EXTLIBDIR) -lPALISADEpke -lPALISADEcore $(NTLLIB) $(GMPLIB) -lpthread $(LOADTHREADFLAG) -fopenmp -lgomp $(SHLWAPI)
# this builds objects from sources for benchmarks
.PRECIOUS: benchmark/build/%.o
benchmark/build/%.o: benchmark/src/%.cpp
@mkdir -p benchmark/build
.PRECIOUS: $(BMARK_BUILD)/%.o
$(BMARK_BUILD)/%.o: $(BMARK_SRC)/%.cpp
@mkdir -p $(BMARK_BUILD)
@$(CC) -MM $(CPPFLAGS) $(BM_IFLAG) $(LIBBENCHMARK_FLAGS) $(BM_IFLAG) $(patsubst $(BMARK_BUILD)/%,$(BMARK_SRC)/%,$(patsubst %.o,%.cpp,$@)) > $(patsubst %.o,%.d,$@)
@mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d.tmp,$@)
@sed -e 's|.*\.o:|$@:|' < $(patsubst %.o,%.d.tmp,$@) > $(patsubst %.o,%.d,$@)
......@@ -100,4 +103,8 @@ cleanbenchmark:
$(RM) -r $(BMARK_BIN) $(BMARK_BUILD) $(BMLIB_OBJ) $(BMLIB_LIB)
bstrings:
@echo $(BMARKS)
@echo BMARKS is $(BMARKS)
@echo BMLIB_SRC is $(BMLIB_SRC)
@echo BMLIB_OBJ is $(BMLIB_OBJ)
@echo $(BMLIB_SRC:.cc=.o)
@echo $(BMLIB_SRCDIR)
......@@ -28,6 +28,8 @@
# Makefile.circuit-disable ; no actual build
################
circuitstring:
allcircuit:
allcircuitdemos:
......
......@@ -29,8 +29,7 @@
# for making all the palisade components
################
TEST_LIB := $(LOADTHREADFLAG) -fopenmp $(GMPLIB) -lgomp
# NOTE select the appropriate set of CPPFLAGS
# most code is checked into git with the first line active
......@@ -40,31 +39,52 @@
#CPPFLAGS += -Wall -Ofast -w -fopenmp -g ##undefine for parallel debug operation
#CPPFLAGS += -Wall -O3 -w -DNDEBUG -pg ##undefine for single thread best performance operation with gprof profiling
##parallel best performance operation with debug
##warn everything
##no threading or optimization when doing coverage testing
CPPFLAGS += -g -Wall -Werror
## handle coverage test options if user set COVERAGE to any value on the command line
ifdef COVERAGE
CPPFLAGS += --coverage -Wno-unknown-pragmas
TEST_LIB += --coverage
LIBSUFFIX=.a
LIBCMD=$(AR) crv
else
CPPFLAGS += -O3 -fopenmp $(COMPTHREADFLAG) ##optimize and threads
endif
## set backend if user set it on the command line
ifdef BACKEND
CPPFLAGS += -DMATHBACKEND=$(BACKEND)
endif
## turn on openmp loop parallelization in the library code
## currently turns on loop parallelization only for the Matrix class
ifdef OMP
CPPFLAGS += -DOMP=$(OMP)
endif
#main best performance configuration for parallel operation - cross-platform
CPPFLAGS += -g -Wall -Werror -O3 -fopenmp $(COMPTHREADFLAG) ##undefine for parallel best performance operation with debug
#CPPFLAGS += -Wall -O3 -w -fopenmp -m64 -DNDEBUG ##undefine for parallel best performance operation with no debug
#THE OPTIONS BELOW SHOULD BE USED WITH CARE AS THEY USE A LOT OF AGGRESSIVE OPTIMIZATION OPTIONS
#CPPFLAGS += -Wall -w -DNDEBUG -m64 -Ofast -flto -march=native -funroll-loops ##undefine for single thread best performance operation
#CPPFLAGS += -Wall -w -DNDEBUG -m64 -Ofast -flto -march=native -funroll-loops -fopenmp ##undefine for multithread really best performance operation
#CPPFLAGS += -Wall -w -m64 -Ofast -flto -march=native -funroll-loops -fopenmp -DNDEBUG ##undefine for multithread really best performance operation
#CPPFLAGS += -Wall -w -m64 -Ofast -flto -march=native -funroll-loops -fopenmp ##undefine for multithread really best performance operation
#CPPFLAGS += -Wall Werror -DNDEBUG -m64 -Ofast -flto -march=native -funroll-loops ##undefine for single thread best performance operation
#CPPFLAGS += -Wall -Werror -DNDEBUG -m64 -Ofast -flto -march=native -funroll-loops -fopenmp ##undefine for multithread really best performance operation
#CPPFLAGS += -Wall -Werror -m64 -Ofast -flto -march=native -funroll-loops -fopenmp -DNDEBUG ##undefine for multithread really best performance operation
#CPPFLAGS += -Wall -Werror -m64 -Ofast -flto -march=native -funroll-loops -fopenmp ##undefine for multithread really best performance operation
TEST_LIB := $(LOADTHREADFLAG) -fopenmp $(NTLLIB) $(GMPLIB) -lgomp
#build directory
BUILDDIR := build
#bin directory
BINDIR := bin
BINDIR ?= bin
#sources for palisade library
EXTLIBDIR := bin/lib
EXTTESTDIR := bin/unittest
EXTDEMODIR := bin/demo
EXTLIBDIR := $(BINDIR)/lib
EXTTESTDIR := $(BINDIR)/unittest
EXTDEMODIR := $(BINDIR)/demo
# extentions for source and header files
SRCEXT := cpp
......@@ -75,9 +95,7 @@ $(objects) : %.o : %.cpp
NTLINCLUDE := -I third-party/include
GMPINCLUDE := -I third-party/include
#DBC added NTL and GML lubraries and turn off profiling
#EXTLIB := -L$(EXTLIBDIR) $(TEST_LIB) -pg #-lmongoclient -L lib -lboost_thread-mt -lboost_filesystem-mt -lboost_system-mt ## include profiling
EXTLIB := -L$(EXTLIBDIR) $(NTLLIB) $(GMPLIB) $(TEST_LIB) #no profiling
EXTLIB := -L$(EXTLIBDIR) $(TEST_LIB) #no profiling
INC := -I src/core/lib -I src/pke/lib -I src/trapdoor/lib -I src/circuit/lib -I test $(OMPINCLUDE) $(NTLINCLUDE) $(GMPINCLUDE)
......@@ -90,9 +108,12 @@ PALISADECIRCUITLIB := libPALISADEcircuit$(LIBSUFFIX)
PALISADEPYLIB := pycrypto$(LIBSUFFIX)
# run make for all components. you can run any individual component separately
# by invoking "make alltargets" for example
# each corresponding makefile will make the allxxxx target
all: allcore allpke alltrapdoor allcircuit
# by invoking "make allxxx" for example, make allcore makes everything in core only
all:
$(MAKE) gmp_all
$(MAKE) ntl_all
$(MAKE) allcore allpke alltrapdoor allcircuit utall
docs: apidocs
......@@ -102,26 +123,40 @@ allpython: allcore allpke alltrapdoor pywrapper
alldemos: allcoredemos allpkedemos alltrapdoordemos allcircuitdemos
testall: testcore testpke testtrapdoor testcircuit
testall: $(CORE_TEST_TARGET) $(PKE_TEST_TARGET) $(TRAPDOOR_TEST_TARGET) $(CIRCUIT_TEST_TARGET) utall
$(BINDIR)/unittest/tests$(EXESUFFIX) -t
# clean up all components. you can clean any individual compoenent separately
# by invoking "make cleantargets" for example
# each corresponding makefile will make the cleanxxxx target
.PHONEY: clean
.PHONEY: clean clobber
clean: cleancore cleanpke cleantrapdoor cleancircuit cleandocs cleanbenchmark
@echo 'Cleaning top level autogenerated directories'
$(RM) -f test/include/gtest/gtest-all.o
$(RM) -rf bin
$(RM) -rf $(BINDIR)
$(RM) -rf src/*/bin
clobber: clean clean_gmp clean_ntl
UNITTESTMAINOBJ := $(BINDIR)/unittest/Main_TestAll.o
$(UNITTESTMAINOBJ): test/include/gtest/Main_TestAll.cpp src/core/lib/math/backend.h
@mkdir -p $(BINDIR)/unittest
$(CC) -c $(CPPFLAGS) $(INC) -o $@ $<
utall: $(BINDIR)/unittest/tests$(EXESUFFIX)
include Makefile.core
include Makefile.pke
include Makefile.trapdoor
include Makefile.circuit
include Makefile.gmp
include Makefile.ntl
include Makefile.wrapper
include Makefile.benchmark #builds the benchmark framework
include Makefile.docs #populates doxgen documentation
test/include/gtest/gtest-all.o: test/include/gtest/gtest-all.cc
$(CC) -c $(CPPFLAGS) -o $@ $<
$(BINDIR)/unittest/tests$(EXESUFFIX): $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(PKEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEPKELIB) $(TRAPDOORUNITOBJECTS) $(EXTLIBDIR)/$(PALISADETRAPDOORLIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(BINDIR)/unittest
$(CC) -o $@ $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(PKEUNITOBJECTS) $(TRAPDOORUNITOBJECTS) $(EXTLIB) -lPALISADEtrapdoor -lPALISADEpke -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB)
......@@ -30,39 +30,42 @@
################
CORESRCDIR := src/core
COREBINDIR := src/core/bin
COREBINDIR := $(BINDIR)/build/core
CORETESTDIR := src/core/unittest
COREDEMODIR := src/core/demo
CORESOURCES := $(shell find $(CORESRCDIR)/lib -name '*.cpp')
CORESOURCES := $(shell find $(CORESRCDIR)/lib -name '*.cpp' ! -name '*-public.cpp')
COREUNITSOURCES := $(wildcard $(CORESRCDIR)/unittest/*.cpp)
COREDEMOSOURCES := $(wildcard $(CORESRCDIR)/demo/*.cpp)
COREOBJECTS := $(patsubst $(CORESRCDIR)/%,$(COREBINDIR)/%,$(patsubst %.cpp,%.o,$(CORESOURCES)))
COREUNITOBJECTS := $(patsubst $(CORESRCDIR)/%,$(COREBINDIR)/%,$(patsubst %.cpp,%.o,$(COREUNITSOURCES)))
COREUNITOBJECTS += test/include/gtest/gtest-all.o
COREDEMOOBJECTS := $(patsubst $(CORESRCDIR)/%,$(COREBINDIR)/%,$(patsubst %.cpp,%.o,$(COREDEMOSOURCES)))
TEST_TARGET := $(EXTTESTDIR)/core/tests$(EXESUFFIX)
CORE_TEST_TARGET := $(EXTTESTDIR)/core/tests$(EXESUFFIX)
-include $(COREOBJECTS:.o=.d)
-include $(COREUNITOBJECTS:.o=.d)
-include $(COREDEMOOBJECTS:.o=.d)
.PHONY:allcore
allcore: $(EXTLIBDIR)/$(PALISADECORELIB) $(TEST_TARGET) allcoredemos
allcore: $(EXTLIBDIR)/$(PALISADECORELIB) $(CORE_TEST_TARGET) allcoredemos
allcoredemos: $(EXTLIBDIR)/$(PALISADECORELIB) $(patsubst $(COREBINDIR)/demo/%,bin/demo/core/%,$(patsubst %.o,%$(EXESUFFIX),$(COREDEMOOBJECTS)))
allcoredemos: $(EXTLIBDIR)/$(PALISADECORELIB) $(patsubst $(COREBINDIR)/demo/%,$(BINDIR)/demo/core/%,$(patsubst %.o,%$(EXESUFFIX),$(COREDEMOOBJECTS)))
bin/demo/core/%$(EXESUFFIX): src/core/bin/demo/%.o $(EXTLIBDIR)/$(PALISADECORELIB)
$(BINDIR)/demo/core/%$(EXESUFFIX): $(COREBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(@D)
$(CC) -o $@ $^ $(EXTLIB) -lPALISADEcore
$(CC) -o $@ $< $(EXTLIB) -lPALISADEcore $(NTLLIB) $(GMPLIB)
#this builds the palisade library out of the objects
$(EXTLIBDIR)/$(PALISADECORELIB): $(COREOBJECTS)
$(EXTLIBDIR)/$(PALISADECORELIB): $(COREOBJECTS) $(NTLLIB) $(GMPLIB)
@echo " -- core:linking $@ from COREOBJECTS"
mkdir -p $(EXTLIBDIR)
$(CC) $(LIBCMD) -o $@ $(COREOBJECTS) $(TEST_LIB)
@mkdir -p $(EXTLIBDIR)
ifdef COVERAGE
$(LIBCMD) $@ $(COREOBJECTS)
else
$(LIBCMD) $@ $(COREOBJECTS) $(NTLLIB) $(GMPLIB)
endif
### #this builds the individual objects that make up the library .
.PRECIOUS: $(COREBINDIR)/%
......@@ -82,15 +85,18 @@ $(COREBINDIR)/%:
.PHONY: cleancore
cleancore:
$(RM) -fr $(COREBINDIR) $(EXTLIBDIR)/$(PALISADECORELIB) `dirname $(TEST_TARGET)` bin/demo/core
$(RM) -fr $(COREBINDIR) $(EXTLIBDIR)/$(PALISADECORELIB) `dirname $(CORE_TEST_TARGET)` $(BINDIR)/demo/core
# this links test executable from objects in the test build directory
$(TEST_TARGET): $(COREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB)
@mkdir -p `dirname $(TEST_TARGET)`
$(CC) -o $(TEST_TARGET) $^ $(EXTLIB) $(TEST_LIB)
$(CORE_TEST_TARGET): $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p `dirname $(CORE_TEST_TARGET)`
$(CC) -o $(CORE_TEST_TARGET) $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(EXTLIB) -lPALISADEcore $(NTLLIB) $(GMPLIB) $(TEST_LIB)
#used to run tests from make
.PHONY: testcore
testcore: $(TEST_TARGET)
$(TEST_TARGET)
testcore: $(CORE_TEST_TARGET)
$(CORE_TEST_TARGET)
corestrings:
@echo $(CORESOURCES)
@echo $(COREOBJECTS)
#Makefile to build and install gmp in palisade
TAR ?= tar
#note change the following directory to the correct one on your install
PALISADE_DIR := $(PWD)
GMP_VER :=6.1.2
#check if the palisade directory is correct
#ifneq ($(wildcard $(PALISADE_DIR)), )
# $(info Makefile.gmp running)
#else
# $(info Makefile.gmp needs to be updated for correct PALISADE_DIR directory)
#endif
THIRD_PARTY_DIR := $(PALISADE_DIR)/third-party
DISTROS_DIR := $(THIRD_PARTY_DIR)/distros
GMP_DISTRO_DIR := $(DISTROS_DIR)/gmp-$(GMP_VER)
#check if gmp has been unpacked into the correct directory
# and installs it if not.
ifneq ($(wildcard $(THIRD_PARTY_DIR)/distros/gmp-$(GMP_VER)), )
#$(info Makefile.gmp: GMP already unpacked)
GMP_UNPACK_NEEDED :=
else
#$(info Makefile.gmp: unpacking GMP)
GMP_UNPACK_NEEDED := gmp_unpack
endif
#check if gmp has been installed into the correct directory
# and installs it if not.
ifneq ($(wildcard $(THIRD_PARTY_DIR)/lib/libgmp.a), )
#$(info Makefile.gmp: GMP already installed)
GMP_CONFIG_NEEDED :=
GMP_MAKE_NEEDED :=
GMP_CHECK_NEEDED :=
GMP_INSTALL_NEEDED :=
else
#$(info Makefile.gmp: installing GMP)
GMP_CONFIG_NEEDED := gmp_config
GMP_MAKE_NEEDED := gmp_make
#GMP_CHECK_NEEDED := gmp_check
GMP_INSTALL_NEEDED := gmp_install
endif
$(GMPLIB): gmp_all
gmp_all: $(GMP_UNPACK_NEEDED) $(GMP_CONFIG_NEEDED) $(GMP_MAKE_NEEDED) $(GMP_CHECK_NEEDED) $(GMP_INSTALL_NEEDED)
gmp_unpack:
@echo 'Unpacking gmp for Palisade into $(GMP_DISTRO_DIR)'
cd $(DISTROS_DIR);\
$(TAR) xf ./gmp-$(GMP_VER).tar.lz
gmp_config: $(GMP_UNPACK_NEEDED)
@echo 'Configuring gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \
./configure --prefix=$(THIRD_PARTY_DIR);
gmp_make: gmp_config
@echo 'making gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \
$(MAKE)
gmp_check: $(GMP_MAKE_NEEDED)
@echo 'checking gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \
$(MAKE) check
gmp_install: $(GMP_CHECK_NEEDED) $(GMP_MAKE_NEEDED)
@echo 'installing gmp for Palisade in $(THIRD_PARTY_DIR)'
cd $(GMP_DISTRO_DIR); \
$(MAKE) install
clean_gmp:
@echo 'Cleaning gmp installation'
cd $(DISTROS_DIR);\
$(RM) -rf gmp-$(GMP_VER)
cd $(THIRD_PARTY_DIR); \
$(RM) -rf include lib share
......@@ -22,7 +22,7 @@ CPPSTD := -std=gnu++11 -fPIC
CC := g++ $(CPPSTD)
LIBSUFFIX := .so
LIBCMD := -fPIC -shared -Wl,--export-dynamic -fopenmp
LIBCMD := $(CC) -fPIC -shared -Wl,--export-dynamic -fopenmp -o #libname to follow
RDYNAMIC := -rdynamic
......
## for mac OSx
TAR := gnutar
OMPINCLUDE := -I /opt/local/include/libomp -fopenmp
ifneq ($(wildcard third-party/include), )
NTLLIB := third-party/lib/libntl.dylib
GMPLIB := third-party/lib/libgmp.dylib
endif
CPPSTD := -std=c++11 -stdlib=libc++ -fPIC
CC := /opt/local/bin/clang++ $(CPPSTD)
BISON := /opt/local/bin/bison
FLEX := /opt/local/bin/flex
LIBSUFFIX := .dylib
LIBCMD := -dynamiclib -undefined suppress -flat_namespace -fopenmp
LIBCMD := $(CC) -dynamiclib -undefined suppress -flat_namespace -fopenmp -o #libname to follow
RDYNAMIC :=
......
......@@ -6,17 +6,24 @@ BOOSTLIB := -L C:/boost_1_60_0/stage/lib/
#BOOSTINCLUDE :=
#BOOSTLIB :=
ifneq ($(wildcard third-party/include), )
#$(info GMP/NTL directory third-party/include exists)
NTLLIB := third-party/lib/libntl.a
GMPLIB := third-party/lib/libgmp.a
else
#$(info GMP/NTL directory third-party does not exist)
endif
OMPINCLUDE :=
CPPSTD := -std=gnu++11
CC := g++ $(CPPSTD)
LIBCMD := -s -shared -Wl,--subsystem,windows -fopenmp
LIBCMD := $(CC) -s -shared -Wl,--subsystem,windows -fopenmp -o #libname to follow
LIBSUFFIX := .dll
EXESUFFIX := .exe
MINGWREGEX := -Lc:/Mingw64/mingw64/opt/lib -lregex -lshlwapi
SHLWAPI := -lshlwapi
RDYNAMIC :=
JNIBUILD := -I "C:/Program Files/java/jdk1.8.0_91/include" -I "C:/Program Files/java/jdk1.8.0_91/include/win32"
......
#Makefile to build and install ntl in palisade
TAR ?= tar
#note change the following directory to the correct one on your install
PALISADE_DIR := $(PWD)
NTL_VER:= 10.5.0
#check if the palisade directory is correct
#ifneq ($(wildcard $(PALISADE_DIR)), )
# $(info Makefile.ntl running PALISADE_DIR found)
#else
# $(info Makefile.ntl needs to be updated for correct PALISADE_DIR directory)
#endif
THIRD_PARTY_DIR := $(PALISADE_DIR)/third-party
DISTROS_DIR := $(THIRD_PARTY_DIR)/distros
NTL_DISTRO_DIR := $(DISTROS_DIR)/ntl-$(NTL_VER)/src
#check if gmp has been installed into the correct directory
# and build gmp if not.
ifneq ($(wildcard $(THIRD_PARTY_DIR)/distros/lib/libgmp.a), )
#$(info Makefile.ntl: GMP install found)
GMP_NEEDED :=
else
#$(info Makefile.ntl: running Makefile.gmp for GMP install)
GMP_NEEDED := gmp_all
endif
#check if ntl has been unpacked into the correct directory
# and installs it if not.
ifneq ($(wildcard $(THIRD_PARTY_DIR)/distros/ntl-$(NTL_VER)), )
#$(info Makefile.ntl: NTL already unpacked)
NTL_UNPACK_NEEDED :=
else
#$(info Makefile.ntl: unpacking NTL)
NTL_UNPACK_NEEDED :=ntl_unpack
endif
#check if ntl has been installed into the correct directory
# and installs it if not.
ifneq ($(wildcard $(THIRD_PARTY_DIR)/lib/libntl.a), )
#$(info Makefile.ntl: NTL already installed)
NTL_CONFIG_NEEDED :=
NTL_MAKE_NEEDED :=
NTL_CHECK_NEEDED :=
NTL_INSTALL_NEEDED :=
else
#$(info Makefile.ntl: installing NTL)
NTL_CONFIG_NEEDED := ntl_config
NTL_MAKE_NEEDED := ntl_make
#NTL_CHECK_NEEDED := ntl_check
NTL_INSTALL_NEEDED := ntl_install
endif
ntl_all: $(GMP_NEEDED) $(NTL_UNPACK_NEEDED) $(NTL_CONFIG_NEEDED) $(NTL_MAKE_NEEDED) $(NTL_CHECK_NEEDED) $(NTL_INSTALL_NEEDED)
@echo $(all)
ntl_unpack:
@echo 'Unpacking ntl for Palisade into $(NTL_DISTRO_DIR)'
cd $(DISTROS_DIR);\
$(TAR) xf ./ntl-$(NTL_VER).tar.gz
ntl_config: $(NTL_UNPACK_NEEDED)
@echo 'Configuring ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(NTL_DISTRO_DIR); \
./configure PREFIX=$(THIRD_PARTY_DIR) GMP_PREFIX=$(THIRD_PARTY_DIR) NTL_THREADS=on NTL_THREAD_BOOST=on NTL_EXCEPTIONS=on SHARED=on NTL_STD_CXX11=on NTL_SAFE_VECTORS=off
ntl_make: ntl_config
@echo 'making ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(NTL_DISTRO_DIR); \
$(MAKE)
ntl_check: $(NTL_MAKE_NEEDED)
@echo 'checking ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(NTL_DISTRO_DIR); \
$(MAKE) check
ntl_install: $(NTL_CHECK_NEEDED) $(NTL_MAKE_NEEDED)
@echo 'installing ntl for Palisade in $(THIRD_PARTY_DIR)'
cd $(NTL_DISTRO_DIR); \
$(MAKE) install
clean_ntl:
@echo 'Cleaning ntl installation'
cd $(DISTROS_DIR);\
$(RM) -rf ntl-$(NTL_VER)
cd $(THIRD_PARTY_DIR); \
$(RM) -rf include lib share includels
......@@ -30,18 +30,17 @@
################
PKESRCDIR := src/pke
PKEBINDIR := src/pke/bin
PKEBINDIR := $(BINDIR)/build/pke
PKETESTDIR := src/pke/unittest
PKEDEMODIR := src/pke/demo
PKESOURCES := $(shell find $(PKESRCDIR)/lib -name '*.cpp')
PKESOURCES := $(shell find $(PKESRCDIR)/lib -name '*.cpp' ! -name '*-public.cpp')
PKEUNITSOURCES := $(wildcard $(PKESRCDIR)/unittest/*.cpp)
PKEDEMOSOURCES := $(wildcard $(PKESRCDIR)/demo/*.cpp)
PKEOBJECTSALL = $(patsubst $(PKESRCDIR)/%,$(PKEBINDIR)/%,$(patsubst %.cpp,%.o,$(PKESOURCES)))
PKEOBJECTS = $(filter %-impl.o,$(PKEOBJECTSALL))
PKEUNITOBJECTS := $(patsubst $(PKESRCDIR)/%,$(PKEBINDIR)/%,$(patsubst %.cpp,%.o,$(PKEUNITSOURCES)))
PKEUNITOBJECTS += test/include/gtest/gtest-all.o
PKEDEMOOBJECTS += $(patsubst $(PKESRCDIR)/%,$(PKEBINDIR)/%,$(patsubst %.cpp,%.o,$(PKEDEMOSOURCES)))
PKE_TEST_TARGET := $(EXTTESTDIR)/pke/tests$(EXESUFFIX)
......@@ -53,17 +52,21 @@ PKE_TEST_TARGET := $(EXTTESTDIR)/pke/tests$(EXESUFFIX)
.PHONY:allpke
allpke: allcore $(EXTLIBDIR)/$(PALISADEPKELIB) $(PKE_TEST_TARGET) allpkedemos
allpkedemos: $(patsubst $(PKEBINDIR)/demo/%,bin/demo/pke/%,$(patsubst %.o,%$(EXESUFFIX),$(PKEDEMOOBJECTS)))
allpkedemos: $(patsubst $(PKEBINDIR)/demo/%,$(BINDIR)/demo/pke/%,$(patsubst %.o,%$(EXESUFFIX),$(PKEDEMOOBJECTS)))
bin/demo/pke/%$(EXESUFFIX): src/pke/bin/demo/%.o $(EXTLIBDIR)/$(PALISADEPKELIB) $(EXTLIBDIR)/$(PALISADECORELIB)
$(BINDIR)/demo/pke/%$(EXESUFFIX): $(PKEBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADEPKELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(@D)
$(CC) -o $@ $^ $(EXTLIB)
$(CC) -o $@ $< $(EXTLIB) -lPALISADEpke -lPALISADEcore $(NTLLIB) $(GMPLIB)
#this builds the palisade library out of the objects
$(EXTLIBDIR)/$(PALISADEPKELIB): $(PKEOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB)
$(EXTLIBDIR)/$(PALISADEPKELIB): $(PKEOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@echo " -- pke:linking $@ from PKEOBJECTS"
mkdir -p $(EXTLIBDIR)
$(CC) $(LIBCMD) -o $@ $(PKEOBJECTS) -L$(EXTLIBDIR) -lPALISADEcore
@mkdir -p $(EXTLIBDIR)
ifdef COVERAGE
$(LIBCMD) $@ $(PKEOBJECTS)
else
$(LIBCMD) $@ $(PKEOBJECTS) $(EXTLIB) -lPALISADEcore $(NTLLIB) $(GMPLIB)
endif
### #this builds the individual objects that make up the library .
.PRECIOUS: $(PKEBINDIR)/%
......@@ -83,12 +86,12 @@ $(PKEBINDIR)/%:
#this target is used to cleanup, it is called from the top Makefile
cleanpke:
$(RM) -fr $(PKEBINDIR) $(EXTLIBDIR)/$(PALISADEPKELIB) `dirname $(PKE_TEST_TARGET)` bin/demo/pke
$(RM) -fr $(PKEBINDIR) $(EXTLIBDIR)/$(PALISADEPKELIB) `dirname $(PKE_TEST_TARGET)` $(BINDIR)/demo/pke
# this links test executable from objects in the test build directory
$(PKE_TEST_TARGET): $(PKEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEPKELIB) $(EXTLIBDIR)/$(PALISADECORELIB)
$(PKE_TEST_TARGET): $(UNITTESTMAINOBJ) $(PKEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEPKELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p `dirname $(PKE_TEST_TARGET)`
$(CC) $(PKEUNITOBJECTS) -o $(PKE_TEST_TARGET) -L$(EXTLIBDIR) -lPALISADEpke -L$(EXTLIBDIR) -lPALISADEcore $(TEST_LIB)
$(CC) -o $(PKE_TEST_TARGET) $(UNITTESTMAINOBJ) $(PKEUNITOBJECTS) $(EXTLIB) -lPALISADEpke -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB)
#used to run tests from make
.PHONY: testpke
......
......@@ -7,7 +7,7 @@ PALISADE Lattice Cryptography Library
[Library Contributors](Contributors.md)
[Library Wiki with documentation](https://git.njit.edu/palisade/PALISADE/wikis/home)
[Library Wiki with documentation](https://git.njit.edu/palisade/palisade-student-edition/wikis/home)
This is a software library for general lattice crypto. We implement this library in the following multiple layers:
......@@ -21,6 +21,13 @@ The library is implemented in C++11.
We build and run the library on Windows, Linux and Mac OSX environments.
We require a version of C++ compiler that supports the C++11 extensions. Recent vintages of GCC or Clang should work fine. The library can also be built under Visual Studio. We also use bison and flex in some parts of the library.
We require a version of C++ compiler that supports the C++11 extensions. Recent vintages of GCC or Clang should work fine. We have removed support for Visual Studio and suggest that it not be used. We also use bison and flex in some parts of the library.
To check if your environment will allow you to build and use PALISADE, run the configure.sh script in the root directory of the library software distribution.
\ No newline at end of file
To check if your environment will allow you to build and use PALISADE, run the configure.sh script in the root directory of the library software distribution.
You build the entirety of PALISADE by running make. There are various command line arguments that can be passed to make to vary the details of what is made and where:
* BINDIR=directory builds the library with a different target directory
* BACKEND=n builds the library with MATHBACKEND set to n (you may want to touch the src/core/lib/math/backend.h file to force the build)
* COVERAGE=any builds the library with coverage testing enabled
* OMP=n builds the library with OMP flag set to n; currently n can be any value; turns on loop parallelization for the Matrix class in src/core/lib/math; additional levels of parallelization will be added in the future.
\ No newline at end of file