~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to libraries/integer-gmp/gmp/ghc.mk

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -----------------------------------------------------------------------------
 
2
#
 
3
# (c) 2009 The University of Glasgow
 
4
#
 
5
# This file is part of the GHC build system.
 
6
#
 
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
 
10
#
 
11
# -----------------------------------------------------------------------------
 
12
 
 
13
ifneq "$(phase)" "0"
 
14
 
 
15
ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
 
16
include libraries/integer-gmp/gmp/config.mk
 
17
endif
 
18
 
 
19
libraries/integer-gmp_CC_OPTS += $(addprefix -I,$(GMP_INCLUDE_DIRS))
 
20
libraries/integer-gmp_CC_OPTS += $(addprefix -L,$(GMP_LIB_DIRS))
 
21
 
 
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 $@
 
24
 
 
25
libraries/integer-gmp/cbits/GmpDerivedConstants.h: libraries/integer-gmp/cbits/mkGmpDerivedConstants$(exeext)
 
26
        $< > $@
 
27
 
 
28
# Compile GMP only if we don't have it already
 
29
#
 
30
# We use GMP's own configuration stuff, because it's all rather hairy
 
31
# and not worth re-implementing in our Makefile framework.
 
32
 
 
33
ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
 
34
BUILD_SHARED=yes
 
35
else
 
36
BUILD_SHARED=no
 
37
endif
 
38
 
 
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)" ""
 
43
HaveLibGmp = YES
 
44
HaveFrameworkGMP = YES
 
45
else
 
46
HaveLibGmp = NO
 
47
HaveFrameworkGMP = NO
 
48
endif
 
49
endif
 
50
 
 
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
 
54
endef
 
55
 
 
56
$(foreach w,$(GhcLibWays),$(eval $(call GmpDerivedConstants-dependencies,$w)))
 
57
 
 
58
ifneq "$(HaveLibGmp)" "YES"
 
59
ifneq "$(HaveFrameworkGMP)" "YES"
 
60
$(libraries/integer-gmp_dist-install_depfile_c_asm): libraries/integer-gmp/gmp/gmp.h
 
61
 
 
62
libraries/integer-gmp/cbits/mkGmpDerivedConstants$(exeext): libraries/integer-gmp/gmp/gmp.h
 
63
 
 
64
libraries/integer-gmp_CC_OPTS += -I$(TOP)/libraries/integer-gmp/gmp
 
65
 
 
66
libraries/integer-gmp_dist-install_EXTRA_OBJS += libraries/integer-gmp/gmp/objs/*.o
 
67
 
 
68
#INSTALL_LIBS += libraries/integer-gmp/gmp/libgmp.a
 
69
#INSTALL_HEADERS += libraries/integer-gmp/gmp/gmp.h
 
70
#
 
71
#$(eval $(call all-target,gmp_dynamic,libraries/integer-gmp/gmp/libgmp.a))
 
72
#
 
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))
 
75
#endif
 
76
 
 
77
endif
 
78
endif
 
79
 
 
80
PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
 
81
 
 
82
# 2007-09-26
 
83
#     set -o igncr 
 
84
# is not a valid command on non-Cygwin-systems.
 
85
# Let it fail silently instead of aborting the build.
 
86
#
 
87
# 2007-07-05
 
88
# We do
 
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
 
93
# for more details.
 
94
 
 
95
# 2007-07-05
 
96
# Passing
 
97
#     as_ln_s='cp -p'
 
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.
 
101
 
 
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.
 
106
 
 
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))
 
109
 
 
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; \
 
116
            PATH=`pwd`:$$PATH; \
 
117
            export PATH; \
 
118
            cd gmpbuild && \
 
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
 
127
 
 
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)))
 
134
endif
 
135
 
 
136
# XXX TODO:
 
137
#stamp.gmp.shared:
 
138
#       $(RM) -rf $(GMP_DIR) gmpbuild-shared
 
139
#       $(TAR_CMD) -zxf $(GMP_TARBALL)
 
140
#       mv $(GMP_DIR) gmpbuild-shared
 
141
#       chmod +x ln
 
142
#       (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
 
143
#           PATH=`pwd`:$$PATH; \
 
144
#           export PATH; \
 
145
#           cd gmpbuild-shared && \
 
146
#           CC=$(WhatGccIsCalled) $(SHELL) configure \
 
147
#                 --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
 
148
#       touch $@
 
149
#
 
150
#gmp.h: stamp.gmp.static
 
151
#       $(CP) gmpbuild/gmp.h .
 
152
#
 
153
#libgmp.a: stamp.gmp.static
 
154
#
 
155
#libgmp-3.dll: stamp.gmp.shared
 
156
#       $(MAKE) -C gmpbuild-shared MAKEFLAGS=
 
157
#       $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
 
158
#
 
159
#libgmp.dll.a: libgmp-3.dll
 
160
#       $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
 
161
 
 
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
 
168
#       $(RM) -rf gmpbuild
 
169
#       $(RM) -rf gmpbuild-shared
 
170
#endif
 
171
 
 
172
endif
 
173