-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
267 lines (218 loc) · 7.27 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
dnl == autoconf source for the Alan PL tools ==
dnl (run "grep '^dnl \*' configure.ac | sed -e 's/dnl / /g; s/\*\*/ +/g;'"
dnl (or some such) to see the outline of this file)
dnl
#
# (c) Tsitsimpis Ilias 2011-2012
#
# Configure script template for GAC
#
# Process with 'autoreconf' to get a working configure script.
#
# For the generated configure script, do "./configure --help" to
# see what flags are available. (Better yet, read the documentation!)
#
AC_INIT([The Glorious Alan Compilation System], [1.0], [[email protected]], [gac])
AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
dnl ----------------------------------------------------------
dnl ** Find unixy sort and find commands,
dnl ** which are needed by FP_SETUP_PROJECT_VERSION
# First off, a distrib sanity check..
AC_CONFIG_SRCDIR([src/gac.cabal.in])
dnl * We require autoconf version 2.52
AC_PREREQ([2.68])
# No, semi-sadly, we don't do `--srcdir'...
if test x"$srcdir" != 'x.' ; then
echo "This configuration does not support the \`--srcdir' option.."
exit 1
fi
dnl --------------------------------------------------------------
dnl * Project specific configuration options
dnl --------------------------------------------------------------
dnl ** Tell the make system which OS we are using
dnl $OSTYPE is set by the operating system to "msys" or "cygwin" or something
AC_SUBST(OSTYPE)
dnl ** What command to use to compile compiler sources ?
dnl --------------------------------------------------------------
AC_ARG_WITH([ghc],
[AC_HELP_STRING([--with-ghc=ARG],
[Use ARG as the path to GHC [default=autodetect]])],
[WithGhc="$withval"],
[if test "$GHC" = ""; then
AC_PATH_PROG([GHC], [ghc])
fi
WithGhc="$GHC"])
dnl ** Must have GHC to build gac
if test "$WithGhc" = ""; then
AC_MSG_ERROR([GHC is required to build gac.])
fi
FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl
if test "$GhcMajVersion" = "unknown" -o "$GhcMinVersion" = "unknown"; then
AC_MSG_ERROR([Cannot determine the version of $WithGhc. Is it really GHC?])
fi
AC_SUBST(GhcVersion)dnl
AC_SUBST(GhcMajVersion)dnl
AC_SUBST(GhcMinVersion)dnl
AC_SUBST(GhcPatchLevel)dnl
FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[7.0.3],
[AC_MSG_ERROR([GHC version 7.0.3 or later is required to compile gac.])])dnl
if test `expr $GhcMinVersion % 2` = "1"; then
AC_MSG_ERROR([
$WithGhc is a development snapshot of GHC, version $GhcVersion.
Compiling using this version of GHC is not supported, and may not
work. Use --with-ghc to specify a different GHC to use.])
fi;
# GHC is passed to Cabal, so we need a native path
ghc_host=`"${WithGhc}" +RTS --info | grep 'Host platform' | sed -e 's/.*, "//' -e 's/")//'`
AC_SUBST([WithGhc])
dnl--------------------------------------------------------------------
dnl * Choose host(/target/build) platform
dnl--------------------------------------------------------------------
dnl We ask the ghc compiler what platform it is for
FPTOOLS_SET_PLATFORM_VARS
checkArch() {
case $1 in
alpha|arm|hppa|hppa1_1|i386|ia64|m68k|mips|mipseb|mipsel|powerpc|powerpc64|rs6000|s390|sparc|sparc64|vax|x86_64)
;;
*)
echo "Unknown arch $1"
exit 1
;;
esac
}
checkVendor() {
case $1 in
dec|unknown|hp|apple|next|sun|sgi|ibm)
;;
*)
echo "Unknown vendor $1"
exit 1
;;
esac
}
checkOS() {
case $1 in
linux|freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|cygwin32|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|aix|haiku)
;;
*)
echo "Unknown OS '$1'"
exit 1
;;
esac
}
TargetPlatform="$TargetArch-$TargetVendor-$TargetOS"
checkArch "$TargetArch"
checkVendor "$TargetVendor"
checkOS "$TargetOS"
AC_SUBST(TargetPlatform)
AC_SUBST(TargetArch)
AC_SUBST(TargetOS)
AC_SUBST(TargetVendor)
dnl --------------------------------------------------------------
dnl End of configure script option section
dnl --------------------------------------------------------------
dnl --------------------------------------------------------------
dnl * General configuration checks
dnl --------------------------------------------------------------
dnl ** does #! work?
AC_SYS_INTERPRETER()
dnl ** check for Python
AC_PATH_PROG(PythonCmd,python)
if test "$PythonCmd" = ""; then
echo "Python is required to run testsuite."
fi
dnl Let's make sure install-sh is executable here. If we got it from
dnl a repo, it might not be (see bug #978).
chmod +x install-sh
dnl ** figure out how to do a BSD-ish install
AC_PROG_INSTALL
dnl ** Find the path to gcc
AC_PATH_PROGS(GCC,gcc,gcc)
dnl ** Find the path to ar
AC_PATH_PROGS(ArCmd,ar,ar)
dnl ** Find the path to llc
AC_PATH_PROGS(LlcCmd,llc,llc)
dnl ** Find the path to opt
AC_PATH_PROGS(OptCmd,opt,opt)
dnl ** Find the path to sed
AC_PATH_PROGS(SedCmd,gsed sed,sed)
dnl ** check for tar
dnl if GNU tar is named gtar, look for it first.
AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar)
dnl ** Find the path to gzip
AC_PATH_PROGS(GZipCmd,gzip,gzip)
dnl ** check for installed happy binary + version
FPTOOLS_HAPPY
dnl ** set ghc flags
AC_ARG_VAR([HFLAGS], [GHC compiler flags])
if test x"$ac_cv_env_HFLAGS_set" != x
then
HFLAGS=$ac_cv_env_HFLAGS_value
else
HFLAGS="-Wall -O2 -dno-debug-output"
fi
AC_SUBST([HFLAGS])
dnl ** set happy flags
AC_ARG_VAR([YFLAGS], [Happy metacompiler flags])
if test x"$ac_cv_env_YFLAGS_set" != x
then
YFLAGS=$ac_cv_env_YFLAGS_value
else
YFLAGS="--info --array --ghc --coerce"
fi
AC_SUBST([YFLAGS])
dnl ** check for installed alex binary + version
FPTOOLS_ALEX
dnl ** set alex flags
AC_ARG_VAR([LFLAGS], [Alex metacompiler flags])
if test x"$ac_cv_env_LFLAGS_set" != x
then
LFLAGS=$ac_cv_env_LFLAGS_value
else
LFLAGS="--ghc"
fi
AC_SUBST([LFLAGS])
dnl --------------------------------------------------
dnl ### program checking section ends here ###
dnl --------------------------------------------------
if grep ' ' src/gac.cabal.in 2>&1 >/dev/null; then
AC_MSG_ERROR([src/gac.cabal.in contains tab characters; please remove them])
fi
AC_CONFIG_FILES([Makefile src/gac.cabal src/Makefile src/config.h libraries/Makefile])
AC_OUTPUT
# 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 gac."
echo "Please use GNU make >= 3.81."
fi
}
checkMake380 make
checkMake380 gmake
echo ["
----------------------------------------------------------------------
Configure completed successfully.
Building GAC version : $PACKAGE_VERSION
Target platform : $TargetPlatform
"]
echo ["\
Compiling using : $WithGhc
which is version : $GhcVersion
"]
echo ["\
Happy : $HappyCmd ($HappyVersion)
Alex : $AlexCmd ($AlexVersion)
Python : $PythonCmd"]
echo ["----------------------------------------------------------------------
"]
echo "\
For a standard build of GAC (fully optimised), type (g)make.
"