4 include $(TOP)/mk/boilerplate.mk
6 # -----------------------------------------------------------------------------
7 # Compile GMP only if we don't have it already
9 # We use GMP's own configuration stuff, because it's all rather hairy
10 # and not worth re-implementing in our Makefile framework.
12 ifneq "$(HaveLibGmp)" "YES"
13 ifneq "$(HaveFrameworkGMP)" "YES"
15 PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
19 # is not a valid command on non-Cygwin-systems.
20 # Let it fail silently instead of aborting the build.
24 # set -o igncr; export SHELLOPTS
25 # here as otherwise checking the size of limbs
26 # makes the build fall over on Cygwin. See the thread
27 # http://www.cygwin.com/ml/cygwin/2006-12/msg00011.html
33 # isn't sufficient to stop cygwin using symlinks the mingw gcc can't
34 # follow, as it isn't used consistently. Instead we put an ln.bat in
35 # path that always fails.
37 GMP_TARBALL := $(firstword $(wildcard gmp*.tar.gz))
38 GMP_DIR := $(subst .tar.gz,,$(GMP_TARBALL))
39 BMP_BUILD_DIR := build
41 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
47 boot :: stamp.gmp.static
48 BINDIST_STAMPS = stamp.gmp.static
49 INSTALL_HEADERS += gmp.h
50 INSTALL_LIBS += libgmp.a
52 ifeq "$(BUILD_SHARED)" "yes"
53 boot :: stamp.gmp.shared
54 BINDIST_STAMPS += stamp.gmp.shared
55 INSTALL_LIBS += libgmp.dll.a
56 INSTALL_PROGS += libgmp-3.dll
59 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
62 $(RM) -rf $(GMP_DIR) gmpbuild
63 $(TAR) -zxf $(GMP_TARBALL)
64 mv $(GMP_DIR) gmpbuild
66 (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
70 CC=$(WhatGccIsCalled) $(SHELL) configure \
71 --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
75 $(RM) -rf $(GMP_DIR) gmpbuild-shared
76 $(TAR) -zxf $(GMP_TARBALL)
77 mv $(GMP_DIR) gmpbuild-shared
79 (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
82 cd gmpbuild-shared && \
83 CC=$(WhatGccIsCalled) $(SHELL) configure \
84 --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
87 gmp.h: stamp.gmp.static
88 $(CP) gmpbuild/gmp.h .
90 libgmp.a: stamp.gmp.static
91 $(MAKE) -C gmpbuild MAKEFLAGS=
92 $(CP) gmpbuild/.libs/libgmp.a .
95 libgmp-3.dll: stamp.gmp.shared
96 $(MAKE) -C gmpbuild-shared MAKEFLAGS=
97 $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
99 libgmp.dll.a: libgmp-3.dll
100 $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
104 # GMP takes a long time to build, but changes rarely. Hence we don't
105 # bother cleaning it before validating, because that adds a
106 # significant overhead to validation.
107 ifeq "$(Validating)" "NO"
108 clean distclean maintainer-clean ::
109 $(RM) -f stamp.gmp.static stamp.gmp.shared
111 $(RM) -rf gmpbuild-shared
114 #-----------------------------------------------------------------------------
118 include $(TOP)/mk/target.mk
121 $(INSTALL_DIR) $(BIN_DIST_DIR)/gmp
122 $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/gmp/
123 ifneq "$(HaveLibGmp)" "YES"
124 ifneq "$(HaveFrameworkGMP)" "YES"
125 $(INSTALL_DATA) $(BINDIST_STAMPS) $(BIN_DIST_DIR)/gmp/
126 ifneq "$(INSTALL_PROGS)" ""
127 $(INSTALL_DATA) $(INSTALL_PROGS) $(BIN_DIST_DIR)/gmp/
129 ifneq "$(INSTALL_LIBS)" ""
130 $(INSTALL_DATA) $(INSTALL_LIBS) $(BIN_DIST_DIR)/gmp/
132 ifneq "$(INSTALL_HEADERS)" ""
133 $(INSTALL_HEADER) $(INSTALL_HEADERS) $(BIN_DIST_DIR)/gmp/