Fix retainer profiling
[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.static
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 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
39 BUILD_SHARED=yes
40 else
41 BUILD_SHARED=no
42 endif
43
44 stamp.gmp.static:
45         $(RM) -rf $(GMP_DIR) gmpbuild
46         $(TAR) -zxf $(GMP_TARBALL)
47         mv $(GMP_DIR) gmpbuild
48         chmod +x ln
49         set -o igncr; export SHELLOPTS; \
50             export PATH=`pwd`:$$PATH; \
51             cd gmpbuild && \
52             CC=$(WhatGccIsCalled) $(SHELL) configure \
53                   --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
54         touch $@
55
56 stamp.gmp.shared:
57         $(RM) -rf $(GMP_DIR) gmpbuild-shared
58         $(TAR) -zxf $(GMP_TARBALL)
59         mv $(GMP_DIR) gmpbuild-shared
60         chmod +x ln
61         set -o igncr; export SHELLOPTS; \
62             export PATH=`pwd`:$$PATH; \
63             cd gmpbuild-shared && \
64             CC=$(WhatGccIsCalled) $(SHELL) configure \
65                   --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
66         touch $@
67
68 libgmp.a: stamp.gmp.static
69         $(MAKE) -C gmpbuild MAKEFLAGS=
70         $(CP) gmpbuild/.libs/libgmp.a .
71         $(RANLIB) libgmp.a
72
73 all :: libgmp.a
74
75 install :: libgmp.a
76
77 INSTALL_LIBS += libgmp.a
78
79 ifeq "$(BUILD_SHARED)" "yes"
80 libgmp-3.dll: stamp.gmp.shared
81         $(MAKE) -C gmpbuild-shared MAKEFLAGS=
82         $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
83
84 libgmp.dll.a: libgmp-3.dll
85         $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
86
87 all :: libgmp-3.dll libgmp.dll.a
88
89 install :: libgmp-3.dll libgmp.dll.a
90
91 INSTALL_LIBS += libgmp.dll.a
92 INSTALL_PROGS += libgmp-3.dll
93 endif
94 endif
95 endif
96
97 clean distclean maintainer-clean ::
98         $(RM) -f stamp.gmp.static stamp.gmp.shared
99         $(RM) -rf gmpbuild
100         $(RM) -rf gmpbuild-shared
101
102 #-----------------------------------------------------------------------------
103 #
104 # binary-dist
105
106 include $(TOP)/mk/target.mk
107
108 binary-dist:
109         @:
110 ifneq "$(HaveLibGmp)" "YES"
111 ifneq "$(HaveFrameworkGMP)" "YES"
112         $(INSTALL_DIR)                         $(BIN_DIST_DIR)/gmp
113         touch $(BIN_DIST_DIR)/gmp/$(GMP_TARBALL)
114         $(INSTALL_DATA)    Makefile            $(BIN_DIST_DIR)/gmp/
115 ifneq "$(INSTALL_PROGS)" ""
116         $(INSTALL_DATA)    $(INSTALL_PROGS)    $(BIN_DIST_DIR)/gmp/
117 endif
118 ifneq "$(INSTALL_LIBS)" ""
119         $(INSTALL_DATA)    $(INSTALL_LIBS)     $(BIN_DIST_DIR)/gmp/
120 endif
121
122 endif
123 endif
124