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