Rip out perl dependency
[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 ** figure out how to do a BSD-ish install **
55 #
56 AC_PROG_INSTALL
57
58 #
59 dnl ** find `find`, used by get-win32-tarballs.sh (see #12502)
60 #
61 FP_PROG_FIND()
62 export FIND
63
64 #
65 dnl ** how to do symlinks **
66 #
67 AC_PROG_LN_S()
68
69 #
70 dnl ** Find the path to sed **
71 #
72 AC_PATH_PROG(SedCmd,gsed sed,sed)
73
74 XCODE_VERSION()
75
76 dnl ** Which gcc to use?
77 dnl --------------------------------------------------------------
78 AC_PROG_CC([gcc clang])
79
80 dnl ** figure out how to invoke the C preprocessor (i.e. `gcc -E`)
81 AC_PROG_CPP
82
83 # --with-hs-cpp/--with-hs-cpp-flags
84 FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
85 AC_SUBST([HaskellCPPCmd])
86 AC_SUBST([HaskellCPPArgs])
87
88 FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS])
89 dnl FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
90 FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
91 FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
92
93 dnl ** Which ld to use?
94 dnl --------------------------------------------------------------
95 FIND_LD([$target],[GccUseLdOpt])
96 CONF_GCC_LINKER_OPTS_STAGE1="$CONF_GCC_LINKER_OPTS_STAGE1 $GccUseLdOpt"
97 CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2 $GccUseLdOpt"
98 LdCmd="$LD"
99 CFLAGS="$CFLAGS $GccUseLdOpt"
100 AC_SUBST([LdCmd])
101
102 FP_PROG_LD_IS_GNU
103 FP_PROG_LD_BUILD_ID
104 FP_PROG_LD_NO_COMPACT_UNWIND
105 FP_PROG_LD_FILELIST
106
107 dnl ** which strip to use?
108 dnl --------------------------------------------------------------
109 AC_CHECK_TARGET_TOOL([STRIP], [strip])
110 StripCmd="$STRIP"
111 AC_SUBST([StripCmd])
112
113 # Here is where we re-target which specific version of the LLVM
114 # tools we are looking for. In the past, GHC supported a number of
115 # versions of LLVM simultaneously, but that stopped working around
116 # 3.5/3.6 release of LLVM.
117 LlvmVersion=@LlvmVersion@
118
119 dnl ** Which LLVM llc to use?
120 dnl --------------------------------------------------------------
121 AC_ARG_VAR(LLC,[Use as the path to LLVM's llc [default=autodetect]])
122 FIND_LLVM_PROG([LLC], [llc], [$LlvmVersion])
123 LlcCmd="$LLC"
124 AC_SUBST([LlcCmd])
125
126 dnl ** Which LLVM opt to use?
127 dnl --------------------------------------------------------------
128 AC_ARG_VAR(OPT,[Use as the path to LLVM's opt [default=autodetect]])
129 FIND_LLVM_PROG([OPT], [opt], [$LlvmVersion])
130 OptCmd="$OPT"
131 AC_SUBST([OptCmd])
132
133 dnl ** Check gcc version and flags we need to pass it **
134 FP_GCC_VERSION
135 FP_GCC_SUPPORTS_NO_PIE
136 FP_GCC_EXTRA_FLAGS
137
138 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
139 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
140 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
141 # Stage 3 won't be supported by cross-compilation
142 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
143
144 AC_SUBST(CONF_CC_OPTS_STAGE0)
145 AC_SUBST(CONF_CC_OPTS_STAGE1)
146 AC_SUBST(CONF_CC_OPTS_STAGE2)
147 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
148 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
149 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
150 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
151 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
152 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
153 AC_SUBST(CONF_CPP_OPTS_STAGE0)
154 AC_SUBST(CONF_CPP_OPTS_STAGE1)
155 AC_SUBST(CONF_CPP_OPTS_STAGE2)
156
157 dnl ** Set up the variables for the platform in the settings file.
158 dnl May need to use gcc to find platform details.
159 dnl --------------------------------------------------------------
160 FPTOOLS_SET_HASKELL_PLATFORM_VARS
161
162 dnl TargetWordSize for settings.in
163 AC_CHECK_SIZEOF(void *, 4)
164 if test "x$ac_cv_sizeof_void_p" = "x0"; then
165     AC_MSG_ERROR([Failed to determine machine word size. Does your toolchain actually work?])
166 fi
167 dnl Check that the toolchain we have is consistent with what the compiler expects
168 if test "x$ac_cv_sizeof_void_p" != "x@TargetWordSize@"; then
169     AC_MSG_ERROR([This binary distribution produces binaries for a target with
170                   word size of @TargetWordSize@, but your target toolchain produces binaries
171                   with a word size of $ac_cv_sizeof_void_p. Are you sure your toolchain
172                   targets the intended target platform of this compiler?])
173 fi
174 TargetWordSize=$ac_cv_sizeof_void_p
175 AC_SUBST(TargetWordSize)
176
177 #
178 dnl ** how to invoke `ar' and `ranlib'
179 #
180 FP_PROG_AR_SUPPORTS_ATFILE
181 FP_PROG_AR_NEEDS_RANLIB
182 RanlibCmd="$RANLIB"
183 AC_SUBST([RanlibCmd])
184
185 dnl ** Have libdw?
186 dnl --------------------------------------------------------------
187 dnl Check for a usable version of libdw/elfutils
188 dnl Currently we need 0.158 or newer.
189 BinDistNeedsLibdw=@UseLibdw@
190 if test "x$BinDistNeedsLibdw" = "xYES" ; then
191   AC_CHECK_LIB(dw, dwfl_attach_state,
192     [UseLibdw=YES],
193     [AC_MSG_ERROR([Binary distribution was built with libdw support but target system doesn't have supported libdw version (needs at least 0.158)])]
194   )
195 fi
196
197 FP_SETTINGS
198
199 #
200 AC_CONFIG_FILES(settings mk/config.mk mk/install.mk)
201 AC_OUTPUT
202
203 # We get caught by
204 #     http://savannah.gnu.org/bugs/index.php?1516
205 #     $(eval ...) inside conditionals causes errors
206 # with make 3.80, so warn the user if it looks like they're about to
207 # try to use it.
208 # We would use "grep -q" here, but Solaris's grep doesn't support it.
209 checkMake380() {
210     if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
211     then
212         echo
213         echo "WARNING: It looks like \"$1\" is GNU make 3.80."
214         echo "This version cannot be used to build GHC."
215         echo "Please use GNU make >= 3.81."
216     fi
217 }
218
219 checkMake380 make
220 checkMake380 gmake
221
222 echo "****************************************************"
223 echo "Configuration done, ready to 'make install'"
224 echo "(see README and INSTALL files for more info.)"
225 echo "****************************************************"