Don't clean gmp when validating (speeds up validation on Windows)
[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 BMP_BUILD_DIR := build
40
41 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
42 BUILD_SHARED=yes
43 else
44 BUILD_SHARED=no
45 endif
46
47 boot :: stamp.gmp.static
48 all :: gmp.h libgmp.a
49 install :: gmp.h libgmp.a
50 INSTALL_HEADERS += gmp.h
51 INSTALL_LIBS += libgmp.a
52
53 ifeq "$(BUILD_SHARED)" "yes"
54 boot :: stamp.gmp.shared
55 all :: libgmp-3.dll libgmp.dll.a
56 install :: libgmp-3.dll libgmp.dll.a
57 INSTALL_LIBS += libgmp.dll.a
58 INSTALL_PROGS += libgmp-3.dll
59 endif
60
61 stamp.gmp.static:
62         $(RM) -rf $(GMP_DIR) gmpbuild
63         $(TAR) -zxf $(GMP_TARBALL)
64         mv $(GMP_DIR) gmpbuild
65         chmod +x ln
66         (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
67             export PATH=`pwd`:$$PATH; \
68             cd gmpbuild && \
69             CC=$(WhatGccIsCalled) $(SHELL) configure \
70                   --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
71         touch $@
72
73 stamp.gmp.shared:
74         $(RM) -rf $(GMP_DIR) gmpbuild-shared
75         $(TAR) -zxf $(GMP_TARBALL)
76         mv $(GMP_DIR) gmpbuild-shared
77         chmod +x ln
78         (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
79             export PATH=`pwd`:$$PATH; \
80             cd gmpbuild-shared && \
81             CC=$(WhatGccIsCalled) $(SHELL) configure \
82                   --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
83         touch $@
84
85 gmp.h: stamp.gmp.static
86         $(CP) gmpbuild/gmp.h .
87
88 libgmp.a: stamp.gmp.static
89         $(MAKE) -C gmpbuild MAKEFLAGS=
90         $(CP) gmpbuild/.libs/libgmp.a .
91         $(RANLIB) libgmp.a
92
93 libgmp-3.dll: stamp.gmp.shared
94         $(MAKE) -C gmpbuild-shared MAKEFLAGS=
95         $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
96
97 libgmp.dll.a: libgmp-3.dll
98         $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
99 endif
100 endif
101
102 # GMP takes a long time to build, but changes rarely.  Hence we don't
103 # bother cleaning it before validating, because that adds a
104 # significant overhead to validation.
105 ifeq "$(Validating)" "NO"
106 clean distclean maintainer-clean ::
107         $(RM) -f stamp.gmp.static stamp.gmp.shared
108         $(RM) -rf gmpbuild
109         $(RM) -rf gmpbuild-shared
110 endif
111
112 #-----------------------------------------------------------------------------
113 #
114 # binary-dist
115
116 include $(TOP)/mk/target.mk
117
118 binary-dist:
119         @:
120 ifneq "$(HaveLibGmp)" "YES"
121 ifneq "$(HaveFrameworkGMP)" "YES"
122         $(INSTALL_DIR)                         $(BIN_DIST_DIR)/gmp
123         touch $(BIN_DIST_DIR)/gmp/$(GMP_TARBALL)
124         $(INSTALL_DATA)    Makefile            $(BIN_DIST_DIR)/gmp/
125 ifneq "$(INSTALL_PROGS)" ""
126         $(INSTALL_DATA)    $(INSTALL_PROGS)    $(BIN_DIST_DIR)/gmp/
127 endif
128 ifneq "$(INSTALL_LIBS)" ""
129         $(INSTALL_DATA)    $(INSTALL_LIBS)     $(BIN_DIST_DIR)/gmp/
130 endif
131 ifneq "$(INSTALL_HEADERS)" ""
132         $(INSTALL_HEADER)  $(INSTALL_HEADERS)  $(BIN_DIST_DIR)/gmp/
133 endif
134
135 endif
136 endif
137