configure.ac.in 6.79 KB
Newer Older
1 2 3 4 5 6
dnl
dnl Binary distribution configure script
dnl
#!/bin/sh
#

7
AC_INIT([The Glorious Glasgow Haskell Compilation System], [@ProjectVersion@], [glasgow-haskell-bugs@haskell.org], [ghc-AC_PACKAGE_VERSION])
8

9 10 11 12
dnl--------------------------------------------------------------------
dnl * Deal with arguments telling us gmp is somewhere odd
dnl--------------------------------------------------------------------

Ian Lynagh's avatar
Ian Lynagh committed
13
FP_GMP
14

15
dnl Various things from the source distribution configure
16
bootstrap_target=@TargetPlatform@
17

18 19 20
HaskellHaveRTSLinker=@HaskellHaveRTSLinker@
AC_SUBST(HaskellHaveRTSLinker)

21 22 23 24 25 26
FFIIncludeDir=@FFIIncludeDir@
FFILibDir=@FFILibDir@
AC_SUBST(FFILibDir)
AC_SUBST(FFIIncludeDir)


27 28 29 30 31 32
# We have to run these unconditionally as FPTOOLS_SET_PLATFORM_VARS wants the
# values it computes.
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

33 34
FPTOOLS_SET_PLATFORM_VARS

35 36 37
# Requires FPTOOLS_SET_PLATFORM_VARS to be run first.
FP_FIND_ROOT

38
# ToDo: if Stage1Only=YES, should be YES
39 40 41 42
CrossCompiling=NO
CrossCompilePrefix=""
TargetPlatformFull="${target}"

43
AC_SUBST(CrossCompiling)
44 45 46
AC_SUBST(CrossCompilePrefix)
AC_SUBST(TargetPlatformFull)

47 48 49
Unregisterised="@Unregisterised@"
AC_SUBST(Unregisterised)

50
#
51 52 53 54 55 56 57
dnl ** Check Perl installation **
#
AC_PATH_PROG(PerlCmd,perl)
if test -z "$PerlCmd"; then
   echo "You must install perl before you can continue"
   echo "Perhaps it is already installed, but not in your PATH?"
   exit 1
58 59
fi

sof's avatar
sof committed
60 61
#
dnl ** figure out how to do a BSD-ish install **
62 63
#
AC_PROG_INSTALL
sof's avatar
sof committed
64

65 66 67 68 69 70
#
dnl ** find `find`, used by get-win32-tarballs.sh (see #12502)
#
FP_PROG_FIND()
export FIND

sof's avatar
sof committed
71 72 73
#
dnl ** how to do symlinks **
#
sof's avatar
sof committed
74
AC_PROG_LN_S()
sof's avatar
sof committed
75 76 77

#
dnl ** Find the path to sed **
78
#
Ian Lynagh's avatar
Ian Lynagh committed
79
AC_PATH_PROG(SedCmd,gsed sed,sed)
80

81
XCODE_VERSION()
82 83 84

dnl ** Which gcc to use?
dnl --------------------------------------------------------------
85
AC_PROG_CC([gcc clang])
86

87 88
# --with-hs-cpp/--with-hs-cpp-flags
FP_CPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs)
thomie's avatar
thomie committed
89 90
AC_SUBST([HaskellCPPCmd])
AC_SUBST([HaskellCPPArgs])
91

92 93 94 95 96 97 98 99
# Here is where we re-target which specific version of the LLVM
# tools we are looking for. In the past, GHC supported a number of
# versions of LLVM simultaneously, but that stopped working around
# 3.5/3.6 release of LLVM.
LlvmVersion=@LlvmVersion@

dnl ** Which LLVM llc to use?
dnl --------------------------------------------------------------
Ben Gamari's avatar
Ben Gamari committed
100
FIND_LLVM_PROG([LLC], [llc], [$LlvmVersion])
101 102 103 104 105
LlcCmd="$LLC"
AC_SUBST([LlcCmd])

dnl ** Which LLVM opt to use?
dnl --------------------------------------------------------------
Ben Gamari's avatar
Ben Gamari committed
106
FIND_LLVM_PROG([OPT], [opt], [$LlvmVersion])
107 108 109
OptCmd="$OPT"
AC_SUBST([OptCmd])

110
FP_GCC_VERSION
Ben Gamari's avatar
Ben Gamari committed
111
FP_GCC_SUPPORTS_NO_PIE
112
AC_PROG_CPP
113

114 115 116
dnl ** Check gcc version and flags we need to pass it **
FP_GCC_EXTRA_FLAGS

117 118 119 120 121
FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS])
dnl FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])

