RGSRC=../../
include $(RGSRC)/envir.mak

CONFIG_FLAGS = --host=$(TARGET_MACHINE) --target=$(TARGET_MACHINE)
ifeq ($(ARCH),arm)
  CONFIG_FLAGS = --host=arm-linux --target=arm-linux --build=i386-linux
endif
ifeq ($(ARCH),mips)
  CONFIG_FLAGS = --host=mips-linux --target=mips-linux --build=i386-linux
endif
ifeq ($(ARCH),i386)
  CONFIG_FLAGS = --host=i386-linux --target=i386-linux --build=i386-linux
endif
ifeq ($(ARCH),um)
  CONFIG_FLAGS = --host=i386-linux --target=i386-linux --build=i386-linux
endif
gmpMakefile=gmp.created_by_configure.mak
export gmpMakefile

all: archconfig dummy 
	if test -f $(gmpMakefile); then \
	$(MAKE) -f $(gmpMakefile) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
	AR=$(AR) RANLIB=$(RANLIB) Makefile=$(gmpMakefile);\
	fi

archconfig: .configure dummy

#XXX a hack so dep will not fail.
dep:

.configure: 
ifndef DIST
	@echo 'error - give param DIST' && false
endif	
	@touch .top_level
	./configure $(CONFIG_FLAGS)
	@rm -f .top_level
	@touch .configure

distclean clean:
	if test -f $(gmpMakefile); then \
	$(MAKE) -f $(gmpMakefile) Makefile=$(gmpMakefile) clean; \
	$(MAKE) -f $(gmpMakefile) Makefile=$(gmpMakefile) distclean; \
	fi
	@rm -f .configure

ifdef CONFIG_DYN_LINK
  RAMDISK_LIB_FILES=libgmp.so.2.0.2
endif
CD_EXPORTED_FILES=$(shell find . -name "*.in") $(shell find . -name "*.[chSs]") configure config.sub move-if-change
include $(COPY_DB)

ifdef CONFIG_DYN_LINK
ramdisk::
	$(call RAMDISK_LN_FUNC,libgmp.so.2.0.2,$(RAMDISK_RW_LIB_DIR)/libgmp.so.2)
endif

force:
.PNONY: check install install-bsdmp install-info-files install-strip uninstall
.PHONY: all clean archconfig distclean ramdisk
