Take strict fields into account in coverage checking
[ghc.git] / distrib / configure.ac.in
1 dnl
2 dnl Binary distribution configure script
3 dnl
4 #!/bin/sh
5 #
6
7 AC_INIT([The Glorious Glasgow Haskell Compilation System], [@ProjectVersion@], [glasgow-haskell-bugs@haskell.org], [ghc-AC_PACKAGE_VERSION])
8
9 dnl See /configure.ac for rationale.
10 AC_PREREQ([2.69])
11
12 dnl--------------------------------------------------------------------
13 dnl * Deal with arguments telling us gmp is somewhere odd
14 dnl--------------------------------------------------------------------
15
16 FP_GMP
17
18 dnl Various things from the source distribution configure
19 bootstrap_target=@TargetPlatform@
20
21 HaskellHaveRTSLinker=@HaskellHaveRTSLinker@
22 AC_SUBST(HaskellHaveRTSLinker)
23
24 FFIIncludeDir=@FFIIncludeDir@
25 FFILibDir=@FFILibDir@
26 AC_SUBST(FFILibDir)
27 AC_SUBST(FFIIncludeDir)
28
29
30 # We have to run these unconditionally as FPTOOLS_SET_PLATFORM_VARS wants the
31 # values it computes.
32 AC_CANONICAL_BUILD
33 AC_CANONICAL_HOST
34 AC_CANONICAL_TARGET
35
36 FPTOOLS_SET_PLATFORM_VARS
37
38 # Requires FPTOOLS_SET_PLATFORM_VARS to be run first.
39 FP_FIND_ROOT
40
41 # ToDo: if Stage1Only=YES, should be YES
42 CrossCompiling=NO
43 CrossCompilePrefix=""
44 TargetPlatformFull="${target}"
45
46 AC_SUBST(CrossCompiling)
47 AC_SUBST(CrossCompilePrefix)
48 AC_SUBST(TargetPlatformFull)
49
50 Unregisterised="@Unregisterised@"
51 AC_SUBST(Unregisterised)
52
53 #
54 dnl ** Check Perl installation **
55 #
56 AC_PATH_PROG(PerlCmd,perl)
57 if test -z "$PerlCmd"; then
58    echo "You must install perl before you can continue"
59    echo "Perhaps it is already installed, but not in your PATH?"
60    exit 1
61 fi
62
63 #
64 dnl ** figure out how to do a BSD-ish install **
65 #
66 AC_PROG_INSTALL
67
68 #
69 dnl ** find `find`, used by get-win32-tarballs.sh (see #12502)
70 #
71 FP_PROG_FIND()
72 export FIND
73
74 #
75 dnl ** how to do symlinks **
76 #
77 AC_PROG_LN_S()
78
79 #
80 dnl ** Find the path to sed **
81 #
82 AC_PATH_PROG(SedCmd,gsed sed,sed)
83
84 XCODE_VERSION()
85
86 dnl ** Which gcc to use?
87 dnl --------------------------------------------------------------
88 AC_PROG_CC([gcc clang])
89
90 dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`)
91 AC_PROG_CPP
92
93 # --with-hs-cpp/--with-hs-cpp-flags
94 FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
95 AC_SUBST([HaskellCPPCmd])
96 AC_SUBST([HaskellCPPArgs])
97
98 FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS])
99 dnl FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
100 FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
101 FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
102
103 dnl ** Which ld to use?
104 dnl --------------------------------------------------------------
105 FIND_LD([$target],[GccUseLdOpt])
106 CONF_GCC_LINKER_OPTS_STAGE1="$CONF_GCC_LINKER_OPTS_STAGE1 $GccUseLdOpt"
107 CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2 $GccUseLdOpt"
108 LdCmd="$LD"
109 CFLAGS="$CFLAGS $GccUseLdOpt"
110 AC_SUBST([LdCmd])
111
112 FP_PROG_LD_IS_GNU
113 FP_PROG_LD_BUILD_ID
114 FP_PROG_LD_NO_COMPACT_UNWIND
115 FP_PROG_LD_FILELIST
116
117 dnl ** which strip to use?
118 dnl --------------------------------------------------------------
119 AC_CHECK_TARGET_TOOL([STRIP], [strip])
120 StripCmd="$STRIP"
121 AC_SUBST([StripCmd])
122
123 # Here is where we re-target which specific version of the LLVM
124 # tools we are looking for. In the past, GHC supported a number of
125 # versions of LLVM simultaneously, but that stopped working around
126 # 3.5/3.6 release of LLVM.
127 LlvmVersion=@LlvmVersion@
128
129 dnl ** Which LLVM llc to use?
130 dnl --------------------------------------------------------------
131 FIND_LLVM_PROG([LLC], [llc], [$LlvmVersion])
132 LlcCmd="$LLC"
133 AC_SUBST([LlcCmd])
134
135 dnl ** Which LLVM opt to use?
136 dnl --------------------------------------------------------------
137 FIND_LLVM_PROG([OPT], [opt], [$LlvmVersion])
138 OptCmd="$OPT"
139 AC_SUBST([OptCmd])
140
141 dnl ** Check gcc version and flags we need to pass it **
142 FP_GCC_VERSION
143 FP_GCC_SUPPORTS_NO_PIE
144 FP_GCC_EXTRA_FLAGS
145
146 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
147 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
148 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
149 # Stage 3 won't be supported by cross-compilation
150 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
151
152 AC_SUBST(CONF_CC_OPTS_STAGE0)
153 AC_SUBST(CONF_CC_OPTS_STAGE1)
154 AC_SUBST(CONF_CC_OPTS_STAGE2)
155 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
156 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
157 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
158 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
159 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
160 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
161 AC_SUBST(CONF_CPP_OPTS_STAGE0)
162 AC_SUBST(CONF_CPP_OPTS_STAGE1)
163 AC_SUBST(CONF_CPP_OPTS_STAGE2)
164
165 dnl ** Set up the variables for the platform in the settings file.
166 dnl May need to use gcc to find platform details.
167 dnl --------------------------------------------------------------
168 FPTOOLS_SET_HASKELL_PLATFORM_VARS
169
170 dnl TargetWordSize for settings.in
171 AC_CHECK_SIZEOF(void *, 4)
172 if test "x$ac_cv_sizeof_void_p" = "x0"; then
173     AC_MSG_ERROR([Failed to determine machine word size. Does your toolchain actually work?])
174 fi
175 dnl Check that the toolchain we have is consistent with what the compiler expects
176 if test "x$ac_cv_sizeof_void_p" != "x@TargetWordSize@"; then
177     AC_MSG_ERROR([This binary distribution produces binaries for a target with
178                   word size of @TargetWordSize@, but your target toolchain produces binaries
179                   with a word size of $ac_cv_sizeof_void_p. Are you sure your toolchain
180                   targets the intended target platform of this compiler?])
181 fi
182 TargetWordSize=$ac_cv_sizeof_void_p
183 AC_SUBST(TargetWordSize)
184
185 #
186 dnl ** how to invoke `ar' and `ranlib'
187 #
188 FP_PROG_AR_SUPPORTS_ATFILE
189 FP_PROG_AR_NEEDS_RANLIB
190
191 dnl ** Have libdw?
192 dnl --------------------------------------------------------------
193 dnl Check for a usable version of libdw/elfutils
194 dnl Currently we need 0.158 or newer.
195 BinDistNeedsLibdw=@UseLibdw@
196 if test "x$BinDistNeedsLibdw" = "xYES" ; then
197   AC_CHECK_LIB(dw, dwfl_attach_state,
198     [UseLibdw=YES],
199     [AC_MSG_ERROR([Binary distribution was built with libdw support but target system doesn't have supported libdw version (needs at least 0.158)])]
200   )
201 fi
202
203 FP_SETTINGS
204
205 #
206 AC_CONFIG_FILES(settings mk/config.mk mk/install.mk)
207 AC_OUTPUT
208
209 # We get caught by
210 #     http://savannah.gnu.org/bugs/index.php?1516
211 #     $(eval ...) inside conditionals causes errors
212 # with make 3.80, so warn the user if it looks like they're about to
213 # try to use it.
214 # We would use "grep -q" here, but Solaris's grep doesn't support it.
215 checkMake380() {
216     if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
217     then
218         echo
219         echo "WARNING: It looks like \"$1\" is GNU make 3.80."
220         echo "This version cannot be used to build GHC."
221         echo "Please use GNU make >= 3.81."
222     fi
223 }
224
225 checkMake380 make
226 checkMake380 gmake
227
228 echo "****************************************************"
229 echo "Configuration done, ready to 'make install'"
230 echo "(see README and INSTALL files for more info.)"
231 echo "****************************************************"