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