# This file is part of the FreeWRT project. FreeWRT is copyrighted
# material, please see the LICENCE file in the top-level directory

include $(TOPDIR)/rules.mk
include ../rules.mk

GMP_VERSION:=6.3.0
GMP_SITE:=@GNU/gmp
SOURCE:=gmp-$(GMP_VERSION).tar.gz
GMP_MD5SUM:=3390cf8cc96bbec5a9123f2fb22480db
GMP_DIR:=$(TOOLCHAIN_BUILD_DIR)/gmp-$(GMP_VERSION)

$(DL_DIR)/$(SOURCE):
	mkdir -p $(DL_DIR)
	$(SCRIPT_DIR)/download.pl $(DL_DIR) $(SOURCE) $(GMP_MD5SUM) $(GMP_SITE)

$(GMP_DIR)/.unpacked: $(DL_DIR)/$(SOURCE)
	${EXTRACT_CMD}
	touch $(GMP_DIR)/.unpacked

$(GMP_DIR)/.configured: $(GMP_DIR)/.unpacked
	mkdir -p $(GMP_DIR)
	(cd $(GMP_DIR); \
		$(GMP_DIR)/configure \
		--prefix=$(STAGING_HOST_DIR)/usr \
		--with-pic \
		--disable-shared \
		--enable-static \
	);
	touch $(GMP_DIR)/.configured

$(GMP_DIR)/.compiled: $(GMP_DIR)/.configured
	$(MAKE) -C $(GMP_DIR) all
	touch $(GMP_DIR)/.compiled

$(GMP_DIR)/.installed: $(GMP_DIR)/.compiled
	$(MAKE) -C $(GMP_DIR) install
	touch $(GMP_DIR)/.installed

source: $(DL_DIR)/$(SOURCE)
prepare: $(GMP_DIR)/.unpacked
compile: $(GMP_DIR)/.compiled
install: $(GMP_DIR)/.installed
clean:
	rm -rf $(GMP_DIR)
