Update the in-tree GMP; fixes trac #832
[ghc-hetmet.git] / gmp / Makefile
1
2 TOP=..
3
4 include $(TOP)/mk/boilerplate.mk
5
6 # -----------------------------------------------------------------------------
7 # Compile GMP only if we don't have it already
8 #
9 # We use GMP's own configuration stuff, because it's all rather hairy
10 # and not worth re-implementing in our Makefile framework.
11
12 ifneq "$(HaveLibGmp)" "YES"
13 ifneq "$(HaveFrameworkGMP)" "YES"
14
15 boot :: stamp.gmp
16
17 PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
18
19 # 2007-07-05
20 # We do
21 #     set -o igncr; export SHELLOPTS
22 # here as otherwise checking the size of limbs
23 # makes the build fall over on Cygwin. See the thread
24 # http://www.cygwin.com/ml/cygwin/2006-12/msg00011.html
25 # for more details.
26
27 # 2007-07-05
28 # Passing
29 #     as_ln_s='cp -p'
30 # isn't sufficient to stop cygwin using symlinks the mingw gcc can't
31 # follow, as it isn't used consistently. Instead we put an ln.bat in
32 # path that always fails.
33
34 GMP_TARBALL := $(firstword $(wildcard gmp*.tar.gz))
35 GMP_DIR := $(subst .tar.gz,,$(GMP_TARBALL))
36 BMP_BUILD_DIR := build
37
38 stamp.gmp:
39         $(RM) -rf $(GMP_DIR) gmpbuild
40         $(TAR) -zxf $(GMP_TARBALL)
41         mv $(GMP_DIR) gmpbuild
42         chmod +x ln
43         set -o igncr; export SHELLOPTS; \
44             export PATH=`pwd`:$$PATH; \
45             cd gmpbuild && \
46             CC=$(WhatGccIsCalled) $(SHELL) configure \
47                   --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
48         touch $@
49
50 all :: gmpbuild/libgmp.a
51
52 ifeq "$(DLLized)" "YES"
53 all :: $(DLL_PEN)/gmp.dll
54
55 $(DLL_PEN)/gmp.dll:
56         $(MAKE) -C gmpbuild gmp.dll
57         $(CP) gmpbuild/gmp.dll $(DLL_PEN)
58 endif
59
60 install :: gmpbuild/libgmp.a
61
62 INSTALL_LIBS += gmpbuild/libgmp.a
63
64 gmpbuild/libgmp.a ::
65         $(MAKE) -C gmpbuild MAKEFLAGS=
66         $(CP) gmpbuild/.libs/libgmp.a gmpbuild
67         $(RANLIB) gmpbuild/libgmp.a
68 endif
69 endif
70
71 clean distclean maintainer-clean ::
72         $(RM) -f stamp.gmp
73         $(RM) -rf gmpbuild
74         $(RM) -rf gmpbuild
75
76 #-----------------------------------------------------------------------------
77 #
78 # Files to install
79 #
80 # Just libHSrts is installed uniformly across ways
81 #
82 ifeq "$(DLLized)" "YES"
83 INSTALL_PROGS += gmpbuild/gmp.dll
84 INSTALL_LIBS += gmpbuild/libgmp_imp.a
85 endif
86
87 #-----------------------------------------------------------------------------
88 #
89 # binary-dist
90
91 include $(TOP)/mk/target.mk
92
93 binary-dist:
94         @:
95 ifneq "$(HaveLibGmp)" "YES"
96 ifneq "$(HaveFrameworkGMP)" "YES"
97         $(INSTALL_DIR)                         $(BIN_DIST_DIR)/gmp
98         $(INSTALL_DIR)                         $(BIN_DIST_DIR)/gmp/gmpbuild
99         touch $(BIN_DIST_DIR)/gmp/$(GMP_TARBALL)
100         $(INSTALL_DATA)    Makefile            $(BIN_DIST_DIR)/gmp/
101 ifneq "$(INSTALL_PROGS)" ""
102         $(INSTALL_DATA)    $(INSTALL_PROGS)    $(BIN_DIST_DIR)/gmp/gmpbuild/
103 endif
104 ifneq "$(INSTALL_LIBS)" ""
105         $(INSTALL_DATA)    $(INSTALL_LIBS)     $(BIN_DIST_DIR)/gmp/gmpbuild/
106 endif
107
108 endif
109 endif
110