-
Notifications
You must be signed in to change notification settings - Fork 55
/
configure.ac
5643 lines (5011 loc) · 181 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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#-----------------------------------------------------------------------------#
# vim: ts=4 sw=4 expandtab
#-----------------------------------------------------------------------------#
# Copyright (C) 1995-2012 The University of Melbourne.
# Copyright (C) 2013-2024 The Mercury team.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
#
# configure.ac: autoconf source code for `configure' script.
#
# This file is automatically processed by `autoconf' to produce the
# `configure' script.
#
#-----------------------------------------------------------------------------#
#
# Define a macro MERCURY_MSG, similar to AC_MSG_RESULT, for displaying output.
#
dnl MERCURY_MSG(MESSAGE)
define(MERCURY_MSG,
[echo $1 1>&AS_MESSAGE_FD])
#-----------------------------------------------------------------------------#
AC_INIT
AC_CONFIG_SRCDIR([scripts/mmc.in])
TMPDIR=${TMPDIR=/tmp}
AC_PREREQ([2.69])
#-----------------------------------------------------------------------------#
#
# Ensure that all messages are saved to a file `configure.log' by
# invoking ourself recursively without output piped into `tee configure.log'.
# The environment variable `SUPPRESS_LOG_FILE_RECURSION' is used to prevent
# infinite recursion.
#
# XXX Currently this is commented out because autoconf 2.60 breaks
# how this works.
#if test "$SUPPRESS_LOG_FILE_RECURSION" != "yes"; then
# SUPPRESS_LOG_FILE_RECURSION=yes
# export SUPPRESS_LOG_FILE_RECURSION
# trap 0 1 2 3 13 15
# rm -f configure.exit_status
# { case $# in
# 0) ${CONFIG_SHELL-/bin/sh} "$0" ;;
# *) ${CONFIG_SHELL-/bin/sh} "$0" "$@" ;;
# esac; echo $? > configure.exit_status; } | exec tee configure.log
# status=`cat configure.exit_status`
# rm -f configure.exit_status
# exit $status
#fi
#-----------------------------------------------------------------------------#
# Work out the default arguments to configure when reconfiguring,
# for example when installing a binary distribution.
# Strip out --no-create and --no-recursion added by config.status.
# Remove any --prefix and --enable-reconfigure arguments passed by
# mercury_config.
# Strip out any site or system specific configuration files since their
# presence when reconfiguring will result in the command line used to invoke
# configure being invalid.
# Also quote any args containing shell metacharacters.
#
# NOTE: Some macros, e.g. AC_CHECK_PROG, overwrite the argument list,
# so this must come before any uses of those macros.
prefix_arg=false
RECONFIGURE_ARGS=
for arg
do
if test "$prefix_arg" = true
then
prefix_arg=false
else
case "$arg" in
--no-create | --no-recursion)
;;
--prefix)
prefix_arg=true
;;
--prefix=*)
;;
--enable-reconfigure=*)
;;
*config.site)
;;
*" "*|*" "*|*[[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]]*)
# The argument needs to be quoted.
RECONFIGURE_ARGS="$RECONFIGURE_ARGS '$arg'"
;;
*)
RECONFIGURE_ARGS="$RECONFIGURE_ARGS $arg"
;;
esac
fi
done
AC_SUBST(RECONFIGURE_ARGS)
#-----------------------------------------------------------------------------#
AC_CONFIG_HEADERS(runtime/mercury_conf.h robdd/robdd_conf.h)
DEFAULT_PREFIX="/usr/local/mercury-`. ./VERSION; echo $VERSION`"
AC_PREFIX_DEFAULT(/usr/local/mercury-`. ./VERSION; echo $VERSION`)
#-----------------------------------------------------------------------------#
#
# Let the user specify an optional package version.
#
AC_ARG_WITH(pkgversion,
AS_HELP_STRING([--with-pkgversion=<pkgversion>],
[Specify the package version for version messages.]),
[PACKAGE="$withval"], [PACKAGE=])
case "$PACKAGE" in
yes)
AC_MSG_ERROR(missing argument to --with-pkgversion=... option)
exit 1
;;
esac
AC_DEFINE_UNQUOTED(MR_PKGVERSION, "$PACKAGE")
AC_SUBST(PACKAGE)
#-----------------------------------------------------------------------------#
#
# Let the user specify which C compiler to use.
#
AC_ARG_WITH(cc,
AS_HELP_STRING([--with-cc=<program>], [Specify which C compiler to use.]),
[mercury_cv_with_cc="$withval"], [mercury_cv_with_cc=""])
case "$mercury_cv_with_cc" in
yes)
AC_MSG_ERROR(missing argument to --with-cc=... option)
exit 1
;;
no)
AC_MSG_ERROR(invalid option --without-cc)
exit 1
;;
"")
;;
*)
CC="$mercury_cv_with_cc"
;;
esac
#-----------------------------------------------------------------------------#
#
# Determine what C compiler to use.
#
# The code in config.guess that distinguishes between the i*86 and x86_64
# versions of Darwin needs to use the C compiler to make that distinction.
# In particular, if we wish to build a 32-bit Mercury installation on an
# x86_64 machine, then we need to tell configure that we are using the
# 32-bit C compiler. If we didn't call the AC_PROG_CC macro at this point,
# then configure's --with-cc option would not do that.
AC_PROG_CC
AC_SUBST([CC])
# Ensure that AC_CANONICAL_HOST uses the value of CC we just determined.
#
export CC
# NOTE: AC_PROG_CC will set the variable GCC if it thinks the C compiler is
# GCC. However, it also sets it if the C compiler is clang -- because they
# both define __GNUC__ -- do *NOT* use the GCC variable to check the C compiler
# type, instead use the value of C_COMPILER_TYPE (defined below).
MERCURY_CC_TYPE
MERCURY_HAVE_CLANG=no
MERCURY_HAVE_GCC=no
MERCURY_HAVE_MSVC=no
case "$mercury_cv_cc_type" in
clang)
MERCURY_HAVE_CLANG=yes
MERCURY_CLANG_VERSION
C_COMPILER_TYPE="clang_${mercury_cv_clang_version}"
;;
gcc)
MERCURY_HAVE_GCC=yes
MERCURY_GCC_VERSION
C_COMPILER_TYPE="gcc_${mercury_cv_gcc_version}"
;;
msvc_x86|msvc_x64)
MERCURY_HAVE_MSVC=yes
MERCURY_MSVC_VERSION
C_COMPILER_TYPE="${mercury_cv_cc_type}_${mercury_cv_msvc_version}"
;;
*)
C_COMPILER_TYPE="unknown"
;;
esac
#-----------------------------------------------------------------------------#
# Work out what CPU type we need to pass to boehm_gc/NT_MAKEFILE.
case "$mercury_cv_cc_type" in
msvc_x64) BOEHM_WINDOWS_CPU_TYPE="x64" ;;
*) BOEHM_WINDOWS_CPU_TYPE="x86" ;;
esac
AC_SUBST([BOEHM_WINDOWS_CPU_TYPE])
#-----------------------------------------------------------------------------#
AC_CANONICAL_HOST
FULLARCH="$host"
AC_SUBST(FULLARCH)
AC_DEFINE_UNQUOTED(MR_FULLARCH, "$FULLARCH")
. ./VERSION
AC_DEFINE_UNQUOTED(MR_VERSION, "$VERSION")
if test "$prefix" = "NONE"; then
PREFIX="$ac_default_prefix"
if test -d "$PREFIX"
then
INSTALLABLE_PREFIX=yes
else
INSTALLABLE_PREFIX=no
fi
else
PREFIX="$prefix"
# the directory may be created later
INSTALLABLE_PREFIX=yes
fi
AC_SUBST(INSTALLABLE_PREFIX)
case "$PREFIX" in
*\ *)
AC_MSG_ERROR(
[cannot install into a directory with a name containing
spaces: '$PREFIX.'])
exit 1
;;
esac
#-----------------------------------------------------------------------------#
case "$cross_compiling" in
yes)
CROSS_COMPILING=yes
BUILD_C_PROGS_FOR_BUILD_SYSTEM=cc
HOST_TOOL_PREFIX="$host-"
;;
*)
CROSS_COMPILING=no
BUILD_C_PROGS_FOR_BUILD_SYSTEM="$CC"
HOST_TOOL_PREFIX=
;;
esac
AC_SUBST(CROSS_COMPILING)
AC_SUBST(BUILD_C_PROGS_FOR_BUILD_SYSTEM)
#-----------------------------------------------------------------------------#
# Versions of Xcode 11 up until 11.4 ship with a broken version of clang.
# NOTE: what we are checking for below is Apple version for clang, Xcode 11.4
# has Apple clang version 11.0.3.
if test "$MERCURY_HAVE_CLANG" = yes
then
case "$host" in *apple*darwin*)
$CC -v 2>&1 | grep Apple | {
read apple llvm version versionnum rest
case $versionnum in 11.0.[[012]])
AC_MSG_WARN(
[
**** Note that this version of Xcode 11 has bugs that prevent Mercury programs
**** from working correctly. Please use Xcode 11.4 or later.
**** See README.MacOS for further details.])
;;
esac }
;;
esac
fi
#-----------------------------------------------------------------------------#
# Ensure that the user does not try to build MSYS executables; we do not
# (currently) support that.
case "$host" in *-pc-msys)
AC_MSG_ERROR(
[
***** The $host architecture is not supported.
***** You probably meant to use one of: x86_64-pc-mingw32, x86_64-pc-mingw64.])
;;
esac
#-----------------------------------------------------------------------------#
# Using `cygpath -m' gives a path that works under both Cygwin and native
# Windows, without causing quoting problems in shell scripts.
# (`cygpath -m' converts the path to Windows format, with '/' as the directory
# separator).
AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo)
AC_CHECK_PROG(CYGPATHU, cygpath, cygpath -u, echo)
AC_SUBST(CYGPATHU)
PREFIX="`$CYGPATH $PREFIX`"
LIBDIR="`$CYGPATH $PREFIX/lib/mercury`"
NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=$PREFIX/lib/nonshared}
AC_SUBST(VERSION)
AC_SUBST(PREFIX)
AC_SUBST(NONSHARED_LIB_DIR)
AC_SUBST(LIBDIR)
DEFAULT_MERCURY_DEBUGGER_INIT_DIR=$LIBDIR/mdb
AC_SUBST(DEFAULT_MERCURY_DEBUGGER_INIT_DIR)
DEFAULT_MERCURY_DEBUGGER_DOC=$DEFAULT_MERCURY_DEBUGGER_INIT_DIR/mdb_doc
AC_SUBST(DEFAULT_MERCURY_DEBUGGER_DOC)
#-----------------------------------------------------------------------------#
# MMC_INVOKE_CMD is the command used to invoke mercury_compile in scripts/mmc.
# On MSYS (MinGW) we cannot use exec, since exec will not find the file because
# it will expect a path relative to the MSYS home directory and will not work
# with a full Windows path. A full Windows path, however must be used for the
# prefix so that mercury_compile will find the standard library.
#
case "$host" in
*mingw*)
MMC_INVOKE_CMD=
;;
*) MMC_INVOKE_CMD=exec
;;
esac
AC_SUBST(MMC_INVOKE_CMD)
#-----------------------------------------------------------------------------#
# Don't document this -- it's only used by the mercury_config script
# to generate a new configuration for an already installed system.
# CONFIG_PREFIX is the PREFIX for a partial installation generated
# by mercury_config containing only the scripts and the configuration
# files, which uses the libraries and executables from a previous
# installation.
AC_ARG_ENABLE(reconfigure,
[],
[reconfiguring=yes
CONFIG_PREFIX="$enableval"
CONFIG_LIBDIR="$CONFIG_PREFIX/lib/mercury"],
[reconfiguring=no
CONFIG_PREFIX="$PREFIX"
CONFIG_LIBDIR="$LIBDIR"]
)
case "$CONFIG_PREFIX" in
yes)
AC_MSG_ERROR(missing argument to --enable-reconfigure=... option)
exit 1
;;
no)
AC_MSG_ERROR(invalid option --no-enable-reconfigure)
exit 1
;;
esac
CONFIG_PREFIX="`$CYGPATH $CONFIG_PREFIX`"
CONFIG_LIBDIR="`$CYGPATH $CONFIG_LIBDIR`"
AC_SUBST(CONFIG_PREFIX)
AC_SUBST(CONFIG_LIBDIR)
#-----------------------------------------------------------------------------#
case "$build" in
i*86-*-solaris2.*) link_static_opt= ;;
*solaris2.10) link_static_opt= ;;
*apple*darwin*) link_static_opt= ;;
*linux*) link_static_opt= ;;
*cygwin*) link_static_opt= ;;
*) link_static_opt="--linkage static" ;;
esac
MERCURY_MSG("looking for an already installed Mercury compiler to bootstrap with...")
AC_PATH_PROG(BOOTSTRAP_MC,mmc)
# Ignore the Microsoft Management Console, which if executed will pop up with
# an annoying error message.
case $BOOTSTRAP_MC in
*Windows*|*system32*|*WINNT*)
BOOTSTRAP_MC=
MERCURY_MSG("ignoring Microsoft Management Console")
;;
esac
DETECTED_MC="$BOOTSTRAP_MC"
if test "$BOOTSTRAP_MC" != ""
then
AC_MSG_CHECKING(whether the above mmc works and is sufficiently recent)
cat > conftest.m << EOF
% This module contains features which did not work in
% previous versions of the Mercury compiler.
% We may also test to see if the installed compiler is
% recent enough by checking what flags mmc takes.
% Use [[ ]] for lists.
:- module conftest.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- implementation.
:- import_module bool, char, string, int, list, uint32, univ.
:- mutable(global_var,
int,
561,
ground,
[[untrailed, attach_to_io_state, thread_local]]
).
:- type abs_enum ---> yes ; no.
:- type abs_enum where type_is_abstract_enum(1).
main(!IO) :-
return_rtti_version(Version),
p(T),
q(T, _),
get_global_var(Global, !IO),
(
% If you change the minimum RTTI version, you also
% need to update the Mercury clause for return_rtti_version
% below.
Version >= 8,
ac(2) ^ elem(3, 5) = 17,
(1 .. 2) = [[1, 2]],
Global = 561
->
trace [[io(!S)]] (
io.print("Hello, ", !S)
),
promise_pure (
semipure io.unsafe_get_io_state(UIO0),
io.print("world\n", UIO0, UIO),
impure io.unsafe_set_io_state(UIO)
)
;
Words = string.words_separator(char.is_alpha, "xx yy"),
io.write(Words, !IO)
).
:- type t ---> a ; b ; c(int).
:- type bear ---> brown ; black ; teddy.
:- pragma foreign_export_enum("Java", bear/0).
:- pred check_int64(int64::out) is det.
:- pragma no_inline(pred(check_int64/1)).
check_int64(561i64).
:- pred my_uint_xor(uint32::in, uint32::out) is det.
my_uint_xor(A, B) :-
disable_warning [[unknown_format_calls]] (
561u32 = uint32.xor(A, B)
).
:- pred p(t::out) is det.
p(b).
:- pred q(t::in, int::out) is det.
:- pragma obsolete(q/2, [[p/1]]).
q(T, N) :-
(
T = a : t,
N = 0 : int
;
( T = b ; T = c(_) ),
N = 1
).
:- type a ---> ac(int).
:- func a ^ elem(int, int) = int.
:- mode in ^ elem(in, in ) = out is det.
ac(T) ^ elem(I, J) = T + I * J.
:- pred return_rtti_version(int::out) is det.
:- pragma foreign_decl("C", local, "
typedef enum {
enum1, enum2
} Enum;
").
:- type c_enum
---> c_enum_1
; c_enum_2.
:- pragma foreign_enum("C", c_enum/0, [[
c_enum_1 - "enum1",
c_enum_2 - "enum2"
]]).
:- type x ---> x.
:- pragma foreign_type("C", x, "MR_Integer",
[[can_pass_as_mercury_type, stable]]).
:- pragma foreign_type("C#", x, "object").
:- pragma foreign_proc("C", return_rtti_version(Version::out),
[[may_call_mercury, promise_pure, terminates,
does_not_affect_liveness, will_not_modify_trail]],
"
Version = MR_RTTI_VERSION;
").
% XXX the non-C backends do not currently define an equivalent
% to MR_RTTI_VERSION.
return_rtti_version(8).
% The code below is the hard_coded/disjs_in_switch test case.
% The compiler now depends on the installed compiler handling
% code like this test case correctly.
:- type tp
---> f(int)
; g(int, int)
; h(float)
; i(string).
:- pred p(tp::in, string::out) is det.
p(T, U) :-
(
( T = f(_)
; T = g(_, _)
),
disable_warning [[suspicious_recursion]] (
U = "f or g"
)
;
( T = h(_)
; T = i(_)
),
U = "h or i"
).
:- pred ext(int::out) is det.
:- pragma external_pred(ext/1).
:- type psv_t
---> psv_t1
; psv_t2
; psv_t3
; psv_t4
; psv_t5
; psv_t6
; psv_t7
; psv_t8.
:- type psv_u
---> psv_u1
; psv_u2.
:- pred preferred_switch_var(psv_t::in, psv_u::in, int::out)
is semidet.
preferred_switch_var(T, U, N) :-
require_switch_arms_semidet [[T]]
(
T = psv_t1,
U = psv_u1,
N = 11
;
T = psv_t2,
U = psv_u2,
N = 22
;
T = psv_t3,
U = psv_u1,
N = 31
;
T = psv_t4,
U = psv_u2,
N = 42
).
EOF
# When this script has been invoked with --prefix=..., these variables
# will have values by the time we get here, but the values will be the
# ones appropriate to the system *we will install*, not the system that is
# *already installed*, i.e. the bootstrap compiler. If we don't temporarily
# unset these variables, the bootstrap test will fail because the Mercury
# compiler won't find the (to-be-installed-later) .int files for the
# standard library modules it needs.
SAVE_MERCURY_CONFIG_DIR="${MERCURY_CONFIG_DIR}"
SAVE_MERCURY_DEFAULT_GRADE="${MERCURY_DEFAULT_GRADE}"
SAVE_MERCURY_STDLIB_DIR="${MERCURY_STDLIB_DIR}"
unset MERCURY_CONFIG_DIR
unset MERCURY_DEFAULT_GRADE
unset MERCURY_STDLIB_DIR
if
echo $BOOTSTRAP_MC conftest >&AS_MESSAGE_LOG_FD 2>&1 &&
$BOOTSTRAP_MC \
--verbose \
$link_static_opt conftest \
--escape-2024-04-28 \
--allow-ho-insts-as-modes \
--no-ssdb \
</dev/null >&AS_MESSAGE_LOG_FD 2>&1 &&
test "`./conftest 2>&1 | tr -d '\015'`" = "Hello, world" &&
$BOOTSTRAP_MC \
--grade none.gc \
--warn-potentially-ambiguous-pragma \
--no-detect-libgrades \
--output-grade-string \
--shlib-linker-install-name-flag "-dummy_flag" \
--ranlib-flags "" \
</dev/null >&AS_MESSAGE_LOG_FD 2>&1
then
AC_MSG_RESULT(yes)
else
BOOTSTRAP_MC=
AC_MSG_RESULT(no)
# This will only work if the user is working with a source
# distribution which includes the pre-generated .C files.
# So do a quick check now to ensure that we fail early with a
# reasonable error message if they are not present.
if test -f compiler/mercury_compile.c ||
test -f compiler/Mercury/cs/mercury_compile.c
then
true
elif
test -f $PREFIX/bin/mercury_compile ||
test -f $PREFIX/bin/mercury_compile.exe
then
# This variable is used to let the tests in the following section
# know that we are going to attempt to bootstrap with the compiler
# $PREFIX/bin.
bootstrap_from_prefix="yes"
AC_MSG_WARN(
[using $PREFIX/bin/mercury_compile to bootstrap])
else
AC_MSG_ERROR(
[You need a working Mercury compiler to bootstrap with])
fi
fi
rm -f conftest*
export MERCURY_CONFIG_DIR="${SAVE_MERCURY_CONFIG_DIR}"
export MERCURY_DEFAULT_GRADE="${SAVE_MERCURY_DEFAULT_GRADE}"
export MERCURY_STDLIB_DIR="${SAVE_MERCURY_STDLIB_DIR}"
fi
#-----------------------------------------------------------------------------#
if test "$BOOTSTRAP_MC" = ""
then
# If we do not have a working bootstrap Mercury compiler, then work out
# whether any .c files we do have were compiled with high level code or
# not. At this point we only check a single file -- this is enough to
# allow us to determine a value for BOOTSTRAP_GRADE below -- we check
# any other pre-generated .c files as part of the call to
# mercury_check_c_files() later on.
#
if test -f compiler/mercury_compile.c
then
highlevel_code=`grep "HIGHLEVEL_CODE=.*" compiler/mercury_compile.c`
else
if test -f compiler/Mercury/cs/mercury_compile.c
then
highlevel_code=`grep "HIGHLEVEL_CODE=.*" compiler/Mercury/cs/mercury_compile.c`
else
# If we are going to attempt to bootstrap from a compiler in
# $PREFIX/bin (see the above section), then it is ok if we do not
# have any pre-generated .c files; if not, then we cannot continue.
#
if test "$bootstrap_from_prefix" != "yes"
then
AC_MSG_ERROR(
[You need a working Mercury compiler to bootstrap with])
fi
fi
fi
case "$highlevel_code" in
*yes)
BOOTSTRAP_HLC="yes"
;;
*no)
BOOTSTRAP_HLC="no"
;;
"")
# This corresponds to the case where we compile using
# $PREFIX/bin/mercury_compile. Since we can (hopefully)
# regenerate any .c files, it is irrelevant whether we used
# --highlevel-code or not when compiling any existing ones.
;;
*)
AC_MSG_ERROR(
[Cannot determine what code model pre-generated .c files use.])
;;
esac
fi
#-----------------------------------------------------------------------------#
#
# Determine whether to define LARGE_CONFIG when compiling boehm_gc.
#
AC_ARG_ENABLE(gc-large-config,
AS_HELP_STRING([--disable-gc-large-config],
[disable large heaps when using conservative GC]),
[enable_gc_large_config="$enableval"],[enable_gc_large_config=yes])
AC_MSG_CHECKING(whether to enable large heaps when using conservative GC)
case "$enable_gc_large_config" in
yes)
AC_MSG_RESULT(yes)
ENABLE_BOEHM_LARGE_CONFIG=-DLARGE_CONFIG
;;
no)
AC_MSG_RESULT(no)
ENABLE_BOEHM_LARGE_CONFIG=
;;
*)
AC_MSG_RESULT(yes)
AC_MSG_WARN([unexpected argument to --enable-gc-large-config])
ENABLE_BOEHM_LARGE_CONFIG=-DLARGE_CONFIG
;;
esac
AC_SUBST(ENABLE_BOEHM_LARGE_CONFIG)
#-----------------------------------------------------------------------------#
#
# Determine whether to define USE_MMAP, USE_MUNMAP when compiling boehm_gc.
#
AC_ARG_ENABLE(gc-mmap,
AS_HELP_STRING([--disable-gc-mmap],
[use sbrk instead of mmap when using Boehm GC]),
[enable_gc_mmap="$enableval"],[enable_gc_mmap=yes])
AC_ARG_ENABLE(gc-munmap,
AS_HELP_STRING([--disable-gc-munmap],
[disable unmapping of unused pages when using Boehm GC]),
[enable_gc_munmap="$enableval"],[enable_gc_munmap=yes])
AC_MSG_CHECKING(whether to enable unmapping of unused pages when using Boehm GC)
case "$enable_gc_munmap" in
yes)
# --enable-gc-munmap implies --enable-gc-mmap
enable_gc_mmap=yes
AC_MSG_RESULT(yes)
;;
no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_ERROR([unexpected argument to --enable-gc-munmap])
;;
esac
AC_MSG_CHECKING(whether to use mmap for Boehm GC)
case "$enable_gc_mmap" in
yes|no)
AC_MSG_RESULT($enable_gc_mmap)
;;
*)
AC_MSG_ERROR([unexpected argument to --enable-gc-mmap])
;;
esac
if test "$enable_gc_mmap" = yes; then
ENABLE_BOEHM_USE_MMAP="-DUSE_MMAP"
else
ENABLE_BOEHM_USE_MMAP=
fi
if test "$enable_gc_munmap" = yes; then
ENABLE_BOEHM_USE_MUNMAP="-DUSE_MUNMAP"
else
ENABLE_BOEHM_USE_MUNMAP=
fi
AC_SUBST(ENABLE_BOEHM_USE_MMAP)
AC_SUBST(ENABLE_BOEHM_USE_MUNMAP)
#-----------------------------------------------------------------------------#
MERCURY_MSG("looking for GNU Make...")
AC_CHECK_PROGS([GNU_MAKE], [gmake make])
if test "$GNU_MAKE" != ""; then
case "`$GNU_MAKE -v bogus </dev/null 2>&1`" in
"GNU Make"*)
;;
*)
GNU_MAKE=
esac
fi
if test "$GNU_MAKE" = ""; then
AC_MSG_ERROR(cannot find GNU Make)
exit 1
else
MERCURY_MSG("found GNU Make: $GNU_MAKE")
fi
AC_SUBST(GNU_MAKE)
#-----------------------------------------------------------------------------#
MERCURY_MSG("looking for a way to create named pipes...")
# Neither mkfifo or mknod exist in a working state on MinGW, so on that
# platform we skip the following tests in order to avoid emitting extra
# warnings.
#
case "$host" in
*mingw*)
MERCURY_MSG("named pipes not available for MinGW")
AC_DEFINE_UNQUOTED(MR_MKFIFO, "")
MKFIFO=none
MKNOD=""
;;
*)
save_PATH="$PATH"
PATH="$PATH:/etc:/usr/etc:/sbin"
AC_PATH_PROG(MKFIFO,mkfifo)
if test "$MKFIFO" != ""; then
# check that it really works
tmp=$TMPDIR/fifo$$
trap "rm -f $tmp" 1 2 3 13 15
if $MKFIFO $tmp && test -p $tmp; then
true
else
MKFIFO=""
fi
rm -f $tmp
fi
if test "$MKFIFO" = ""; then
AC_PATH_PROG(MKNOD,mknod)
if test "$MKNOD" != ""; then
# check that it really works
tmp=$TMPDIR/fifo$$
trap "rm -f $tmp" 1 2 3 13 15
if $MKNOD $tmp p && test -p $tmp; then
MKFIFO=mkfifo_using_mknod
else
MKNOD=
fi
fi
fi
if test "$MKFIFO" = ""; then
AC_MSG_WARN(cannot find a working 'mkfifo' or 'mknod')
MKFIFO=none
AC_DEFINE_UNQUOTED(MR_MKFIFO, "")
else
AC_DEFINE_UNQUOTED(MR_MKFIFO, "$MKFIFO")
fi
PATH="$save_PATH"
;;
esac
AC_SUBST(MKFIFO)
test "$MKNOD" = "" && MKNOD=mknod
AC_SUBST(MKNOD)
#-----------------------------------------------------------------------------#
MERCURY_MSG("looking for a way to create temporary files...")
AC_PATH_PROG(MKTEMP,mktemp)
if test "$MKTEMP" != ""; then
# check that it really works
TMPFILE="`mktemp $TMPDIR/configure.XXXXXX < /dev/null`"
case "$TMPFILE" in
$TMPDIR/configure.*)
rm -f $TMPFILE
;;
*)
MKTEMP=""
;;
esac
fi
if test "$MKTEMP" = ""; then
AC_MSG_WARN(cannot find a working 'mktemp', using 'mkdir || exit')
MKTEMP=""
fi
AC_SUBST(MKTEMP)
#-----------------------------------------------------------------------------#
# Determine if we should install Windows-specific files such as the batch
# files. We only do this where there is a chance they can be useful.
INSTALL_WINDOWS_SCRIPTS=no
case "$host" in
*mingw*)
INSTALL_WINDOWS_SCRIPTS=yes
;;
*)
if test "$ac_microsoft" = "yes"
then
INSTALL_WINDOWS_SCRIPTS=yes
else
INSTALL_WINDOWS_SCRIPTS=no
fi
;;
esac
AC_SUBST(INSTALL_WINDOWS_SCRIPTS)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(INSTALL_INFO,install-info)
AC_SUBST(INSTALL_INFO)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(TEXI2DVI,texi2dvi)
AC_SUBST(TEXI2DVI)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(PDFTEX, pdftex)
AC_SUBST(PDFTEX)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(LYNX,lynx)
AC_SUBST(LYNX)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(DVIPS,dvips)
AC_SUBST(DVIPS)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(MAKEINFO,makeinfo)
AC_SUBST(MAKEINFO)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(INFO,info)
AC_SUBST(INFO)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(PERL,perl)
AC_SUBST(PERL)
#-----------------------------------------------------------------------------#
AC_PATH_PROG(HOSTNAMECMD,hostname uname)
case "$HOSTNAMECMD" in
*hostname)
# OS X uses BSD's hostname command which outputs
# the fully qualified domain name by default. It
# doesn't have a `-f' flag.
# XXX We should probably check that the user isn't
# using GNU's hostname on OS X instead.
case "$host" in
*apple*darwin*)
HOSTNAMECMD="$HOSTNAMECMD"
;;
*)
HOSTNAMECMD="$HOSTNAMECMD -f"
;;
esac
;;
esac
AC_DEFINE_UNQUOTED(MR_HOSTNAMECMD, "$HOSTNAMECMD")
#-----------------------------------------------------------------------------#
MERCURY_CHECK_CC_NEEDS_TRAD_CPP
if test "$MERCURY_HAVE_GCC" = "yes"
then
GCC_PROG=$CC
else
AC_PATH_PROG(GCC_PROG,gcc)
fi
AC_EXEEXT
AC_SUBST(EXEEXT)
# We need to ensure that CFLAGS does not contain `-g', because
# on some (broken) distributions of Linux (specifically Debian 0.93R6),
# the `-lc' and `-lg' libraries have different contents; specifically,
# only the latter contains memalign(). We need to make sure that the test
# for memalign() doesn't use `-g', since `ml' doesn't use `-g'.
CFLAGS="-O"
# We need to define _XOPEN_SOURCE when building boehm on Darwin 10
# so that we don't get errors about the functions in ucontext.h being
# deprecated.
case "$host" in
*apple*darwin*10*)
ENABLE_BOEHM_XOPEN_SOURCE="-D_XOPEN_SOURCE"
;;
*)
ENABLE_BOEHM_XOPEN_SOURCE=
;;
esac
AC_SUBST(ENABLE_BOEHM_XOPEN_SOURCE)
# We also need to add the appropriate `-I' options so that the test programs
# can #include various Mercury runtime headers.
case "$MERCURY_CONF_RECONFIGURE" in
"")
CPPFLAGS="-Iruntime -Iruntime/machdeps -Itrace $CPPFLAGS"
;;