Merge branch 'master' of http://darcs.haskell.org/ghc
[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])
8
9 FP_BINDIST_GHC_PWD
10 FP_FIND_ROOT
11
12 BootingFromHc=NO
13 AC_SUBST(BootingFromHc)
14
15 dnl--------------------------------------------------------------------
16 dnl * Deal with arguments telling us gmp is somewhere odd
17 dnl--------------------------------------------------------------------
18
19 FP_GMP
20
21 bootstrap_target=`ghc/stage2/build/tmp/ghc-stage2 +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'`
22 FPTOOLS_SET_PLATFORM_VARS
23
24 #
25 dnl ** Check Perl installation **
26 #
27 AC_PATH_PROG(PerlCmd,perl)
28 if test -z "$PerlCmd"; then
29    echo "You must install perl before you can continue"
30    echo "Perhaps it is already installed, but not in your PATH?"
31    exit 1
32 fi
33 FPTOOLS_SHEBANG_PERL
34
35 #
36 dnl ** figure out how to do a BSD-ish install **
37 #
38 AC_PROG_INSTALL
39
40 #
41 dnl ** how to do symlinks **
42 #
43 AC_PROG_LN_S()
44
45 #
46 dnl ** Find the path to sed **
47 #
48 AC_PATH_PROG(SedCmd,gsed sed,sed)
49
50 #
51 dnl ** How to invoke gcc/cpp **
52 #
53 if test "$TargetOS_CPP" = "darwin"
54 then
55     AC_MSG_CHECKING(XCode version)
56     XCodeVersion=`xcodebuild -version | grep Xcode | sed "s/Xcode //"`
57     # Old XCode versions don't actually give the XCode version
58     if test "$XCodeVersion" = ""
59     then
60         AC_MSG_RESULT(not found (too old?))
61     else
62         AC_MSG_RESULT($XCodeVersion)
63         XCodeVersion1=`echo "$XCodeVersion" | sed 's/\..*//'`
64 changequote(, )dnl
65         XCodeVersion2=`echo "$XCodeVersion" | sed 's/[^.]*\.\([^.]*\).*/\1/'`
66 changequote([, ])dnl
67         AC_MSG_NOTICE(XCode version component 1: $XCodeVersion1)
68         AC_MSG_NOTICE(XCode version component 2: $XCodeVersion2)
69     fi
70 fi
71
72 dnl ** Which gcc to use?
73 dnl --------------------------------------------------------------
74 if test "$TargetOS_CPP" = "darwin" &&
75    test "$XCodeVersion1" -ge 4
76 then
77   # From Xcode 4, use 'gcc-4.2' to force the use of the gcc legacy backend (instead of the LLVM
78   # backend)
79   FP_ARG_WITH_PATH_GNU_PROG([CC], [gcc-4.2])
80 else
81   FP_ARG_WITH_PATH_GNU_PROG([CC], [gcc])
82 fi
83 export CC
84 WhatGccIsCalled="$CC"
85 AC_SUBST(WhatGccIsCalled)
86
87 FP_GCC_VERSION
88 AC_PROG_CPP
89
90 #
91 dnl ** Check gcc version and flags we need to pass it **
92 #
93 FP_GCC_EXTRA_FLAGS
94
95 FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS])
96 FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0])
97 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1])
98 # Stage 3 won't be supported by cross-compilation
99 FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2])
100
101 AC_SUBST(CONF_CC_OPTS_STAGE0)
102 AC_SUBST(CONF_CC_OPTS_STAGE1)
103 AC_SUBST(CONF_CC_OPTS_STAGE2)
104 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0)
105 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1)
106 AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2)
107 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0)
108 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1)
109 AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2)
110 AC_SUBST(CONF_CPP_OPTS_STAGE0)
111 AC_SUBST(CONF_CPP_OPTS_STAGE1)
112 AC_SUBST(CONF_CPP_OPTS_STAGE2)
113
114 FP_SETTINGS
115
116 #
117 dnl ** how to invoke `ar' and `ranlib'
118 #
119 FP_PROG_AR_NEEDS_RANLIB
120
121 #
122 AC_CONFIG_FILES(settings mk/config.mk mk/install.mk)
123 AC_OUTPUT
124
125 # We get caught by
126 #     http://savannah.gnu.org/bugs/index.php?1516
127 #     $(eval ...) inside conditionals causes errors
128 # with make 3.80, so warn the user if it looks like they're about to
129 # try to use it.
130 # We would use "grep -q" here, but Solaris's grep doesn't support it.
131 checkMake380() {
132     if $1 --version 2>&1 | head -1 | grep 'GNU Make 3\.80' > /dev/null
133     then
134         echo
135         echo "WARNING: It looks like \"$1\" is GNU make 3.80."
136         echo "This version cannot be used to build GHC."
137         echo "Please use GNU make >= 3.81."
138     fi
139 }
140
141 checkMake380 make
142 checkMake380 gmake
143
144 echo "****************************************************"
145 echo "Configuration done, ready to 'make install'"
146 echo "(see README and INSTALL files for more info.)"
147 echo "****************************************************"