Makefile.ntl 2.77 KB
Newer Older
Gerard Ryan's avatar
Gerard Ryan committed
1 2 3 4 5 6
#Makefile to build and install ntl in palisade

TAR ?= tar 

#note change the following directory to the correct one on your install

Gerard Ryan's avatar
Gerard Ryan committed
7
PALISADE_DIR := $(CURDIR)
Gerard Ryan's avatar
Gerard Ryan committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
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

Gerard Ryan's avatar
Gerard Ryan committed
59
.PHONY: ntl_all
Gerard Ryan's avatar
Gerard Ryan committed
60 61 62
ntl_all: $(GMP_NEEDED) $(NTL_UNPACK_NEEDED) $(NTL_CONFIG_NEEDED) $(NTL_MAKE_NEEDED) $(NTL_CHECK_NEEDED) $(NTL_INSTALL_NEEDED)
	@echo $(all)

Gerard Ryan's avatar
Gerard Ryan committed
63
.PHONY: ntl_unpack
Gerard Ryan's avatar
Gerard Ryan committed
64 65 66 67 68
ntl_unpack: 
	@echo 'Unpacking ntl for Palisade into $(NTL_DISTRO_DIR)'
	cd $(DISTROS_DIR);\
	$(TAR) xf ./ntl-$(NTL_VER).tar.gz

Gerard Ryan's avatar
Gerard Ryan committed
69
.PHONY: ntl_config
Gerard Ryan's avatar
Gerard Ryan committed
70 71 72 73 74
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

Gerard Ryan's avatar
Gerard Ryan committed
75
.PHONY: ntl_make
Gerard Ryan's avatar
Gerard Ryan committed
76 77 78 79 80
ntl_make: ntl_config
	@echo 'making ntl for Palisade in $(NTL_DISTRO_DIR)'
	cd $(NTL_DISTRO_DIR); \
	$(MAKE)

Gerard Ryan's avatar
Gerard Ryan committed
81
.PHONY: ntl_check
Gerard Ryan's avatar
Gerard Ryan committed
82 83 84 85
ntl_check: $(NTL_MAKE_NEEDED)
	@echo 'checking ntl for Palisade in $(NTL_DISTRO_DIR)'
	cd $(NTL_DISTRO_DIR); \
	$(MAKE) check
Gerard Ryan's avatar
Gerard Ryan committed
86 87

.PHONY: ntl_install
Gerard Ryan's avatar
Gerard Ryan committed
88 89 90 91
ntl_install: $(NTL_CHECK_NEEDED) $(NTL_MAKE_NEEDED)
	@echo 'installing ntl for Palisade in $(THIRD_PARTY_DIR)'
	cd $(NTL_DISTRO_DIR); \
	$(MAKE) install
Gerard Ryan's avatar
Gerard Ryan committed
92 93

.PHONY: clean_ntl
Gerard Ryan's avatar
Gerard Ryan committed
94 95 96 97 98
clean_ntl:
	@echo 'Cleaning ntl installation'
	cd $(DISTROS_DIR);\
	$(RM) -rf ntl-$(NTL_VER)
	cd $(THIRD_PARTY_DIR); \
Gerard Ryan's avatar
Gerard Ryan committed
99
	$(RM) -rf include/NTL lib share includels