1
# -----------------------------------------------------------------------------
3
# (c) 2009 The University of Glasgow
5
# This file is part of the GHC build system.
7
# To understand how the build system works and how to modify it, see
8
# http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9
# http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
11
# -----------------------------------------------------------------------------
15
ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
16
include libraries/integer-gmp/gmp/config.mk
19
libraries/integer-gmp_CC_OPTS += $(addprefix -I,$(GMP_INCLUDE_DIRS))
20
libraries/integer-gmp_CC_OPTS += $(addprefix -L,$(GMP_LIB_DIRS))
22
libraries/integer-gmp/cbits/mkGmpDerivedConstants$(exeext): libraries/integer-gmp/cbits/mkGmpDerivedConstants.c
23
"$(CC)" $(SRC_CC_OPTS) $(CONF_CC_OPTS_STAGE1) $(libraries/integer-gmp_CC_OPTS) $< -o $@
25
libraries/integer-gmp/cbits/GmpDerivedConstants.h: libraries/integer-gmp/cbits/mkGmpDerivedConstants$(exeext)
28
# Compile GMP only if we don't have it already
30
# We use GMP's own configuration stuff, because it's all rather hairy
31
# and not worth re-implementing in our Makefile framework.
33
ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
39
# In a bindist, we don't want to know whether /this/ machine has gmp,
40
# but whether the machine the bindist was built on had gmp.
41
ifeq "$(BINDIST)" "YES"
42
ifeq "$(wildcard libraries/integer-gmp/gmp/libgmp.a)" ""
44
HaveFrameworkGMP = YES
51
define GmpDerivedConstants-dependencies # args: $1 = way
52
$$(libraries/integer-gmp_dist-install_$1_CMM_OBJS): libraries/integer-gmp/cbits/GmpDerivedConstants.h
53
$$(libraries/integer-gmp_dist-install_$1_C_OBJS): libraries/integer-gmp/cbits/GmpDerivedConstants.h
56
$(foreach w,$(GhcLibWays),$(eval $(call GmpDerivedConstants-dependencies,$w)))
58
ifneq "$(HaveLibGmp)" "YES"
59
ifneq "$(HaveFrameworkGMP)" "YES"
60
$(libraries/integer-gmp_dist-install_depfile_c_asm): libraries/integer-gmp/gmp/gmp.h
62
libraries/integer-gmp/cbits/mkGmpDerivedConstants$(exeext): libraries/integer-gmp/gmp/gmp.h
64
libraries/integer-gmp_CC_OPTS += -I$(TOP)/libraries/integer-gmp/gmp
66
libraries/integer-gmp_dist-install_EXTRA_OBJS += libraries/integer-gmp/gmp/objs/*.o
68
#INSTALL_LIBS += libraries/integer-gmp/gmp/libgmp.a
69
#INSTALL_HEADERS += libraries/integer-gmp/gmp/gmp.h
71
#$(eval $(call all-target,gmp_dynamic,libraries/integer-gmp/gmp/libgmp.a))
73
#ifeq "$(BUILD_SHARED)" "yes"
74
#$(eval $(call all-target,gmp_dynamic,libraries/integer-gmp/gmp/libgmp.dll.a libraries/integer-gmp/gmp/libgmp-3.dll))
80
PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
84
# is not a valid command on non-Cygwin-systems.
85
# Let it fail silently instead of aborting the build.
89
# set -o igncr; export SHELLOPTS
90
# here as otherwise checking the size of limbs
91
# makes the build fall over on Cygwin. See the thread
92
# http://www.cygwin.com/ml/cygwin/2006-12/msg00011.html
98
# isn't sufficient to stop cygwin using symlinks the mingw gcc can't
99
# follow, as it isn't used consistently. Instead we put an ln.bat in
100
# path that always fails.
102
# We use a tarball like gmp-4.2.4-nodoc.tar.bz2, which is
103
# gmp-4.2.4.tar.bz2 repacked without the doc/ directory contents.
104
# That's because the doc/ directory contents are under the GFDL,
105
# which causes problems for Debian.
107
GMP_TARBALL := $(wildcard libraries/integer-gmp/gmp/tarball/gmp*.tar.bz2)
108
GMP_DIR := $(patsubst libraries/integer-gmp/gmp/tarball/%-nodoc-patched.tar.bz2,%,$(GMP_TARBALL))
110
libraries/integer-gmp/gmp/libgmp.a libraries/integer-gmp/gmp/gmp.h:
111
$(RM) -rf libraries/integer-gmp/gmp/$(GMP_DIR) libraries/integer-gmp/gmp/gmpbuild libraries/integer-gmp/gmp/objs
112
cat $(GMP_TARBALL) | $(BZIP2_CMD) -d | { cd libraries/integer-gmp/gmp && $(TAR_CMD) -xf - ; }
113
mv libraries/integer-gmp/gmp/$(GMP_DIR) libraries/integer-gmp/gmp/gmpbuild
114
chmod +x libraries/integer-gmp/gmp/ln
115
cd libraries/integer-gmp/gmp; (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
119
CC=$(WhatGccIsCalled) NM=$(NM) AR=$(AR) $(SHELL) configure \
120
--enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
121
$(MAKE) -C libraries/integer-gmp/gmp/gmpbuild MAKEFLAGS=
122
$(CP) libraries/integer-gmp/gmp/gmpbuild/gmp.h libraries/integer-gmp/gmp/
123
$(CP) libraries/integer-gmp/gmp/gmpbuild/.libs/libgmp.a libraries/integer-gmp/gmp/
124
$(MKDIRHIER) libraries/integer-gmp/gmp/objs
125
cd libraries/integer-gmp/gmp/objs && $(AR) x ../libgmp.a
126
$(RANLIB) libraries/integer-gmp/gmp/libgmp.a
128
ifneq "$(NO_CLEAN_GMP)" "YES"
129
$(eval $(call clean-target,gmp,,\
130
libraries/integer-gmp/gmp/libgmp.a \
131
libraries/integer-gmp/gmp/gmp.h \
132
libraries/integer-gmp/gmp/gmpbuild \
133
libraries/integer-gmp/gmp/$(GMP_DIR)))
138
# $(RM) -rf $(GMP_DIR) gmpbuild-shared
139
# $(TAR_CMD) -zxf $(GMP_TARBALL)
140
# mv $(GMP_DIR) gmpbuild-shared
142
# (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
143
# PATH=`pwd`:$$PATH; \
145
# cd gmpbuild-shared && \
146
# CC=$(WhatGccIsCalled) $(SHELL) configure \
147
# --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
150
#gmp.h: stamp.gmp.static
151
# $(CP) gmpbuild/gmp.h .
153
#libgmp.a: stamp.gmp.static
155
#libgmp-3.dll: stamp.gmp.shared
156
# $(MAKE) -C gmpbuild-shared MAKEFLAGS=
157
# $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
159
#libgmp.dll.a: libgmp-3.dll
160
# $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
162
## GMP takes a long time to build, but changes rarely. Hence we don't
163
## bother cleaning it before validating, because that adds a
164
## significant overhead to validation.
165
#ifeq "$(Validating)" "NO"
166
#clean distclean maintainer-clean ::
167
# $(RM) -f stamp.gmp.static stamp.gmp.shared
169
# $(RM) -rf gmpbuild-shared