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 # We use a tarball like gmp-4.2.1-nodoc.tar.gz, which is
38 # gmp-4.2.1.tar.gz repacked without the doc/ directory contents.
39 # That's because the doc/ directory contents are under the GFDL,
40 # which causes problems for Debian.
42 GMP_TARBALL := $(firstword $(wildcard gmp*.tar.gz))
43 GMP_DIR := $(subst -nodoc.tar.gz,,$(GMP_TARBALL))
45 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
51 BINDIST_STAMPS = stamp.gmp.static
52 INSTALL_HEADERS += gmp.h
53 INSTALL_LIBS += libgmp.a
55 ifeq "$(BUILD_SHARED)" "yes"
56 BINDIST_STAMPS += stamp.gmp.shared
57 INSTALL_LIBS += libgmp.dll.a
58 INSTALL_PROGS += libgmp-3.dll
61 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
64 $(RM) -rf $(GMP_DIR) gmpbuild
65 $(TAR) -zxf $(GMP_TARBALL)
66 mv $(GMP_DIR) gmpbuild
68 (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
72 CC=$(WhatGccIsCalled) $(SHELL) configure \
73 --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
77 $(RM) -rf $(GMP_DIR) gmpbuild-shared
78 $(TAR) -zxf $(GMP_TARBALL)
79 mv $(GMP_DIR) gmpbuild-shared
81 (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
84 cd gmpbuild-shared && \
85 CC=$(WhatGccIsCalled) $(SHELL) configure \
86 --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
89 gmp.h: stamp.gmp.static
90 $(CP) gmpbuild/gmp.h .
92 libgmp.a: stamp.gmp.static
93 $(MAKE) -C gmpbuild MAKEFLAGS=
94 $(CP) gmpbuild/.libs/libgmp.a .
97 libgmp-3.dll: stamp.gmp.shared
98 $(MAKE) -C gmpbuild-shared MAKEFLAGS=
99 $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
101 libgmp.dll.a: libgmp-3.dll
102 $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
106 # GMP takes a long time to build, but changes rarely. Hence we don't
107 # bother cleaning it before validating, because that adds a
108 # significant overhead to validation.
109 ifeq "$(Validating)" "NO"
110 clean distclean maintainer-clean ::
111 $(RM) -f stamp.gmp.static stamp.gmp.shared
113 $(RM) -rf gmpbuild-shared
116 #-----------------------------------------------------------------------------
120 include $(TOP)/mk/target.mk
122 BINDIST_EXTRAS += $(BINDIST_STAMPS)
123 BINDIST_EXTRAS += $(INSTALL_PROGS)
124 BINDIST_EXTRAS += $(INSTALL_LIBS)
125 BINDIST_EXTRAS += $(INSTALL_HEADERS)
126 include $(TOP)/mk/bindist.mk