Remove the doc/ contents from the GMP tarball
[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 # We use a tarball like gmp-4.2.1-nodoc.tar.gz, which is
38 # gmp-4.2.1.tar.gz repacked without the doc/ directory contents.
39 # That's because the doc/ directory contents are under the GFDL,
40 # which causes problems for Debian.
41
42 GMP_TARBALL := $(firstword $(wildcard gmp*.tar.gz))
43 GMP_DIR := $(subst -nodoc.tar.gz,,$(GMP_TARBALL))
44
45 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
46 BUILD_SHARED=yes
47 else
48 BUILD_SHARED=no
49 endif
50
51 BINDIST_STAMPS = stamp.gmp.static
52 INSTALL_HEADERS += gmp.h
53 INSTALL_LIBS += libgmp.a
54
55 ifeq "$(BUILD_SHARED)" "yes"
56 BINDIST_STAMPS += stamp.gmp.shared
57 INSTALL_LIBS += libgmp.dll.a
58 INSTALL_PROGS += libgmp-3.dll
59 endif
60
61 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
62
63 stamp.gmp.static:
64         $(RM) -rf $(GMP_DIR) gmpbuild
65         $(TAR) -zxf $(GMP_TARBALL)
66         mv $(GMP_DIR) gmpbuild
67         chmod +x ln
68         (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
69             PATH=`pwd`:$$PATH; \
70             export PATH; \
71             cd gmpbuild && \
72             CC=$(WhatGccIsCalled) $(SHELL) configure \
73                   --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
74         touch $@
75
76 stamp.gmp.shared:
77         $(RM) -rf $(GMP_DIR) gmpbuild-shared
78         $(TAR) -zxf $(GMP_TARBALL)
79         mv $(GMP_DIR) gmpbuild-shared
80         chmod +x ln
81         (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
82             PATH=`pwd`:$$PATH; \
83             export PATH; \
84             cd gmpbuild-shared && \
85             CC=$(WhatGccIsCalled) $(SHELL) configure \
86                   --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
87         touch $@
88
89 gmp.h: stamp.gmp.static
90         $(CP) gmpbuild/gmp.h .
91
92 libgmp.a: stamp.gmp.static
93         $(MAKE) -C gmpbuild MAKEFLAGS=
94         $(CP) gmpbuild/.libs/libgmp.a .
95         $(RANLIB) libgmp.a
96
97 libgmp-3.dll: stamp.gmp.shared
98         $(MAKE) -C gmpbuild-shared MAKEFLAGS=
99         $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
100
101 libgmp.dll.a: libgmp-3.dll
102         $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
103 endif
104 endif
105
106 # GMP takes a long time to build, but changes rarely.  Hence we don't
107 # bother cleaning it before validating, because that adds a
108 # significant overhead to validation.
109 ifeq "$(Validating)" "NO"
110 clean distclean maintainer-clean ::
111         $(RM) -f stamp.gmp.static stamp.gmp.shared
112         $(RM) -rf gmpbuild
113         $(RM) -rf gmpbuild-shared
114 endif
115
116 #-----------------------------------------------------------------------------
117 #
118 # binary-dist
119
120 include $(TOP)/mk/target.mk
121
122 BINDIST_EXTRAS += $(BINDIST_STAMPS)
123 BINDIST_EXTRAS += $(INSTALL_PROGS)
124 BINDIST_EXTRAS += $(INSTALL_LIBS)
125 BINDIST_EXTRAS += $(INSTALL_HEADERS)
126 include $(TOP)/mk/bindist.mk
127