Bump version to 0.2.0.0
[packages/integer-gmp.git] / gmp / ghc.mk
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/cbits/mkGmpDerivedConstants$(exeext): libraries/integer-gmp/cbits/mkGmpDerivedConstants.c
20 "$(CC)" $(SRC_CC_OPTS) $(CONF_CC_OPTS) $(libraries/integer-gmp_CC_OPTS) $< -o $@
21
22 libraries/integer-gmp/cbits/GmpDerivedConstants.h: libraries/integer-gmp/cbits/mkGmpDerivedConstants$(exeext)
23 $< > $@
24
25 # Compile GMP only if we don't have it already
26 #
27 # We use GMP's own configuration stuff, because it's all rather hairy
28 # and not worth re-implementing in our Makefile framework.
29
30 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
31 BUILD_SHARED=yes
32 else
33 BUILD_SHARED=no
34 endif
35
36 # In a bindist, we don't want to know whether /this/ machine has gmp,
37 # but whether the machine the bindist was built on had gmp.
38 ifeq "$(BINDIST)" "YES"
39 ifeq "$(wildcard libraries/integer-gmp/gmp/libgmp.a)" ""
40 HaveLibGmp = YES
41 HaveFrameworkGMP = YES
42 else
43 HaveLibGmp = NO
44 HaveFrameworkGMP = NO
45 endif
46 endif
47
48 define GmpDerivedConstants-dependencies # args: $1 = way
49 $$(libraries/integer-gmp_dist-install_$1_CMM_OBJS): libraries/integer-gmp/cbits/GmpDerivedConstants.h
50 $$(libraries/integer-gmp_dist-install_$1_C_OBJS): libraries/integer-gmp/cbits/GmpDerivedConstants.h
51 endef
52
53 $(foreach w,$(GhcLibWays),$(eval $(call GmpDerivedConstants-dependencies,$w)))
54
55 ifneq "$(HaveLibGmp)" "YES"
56 ifneq "$(HaveFrameworkGMP)" "YES"
57 libraries/integer-gmp/cbits/mkGmpDerivedConstants$(exeext): libraries/integer-gmp/gmp/gmp.h
58
59 libraries/integer-gmp_CC_OPTS += -I$(TOP)/libraries/integer-gmp/gmp
60
61 libraries/integer-gmp_dist-install_EXTRA_OBJS += libraries/integer-gmp/gmp/objs/*.o
62
63 #INSTALL_LIBS += libraries/integer-gmp/gmp/libgmp.a
64 #INSTALL_HEADERS += libraries/integer-gmp/gmp/gmp.h
65 #
66 #$(eval $(call all-target,gmp_dynamic,libraries/integer-gmp/gmp/libgmp.a))
67 #
68 #ifeq "$(BUILD_SHARED)" "yes"
69 #$(eval $(call all-target,gmp_dynamic,libraries/integer-gmp/gmp/libgmp.dll.a libraries/integer-gmp/gmp/libgmp-3.dll))
70 #endif
71
72 endif
73 endif
74
75 PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
76
77 # 2007-09-26
78 # set -o igncr
79 # is not a valid command on non-Cygwin-systems.
80 # Let it fail silently instead of aborting the build.
81 #
82 # 2007-07-05
83 # We do
84 # set -o igncr; export SHELLOPTS
85 # here as otherwise checking the size of limbs
86 # makes the build fall over on Cygwin. See the thread
87 # http://www.cygwin.com/ml/cygwin/2006-12/msg00011.html
88 # for more details.
89
90 # 2007-07-05
91 # Passing
92 # as_ln_s='cp -p'
93 # isn't sufficient to stop cygwin using symlinks the mingw gcc can't
94 # follow, as it isn't used consistently. Instead we put an ln.bat in
95 # path that always fails.
96
97 # We use a tarball like gmp-4.2.4-nodoc.tar.bz2, which is
98 # gmp-4.2.4.tar.bz2 repacked without the doc/ directory contents.
99 # That's because the doc/ directory contents are under the GFDL,
100 # which causes problems for Debian.
101
102 GMP_TARBALL := $(wildcard libraries/integer-gmp/gmp/tarball/gmp*.tar.bz2)
103 GMP_DIR := $(patsubst libraries/integer-gmp/gmp/tarball/%-nodoc-patched.tar.bz2,%,$(GMP_TARBALL))
104
105 libraries/integer-gmp/gmp/libgmp.a libraries/integer-gmp/gmp/gmp.h:
106 $(RM) -rf $(GMP_DIR) libraries/integer-gmp/gmp/gmpbuild libraries/integer-gmp/gmp/objs
107 cd libraries/integer-gmp/gmp && $(TAR) -jxf ../../../$(GMP_TARBALL)
108 mv libraries/integer-gmp/gmp/$(GMP_DIR) libraries/integer-gmp/gmp/gmpbuild
109 chmod +x libraries/integer-gmp/gmp/ln
110 cd libraries/integer-gmp/gmp; (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
111 PATH=`pwd`:$$PATH; \
112 export PATH; \
113 cd gmpbuild && \
114 CC=$(WhatGccIsCalled) $(SHELL) configure \
115 --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
116 $(MAKE) -C libraries/integer-gmp/gmp/gmpbuild MAKEFLAGS=
117 $(CP) libraries/integer-gmp/gmp/gmpbuild/gmp.h libraries/integer-gmp/gmp/
118 $(CP) libraries/integer-gmp/gmp/gmpbuild/.libs/libgmp.a libraries/integer-gmp/gmp/
119 $(MKDIRHIER) libraries/integer-gmp/gmp/objs
120 # XXX This should be $(AR), except that has the creation options baked in,
121 # so we use ar for now instead
122 cd libraries/integer-gmp/gmp/objs && ar x ../libgmp.a
123 $(RANLIB) libraries/integer-gmp/gmp/libgmp.a
124
125 ifneq "$(NO_CLEAN_GMP)" "YES"
126 $(eval $(call clean-target,gmp,,\
127 libraries/integer-gmp/gmp/libgmp.a \
128 libraries/integer-gmp/gmp/gmp.h \
129 libraries/integer-gmp/gmp/gmpbuild \
130 libraries/integer-gmp/gmp/$(GMP_DIR)))
131 endif
132
133 # XXX TODO:
134 #stamp.gmp.shared:
135 # $(RM) -rf $(GMP_DIR) gmpbuild-shared
136 # $(TAR) -zxf $(GMP_TARBALL)
137 # mv $(GMP_DIR) gmpbuild-shared
138 # chmod +x ln
139 # (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
140 # PATH=`pwd`:$$PATH; \
141 # export PATH; \
142 # cd gmpbuild-shared && \
143 # CC=$(WhatGccIsCalled) $(SHELL) configure \
144 # --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
145 # touch $@
146 #
147 #gmp.h: stamp.gmp.static
148 # $(CP) gmpbuild/gmp.h .
149 #
150 #libgmp.a: stamp.gmp.static
151 #
152 #libgmp-3.dll: stamp.gmp.shared
153 # $(MAKE) -C gmpbuild-shared MAKEFLAGS=
154 # $(CP) gmpbuild-shared/.libs/libgmp-3.dll .
155 #
156 #libgmp.dll.a: libgmp-3.dll
157 # $(CP) gmpbuild-shared/.libs/libgmp.dll.a .
158
159 ## GMP takes a long time to build, but changes rarely. Hence we don't
160 ## bother cleaning it before validating, because that adds a
161 ## significant overhead to validation.
162 #ifeq "$(Validating)" "NO"
163 #clean distclean maintainer-clean ::
164 # $(RM) -f stamp.gmp.static stamp.gmp.shared
165 # $(RM) -rf gmpbuild
166 # $(RM) -rf gmpbuild-shared
167 #endif
168
169 endif
170