Makefile.gmp 2.32 KB
Newer Older
Gerard Ryan's avatar
Gerard Ryan committed
1 2 3 4 5 6 7 8 9 10
#Makefile to build and install gmp in palisade





TAR ?= tar 

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

Gerard Ryan's avatar
Gerard Ryan committed
11
PALISADE_DIR := $(CURDIR)
Gerard Ryan's avatar
Gerard Ryan committed
12
GMP_VER := 6.1.2
Gerard Ryan's avatar
Gerard Ryan committed
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

#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

Gerard Ryan's avatar
Gerard Ryan committed
56
.PHONY: gmp_all
Gerard Ryan's avatar
Gerard Ryan committed
57 58
gmp_all: $(GMP_UNPACK_NEEDED) $(GMP_CONFIG_NEEDED) $(GMP_MAKE_NEEDED) $(GMP_CHECK_NEEDED) $(GMP_INSTALL_NEEDED)

Gerard Ryan's avatar
Gerard Ryan committed
59
.PHONY: gmp_unpack
Gerard Ryan's avatar
Gerard Ryan committed
60 61 62 63 64
gmp_unpack: 
	@echo 'Unpacking gmp for Palisade into $(GMP_DISTRO_DIR)'
	cd $(DISTROS_DIR);\
	$(TAR) xf ./gmp-$(GMP_VER).tar.lz

Gerard Ryan's avatar
Gerard Ryan committed
65
.PHONY: gmp_config
Gerard Ryan's avatar
Gerard Ryan committed
66 67 68 69 70
gmp_config: $(GMP_UNPACK_NEEDED)
	@echo 'Configuring gmp for Palisade in $(GMP_DISTRO_DIR)'
	cd $(GMP_DISTRO_DIR); \
	./configure --prefix=$(THIRD_PARTY_DIR);

Gerard Ryan's avatar
Gerard Ryan committed
71
.PHONY: gmp_make
Gerard Ryan's avatar
Gerard Ryan committed
72 73 74 75 76
gmp_make: gmp_config
	@echo 'making gmp for Palisade in $(GMP_DISTRO_DIR)'
	cd $(GMP_DISTRO_DIR); \
	$(MAKE)

Gerard Ryan's avatar
Gerard Ryan committed
77
.PHONY: gmp_check
Gerard Ryan's avatar
Gerard Ryan committed
78 79 80 81
gmp_check: $(GMP_MAKE_NEEDED)
	@echo 'checking gmp for Palisade in $(GMP_DISTRO_DIR)'
	cd $(GMP_DISTRO_DIR); \
	$(MAKE) check
Gerard Ryan's avatar
Gerard Ryan committed
82 83

.PHONY: gmp_install
Gerard Ryan's avatar
Gerard Ryan committed
84 85 86 87
gmp_install: $(GMP_CHECK_NEEDED) $(GMP_MAKE_NEEDED)
	@echo 'installing gmp for Palisade in $(THIRD_PARTY_DIR)'
	cd $(GMP_DISTRO_DIR); \
	$(MAKE) install
Gerard Ryan's avatar
Gerard Ryan committed
88 89

.PHONY: clean_gmp
Gerard Ryan's avatar
Gerard Ryan committed
90 91 92 93 94
clean_gmp:
	@echo 'Cleaning gmp installation'
	cd $(DISTROS_DIR);\
	$(RM) -rf gmp-$(GMP_VER)
	cd $(THIRD_PARTY_DIR); \
Gerard Ryan's avatar
Gerard Ryan committed
95
	$(RM) -rf include/gmp.h lib share