Add (a) CoreM monad, (b) new Annotations feature
[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 PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
16
17 # 2007-09-26
18 #     set -o igncr 
19 # is not a valid command on non-Cygwin-systems.
20 # Let it fail silently instead of aborting the build.
21 #
22 # 2007-07-05
23 # We do
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
28 # for more details.
29
30 # 2007-07-05
31 # Passing
32 #     as_ln_s='cp -p'
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.
36
37 GMP_TARBALL := $(firstword $(wildcard gmp*.tar.gz))
38 GMP_DIR := $(subst .tar.gz,,$(GMP_TARBALL))
39
40 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
41 BUILD_SHARED=yes
42 else
43 BUILD_SHARED=no
44 endif
45
46 BINDIST_STAMPS = stamp.gmp.static
47 INSTALL_HEADERS += gmp.h
48 INSTALL_LIBS += libgmp.a
49
50 ifeq "$(BUILD_SHARED)" "yes"
51 BINDIST_STAMPS += stamp.gmp.shared
52 INSTALL_LIBS += libgmp.dll.a
53 INSTALL_PROGS += libgmp-3.dll
54 endif
55
56 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
57
58 stamp.gmp.static:
59         $(RM) -rf $(GMP_DIR) gmpbuild
60         $(TAR) -zxf $(GMP_TARBALL)
61         mv $(GMP_DIR) gmpbuild
62         chmod +x ln
63         (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
64             PATH=`pwd`:$$PATH; \
65             export PATH; \
66             cd gmpbuild && \
67             CC=$(WhatGccIsCalled) $(SHELL) configure \
68                   --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
69         touch $@
70
71 stamp.gmp.shared:
72         $(RM) -rf $(GMP_DIR) gmpbuild-shared
73         $(TAR) -zxf $(GMP_TARBALL)
74         mv $(GMP_DIR) gmpbuild-shared
75         chmod +x ln
76         (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
77             PATH=`pwd`:$$PATH; \
78             export PATH; \
79             cd gmpbuild-shared && \
80             CC=$(WhatGccIsCalled) $(SHELL) configure \
81                   --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
82         touch $@
83
84 gmp.h: stamp.gmp.static
85         $(CP) gmpbuild/gmp.h .
86
87 libgmp.a: stamp.gmp.static
88         $(MAKE) -C gmpbuild MAKEFLAGS=
89         $(CP) gmpbuild/.libs/libgmp.a .
90         $(RANLIB) libgmp.a
91
92 libgmp-3.dll: stamp.gmp.shared
93         $(MAKE) -C gmpbuild-shared MAKEFLAGS=
94         $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
95
96 libgmp.dll.a: libgmp-3.dll
97         $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
98 endif
99 endif
100
101 # GMP takes a long time to build, but changes rarely.  Hence we don't
102 # bother cleaning it before validating, because that adds a
103 # significant overhead to validation.
104 ifeq "$(Validating)" "NO"
105 clean distclean maintainer-clean ::
106         $(RM) -f stamp.gmp.static stamp.gmp.shared
107         $(RM) -rf gmpbuild
108         $(RM) -rf gmpbuild-shared
109 endif
110
111 #-----------------------------------------------------------------------------
112 #
113 # binary-dist
114
115 include $(TOP)/mk/target.mk
116
117 BINDIST_EXTRAS += $(BINDIST_STAMPS)
118 BINDIST_EXTRAS += $(INSTALL_PROGS)
119 BINDIST_EXTRAS += $(INSTALL_LIBS)
120 BINDIST_EXTRAS += $(INSTALL_HEADERS)
121 include $(TOP)/mk/bindist.mk
122