This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
configure.ac
425 lines (378 loc) · 13.3 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
dnl BANNERSTART
dnl - Copyright 2006-2008, Galois, Inc.
dnl - This software is distributed under a standard, three-clause BSD license.
dnl - Please see the file LICENSE, distributed with this software, for specific
dnl - terms and conditions.
dnl Author: Adam Wick <[email protected]>
dnl BANNEREND
AC_PREREQ(2.60)
AC_INIT(HALVM,2.4.3,[email protected],halvm)
dnl -------------------------------------------------------------------------
dnl
dnl Message logging system for autoconf. Allows us to stack up errors and
dnl warnings and print them all in a lump at the end.
dnl
dnl -------------------------------------------------------------------------
MESSAGE_LOG=
FAILED=No
AC_DEFUN([LOG_FAILURE], [
MESSAGE_LOG=${MESSAGE_LOG}"-IT- ERROR: "$1
FAILED=Yes
])
AC_DEFUN([LOG_FAILUREC], [
MESSAGE_LOG=${MESSAGE_LOG}"-EBR-"$1
])
AC_DEFUN([LOG_WARNING], [
MESSAGE_LOG=${MESSAGE_LOG}"-IT- WARNING: "$1
])
AC_DEFUN([LOG_WARNINGC], [
MESSAGE_LOG=${MESSAGE_LOG}"-WBR-"$1
])
AC_DEFUN([AC_FORCE_EXIST], [
AC_PATH_PROGS([$1], [$2], no)
if test "$$1" == no; then
LOG_FAILURE("Couldn't find required program $2")
fi
])
AC_DEFUN([AC_TESTS_WANT_EXIST], [
AC_PATH_PROGS([$1], [$2], no)
if test "$$1" == no; then
LOG_WARNING("Couldn't find required program $2 (needed to run test suite)")
fi
])
AC_DEFUN([AC_CHECK_PROG_VER],
[AC_PATH_PROGS([$1], [$2])
if test -z "[$]$1"; then
ac_verc_fail=yes
else
# Found it, now check the version.
AC_MSG_CHECKING([version of [$]$1])
changequote(<<,>>)dnl
ac_prog_version=`<<$>>$1 $3 2>&1 ifelse(<<$4>>,,,
<<| sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'>>)`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
<<$5>>)
changequote([,])dnl
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
esac
AC_MSG_RESULT([$ac_prog_version])
fi
ifelse([$6],,,
[if test $ac_verc_fail = yes; then
$6
fi])
])
dnl -------------------------------------------------------------------------
dnl
dnl Basic program requirements: If these don't exist, then the rest of our
dnl autoconf system won't work.
dnl
dnl -------------------------------------------------------------------------
dnl Check for sed and echo first, with an abrupt failure if they're not found,
dnl because we need these to show output.
AC_PATH_PROGS(SED, sed, no)
if test "$SED" == no; then
AC_MSG_ERROR("The HaLVM requires sed to build.")
fi
AC_PATH_PROGS(ECHO, echo, no)
if test "$ECHO" == no; then
AC_MSG_ERROR("The HaLVM requires echo to build.")
fi
dnl -------------------------------------------------------------------------
dnl
dnl Other program requirements: If these don't exist, then the autoconf
dnl script will run correctly, but we either we won't be able to build
dnl anything or we'll have to disable some portion of the system.
dnl
dnl -------------------------------------------------------------------------
dnl From this point on, we should use LOG_FAILURE instead of AC_FORCE_EXIST.
AC_FORCE_EXIST(AR,ar)
AC_FORCE_EXIST(AUTOMAKE,automake)
AC_FORCE_EXIST(AUTORECONF,autoreconf)
AC_FORCE_EXIST(CC,gcc)
AC_FORCE_EXIST(CHMOD,chmod)
AC_FORCE_EXIST(CP,cp)
AC_FORCE_EXIST(CPP,cpp)
AC_FORCE_EXIST(ECHO,echo)
AC_FORCE_EXIST(FIND,find)
AC_FORCE_EXIST(GIT,git)
AC_FORCE_EXIST(INSTALL,install)
AC_FORCE_EXIST(LD,ld)
AC_FORCE_EXIST(LIBTOOL,libtool) dnl Required by Ubuntu 12 for autoreconf
AC_FORCE_EXIST(LN,ln)
AC_FORCE_EXIST(MAKE,make)
AC_FORCE_EXIST(MKDIR,mkdir)
AC_FORCE_EXIST(MV,mv)
AC_FORCE_EXIST(NM,nm)
AC_FORCE_EXIST(OBJDUMP,objdump)
AC_FORCE_EXIST(PATCH,patch)
AC_FORCE_EXIST(PERL,perl)
AC_FORCE_EXIST(RANLIB,ranlib)
AC_FORCE_EXIST(RM,rm)
AC_FORCE_EXIST(SED,sed)
AC_FORCE_EXIST(TAR,tar)
AC_FORCE_EXIST(TOUCH,touch)
AC_CHECK_PROG_VER(ALEX, alex, --version, [Alex version \([0-9.]*\)],
[3.*], LOG_FAILURE("Couldn't find required version of Alex"))
AC_CHECK_PROG_VER(CABAL, cabal, --version, [cabal-install version \([0-9.]*\)],
[1.2[456789].*],
LOG_FAILURE("Couldn't find required version of Cabal"))
AC_CHECK_PROG_VER(GHC, ghc, --version, [version \([0-9.]*\)],
[8.0.*], LOG_FAILURE("Couldn't find required version of GHC"))
AC_CHECK_PROG_VER(HADDOCK, haddock, --version, [Haddock version \([0-9.]*\)],
[2.17.*],
LOG_FAILURE("Couldn't find required version of Haddock"))
AC_CHECK_PROG_VER(HAPPY, happy, --version, [Happy Version \([0-9.]*\)],
[1.19.*],
LOG_FAILURE("Couldn't find required version of Happy"))
AC_CHECK_PROG_VER(HSCOLOUR, HsColour, --version, [HsColour \([0-9.]*\)],
[1.24*],
LOG_FAILURE("Couldn't find required version of HsColour"))
AC_CHECK_PROG_VER(HSC2HS, hsc2hs, --version, [hsc2hs version \([0-9.]*\)],
[0.68*],
LOG_FAILURE("Couldn't find required version of hsc2hs"))
AC_SUBST(PLATFORMDIR, `dirname $(dirname ${ALEX})`)
AC_CHECK_HEADER(ncurses.h, HAVE_NCURSES=y,
[AC_CHECK_HEADER(curses.h, HAVE_NCURSES=y,
LOG_FAILURE("The HaLVM requires the ncurses development library."))])
AC_CHECK_HEADER(zlib.h, HAVE_ZLIB=y,
[LOG_FAILURE("The HaLVM requires zlib in order to build.")])
AC_CHECK_LIB(gmp, __gmpz_init, ,
LOG_FAILURE("The HaLVM requires libgmp to build."))
if test "${GHC}" != "no"; then
AC_MSG_CHECKING(for globally-installed GHC terminfo package)
if ${GHC}-pkg list --simple-output --no-user-package-conf | grep -q terminfo;
then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
LOG_FAILURE("The HaLVM requires GHC's terminfo library to be installed globally.")
fi
fi
dnl -------------------------------------------------------------------------
dnl
dnl C Compiler Oddities: Here we check for a few different flags that we
dnl may need to pass in order fo the HaLVM to run correctly.
dnl
dnl -------------------------------------------------------------------------
AC_LANG_PUSH(C)
AC_DEFUN([GCC_FLAG_CHECK], [
AC_CACHE_CHECK([whether gcc has $1], [$2], [
OLD_CFLAGS=${CFLAGS}
CFLAGS="${CFLAGS} $1"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(int a,char*b){return 1;}]])],
[$2=yes],
[$2=no])
CFLAGS=${OLD_CFLAGS}
])
if test "$$2" = "yes"; then
AC_SUBST($3,"$1")
else
AC_SUBST($3,"")
fi
])
GCC_FLAG_CHECK(-fno-unit-at-a-time,fp_cv_gcc_has_no_unit_at_a_time,
NO_UNIT_AT_A_TIME_OPT)
GCC_FLAG_CHECK(-fno-stack-protector,fp_cv_gcc_has_no_stack_protector,
NO_STACK_PROT_OPT)
GCC_FLAG_CHECK(-fomit-frame-pointer,fp_cv_gcc_has_omit_frame_pointer,
NO_FRAME_PTR_OPT)
GCC_FLAG_CHECK(-fno-asynchronous-unwind-tables,fp_cv_gcc_has_no_async_unwind,
NO_ASYNC_UNWIND_OPT)
GCC_FLAG_CHECK(-mno-red-zone,fp_cv_gcc_has_no_red_zone,
NO_RED_ZONE_OPT)
GCC_FLAG_CHECK(-fno-builtin,gp_cv_gcc_has_no_builtin,
NO_BUILTIN_OPT)
AC_LANG_POP(C)
dnl Build with GMP?
AC_ARG_ENABLE([gmp],
[AC_HELP_STRING([--enable-gmp],
[Build with gmp instead of integer-simple])],
[if test "$enableval" = "yes"; then
int_library=integer-gmp
else
int_library=integer-simple
fi],
[int_library=integer-simple])
AC_SUBST(INTEGER_LIBRARY, [$int_library])
dnl Enable halvm-ghc /dev/urandom emulation
AC_ARG_ENABLE([urandom],
[AC_HELP_STRING([--enable-urandom],
[Emulate filesystem access to /dev/urandom in the halvm-ghc RTS])],
[if test "$enableval" = "yes"; then
emulate_urandom=YES
else
emulate_urandom=NO
fi],
[emulate_urandom=NO])
AC_SUBST(EMULATE_URANDOM, [$emulate_urandom])
AC_CHECK_FILE(/etc/centos-release,
[if `grep -q "release 7" /etc/centos-release`; then
AC_SUBST(PLATFORM,"deb7")
else
AC_SUBST(PLATFORM,"centos65")
fi],
AC_SUBST(PLATFORM,"deb7"))
dnl -------------------------------------------------------------------------
dnl
dnl GHC Config
dnl
dnl -------------------------------------------------------------------------
AC_ARG_ENABLE(docs,
[AS_HELP_STRING([--enable-docs], [build documentation])],
[if test "$enableval" = "yes"; then
enable_docs="yes"
else
enable_docs="no"
fi
], [enable_docs="maybe"])
AC_PATH_PROGS(HADDOCK,haddock,no)
AC_PATH_PROGS(HSCOLOUR,hscolour,no)
case "$enable_docs" in
"yes")
AC_SUBST(ENABLE_DOCS,"YES")
;;
"no")
AC_SUBST(ENABLE_DOCS,"NO")
;;
"maybe")
if test "${HADDOCK}" == "no"; then
HADDOCK_TEST="no"
else
HADDOCK_TEST="yes"
fi
if test "${HSCOLOUR}" == "no"; then
HSCOLOUR_TEST="no"
else
HSCOLOUR_TEST="yes"
fi
case "${HADDOCK_TEST}${HSCOLOUR_TEST}" in
"nono") AC_SUBST(ENABLE_DOCS,"NO")
doc_reason="(no haddock or hscolour)";;
"yesno") AC_SUBST(ENABLE_DOCS,"NO")
doc_reason="(no hscolour)";;
"noyes") AC_SUBST(ENABLE_DOCS,"NO")
doc_reason="(no haddock)";;
"yesyes") AC_SUBST(ENABLE_DOCS,"YES");;
*) echo "Fail: |${HADDOCK}${HSCOLOUR}|"
esac
;;
esac
dnl -------------------------------------------------------------------------
dnl
dnl Xen Stuff
dnl
dnl -------------------------------------------------------------------------
AC_ARG_WITH(xen-tree,
[AS_HELP_STRING([--with-xen-tree=ARG],
[build against the given Xen source tree])],
[INCLUDE_DIRS="$withval"
CURDIR=`pwd`
CPPFLAGS="${CPPFLAGS} -I${withval}/dist/install/usr/include"
AC_SUBST(XEN_INCLUDE_DIRECTORY,"${withval}/dist/install/usr/include")
AC_SUBST(XEN_LIBRARY_DIRECTORY,"${withval}/dist/install/usr/lib")
AC_SUBST(XEN_BIN_ROOT,"${withval}/dist/install/")],
[AC_SUBST(XEN_BIN_ROOT,"/")
AC_SUBST(XEN_INCLUDE_DIRECTORY,"/usr/include")
AC_SUBST(XEN_LIBRARY_DIRECTORY,"/usr/lib")])
dnl First, see if we have Xen around.
AC_CHECK_HEADER(xen/xen.h,[],[
LOG_FAILURE("Couldn't find the Xen headers. Please either install them")
LOG_FAILUREC(["(they're probably in something like xen-devel), or use the"])
LOG_FAILUREC(["--with-xen-tree configure flag to point this script at the"])
LOG_FAILUREC(["base of a Xen source repository checkout."])])
AC_CHECK_HEADER(xenstore.h, HAVE_XENSTORE_H=yes, HAVE_XENSTORE_H=no)
AC_CHECK_HEADER(xs.h, HAVE_XS_H=yes, HAVE_XS_H=no)
if test "${HAVE_XENSTORE_H}${HAVE_XS_H}" = "nono"; then
LOG_FAILURE("The HaLVM requires either xenstore.h or xs.h.")
fi
if test "${HAVE_XENSTORE_H}" = "yes"; then
AC_SUBST(XENSTORE_H_OPT, "-DHAVE_XENSTORE_H")
else
AC_SUBST(XENSTORE_H_OPT, "")
fi
dnl Is this a 64-bit platform?
if test `uname -m` = "x86_64"; then
memory_model="64";
arch="x86_64"
abi="64"
else
arch="i386"
abi="32"
fi
AC_SUBST(ARCHITECTURE, "$arch")
AC_SUBST(ABI, "$abi")
AC_SUBST(target,"${arch}-unknown-HaLVM")
AC_SUBST(target_prefix,"${arch}-unknown-HaLVM-")
if test "$memory_model" != "64"; then
AC_ARG_ENABLE(pae,
[AS_HELP_STRING([--enable-pae],
[use the Intel PAE memory model. This is the default.])],
[if test "$enableval" = "yes"; then
memory_model="32p"
else
memory_model="32"
fi ],
[memory_model="32p"])
fi
AC_CHECK_DECL(xc_gnttab_open,
[AC_SUBST(BUILD_LIBIVC, "y")],
[AC_SUBST(BUILD_LIBIVC, "n")],
[#include <xenctrl.h>])
case "$memory_model" in
"32") AC_SUBST(ARCH_OPTION, "-DCONFIG_X86_32")
MEMMODEL_STR="32-bit" ;
ARCH=i386 ;;
"32p") AC_SUBST(ARCH_OPTION, "-DCONFIG_X86_PAE")
MEMMODEL_STR="PAE (36-bit physical / 32-bit virtual)" ;
ARCH=i386 ;;
"64") AC_SUBST(ARCH_OPTION, "-DCONFIG_X86_64")
MEMMODEL_STR="64-bit" ;
ARCH=x86_64 ;;
*) LOG_FAILURE("Unknown memory model (internal error?)") ;;
esac
AC_CHECK_FILE(/etc/os-release,
[source /etc/os-release
case "${ID}" in
"ubuntu") AC_SUBST(PACKAGE_TARGET, "deb") ;;
"debian") AC_SUBST(PACKAGE_TARGET, "deb") ;;
"fedora") AC_SUBST(PACKAGE_TARGET, "RPM") ;;
"centos") AC_SUBST(PACKAGE_TARGET, "RPM") ;;
*) AC_SUBST(PACKAGE_TARGET, "Unfamiliar (${ID})") ;;
esac],
AC_SUBST(PACKAGE_TARGET, "Unknown"))
dnl -------------------------------------------------------------------------
dnl
dnl Final message and file dump
dnl
dnl -------------------------------------------------------------------------
if test "${MESSAGE_LOG}" != ""; then
echo ${MESSAGE_LOG} | sed -e "s/-IT-/\n /g" -e "s/-WBR-/\n /g" -e "s/-EBR-/\n /g"
fi
if test "${FAILED}" == "Yes"; then
echo
echo "Fix these errors, and then try again."
else
echo
echo " HaLVM Memory Model: ${MEMMODEL_STR}"
echo " Integer library: ${INTEGER_LIBRARY}"
echo " Building documentation: ${ENABLE_DOCS} ${doc_reason}"
echo " Package target: ${PACKAGE_TARGET}"
echo
AC_CONFIG_FILES([
autoconf.mk
examples/standard.mk
src/HALVMCore/HALVMCore.buildinfo
src/debian/rules
src/misc/build.mk
src/scripts/halvm-cabal
src/scripts/halvm-config
src/scripts/halvm-ghc
src/scripts/halvm-ghc-pkg
src/scripts/hsc2hs
src/scripts/ldkernel
])
AC_OUTPUT
fi