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
41 INSTALL_HEADERS += gmp/gmp.h
43 $(eval $(call all-target,gmp_dynamic,gmp/libgmp.a))
45 ifeq "$(BUILD_SHARED)" "yes"
46 $(eval $(call all-target,gmp_dynamic,gmp/libgmp.dll.a gmp/libgmp-3.dll))
52 PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
56 # is not a valid command on non-Cygwin-systems.
57 # Let it fail silently instead of aborting the build.
61 # set -o igncr; export SHELLOPTS
62 # here as otherwise checking the size of limbs
63 # makes the build fall over on Cygwin. See the thread
64 # http://www.cygwin.com/ml/cygwin/2006-12/msg00011.html
70 # isn't sufficient to stop cygwin using symlinks the mingw gcc can't
71 # follow, as it isn't used consistently. Instead we put an ln.bat in
72 # path that always fails.
74 # We use a tarball like gmp-4.2.4-nodoc.tar.bz2, which is
75 # gmp-4.2.4.tar.bz2 repacked without the doc/ directory contents.
76 # That's because the doc/ directory contents are under the GFDL,
77 # which causes problems for Debian.
79 GMP_TARBALL := $(wildcard gmp/tarball/gmp*.tar.bz2)
80 GMP_DIR := $(patsubst gmp/tarball/%-nodoc.tar.bz2,%,$(GMP_TARBALL))
82 gmp/libgmp.a gmp/gmp.h:
83 $(RM) -rf $(GMP_DIR) gmp/gmpbuild
84 cd gmp && $(TAR) -jxf ../$(GMP_TARBALL)
85 mv gmp/$(GMP_DIR) gmp/gmpbuild
87 cd gmp; (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
91 CC=$(WhatGccIsCalled) $(SHELL) configure \
92 --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
93 $(MAKE) -C gmp/gmpbuild MAKEFLAGS=
94 $(CP) gmp/gmpbuild/gmp.h gmp/
95 $(CP) gmp/gmpbuild/.libs/libgmp.a gmp/
96 $(RANLIB) gmp/libgmp.a
98 ifneq "$(NO_CLEAN_GMP)" "YES"
99 $(eval $(call clean-target,gmp,,\
100 gmp/libgmp.a gmp/gmp.h gmp/gmpbuild gmp/$(GMP_DIR)))
105 # $(RM) -rf $(GMP_DIR) gmpbuild-shared
106 # $(TAR) -zxf $(GMP_TARBALL)
107 # mv $(GMP_DIR) gmpbuild-shared
109 # (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
110 # PATH=`pwd`:$$PATH; \
112 # cd gmpbuild-shared && \
113 # CC=$(WhatGccIsCalled) $(SHELL) configure \
114 # --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
117 #gmp.h: stamp.gmp.static
118 # $(CP) gmpbuild/gmp.h .
120 #libgmp.a: stamp.gmp.static
122 #libgmp-3.dll: stamp.gmp.shared
123 # $(MAKE) -C gmpbuild-shared MAKEFLAGS=
124 # $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
126 #libgmp.dll.a: libgmp-3.dll
127 # $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
129 ## GMP takes a long time to build, but changes rarely. Hence we don't
130 ## bother cleaning it before validating, because that adds a
131 ## significant overhead to validation.
132 #ifeq "$(Validating)" "NO"
133 #clean distclean maintainer-clean ::
134 # $(RM) -f stamp.gmp.static stamp.gmp.shared
136 # $(RM) -rf gmpbuild-shared