1 # -----------------------------------------------------------------------------
3 # (c) 2009 The University of Glasgow
5 # This file is part of the GHC build system.
7 # To understand how the build system works and how to modify it, see
8 # http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
11 # -----------------------------------------------------------------------------
14 # Compile GMP only if we don't have it already
16 # We use GMP's own configuration stuff, because it's all rather hairy
17 # and not worth re-implementing in our Makefile framework.
19 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
25 # In a bindist, we don't want to know whether /this/ machine has gmp,
26 # but whether the machine the bindist was built on had gmp.
27 ifeq "$(BINDIST)" "YES"
28 ifeq "$(wildcard gmp/libgmp.a)" ""
30 HaveFrameworkGMP = YES
37 ifneq "$(HaveLibGmp)" "YES"
38 ifneq "$(HaveFrameworkGMP)" "YES"
40 INSTALL_LIBS += gmp/libgmp.a
42 $(eval $(call all-target,gmp_dynamic,gmp/libgmp.a))
44 ifeq "$(BUILD_SHARED)" "yes"
45 $(eval $(call all-target,gmp_dynamic,gmp/libgmp.dll.a gmp/libgmp-3.dll))
51 PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
55 # is not a valid command on non-Cygwin-systems.
56 # Let it fail silently instead of aborting the build.
60 # set -o igncr; export SHELLOPTS
61 # here as otherwise checking the size of limbs
62 # makes the build fall over on Cygwin. See the thread
63 # http://www.cygwin.com/ml/cygwin/2006-12/msg00011.html
69 # isn't sufficient to stop cygwin using symlinks the mingw gcc can't
70 # follow, as it isn't used consistently. Instead we put an ln.bat in
71 # path that always fails.
73 # We use a tarball like gmp-4.2.4-nodoc.tar.bz2, which is
74 # gmp-4.2.4.tar.bz2 repacked without the doc/ directory contents.
75 # That's because the doc/ directory contents are under the GFDL,
76 # which causes problems for Debian.
78 GMP_TARBALL := $(wildcard gmp/tarball/gmp*.tar.bz2)
79 GMP_DIR := $(patsubst gmp/tarball/%-nodoc.tar.bz2,%,$(GMP_TARBALL))
81 # XXX INSTALL_HEADERS += gmp.h
84 $(RM) -rf $(GMP_DIR) gmp/gmpbuild
85 cd gmp && $(TAR) -jxf ../$(GMP_TARBALL)
86 mv gmp/$(GMP_DIR) gmp/gmpbuild
88 cd gmp; (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
92 CC=$(WhatGccIsCalled) $(SHELL) configure \
93 --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
94 $(MAKE) -C gmp/gmpbuild MAKEFLAGS=
95 $(CP) gmp/gmpbuild/.libs/libgmp.a gmp/
96 $(RANLIB) gmp/libgmp.a
98 $(eval $(call clean-target,gmp,,\
99 gmp/libgmp.a gmp/gmpbuild gmp/$(GMP_DIR)))
103 # $(RM) -rf $(GMP_DIR) gmpbuild-shared
104 # $(TAR) -zxf $(GMP_TARBALL)
105 # mv $(GMP_DIR) gmpbuild-shared
107 # (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
108 # PATH=`pwd`:$$PATH; \
110 # cd gmpbuild-shared && \
111 # CC=$(WhatGccIsCalled) $(SHELL) configure \
112 # --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
115 #gmp.h: stamp.gmp.static
116 # $(CP) gmpbuild/gmp.h .
118 #libgmp.a: stamp.gmp.static
120 #libgmp-3.dll: stamp.gmp.shared
121 # $(MAKE) -C gmpbuild-shared MAKEFLAGS=
122 # $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
124 #libgmp.dll.a: libgmp-3.dll
125 # $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
127 ## GMP takes a long time to build, but changes rarely. Hence we don't
128 ## bother cleaning it before validating, because that adds a
129 ## significant overhead to validation.
130 #ifeq "$(Validating)" "NO"
131 #clean distclean maintainer-clean ::
132 # $(RM) -f stamp.gmp.static stamp.gmp.shared
134 # $(RM) -rf gmpbuild-shared