122 123 124 125 126
FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
# Stage 3 won't be supported by cross-compilation
FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
127 128 129 130

AC_SUBST(CONF_CC_OPTS_STAGE0)
AC_SUBST(CONF_CC_OPTS_STAGE1)
AC_SUBST(CONF_CC_OPTS_STAGE2)
131 132 133 134 135 136 137 138 139
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
AC_SUBST(CONF_CPP_OPTS_STAGE0)
AC_SUBST(CONF_CPP_OPTS_STAGE1)
AC_SUBST(CONF_CPP_OPTS_STAGE2)
140

141 142 143 144 145 146
dnl ** Which ld to use?
dnl --------------------------------------------------------------
FIND_LD([$target],[GccUseLdOpt])
CONF_GCC_LINKER_OPTS_STAGE1="$CONF_GCC_LINKER_OPTS_STAGE1 $GccUseLdOpt"
CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2 $GccUseLdOpt"
LdCmd="$LD"
147
CFLAGS="$CFLAGS $GccUseLdOpt"
148 149 150 151 152 153 154
AC_SUBST([LdCmd])

FP_PROG_LD_IS_GNU
FP_PROG_LD_BUILD_ID
FP_PROG_LD_NO_COMPACT_UNWIND
FP_PROG_LD_FILELIST

155 156 157 158 159
dnl ** Set up the variables for the platform in the settings file.
dnl May need to use gcc to find platform details.
dnl --------------------------------------------------------------
FPTOOLS_SET_HASKELL_PLATFORM_VARS

160
dnl TargetWordSize for settings.in
161
AC_CHECK_SIZEOF(void *, 4)
162 163 164 165 166 167 168 169 170 171 172 173
if test "x$ac_cv_sizeof_void_p" = "x0"; then
    AC_MSG_ERROR([Failed to determine machine word size. Does your toolchain actually work?])
fi
dnl Check that the toolchain we have is consistent with what the compiler expects
if test "x$ac_cv_sizeof_void_p" != "x@TargetWordSize@"; then
    AC_MSG_ERROR([This binary distribution produces binaries for a target with
                  word size of @TargetWordSize@, but your target toolchain produces binaries
                  with a word size of $ac_cv_sizeof_void_p. Are you sure your toolchain
                  targets the intended target platform of this compiler?])
fi
TargetWordSize=$ac_cv_sizeof_void_p
AC_SUBST(TargetWordSize)
174

Ian Lynagh's avatar
Ian Lynagh committed
175 176 177
#
dnl ** how to invoke `ar' and `ranlib'
#
178
FP_PROG_AR_SUPPORTS_ATFILE
Ian Lynagh's avatar
Ian Lynagh committed
179 180
FP_PROG_AR_NEEDS_RANLIB

181 182 183 184 185 186
dnl ** which strip to use?
dnl --------------------------------------------------------------
AC_CHECK_TARGET_TOOL([STRIP], [strip])
StripCmd="$STRIP"
AC_SUBST([StripCmd])

Ben Gamari's avatar
Ben Gamari committed
187 188 189 190 191 192 193 194 195 196 197 198
dnl ** Have libdw?
dnl --------------------------------------------------------------
dnl Check for a usable version of libdw/elfutils
dnl Currently we need 0.158 or newer.
BinDistNeedsLibdw=@UseLibdw@
if test "x$BinDistNeedsLibdw" = "xYES" ; then
  AC_CHECK_LIB(dw, dwfl_attach_state,
    [UseLibdw=YES],
    [AC_MSG_ERROR([Binary distribution was built with libdw support but target system doesn't have supported libdw version (needs at least 0.158)])]
  )
fi

199 200
FP_SETTINGS

201
#
202
AC_CONFIG_FILES(settings mk/config.mk mk/install.mk)
203
AC_OUTPUT
204

205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
# We get caught by
#     http://savannah.gnu.org/bugs/index.php?1516
#     $(eval ...) inside conditionals causes errors
# with make 3.80, so warn the user if it looks like they're about to
# try to use it.
# We would use "grep -q" here, but Solaris's grep doesn't support it.
checkMake380() {
    if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
    then
        echo
        echo "WARNING: It looks like \"$1\" is GNU make 3.80."
        echo "This version cannot be used to build GHC."
        echo "Please use GNU make >= 3.81."
    fi
}

checkMake380 make
checkMake380 gmake

224
echo "****************************************************"
225
echo "Configuration done, ready to 'make install'"
sof's avatar
sof committed
226
echo "(see README and INSTALL files for more info.)"
227
echo "****************************************************"