Commit c0c73f4b authored by Gerard Ryan's avatar Gerard Ryan

Update for v1.4.0

parent 09e112be
#
#Copyright (c) 2015, New Jersey Institute of Technology (NJIT)
#All rights reserved.
#Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
#met:
#1. Redistributions of source code must retain the above copyright
#notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
#notice, this list of conditions and the following disclaimer in the
#documentation and/or other materials provided with the distribution.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
#IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#PARTICULAR PURPOSE ARE DISCLAIMED.
#IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
#OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
#STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
#IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#POSSIBILITY OF SUCH DAMAGE.
#
################
# Makefile.abe builds the attribute-based encryption components of the PALISADE library
# Includes unit tests and demos
################
ABESRCDIR := src/abe
ABEBINDIR := $(BINDIR)/build/abe
ABETESTDIR := src/abe/unittest
ABEDEMODIR := src/abe/demo
ABESOURCES := $(shell find $(ABESRCDIR)/lib -name '*.cpp' ! -name '*-public.cpp')
ABEUNITSOURCES := $(wildcard $(ABESRCDIR)/unittest/*.cpp)
ABEDEMOSOURCES := $(wildcard $(ABESRCDIR)/demo/*.cpp)
ABEOBJECTSALL = $(patsubst $(ABESRCDIR)/%,$(ABEBINDIR)/%,$(patsubst %.cpp,%.o,$(ABESOURCES)))
ABEOBJECTS = $(filter %-impl.o,$(ABEOBJECTSALL))
ABEUNITOBJECTS := $(patsubst $(ABESRCDIR)/%,$(ABEBINDIR)/%,$(patsubst %.cpp,%.o,$(ABEUNITSOURCES)))
ABEDEMOOBJECTS += $(patsubst $(ABESRCDIR)/%,$(ABEBINDIR)/%,$(patsubst %.cpp,%.o,$(ABEDEMOSOURCES)))
ABE_TEST_TARGET := $(EXTTESTDIR)/abe/tests$(EXESUFFIX)
-include $(ABEOBJECTS:.o=.d)
-include $(ABEUNITOBJECTS:.o=.d)
-include $(ABEDEMOOBJECTS:.o=.d)
.PHONY: allabe
allabe: allcore $(EXTLIBDIR)/$(PALISADEABELIB) $(ABE_TEST_TARGET) allabedemos
.PHONY: allabedemos
allabedemos: $(patsubst $(ABEBINDIR)/demo/%,$(BINDIR)/demo/abe/%,$(patsubst %.o,%$(EXESUFFIX),$(ABEDEMOOBJECTS)))
$(BINDIR)/demo/abe/%$(EXESUFFIX): $(ABEBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADEABELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(@D)
$(CC) -o $@ $< $(EXTLIB) -lPALISADEabe -lPALISADEcore $(NTLLIB) $(GMPLIB)
#this builds the palisade library out of the objects
$(EXTLIBDIR)/$(PALISADEABELIB): $(ABEOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@echo " -- abe:linking $@ from ABEOBJECTS"
@mkdir -p $(EXTLIBDIR)
ifdef COVERAGE
$(LIBCMD) $@ $(ABEOBJECTS)
else
$(LIBCMD) $@ $(ABEOBJECTS) $(EXTLIB) -lPALISADEcore $(NTLLIB) $(GMPLIB)
endif
### #this builds the individual objects that make up the library .
.PRECIOUS: $(ABEBINDIR)/%
$(ABEBINDIR)/%:
@if [ "$(suffix $@)" = ".o" ] ; \
then \
mkdir -p $(@D) ;\
echo $(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(ABEBINDIR)/%,$(ABESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
$(CC) -MM $(CPPFLAGS) $(INC) $(patsubst $(ABEBINDIR)/%,$(ABESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) > $(patsubst %.o,%.d,$@) ;\
mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d.tmp,$@) ;\
sed -e 's|.*\.o:|$(ABEBINDIR)/$*:|' < $(patsubst %.o,%.d.tmp,$@) > $(patsubst %.o,%.d,$@) ;\
rm -f $(patsubst %.o,%.d.tmp,$@) ; \
$(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(ABEBINDIR)/%,$(ABESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
fi
#this target is used to cleanup, it is called from the top Makefile
.PHONY: cleanabe
cleanabe:
$(RM) -fr $(ABEBINDIR) $(EXTLIBDIR)/$(PALISADEABELIB) `dirname $(ABE_TEST_TARGET)` $(BINDIR)/demo/abe
# this links test executable from objects in the test build directory
$(ABE_TEST_TARGET): $(UNITTESTMAINOBJ) $(ABEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEABELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p `dirname $(ABE_TEST_TARGET)`
$(CC) -o $(ABE_TEST_TARGET) $(UNITTESTMAINOBJ) $(ABEUNITOBJECTS) $(EXTLIB) -lPALISADEabe -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB)
#used to run tests from make
.PHONY: testabe
testabe: $(ABE_TEST_TARGET)
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(ABE_TEST_TARGET)
.PHONY: installabe
installabe: installdirs
install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADEABELIB)
.PHONY: uninstallabe
uninstallabe:
rm $(LIB_DEST)/$(PALISADEABELIB)
...@@ -48,7 +48,7 @@ WARNING_FLAG := -Wno-unused-but-set-variable ...@@ -48,7 +48,7 @@ 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 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
#define list of source files (all files with .cc in the BMARK_SRC #define list of source files (all files with .cc in the BMARK_SRC
BM_SOURCES := $(wildcard $(BMARK_SRC)/*.cpp) BM_SOURCES := $(wildcard $(BMARK_SRC)/*.cpp)
BM_OBJS := $(BM_SOURCES:$(BMARK_SRC)%.cpp=$(BMARK_BUILD)%.o) BM_OBJS := $(BM_SOURCES:$(BMARK_SRC)%.cpp=$(BMARK_BUILD)%.o)
......
...@@ -50,7 +50,12 @@ ifdef COVERAGE ...@@ -50,7 +50,12 @@ ifdef COVERAGE
LIBSUFFIX=.a LIBSUFFIX=.a
LIBCMD=$(AR) crv LIBCMD=$(AR) crv
else else
CPPFLAGS += -O3 -fopenmp $(COMPTHREADFLAG) ##optimize and threads ifdef MEM
CPPFLAGS += -O0
else
CPPFLAGS += -O3
endif
CPPFLAGS += -fopenmp $(COMPTHREADFLAG) ##optimize and threads
endif endif
## set backend if user set it on the command line ## set backend if user set it on the command line
...@@ -69,8 +74,8 @@ endif ...@@ -69,8 +74,8 @@ endif
# base directory of project # base directory of project
ROOTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) ROOTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PROJECT := palisade PACKAGE := palisade
VERSION := 1.3.0 VERSION := 1.4.0
#build directory #build directory
BUILDDIR := build BUILDDIR := build
...@@ -90,7 +95,7 @@ HDREXT := h ...@@ -90,7 +95,7 @@ HDREXT := h
$(objects) : %.o : %.cpp $(objects) : %.o : %.cpp
# sub makefiles: each src subdirectory needs to be here # sub makefiles: each src subdirectory needs to be here
SUBMAKEFILES := core pke SUBMAKEFILES := core pke abe signature
# third party directories # third party directories
THIRDPARTYDIR := third-party THIRDPARTYDIR := third-party
...@@ -101,34 +106,46 @@ THIRDPARTYINCLUDE := -I $(THIRDPARTYDIR)/include -I $(THIRDPARTYDIR)/include/rap ...@@ -101,34 +106,46 @@ THIRDPARTYINCLUDE := -I $(THIRDPARTYDIR)/include -I $(THIRDPARTYDIR)/include/rap
ifeq ($(PREFIX),) ifeq ($(PREFIX),)
PREFIX := /usr/local PREFIX := /usr/local
endif endif
LIB_DEST := $(PREFIX)/lib/$(PROJECT)/$(VERSION) LIB_DEST := $(PREFIX)/lib/$(PACKAGE)/$(VERSION)
EXTLIB := -L$(EXTLIBDIR) $(TEST_LIB) #no profiling
EXTLIB := -L$(EXTLIBDIR) $(TEST_LIB) $(TCMLIB) #no profiling
INC := -I src $(patsubst %,-Isrc/%/lib,$(SUBMAKEFILES)) -I test $(OMPINCLUDE) $(THIRDPARTYINCLUDE) INC := -I src $(patsubst %,-Isrc/%/lib,$(SUBMAKEFILES)) -I test $(OMPINCLUDE) $(THIRDPARTYINCLUDE)
ABEOBJECTSALL = $(patsubst $(ABESRCDIR)/%,$(ABEBINDIR)/%,$(patsubst %.cpp,%.o,$(ABESOURCES)))
#the name of the shared object library for palisade objects. #the name of the shared object library for palisade objects.
PALISADECORELIB := libPALISADEcore$(LIBSUFFIX) PALISADECORELIB := libPALISADEcore$(LIBSUFFIX)
PALISADEPKELIB := libPALISADEpke$(LIBSUFFIX) PALISADEPKELIB := libPALISADEpke$(LIBSUFFIX)
PALISADEABELIB := libPALISADEabe$(LIBSUFFIX)
PALISADESIGNATURELIB := libPALISADEsignature$(LIBSUFFIX)
PALISADEPYLIB := pycrypto$(LIBSUFFIX) PALISADEPYLIB := pycrypto$(LIBSUFFIX)
# run make for all components. you can run any individual component separately # run make for all components. you can run any individual component separately
# by invoking "make allxxx" for example, make allcore makes everything in core only # by invoking "make allxxx" for example, make allcore makes everything in core only
.PHONY: all
all: all:
$(MAKE) gmp_all $(MAKE) gmp_all
$(MAKE) ntl_all $(MAKE) ntl_all
$(MAKE) allcore allpke utall $(MAKE) allcore allpke allabe allsignature utall
.PHONY: docs
docs: apidocs docs: apidocs
.PHONY: alljava
alljava: allcore allpke jwrapper alljava: allcore allpke jwrapper
allpython: allcore allpke pywrapper .PHONY: allpython
allpython: allcore allpke alltrapdoor allwip pywrapper
alldemos: allcoredemos allpkedemos .PHONY: alldemos
alldemos: allcoredemos allpkedemos allabedemos allsignaturedemos
.PHONY: testall
testall: $(CORE_TEST_TARGET) $(PKE_TEST_TARGET) $(TRAPDOOR_TEST_TARGET) $(WIP_TEST_TARGET) $(CIRCUIT_TEST_TARGET) $(ABE_TEST_TARGET) $(SIGNATURE_TEST_TARGET) utall testall: $(CORE_TEST_TARGET) $(PKE_TEST_TARGET) $(TRAPDOOR_TEST_TARGET) $(WIP_TEST_TARGET) $(CIRCUIT_TEST_TARGET) $(ABE_TEST_TARGET) $(SIGNATURE_TEST_TARGET) utall
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(BINDIR)/unittest/tests$(EXESUFFIX) -t LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(BINDIR)/unittest/tests$(EXESUFFIX) -t
...@@ -136,7 +153,7 @@ testall: $(CORE_TEST_TARGET) $(PKE_TEST_TARGET) $(TRAPDOOR_TEST_TARGET) $(WIP_TE ...@@ -136,7 +153,7 @@ testall: $(CORE_TEST_TARGET) $(PKE_TEST_TARGET) $(TRAPDOOR_TEST_TARGET) $(WIP_TE
# by invoking "make cleantargets" for example # by invoking "make cleantargets" for example
# each corresponding makefile will make the cleanxxxx target # each corresponding makefile will make the cleanxxxx target
.PHONY: clean .PHONY: clean
clean: cleancore cleanpke cleandocs cleanbenchmark clean: cleancore cleanpke cleandocs cleanbenchmark cleanabe cleansignature
@echo 'Cleaning top level autogenerated directories' @echo 'Cleaning top level autogenerated directories'
$(RM) -rf $(BINDIR) $(RM) -rf $(BINDIR)
$(RM) -rf src/*/bin $(RM) -rf src/*/bin
...@@ -144,15 +161,26 @@ clean: cleancore cleanpke cleandocs cleanbenchmark ...@@ -144,15 +161,26 @@ clean: cleancore cleanpke cleandocs cleanbenchmark
.PHONY: clobber .PHONY: clobber
clobber: clean clean_gmp clean_ntl clobber: clean clean_gmp clean_ntl
.PHONY: libdir .PHONY: installdirs
libdir: installdirs:
install --directory $(LIB_DEST) install --directory $(LIB_DEST)
.PHONY: install .PHONY: install
install: installcore installpke install: installcore installpke installtrapdoor installwip installcircuit installabe installsignature
.PHONY: dist
dist:
mkdir $(PACKAGE)-$(VERSION)
cp $(EXTLIBDIR)/$(PALISADECORELIB) $(PACKAGE)-$(VERSION)
cp $(EXTLIBDIR)/$(PALISADEPKELIB) $(PACKAGE)-$(VERSION)
cp $(EXTLIBDIR)/$(PALISADEABELIB) $(PACKAGE)-$(VERSION)
cp $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(PACKAGE)-$(VERSION)
tar -zcvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
rm -rf $(PACKAGE)-$(VERSION)
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstallcore uninstallpke uninstall: uninstallcore uninstallpke uninstallabe uninstallsignature
UNITTESTMAINOBJ := $(BINDIR)/unittest/Main_TestAll.o UNITTESTMAINOBJ := $(BINDIR)/unittest/Main_TestAll.o
...@@ -160,10 +188,13 @@ $(UNITTESTMAINOBJ): test/include/gtest/Main_TestAll.cpp src/core/lib/math/backen ...@@ -160,10 +188,13 @@ $(UNITTESTMAINOBJ): test/include/gtest/Main_TestAll.cpp src/core/lib/math/backen
@mkdir -p $(BINDIR)/unittest @mkdir -p $(BINDIR)/unittest
$(CC) -c $(CPPFLAGS) $(INC) -o $@ $< $(CC) -c $(CPPFLAGS) $(INC) -o $@ $<
.PHONY: utall
utall: $(BINDIR)/unittest/tests$(EXESUFFIX) utall: $(BINDIR)/unittest/tests$(EXESUFFIX)
include Makefile.core include Makefile.core
include Makefile.pke include Makefile.pke
include Makefile.abe
include Makefile.signature
include Makefile.gmp include Makefile.gmp
include Makefile.ntl include Makefile.ntl
...@@ -171,6 +202,6 @@ include Makefile.ntl ...@@ -171,6 +202,6 @@ include Makefile.ntl
include Makefile.benchmark #builds the benchmark framework include Makefile.benchmark #builds the benchmark framework
include Makefile.docs #populates doxgen documentation include Makefile.docs #populates doxgen documentation
$(BINDIR)/unittest/tests$(EXESUFFIX): $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(PKEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEPKELIB) $(NTLLIB) $(GMPLIB) $(BINDIR)/unittest/tests$(EXESUFFIX): $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(PKEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEPKELIB) $(ABEUNITOBJECTS) $(EXTLIBDIR)/$(PALISADEABELIB) $(SIGNATUREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(BINDIR)/unittest @mkdir -p $(BINDIR)/unittest
$(CC) -o $@ $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(PKEUNITOBJECTS) $(EXTLIB) -lPALISADEpke -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB) $(CC) -o $@ $(UNITTESTMAINOBJ) $(COREUNITOBJECTS) $(PKEUNITOBJECTS) $(ABEUNITOBJECTS) $(SIGNATUREUNITOBJECTS) $(EXTLIB) -lPALISADEsignature -lPALISADEabe -lPALISADEpke -lPALISADEcore $(TEST_LIB) $(NTLLIB) $(GMPLIB)
...@@ -49,8 +49,9 @@ CORE_TEST_TARGET := $(EXTTESTDIR)/core/tests$(EXESUFFIX) ...@@ -49,8 +49,9 @@ CORE_TEST_TARGET := $(EXTTESTDIR)/core/tests$(EXESUFFIX)
-include $(COREDEMOOBJECTS:.o=.d) -include $(COREDEMOOBJECTS:.o=.d)
.PHONY: allcore .PHONY: allcore
allcore: ntl_all $(EXTLIBDIR)/$(PALISADECORELIB) $(CORE_TEST_TARGET) allcoredemos allcore: $(EXTLIBDIR)/$(PALISADECORELIB) $(CORE_TEST_TARGET) allcoredemos
.PHONY: allcoredemos
allcoredemos: $(EXTLIBDIR)/$(PALISADECORELIB) $(patsubst $(COREBINDIR)/demo/%,$(BINDIR)/demo/core/%,$(patsubst %.o,%$(EXESUFFIX),$(COREDEMOOBJECTS))) allcoredemos: $(EXTLIBDIR)/$(PALISADECORELIB) $(patsubst $(COREBINDIR)/demo/%,$(BINDIR)/demo/core/%,$(patsubst %.o,%$(EXESUFFIX),$(COREDEMOOBJECTS)))
$(BINDIR)/demo/core/%$(EXESUFFIX): $(COREBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB) $(BINDIR)/demo/core/%$(EXESUFFIX): $(COREBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
...@@ -83,7 +84,6 @@ $(COREBINDIR)/%: ...@@ -83,7 +84,6 @@ $(COREBINDIR)/%:
#this target is used to cleanup, it is called from the top Makefile #this target is used to cleanup, it is called from the top Makefile
.PHONY: cleancore .PHONY: cleancore
cleancore: cleancore:
$(RM) -fr $(COREBINDIR) $(EXTLIBDIR)/$(PALISADECORELIB) `dirname $(CORE_TEST_TARGET)` $(BINDIR)/demo/core $(RM) -fr $(COREBINDIR) $(EXTLIBDIR)/$(PALISADECORELIB) `dirname $(CORE_TEST_TARGET)` $(BINDIR)/demo/core
...@@ -98,13 +98,14 @@ testcore: $(CORE_TEST_TARGET) ...@@ -98,13 +98,14 @@ testcore: $(CORE_TEST_TARGET)
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(CORE_TEST_TARGET) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(CORE_TEST_TARGET)
.PHONY: installcore .PHONY: installcore
installcore: libdir installcore: installdirs
install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADECORELIB) install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADECORELIB)
.PHONY: uninstallcore .PHONY: uninstallcore
uninstallcore: uninstallcore:
rm $(LIB_DEST)/$(PALISADECORELIB) rm $(LIB_DEST)/$(PALISADECORELIB)
.PHONY: corestrings
corestrings: corestrings:
@echo $(CORESOURCES) @echo $(CORESOURCES)
@echo $(COREOBJECTS) @echo $(COREOBJECTS)
...@@ -38,5 +38,3 @@ $(INDEXFILE): ...@@ -38,5 +38,3 @@ $(INDEXFILE):
cleandocs: cleandocs:
@echo " Cleaning docs..." @echo " Cleaning docs..."
rm -rf doc/apidocs rm -rf doc/apidocs
...@@ -9,7 +9,7 @@ TAR ?= tar ...@@ -9,7 +9,7 @@ TAR ?= tar
#note change the following directory to the correct one on your install #note change the following directory to the correct one on your install
PALISADE_DIR := $(CURDIR) PALISADE_DIR := $(CURDIR)
GMP_VER :=6.1.2 GMP_VER := 6.1.2
#check if the palisade directory is correct #check if the palisade directory is correct
#ifneq ($(wildcard $(PALISADE_DIR)), ) #ifneq ($(wildcard $(PALISADE_DIR)), )
...@@ -53,31 +53,40 @@ endif ...@@ -53,31 +53,40 @@ endif
$(GMPLIB): gmp_all $(GMPLIB): gmp_all
.PHONY: gmp_all
gmp_all: $(GMP_UNPACK_NEEDED) $(GMP_CONFIG_NEEDED) $(GMP_MAKE_NEEDED) $(GMP_CHECK_NEEDED) $(GMP_INSTALL_NEEDED) gmp_all: $(GMP_UNPACK_NEEDED) $(GMP_CONFIG_NEEDED) $(GMP_MAKE_NEEDED) $(GMP_CHECK_NEEDED) $(GMP_INSTALL_NEEDED)
.PHONY: gmp_unpack
gmp_unpack: gmp_unpack:
@echo 'Unpacking gmp for Palisade into $(GMP_DISTRO_DIR)' @echo 'Unpacking gmp for Palisade into $(GMP_DISTRO_DIR)'
cd $(DISTROS_DIR);\ cd $(DISTROS_DIR);\
$(TAR) xf ./gmp-$(GMP_VER).tar.lz $(TAR) xf ./gmp-$(GMP_VER).tar.lz
.PHONY: gmp_config
gmp_config: $(GMP_UNPACK_NEEDED) gmp_config: $(GMP_UNPACK_NEEDED)
@echo 'Configuring gmp for Palisade in $(GMP_DISTRO_DIR)' @echo 'Configuring gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \ cd $(GMP_DISTRO_DIR); \
./configure --prefix=$(THIRD_PARTY_DIR); ./configure --prefix=$(THIRD_PARTY_DIR);
.PHONY: gmp_make
gmp_make: gmp_config gmp_make: gmp_config
@echo 'making gmp for Palisade in $(GMP_DISTRO_DIR)' @echo 'making gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \ cd $(GMP_DISTRO_DIR); \
$(MAKE) $(MAKE)
.PHONY: gmp_check
gmp_check: $(GMP_MAKE_NEEDED) gmp_check: $(GMP_MAKE_NEEDED)
@echo 'checking gmp for Palisade in $(GMP_DISTRO_DIR)' @echo 'checking gmp for Palisade in $(GMP_DISTRO_DIR)'
cd $(GMP_DISTRO_DIR); \ cd $(GMP_DISTRO_DIR); \
$(MAKE) check $(MAKE) check
.PHONY: gmp_install
gmp_install: $(GMP_CHECK_NEEDED) $(GMP_MAKE_NEEDED) gmp_install: $(GMP_CHECK_NEEDED) $(GMP_MAKE_NEEDED)
@echo 'installing gmp for Palisade in $(THIRD_PARTY_DIR)' @echo 'installing gmp for Palisade in $(THIRD_PARTY_DIR)'
cd $(GMP_DISTRO_DIR); \ cd $(GMP_DISTRO_DIR); \
$(MAKE) install $(MAKE) install
.PHONY: clean_gmp
clean_gmp: clean_gmp:
@echo 'Cleaning gmp installation' @echo 'Cleaning gmp installation'
cd $(DISTROS_DIR);\ cd $(DISTROS_DIR);\
......
...@@ -17,9 +17,23 @@ else ...@@ -17,9 +17,23 @@ else
#$(info GMP/NTL directory third-party does not exist) #$(info GMP/NTL directory third-party does not exist)
endif endif
## library for tcmalloc for linux machines
ifneq ($(wildcard third-party/lib/libtcmalloc_minimal.a), )
#$(info TCMALLOC library third-party/lib exists)
TCMLIB := third-party/lib/libtcmalloc_minimal.so
CPPSTD := -std=gnu++11 -fPIC -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
else
#$(info TCMALLOC directory third-party does not exist)
CPPSTD := -std=gnu++11 -fPIC
endif
##CPPSTD := -std=gnu++11 -fPIC ##CPPSTD := -std=gnu++11 -fPIC
CPPSTD := -std=gnu++11 -fPIC ##-mcmodel=large ## static allocator requires this memory model CPPSTD := -std=gnu++11 -fPIC ##-mcmodel=large ## static allocator requires this memory model
CC := g++ $(CPPSTD) CC := g++ $(CPPSTD)
LIBSUFFIX := .so LIBSUFFIX := .so
...@@ -35,5 +49,3 @@ LIBPYTHON := -lpython2.7 ...@@ -35,5 +49,3 @@ LIBPYTHON := -lpython2.7
COMPTHREADFLAG := -pthread COMPTHREADFLAG := -pthread
LOADTHREADFLAG := -pthread LOADTHREADFLAG := -pthread
...@@ -56,32 +56,41 @@ else ...@@ -56,32 +56,41 @@ else
NTL_INSTALL_NEEDED := ntl_install NTL_INSTALL_NEEDED := ntl_install
endif endif
.PHONY: ntl_all
ntl_all: $(GMP_NEEDED) $(NTL_UNPACK_NEEDED) $(NTL_CONFIG_NEEDED) $(NTL_MAKE_NEEDED) $(NTL_CHECK_NEEDED) $(NTL_INSTALL_NEEDED) ntl_all: $(GMP_NEEDED) $(NTL_UNPACK_NEEDED) $(NTL_CONFIG_NEEDED) $(NTL_MAKE_NEEDED) $(NTL_CHECK_NEEDED) $(NTL_INSTALL_NEEDED)
@echo $(all) @echo $(all)
.PHONY: ntl_unpack
ntl_unpack: ntl_unpack:
@echo 'Unpacking ntl for Palisade into $(NTL_DISTRO_DIR)' @echo 'Unpacking ntl for Palisade into $(NTL_DISTRO_DIR)'
cd $(DISTROS_DIR);\ cd $(DISTROS_DIR);\
$(TAR) xf ./ntl-$(NTL_VER).tar.gz $(TAR) xf ./ntl-$(NTL_VER).tar.gz
.PHONY: ntl_config
ntl_config: $(NTL_UNPACK_NEEDED) ntl_config: $(NTL_UNPACK_NEEDED)
@echo 'Configuring ntl for Palisade in $(NTL_DISTRO_DIR)' @echo 'Configuring ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(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 ./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
.PHONY: ntl_make
ntl_make: ntl_config ntl_make: ntl_config
@echo 'making ntl for Palisade in $(NTL_DISTRO_DIR)' @echo 'making ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(NTL_DISTRO_DIR); \ cd $(NTL_DISTRO_DIR); \
$(MAKE) $(MAKE)
.PHONY: ntl_check
ntl_check: $(NTL_MAKE_NEEDED) ntl_check: $(NTL_MAKE_NEEDED)
@echo 'checking ntl for Palisade in $(NTL_DISTRO_DIR)' @echo 'checking ntl for Palisade in $(NTL_DISTRO_DIR)'
cd $(NTL_DISTRO_DIR); \ cd $(NTL_DISTRO_DIR); \
$(MAKE) check $(MAKE) check
.PHONY: ntl_install
ntl_install: $(NTL_CHECK_NEEDED) $(NTL_MAKE_NEEDED) ntl_install: $(NTL_CHECK_NEEDED) $(NTL_MAKE_NEEDED)
@echo 'installing ntl for Palisade in $(THIRD_PARTY_DIR)' @echo 'installing ntl for Palisade in $(THIRD_PARTY_DIR)'
cd $(NTL_DISTRO_DIR); \ cd $(NTL_DISTRO_DIR); \
$(MAKE) install $(MAKE) install
.PHONY: clean_ntl
clean_ntl: clean_ntl:
@echo 'Cleaning ntl installation' @echo 'Cleaning ntl installation'
cd $(DISTROS_DIR);\ cd $(DISTROS_DIR);\
......
...@@ -49,7 +49,7 @@ PKE_TEST_TARGET := $(EXTTESTDIR)/pke/tests$(EXESUFFIX) ...@@ -49,7 +49,7 @@ PKE_TEST_TARGET := $(EXTTESTDIR)/pke/tests$(EXESUFFIX)
-include $(PKEUNITOBJECTS:.o=.d) -include $(PKEUNITOBJECTS:.o=.d)
-include $(PKEDEMOOBJECTS:.o=.d) -include $(PKEDEMOOBJECTS:.o=.d)
.PHONY:allpke .PHONY: allpke
allpke: allcore $(EXTLIBDIR)/$(PALISADEPKELIB) $(PKE_TEST_TARGET) allpkedemos allpke: allcore $(EXTLIBDIR)/$(PALISADEPKELIB) $(PKE_TEST_TARGET) allpkedemos
allpkedemos: $(patsubst $(PKEBINDIR)/demo/%,$(BINDIR)/demo/pke/%,$(patsubst %.o,%$(EXESUFFIX),$(PKEDEMOOBJECTS))) allpkedemos: $(patsubst $(PKEBINDIR)/demo/%,$(BINDIR)/demo/pke/%,$(patsubst %.o,%$(EXESUFFIX),$(PKEDEMOOBJECTS)))
...@@ -82,9 +82,8 @@ $(PKEBINDIR)/%: ...@@ -82,9 +82,8 @@ $(PKEBINDIR)/%:
$(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(PKEBINDIR)/%,$(PKESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\ $(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(PKEBINDIR)/%,$(PKESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
fi fi
.PHONY: cleanpke
#this target is used to cleanup, it is called from the top Makefile #this target is used to cleanup, it is called from the top Makefile
.PHONY: cleanpke
cleanpke: cleanpke:
$(RM) -fr $(PKEBINDIR) $(EXTLIBDIR)/$(PALISADEPKELIB) `dirname $(PKE_TEST_TARGET)` $(BINDIR)/demo/pke $(RM) -fr $(PKEBINDIR) $(EXTLIBDIR)/$(PALISADEPKELIB) `dirname $(PKE_TEST_TARGET)` $(BINDIR)/demo/pke
...@@ -99,7 +98,7 @@ testpke: $(PKE_TEST_TARGET) ...@@ -99,7 +98,7 @@ testpke: $(PKE_TEST_TARGET)
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(PKE_TEST_TARGET) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(ROOTDIR)/$(THIRDPARTYLIBDIR):$(ROOTDIR)/$(EXTLIBDIR) $(PKE_TEST_TARGET)
.PHONY: installpke .PHONY: installpke
installpke: libdir installpke: installdirs
install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADEPKELIB) install -t $(LIB_DEST) $(EXTLIBDIR)/$(PALISADEPKELIB)
.PHONY: uninstallpke .PHONY: uninstallpke
......
#
#Copyright (c) 2015, New Jersey Institute of Technology (NJIT)
#All rights reserved.
#Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
#met:
#1. Redistributions of source code must retain the above copyright
#notice, this list of conditions and the following disclaimer.
#2. Redistributions in binary form must reproduce the above copyright
#notice, this list of conditions and the following disclaimer in the
#documentation and/or other materials provided with the distribution.
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
#IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
#TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
#PARTICULAR PURPOSE ARE DISCLAIMED.
#IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
#OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
#STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
#IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#POSSIBILITY OF SUCH DAMAGE.
#
################
# Makefile.signature builds the attribute-based encryption components of the PALISADE library
# Includes unit tests and demos
################
SIGNATURESRCDIR := src/signature
SIGNATUREBINDIR := $(BINDIR)/build/signature
SIGNATURETESTDIR := src/signature/unittest
SIGNATUREDEMODIR := src/signature/demo
SIGNATURESOURCES := $(shell find $(SIGNATURESRCDIR)/lib -name '*.cpp' ! -name '*-public.cpp')
SIGNATUREUNITSOURCES := $(wildcard $(SIGNATURESRCDIR)/unittest/*.cpp)
SIGNATUREDEMOSOURCES := $(wildcard $(SIGNATURESRCDIR)/demo/*.cpp)
SIGNATUREOBJECTSALL = $(patsubst $(SIGNATURESRCDIR)/%,$(SIGNATUREBINDIR)/%,$(patsubst %.cpp,%.o,$(SIGNATURESOURCES)))
SIGNATUREOBJECTS = $(filter %-impl.o,$(SIGNATUREOBJECTSALL))
SIGNATUREUNITOBJECTS := $(patsubst $(SIGNATURESRCDIR)/%,$(SIGNATUREBINDIR)/%,$(patsubst %.cpp,%.o,$(SIGNATUREUNITSOURCES)))
SIGNATUREDEMOOBJECTS += $(patsubst $(SIGNATURESRCDIR)/%,$(SIGNATUREBINDIR)/%,$(patsubst %.cpp,%.o,$(SIGNATUREDEMOSOURCES)))
SIGNATURE_TEST_TARGET := $(EXTTESTDIR)/signature/tests$(EXESUFFIX)
-include $(SIGNATUREOBJECTS:.o=.d)
-include $(SIGNATUREUNITOBJECTS:.o=.d)
-include $(SIGNATUREDEMOOBJECTS:.o=.d)
.PHONY: allsignature
allsignature: allcore $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(SIGNATURE_TEST_TARGET) allsignaturedemos
.PHONY: allsignaturedemos
allsignaturedemos: $(patsubst $(SIGNATUREBINDIR)/demo/%,$(BINDIR)/demo/signature/%,$(patsubst %.o,%$(EXESUFFIX),$(SIGNATUREDEMOOBJECTS)))
$(BINDIR)/demo/signature/%$(EXESUFFIX): $(SIGNATUREBINDIR)/demo/%.o $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p $(@D)
$(CC) -o $@ $< $(EXTLIB) -lPALISADEsignature -lPALISADEcore $(NTLLIB) $(GMPLIB)
#this builds the palisade library out of the objects
$(EXTLIBDIR)/$(PALISADESIGNATURELIB): $(SIGNATUREOBJECTS) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@echo " -- signature:linking $@ from SIGNATUREOBJECTS"
@mkdir -p $(EXTLIBDIR)
ifdef COVERAGE
$(LIBCMD) $@ $(SIGNATUREOBJECTS)
else
$(LIBCMD) $@ $(SIGNATUREOBJECTS) $(EXTLIB) -lPALISADEcore $(NTLLIB) $(GMPLIB)
endif
### #this builds the individual objects that make up the library .
.PRECIOUS: $(SIGNATUREBINDIR)/%
$(SIGNATUREBINDIR)/%:
@if [ "$(suffix $@)" = ".o" ] ; \
then \
mkdir -p $(@D) ;\
echo $(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(SIGNATUREBINDIR)/%,$(SIGNATURESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
$(CC) -MM $(CPPFLAGS) $(INC) $(patsubst $(SIGNATUREBINDIR)/%,$(SIGNATURESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) > $(patsubst %.o,%.d,$@) ;\
mv -f $(patsubst %.o,%.d,$@) $(patsubst %.o,%.d.tmp,$@) ;\
sed -e 's|.*\.o:|$(SIGNATUREBINDIR)/$*:|' < $(patsubst %.o,%.d.tmp,$@) > $(patsubst %.o,%.d,$@) ;\
rm -f $(patsubst %.o,%.d.tmp,$@) ; \
$(CC) $(CPPFLAGS) $(INC) -c -o $@ $(patsubst $(SIGNATUREBINDIR)/%,$(SIGNATURESRCDIR)/%,$(patsubst %.o,%.cpp,$@)) ;\
fi
#this target is used to cleanup, it is called from the top Makefile
.PHONY: cleansignature
cleansignature:
$(RM) -fr $(SIGNATUREBINDIR) $(EXTLIBDIR)/$(PALISADESIGNATURELIB) `dirname $(SIGNATURE_TEST_TARGET)` $(BINDIR)/demo/signature
# this links test executable from objects in the test build directory
$(SIGNATURE_TEST_TARGET): $(UNITTESTMAINOBJ) $(SIGNATUREUNITOBJECTS) $(EXTLIBDIR)/$(PALISADESIGNATURELIB) $(EXTLIBDIR)/$(PALISADECORELIB) $(NTLLIB) $(GMPLIB)
@mkdir -p `dirname $(SIGNATURE_TEST_TARGET)`