-
Notifications
You must be signed in to change notification settings - Fork 10
/
configure.in
1052 lines (929 loc) · 31.5 KB
/
configure.in
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
AC_PREREQ([2.69])
AC_INIT([XcodeML-Tools], [1.3.0], [omni-compiler@googlegroups.com], [xcodeml])
AC_CONFIG_AUX_DIR([./buildutils])
AC_CONFIG_MACRO_DIR([./buildutils])
AC_CANONICAL_TARGET
AC_CONFIG_SRCDIR([include/exc_platform.h])
AC_CONFIG_HEADER([include/config.h Driver/atool/src/include/nata/nata_config.h])
#--------------------------------------------------------------------
# See http://unix.stackexchange.com/questions/101080/realpath-command-not-found
realpath ()
{
f=$@;
if test -d "$f"; then
base="";
dir="$f";
else
base="/$(basename "$f")";
dir=$(dirname "$f");
fi;
dir=$(cd "$dir" && /bin/pwd);
echo "$dir$base"
}
#--------------------------------------------------------------------
# Save environmental variables set by user before AC_PROG_CC and so on.
userCFLAGS=${CFLAGS}
# Checks for programs.
AC_PROG_CPP
AC_PROG_CC
AC_PROG_FC
#AC_PROG_MAKE_SET
AC_PROG_AWK
AC_PROG_YACC
AC_PROG_LEX
AC_PROG_LN_S
AC_PROG_MAKE_SET
#AC_PROG_RANLIB
# Checks for libraries.
# Need this to get around rpc_malloc error in AIX
# see https://www.mail-archive.com/gsoap@yahoogroups.com/msg00385.html
if test "$target" = "powerpc-hitachi-aix"; then
export ac_cv_func_malloc_0_nonnull=yes
export ac_cv_func_realloc_0_nonnull=yes
fi
# Checks for header files.
AC_FUNC_ALLOCA
AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h inttypes.h limits.h locale.h malloc.h memory.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h wchar.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_TYPE_UID_T
AC_C_INLINE
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INT8_T
AC_TYPE_MODE_T
AC_FUNC_OBSTACK
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_C_RESTRICT
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_STRUCT_TIMEZONE
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
AC_CHECK_TYPES([ptrdiff_t])
# Checks for library functions.
AC_FUNC_CHOWN
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_FSEEKO
AC_FUNC_GETGROUPS
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_REALLOC
AC_FUNC_STRCOLL
AC_FUNC_STRERROR_R
#AC_FUNC_STRNLEN
AC_FUNC_STRTOD
AC_CHECK_FUNCS([alarm atexit bzero clock_gettime dup2 euidaccess fchdir fdatasync floor ftruncate getcwd getdelim gethostbyaddr gethostbyname gethostname gethrtime getpagesize getpass gettimeofday getusershell inet_ntoa lchown localtime_r mblen memchr memmove mempcpy memset mkdir pathconf pow putenv realpath regcomp rmdir rpmatch select setenv sethostname setlocale socket stime stpcpy strcasecmp strchr strcspn strdup strerror strncasecmp strndup strpbrk strrchr strspn strstr strtol strtoul strtoull strverscmp tzset])
# Options of old configure
# Not needed ?
AC_C_BIGENDIAN
AC_C_CONST
AC_STRUCT_TM
AC_HEADER_STDC
AC_HEADER_TIME
#--------------------------------------------------------------------
# Set useful commands
RM="rm -f"
AC_SUBST(RM)
INSTALL="install"
AC_SUBST(INSTALL)
MKDIR_P="install -m 755 -d"
AC_SUBST(MKDIR_P)
#--------------------------------------------------------------------
# Set true/false
FALSE=1
TRUE=0
#--------------------------------------------------------------------
# Set options
# specify libxmp path
AC_ARG_WITH(libxml2,
[ --with-libxml2=DIR specify prefix directory for installed libxml2 package (default: /usr)
Equivalent to --with-libxml2-include=PATH/include plus --with-libxml2-lib=PATH/lib64],
[LIBXML2_PREFIX="${withval}"], [LIBXML2_PREFIX="/usr"])
AC_ARG_WITH(libxml2-include,
[ --with-libxml2-include=DIR specify directory for installed libxml2 include files],
[LIBXML2_INCLUDE_DIR="${withval}"], [LIBXML2_INCLUDE_DIR="${LIBXML2_PREFIX}/include/"])
AC_ARG_WITH(libxml2-lib,
[ --with-libxml2-lib=DIR specify directory for installed libxml2 library],
[LIBXML2_LIB_DIR="${withval}"], [LIBXML2_LIB_DIR="${LIBXML2_PREFIX}/lib64"])
# check dirs
if ! test -d "$LIBXML2_INCLUDE_DIR"; then
AC_MSG_ERROR([$LIBXML2_INCLUDE_DIR not found. Please attach --with-libxml2=<DIR> or --with-libxml2-include=<DIR>.])
fi
if ! test -d "$LIBXML2_LIB_DIR"; then
LIBXML2_LIB_DIR=${LIBXML2_PREFIX}/lib
fi
if ! test -d "$LIBXML2_LIB_DIR"; then
AC_MSG_ERROR([$LIBXML2_LIB_DIR not found. Please attach --with-libxml2=<DIR> or --with-libxml2-lib=<DIR>.])
fi
# check libxml/parser.h
tmp_file=/tmp/_omni_$$
tmp_file_c=/tmp/_omni_$$.c
echo "#include <libxml/parser.h>" > $tmp_file_c
${CC} -E -I$LIBXML2_INCLUDE_DIR/libxml2 $tmp_file_c 2> /dev/null > /dev/null
if test $? -ne 0; then
rm -f $tmp_file_c
AC_MSG_ERROR([parser.h not found. Please attach --with-libxml2=<DIR> or --with-libxml2-include=<DIR>.])
fi
# check -lxml2
echo "int main(){return 0;}" > $tmp_file_c
${CC} -L$LIBXML2_LIB_DIR -lxml2 $tmp_file_c -o $tmp_file
if test $? -ne 0; then
rm -f $tmp_file $tmp_file_c
AC_MSG_ERROR([-lxml2 not found. Please attach --with-libxml2=<DIR> or --with-libxml2-lib=<DIR>.])
fi
rm -f $tmp_file $tmp_file_c
# specify mpfr path
AC_ARG_WITH(mpfr,
[ --with-mpfr=DIR specify prefix directory for installed mpfr package (default: /usr)
Equivalent to --with-mpfr-include=PATH/include and --with-mpfr-lib=PATH/lib64],
[MPFR_PREFIX="${withval}"], [MPFR_PREFIX="/usr"])
AC_ARG_WITH(mpfr-include,
[ --with-mpfr-include=DIR specify directory for installed mpfr include files],
[MPFR_INCLUDE_DIR="${withval}"], [MPFR_INCLUDE_DIR="${MPFR_PREFIX}/include"])
AC_ARG_WITH(mpfr-lib,
[ --with-mpfr-lib=DIR specify directory for installed mpfr library],
[MPFR_LIB_DIR="${withval}"], [MPFR_LIB_DIR="${MPFR_PREFIX}/lib64"])
# specify gmp path
AC_ARG_WITH(gmp,
[ --with-gmp=DIR specify prefix directory for installed gmp package (default: /usr)
Equivalent to --with-gmp-include=PATH/include plus --with-gmp-lib=PATH/lib64],
[GMP_PREFIX="${withval}"], [GMP_PREFIX="/usr"])
AC_ARG_WITH(gmp-include,
[ --with-gmp-include=DIR specify directory for installed gmp include files],
[GMP_INCLUDE_DIR="${withval}"], [GMP_INCLUDE_DIR="${GMP_PREFIX}/include"])
AC_ARG_WITH(gmp-lib,
[ --with-gmp-lib=DIR specify directory for installed gmp library],
[GMP_LIB_DIR="${withval}"], [GMP_LIB_DIR="${GMP_PREFIX}/lib64"])
if ! test -d "$GMP_LIB_DIR"; then
GMP_LIB_DIR=${GMP_PREFIX}/lib
fi
ENABLE_UCHARDET=no
AC_ARG_ENABLE(uchardet,
[ --enable-uchardet enable uchardet Library (false default)],
[ENABLE_UCHARDET=yes], [ENABLE_UCHARDET=no])
#specify uchardet path
AC_ARG_WITH(uchardet,
[ --with-uchardet=DIR specify prefix directory for installed uchardet package (default: /usr)
Equivalent to --with-uchardet-include=PATH/include plus --with-uchardet-lib=PATH/lib64],
[UCHARDET_PREFIX="${withval}"], [UCHARDET_PREFIX="/usr"])
AC_ARG_WITH(uchardet-include,
[ --with-uchardet-include=DIR specify directory for installed uchardet include files],
[UCHARDET_INCLUDE_DIR="${withval}"], [UCHARDET_INCLUDE_DIR="${UCHARDET_PREFIX}/include/"])
AC_ARG_WITH(uchardet-lib,
[ --with-uchardet-lib=DIR specify directory for installed uchardet library],
[UCHARDET_LIB_DIR="${withval}"], [UCHARDET_LIB_DIR="${UCHARDET_PREFIX}/lib64"])
AC_ARG_ENABLE(atool,
[ --enable-atool enable atool (false default)],
[doatool=yes], [doatool=no])
AC_ARG_ENABLE(mod2xmod,
[ --enable-mod2xmod enable to translate .mod to .xmod on only gfortran (false default)],
[domod2xmod=yes], [domod2xmod=no])
AC_ARG_ENABLE(gnu-extension,
[ --enable-gnu-extension enable Fortran GNU intrinsic extension (false default).],
[dognuext=yes], [dognuext=no])
#--------------------------------------------------------------------
# Fortran GNU Extension
#--------------------------------------------------------------------
EXTENSION_FLAGS=""
if test "x${dognuext}" = "xyes"; then
EXTENSION_FLAGS="-DGNU_INTRINSIC_EXTENSION"
fi
AC_SUBST(EXTENSION_FLAGS)
#--------------------------------------------------------------------
# General
#--------------------------------------------------------------------
T_FJMODULE=$FALSE
if test "x${target}" = "xKcomputer-linux-gnu" -o "x${target}" = "xFX10-linux-gnu" -o "x${target}" = "xFX100-linux-gnu"; then
if test "x${domod2xmod}" = "xyes"; then
T_FJMODULE=$TRUE
fi
fi
AC_SUBST(T_FJMODULE)
#--------------------------------------------------------------------
TARGET=$target
AC_SUBST(TARGET)
#--------------------------------------------------------------------
# Check basic command
if test "${CPP}" = ""; then
AC_MSG_ERROR([CPP is not found.])
fi
if test "${CC}" = ""; then
AC_MSG_ERROR([CC is not found.])
fi
if test "${AWK}" = ""; then
AC_MSG_ERROR([AWK is not found.])
fi
# If yacc is not available, set YACC to 'yacc' in AC_PROG_YACC.
if test "x${YACC}" = "xyacc"; then
AC_MSG_ERROR([byacc is not found.])
fi
# https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Particular-Programs.html
# If lex is not available, set LEX to ':' in "AC_PROG_LEX".
if test "x${LEX}" = "x:"; then
AC_MSG_ERROR([flex is not found.])
fi
# set ATOOLS
ATOOL=$FALSE
if test "x${doatool}" = "xyes"; then
ATOOL=$TRUE
fi
AC_SUBST(ATOOL)
if test "${userCFLAGS}" != ""; then
CFLAGS="${userCFLAGS}"
elif test "$CC" = "gcc"; then
CFLAGS="-O2 -std=gnu99 -Wall -Wpointer-arith -fopenmp"
elif test "$CC" = "icc"; then
CFLAGS="-O2 -qopenmp"
elif test "$CC" = "pgcc"; then
CFLAGS="-fast -c99 -mp"
fi
AC_SUBST(LIBXML2_INCLUDE_DIR)
AC_SUBST(LIBXML2_LIB_DIR)
AC_SUBST(ENABLE_UCHARDET)
AC_SUBST(UCHARDET_INCLUDE_DIR)
AC_SUBST(UCHARDET_LIB_DIR)
#--------------------------------------------------------------------
# check --enable-mod2xmod
if test "x${target}" = "xKcomputer-linux-gnu" -o "x${target}" = "xFX10-linux-gnu" -o "x${target}" = "xFX100-linux-gnu"; then
KIND_FORTRAN=frtpx
else
chk=`${FC} --version | head -n1`
case $chk in
"GNU Fortran"*)
KIND_FORTRAN=gfortran
;;
*)
KIND_FORTRAN=other
;;
esac
fi
if test "$domod2xmod" = "yes" -a "$KIND_FORTRAN" = "other"; then
AC_MSG_ERROR("--enable-mod2xmod option can be used when Backend compiler is gfortran.")
fi
MOD2XMOD=$FALSE
if test "$domod2xmod" = "yes" -a \( "$KIND_FORTRAN" = "gfortran" -o "$KIND_FORTRAN" = "frtpx" \); then
MOD2XMOD=$TRUE
fi
NEED_MAKE_MOD2XMOD=$FALSE
if test "$MOD2XMOD" = $TRUE -a "$KIND_FORTRAN" = "gfortran"; then
NEED_MAKE_MOD2XMOD=$TRUE
fi
AC_SUBST(MOD2XMOD)
AC_SUBST(KIND_FORTRAN)
AC_SUBST(NEED_MAKE_MOD2XMOD)
if test "$NEED_MAKE_MOD2XMOD" = $TRUE; then
#### GMP ####
# check dirs
if ! test -d "$GMP_INCLUDE_DIR"; then
AC_MSG_ERROR([$GMP_INCLUDE_DIR not found. Please attach --with-gmp=<DIR> or --with-gmp-include=<DIR>.])
fi
if ! test -d "$GMP_LIB_DIR"; then
AC_MSG_ERROR([$GMP_LIB_DIR not found. Please attach --with-gmp=<DIR> or --with-gmp-lib=<DIR>.])
fi
# check gmp.h
tmp_file=/tmp/_omni_$$
tmp_file_c=/tmp/_omni_$$.c
echo "#include <gmp.h>" > $tmp_file_c
${CC} -E -I$GMP_INCLUDE_DIR $tmp_file_c 2> /dev/null > /dev/null
if test $? -ne 0; then
rm -f $tmp_file_c
AC_MSG_ERROR([gmp.h not found. Please attach --with-gmp=<DIR> or --with-gmp-include=<DIR>.])
fi
# check -lgmp
echo "int main(){return 0;}" > $tmp_file_c
${CC} -L$GMP_LIB_DIR -lgmp $tmp_file_c -o $tmp_file
if test $? -ne 0; then
rm -f $tmp_file $tmp_file_c
AC_MSG_ERROR([-lgmp not found. Please attach --with-gmp=<DIR> or --with-gmp-lib=<DIR>.])
fi
rm -f $tmp_file $tmp_file_c
AC_SUBST(GMP_INCLUDE_DIR)
AC_SUBST(GMP_LIB_DIR)
#### MPFR ####
# check dirs
if ! test -d "$MPFR_INCLUDE_DIR"; then
AC_MSG_ERROR([$MPFR_INCLUDE_DIR not found. Please attach --with-mpfr=<DIR> or --with-mpfr-include=<DIR>.])
fi
if ! test -d "$MPFR_LIB_DIR"; then
MPFR_LIB_DIR=${MPFR_PREFIX}/lib
if ! test -d "$MPFR_LIB_DIR"; then
AC_MSG_ERROR([$MPFR_LIB_DIR not found. Please attach --with-mpfr=<DIR> or --with-mpfr-lib=<DIR>.])
fi
fi
# check mpfr.h
echo "#include <mpfr.h>" > $tmp_file_c
${CC} -E -I$MPFR_INCLUDE_DIR -I$GMP_INCLUDE_DIR $tmp_file_c 2> /dev/null > /dev/null
if test $? -ne 0; then
rm -f $tmp_file_c
AC_MSG_ERROR([mpfr.h not found. Please attach --with-mpfr=<DIR> or --with-mpfr-include=<DIR>.])
fi
# check -lmpfr
echo "int main(){return 0;}" > $tmp_file_c
${CC} -L$MPFR_LIB_DIR -lmpfr $tmp_file_c -o $tmp_file
if test $? -ne 0; then
rm -f $tmp_file tmp_file_c
AC_MSG_ERROR([-lmpfr not found. Please attach --with-mpfr=<DIR> or --with-mpfr-lib=<DIR>.])
fi
rm -f $tmp_file tmp_file_c
AC_SUBST(MPFR_INCLUDE_DIR)
AC_SUBST(MPFR_LIB_DIR)
fi
#--------------------------------------------------------------------
# check Perl versoin is 5
AC_CHECK_PROG(PERL5, [perl], [perl])
if test "$PERL5" = ""; then
AC_MSG_ERROR([perl is not found.])
else
PERL5=$(realpath `which $PERL5`)
isPerlVersion5=no
AC_MSG_CHECKING(Perl version is 5)
pTmp=/tmp/.btoolPerlChk.$$
${PERL5} -e 'require 5;' > ${pTmp} 2>&1
if test "$?" = "0"; then
AC_MSG_RESULT([yes])
isPerlVersion5=yes
else
AC_MSG_RESULT([no])
isPerlVersion5=no
fi
rm -f ${pTmp}
unset chk pTmp
fi
AC_SUBST(PERL5)
#--------------------------------------------------------------------
# check java
AC_CHECK_PROG([JAVA], [java], [java])
AC_CHECK_PROG([JAVAC], [javac], [javac])
AC_CHECK_PROG([JAR], [jar], [jar])
which ${JAVA} 1>/dev/null 2>/dev/null
if test $? -ne 0; then
AC_MSG_ERROR([JAVA is not found.])
fi
which ${JAVAC} 1>/dev/null 2>/dev/null
if test $? -ne 0; then
AC_MSG_ERROR([JAVAC is not found.])
fi
which ${JAR} 1>/dev/null 2>/dev/null
if test $? -ne 0; then
AC_MSG_ERROR([JAR is not found.])
fi
JAVA=$(realpath `which $JAVA`)
JAVAC=$(realpath `which $JAVAC`)
JAR=$(realpath `which $JAR`)
AC_SUBST(JAVA)
AC_SUBST(JAVAC)
AC_SUBST(JAR)
JAVA_OPT="-Xmx200m -Xms200m" # Fix: #338
JAVAC_OPT="-encoding utf8 -Xlint:deprecation,unchecked "
JAR_OPT=
# Set a small Heap Memory because Java installed on frontend machines of the K computer
if test "$target" = "Kcomputer-linux-gnu"; then
#JAVA_OPT="-Xmx1600m -Xms800m"
JAVAC_OPT+="-J-Xmx200m -J-Xms200m"
JAR_OPT="-J-Xmx200m -J-Xms200m"
fi
AC_SUBST(JAVA_OPT)
AC_SUBST(JAVAC_OPT)
AC_SUBST(JAR_OPT)
#--------------------------------------------------------------------
# The code below deals with several issues related to gettimeofday:
# 1. Some systems don't provide a gettimeofday function at all
# (set NO_GETTOD if this is the case).
# 2. SGI systems don't use the BSD form of the gettimeofday function,
# but they have a BSDgettimeofday function that can be used instead.
# 3. See if gettimeofday is declared in the <sys/time.h> header file.
# if not, set the GETTOD_NOT_DECLARED flag so that tclPort.h can
# declare it.
#--------------------------------------------------------------------
AC_CHECK_FUNCS(gettimeofday, , [AC_DEFINE(NO_GETTOD)])
AH_TEMPLATE(NO_GETTOD, [no gettimeofday])
AC_EGREP_HEADER(gettimeofday, sys/time.h, , AC_DEFINE(GETTOD_NOT_DECLARED))
AH_TEMPLATE(GETTOD_NOT_DECLARED, [not declared gettimeofday in sys/time.h])
#--------------------------------------------------------------------
# check type size/align
AC_CHECK_SIZEOF(unsigned char)
AC_CHECK_SIZEOF(unsigned short)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned long long)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
AC_CHECK_SIZEOF(long double)
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(_Bool)
SIZEOF_DOUBLE=$ac_cv_sizeof_double
AC_SUBST(SIZEOF_DOUBLE)
SIZEOF_FLOAT=$ac_cv_sizeof_float
AC_SUBST(SIZEOF_FLOAT)
SIZEOF_LONG_DOUBLE=$ac_cv_sizeof_long_double
AC_SUBST(SIZEOF_LONG_DOUBLE)
SIZEOF_UNSIGNED_CHAR=$ac_cv_sizeof_unsigned_char
AC_SUBST(SIZEOF_UNSIGNED_CHAR)
SIZEOF_UNSIGNED_INT=$ac_cv_sizeof_unsigned_int
AC_SUBST(SIZEOF_UNSIGNED_INT)
SIZEOF_UNSIGNED_LONG=$ac_cv_sizeof_unsigned_long
AC_SUBST(SIZEOF_UNSIGNED_LONG)
SIZEOF_UNSIGNED_LONG_LONG=$ac_cv_sizeof_unsigned_long_long
AC_SUBST(SIZEOF_UNSIGNED_LONG_LONG)
SIZEOF_UNSIGNED_SHORT=$ac_cv_sizeof_unsigned_short
AC_SUBST(SIZEOF_UNSIGNED_SHORT)
SIZEOF_VOID_P=$ac_cv_sizeof_void_p
AC_SUBST(SIZEOF_VOID_P)
SIZEOF__BOOL=$ac_cv_sizeof__Bool
AC_SUBST(SIZEOF__BOOL)
AC_CHECK_ALIGNOF(unsigned char)
AC_CHECK_ALIGNOF(unsigned short)
AC_CHECK_ALIGNOF(unsigned int)
AC_CHECK_ALIGNOF(unsigned long)
AC_CHECK_ALIGNOF(unsigned long long)
AC_CHECK_ALIGNOF(float)
AC_CHECK_ALIGNOF(double)
AC_CHECK_ALIGNOF(long double)
AC_CHECK_ALIGNOF(void *)
AC_CHECK_ALIGNOF(_Bool)
#--------------------------------------------------------------------
# 32/64 bit int type
rm -rf ./szchk ./szchk.*
AC_MSG_RESULT([Creating size check program])
${CC} ${CPPFLAGS} ${CFLAGS} ${hasLLFlags} ./buildutils/szchk.c -o ./szchk
if test ! -x ./szchk; then
AC_MSG_ERROR([can't create size check program.])
fi
F2C_INT64_FLAGS=""
for i in 16 32 64
do
AC_MSG_CHECKING([$i bit integer])
typName=`./szchk $i`
if test "x${typName}" = "xunknown"; then
case $i in
16)
TYPE_INT16="short"
AC_SUBST(TYPE_INT16)
asump=${TYPE_INT16};;
32)
TYPE_INT32="int"
AC_SUBST(TYPE_INT32)
asump=${TYPE_INT32};;
64)
TYPE_INT64="long long int"
AC_SUBST(TYPE_INT64)
asump=${TYPE_INT64};;
esac
AC_MSG_RESULT([not supported. use $asump])
else
AC_MSG_RESULT([$typName])
case $i in
16)
AC_DEFINE(HAS_INT16)
AH_TEMPLATE(HAS_INT16, [has int16])
TYPE_INT16=${typName}
AC_SUBST(TYPE_INT16);;
32)
AC_DEFINE(HAS_INT32)
AH_TEMPLATE(HAS_INT32, [has int32])
TYPE_INT32=${typName}
AC_SUBST(TYPE_INT32);;
64)
AC_DEFINE(HAS_INT64)
AH_TEMPLATE(HAS_INT64, [has int64])
F2C_INT64_FLAGS="-DAllow_TYQUAD"
TYPE_INT64=${typName}
AC_SUBST(TYPE_INT64);;
esac
fi
done
AC_SUBST(F2C_INT64_FLAGS)
rm -rf ./szchk ./szchk.*
#--------------------------------------------------------------------
# check size of integer enough to hold size of void *
AC_MSG_CHECKING([integer type enough to hold void pointer])
${CC} -I. ${CPPFLAGS} ${CFLAGS} ${hasLLFlags} ./buildutils/chkvoidp.c -o chkvoidp
voidPint="unknown"
if test -x ./chkvoidp; then
voidPint=`./chkvoidp`
else
AC_MSG_ERROR([can't create check program.])
fi
if test "x${voidPint}" = "xunknown"; then
AC_MSG_ERROR([can't determine????])
else
AC_MSG_RESULT([$voidPint])
fi
INT_ENUFF_FOR_VOIDP=$voidPint
AC_SUBST(INT_ENUFF_FOR_VOIDP)
rm -f ./chkvoidp.* ./chkvoidp
#--------------------------------------------------------------------
# check 64 bit virtual address
AC_MSG_CHECKING([64 bit virtual address])
${CC} -I. ${CPPFLAGS} ${CFLAGS} ./buildutils/addr64.c -o ./addr64
addrIs64="unknown"
if test -x ./addr64; then
addrIs64=`./addr64`
else
AC_MSG_ERROR([can't create check program.])
fi
if test "x$addrIs64" = "xunknown"; then
AC_MSG_ERROR([can't determine????])
else
if test "x$addrIs64" = "x8"; then
AC_MSG_RESULT([yes])
AC_DEFINE(ADDR_IS_64)
AH_TEMPLATE(ADDR_IS_64, [])
else
AC_MSG_RESULT([no])
fi
fi
rm -f ./addr64.* ./addr64
#--------------------------------------------------------------------
# has printf "%qd"
rm -f ./hasqd.* ./hasqd
AC_MSG_CHECKING([has quad-precision print format])
${CC} -I. ${CPPFLAGS} ${CFLAGS} ./buildutils/hasqd.c -o ./hasqd > /dev/null 2>&1
hasQD=no
if test -x ./hasqd; then
ret=`./hasqd`
if test "x$ret" = "xqd" -o "x$ret" = "x%qd"; then
hasQD=no
else
hasQD=yes
fi
fi
AC_MSG_RESULT([${hasQD}])
if test "x${hasQD}" = "xyes"; then
AC_DEFINE(HAVE_QUAD_PRINT)
AH_TEMPLATE(HAVE_QUAD_PRINT, [has printf "%qd"])
fi
rm -f ./hasqd.* ./hasqd
#--------------------------------------------------------------------
# quad real support
gmpIncOpt=""
gmpDirOpt=""
qRealPrecBits=128
AC_ARG_ENABLE(mreal,
[ --enable-mreal enable multiple precision real (and real*16) support of Fortran 77 (false default)],
[doQReal=yes], [doQReal=no])
if test "x${doQReal}" = "xyes"; then
if test -f ${GMP_INCLUDE_DIR}/gmp.h; then
true
else
AC_MSG_ERROR([can't find ${GMP_INCLUDE_DIR}/gmp.h. Please attach --with-gmp=<DIR> or --with-gmp-lib=<DIR>.])
fi
if ! test -d "$GMP_LIB_DIR"; then
AC_MSG_ERROR([$GMP_LIB_DIR not found. Please attach --with-gmp=<DIR> or --with-gmp-lib=<DIR>.])
fi
gmpLibs=`ls ${GMP_LIB_DIR}/libgmp.* 2> /dev/null`
if test "x${gmpLibs}" = "x"; then
AC_MSG_ERROR([can't find ${GMP_LIB_DIR}/libgmp.*. Please attach --with-gmp=<DIR> or --with-gmp-lib=<DIR>.])
fi
gmpIncOpt="-I${GMP_INCLUDE_DIR}"
gmpLibOpt="-L${GMP_LIB_DIR} -lgmp"
fi
AC_ARG_WITH(precision,
[ --with-precision=NUM the default precision of real*16 in bits (128)],
[qRealPrecBits=$withval], [qRealPrecBits=128])
# libgmp check
omniLimbT="int"
omniExpT="int"
omniQRealPrecInLimb="1"
omniQRealFillGap=""
if test "x${doQReal}" = "xyes"; then
omniQPrec=$qRealPrecBits
AC_DEFINE(ENABLE_QREAL)
AH_TEMPLATE(ENABLE_QREAL, [quad real])
AC_DEFINE_UNQUOTED(OMNI_QREAL_PREC, $omniQPrec)
AH_TEMPLATE(OMNI_QREAL_PREC, [quad real])
qcCC () {
rm -f $2 ${2}.*
${CC} -I. ${CPPFLAGS} ${CFLAGS} -DENABLE_QREAL ${hasLLFlags} ${gmpIncOpt} $3 $1 -o $2 ${gmpLibOpt}
if test -x $2; then
ret=`$2 $4`
if test "x${ret}" = "x"; then
AC_MSG_ERROR([can't determine??.])
else
rm -f $2 ${2}.*
echo ${ret}
fi
else
AC_MSG_ERROR([can't create check program.])
fi
}
# check size of mp_exp_t
AC_MSG_CHECKING([size of GNU-MP mp_exp_t])
eSz=`qcCC buildutils/csMPexp.c ./csMPexp`
AC_MSG_RESULT([${eSz}])
omniExpT=""
case ${eSz} in
2)
omniExpT=${TYPE_INT16};;
4)
omniExpT=${TYPE_INT32};;
8)
omniExpT=${TYPE_INT64};;
*)
AC_MSG_ERROR([can't determine basic type of mp_exp_t ??.])
esac
AC_DEFINE_UNQUOTED(OMNI_SIZEOF_QEXP_T, $eSz)
AH_TEMPLATE(OMNI_SIZEOF_QEXP_T, [size of mp_exp_t])
# check size of mp_limb_t
AC_MSG_CHECKING([size of GNU-MP mp_limb_t])
lSz=`qcCC buildutils/csMPlimb.c ./csMPlimb`
AC_MSG_RESULT([${lSz}])
omniLimbT=""
case ${lSz} in
2)
omniLimbT=${TYPE_INT16};;
4)
omniLimbT=${TYPE_INT32};;
8)
omniLimbT=${TYPE_INT64};;
*)
AC_MSG_ERROR([can't determine basic type of mp_limb_t ??.]);;
esac
AC_DEFINE_UNQUOTED(OMNI_SIZEOF_QLIM_T, $lSz)
AH_TEMPLATE(OMNI_SIZEOF_QLIM_T, [size of mp_limb_t])
# check how many mp_limb_t the GNU-MP needed for N bit precision.
AC_MSG_CHECKING([how many mp_limb_t needed for $omniQPrec bit precision])
omniQRealPrecInLimb=`qcCC buildutils/cMPlb.c ./cMPlb '' $omniQPrec`
AC_MSG_RESULT([$omniQRealPrecInLimb])
AC_DEFINE_UNQUOTED(OMNI_QLIM_LEN, $omniQRealPrecInLimb)
AH_TEMPLATE(OMNI_QLIM_LEN, [how many mp_limb_t the GNU-MP needed for N bit precision])
# check _omQReal_t needs a gap between _mp_exp and _mp_d[omniQRealPrecInLimb].
AC_MSG_CHECKING([_omQReal_t needs a gap between _mp_exp and _mp_d])
gapInByte=`expr $lSz - $eSz`
subStr=""
if test ${gapInByte} -gt 0; then
case ${gapInByte} in
2)
# lim == int, exp == short
subStr="${TYPE_INT16} _gap_;";;
4)
# lim == long long, exp == int
subStr="${TYPE_INT32} _gap_;";;
*)
# lim == long long, exp == short
changequote(<<, >>)
subStr="char _gap_[${gapInByte}];"
changequote([, ])
;;
esac
fi
if test "x${subStr}" != "x"; then
# TODO
AC_MSG_RESULT([yes, put a "${subStr}" member in _omQReal_t.])
omniQRealFillGap=${subStr}
AC_DEFINE(OMNI_QREAL_NEED_GAP_MEMBER)
AH_TEMPLATE(OMNI_QREAL_NEED_GAP_MEMBER, [])
AC_DEFINE_UNQUOTED(OMNI_QREAL_GAP_SIZE, ${gapInByte})
AH_TEMPLATE(OMNI_QREAL_GAP_SIZE, [GNU-MP gapInByte])
else
omniQRealFillGap="/* if ((sizeof(mp_exp_t) < sizeof(mp_limb_t)), here must be a gap filling member. */"
AC_MSG_RESULT([no])
fi
# check libgmp has an mpf_floor(), appeared in gmp3 later.
oLIBS=${LIBS}
LIBS="${LIBS} ${gmpLibOpt}"
oCFLAGS=${CFLAGS}
CFLAGS="${CFLAGS} ${CPPFLAGS} -DENABLE_QREAL ${gmpIncOpt}"
AC_MSG_CHECKING([mpf_floor() in $LIBS])
hasFloor=no
AC_TRY_LINK(
[
#include "gmp.h"
],
[
mpf_t a;
mpf_t b;
(void)mpf_floor(a, b);
],
[AC_MSG_RESULT(yes); hasFloor=yes],
[AC_MSG_RESULT(no)]
)
LIBS=${oLIBS}
CFLAGS=${oCFLAGS}
if test "x${hasFloor}" = "xno"; then
AC_MSG_ERROR([You have to use gmp3 or later.])
fi
fi
AC_SUBST(doQReal)
AC_SUBST(gmpIncOpt)
AC_SUBST(gmpLibOpt)
AC_SUBST(omniQPrec)
AC_SUBST(omniExpT)
AC_SUBST(omniLimbT)
AC_SUBST(omniQRealPrecInLimb)
AC_SUBST(omniQRealFillGap)
#--------------------------------------------------------------------
# Export Omni Config Variable
PWD=`pwd`
if test "${prefix}" = ${PWD}; then
AC_MSG_ERROR("${PWD}" is not specified in --prefix=)
elif test "${prefix}" = "NONE" -o "${prefix}" = ""; then
OMNI_HOME=/usr/local
else
OMNI_HOME=${prefix}
fi
AC_SUBST(OMNI_HOME)
AH_TEMPLATE(OMNI_HOME, [XcodeML-Tools install directory])
AC_DEFINE_UNQUOTED(OMNI_HOME, "${OMNI_HOME}")
# If "--sysconfdir=" is set,
if test "${sysconfdir}" != '${prefix}/etc'; then
OM_DRIVER_CONF_DIR="${sysconfdir}"
else
OM_DRIVER_CONF_DIR="${OMNI_HOME}/etc"
fi
AC_SUBST(OM_DRIVER_CONF_DIR)
AH_TEMPLATE(OM_DRIVER_CONF_DIR, [XcodeML-Tools configuration file directory])
AC_DEFINE_UNQUOTED(OM_DRIVER_CONF_DIR, "${OM_DRIVER_CONF_DIR}")
#--------------------------------------------------------------------
# headers/macros
AC_CHECK_HEADER(sys/param.h, [AC_DEFINE([HAVE_SYS_PARAM_H], [1], [ ])])
AC_CHECK_HEADER(ctype.h, [AC_DEFINE([HAVE_CTYPE_H], [1], [ ])])
AC_CHECK_HEADER(stdio.h, [AC_DEFINE([HAVE_STDIO_H], [1], [ ])])
AC_CHECK_HEADER(stdarg.h, [AC_DEFINE([HAVE_STDARG_H], [1], [ ])])
AC_CHECK_HEADER(dirent.h, [AC_DEFINE([HAVE_DIRENT_H], [1], [ ])])
AC_CHECK_HEADER(time.h, [AC_DEFINE([HAVE_TIME_H], [1], [ ])])
AC_CHECK_HEADER(sys/termios.h, [AC_DEFINE([HAVE_SYS_TERMIOS_H], [1], [ ])])
AC_CHECK_HEADER(signal.h, [AC_DEFINE([HAVE_SIGNAL_H], [1], [ ])])
AC_CHECK_HEADER(netdb.h, [AC_DEFINE([HAVE_NETDB_H], [1], [ ])])
AC_CHECK_HEADER(netinet/tcp.h, [AC_DEFINE([HAVE_NETINET_TCP_H], [1], [ ])])
AC_CHECK_HEADER(sys/socket.h, [AC_DEFINE([HAVE_SYS_SOCKET_H], [1], [ ])])
AC_CHECK_HEADER(arpa/inet.h, [AC_DEFINE([HAVE_ARPA_INET_H], [1], [ ])])
AC_CHECK_HEADER(sys/ioctl.h, [AC_DEFINE([HAVE_SYS_IOCTL_H], [1], [ ])])
AC_CHECK_HEADER(pthread.h, [AC_DEFINE([HAVE_PTHREAD_H], [1], [ ])])
AC_CHECK_HEADER(stdbool.h, [AC_DEFINE([HAVE_STDBOOL_H], [1], [ ])])
AC_CHECK_HEADER(sys/resource.h, [AC_DEFINE([HAVE_SYS_RESOURCE_H], [1], [ ])])
AC_CHECK_HEADER(regex.h, [AC_DEFINE([HAVE_REGEX_H], [1], [ ])])
AC_CHECK_FUNC(strtold, [AC_DEFINE([HAVE_STRTOLD], [1], [ ])])
# Assume 32 bit for cross compilation.
AC_CHECK_SIZEOF(short int, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long int, 4)
AC_CHECK_SIZEOF(long long, 8)
AC_CHECK_SIZEOF(int64_t, 8)
AC_CHECK_SIZEOF(size_t, 4)
AC_CHECK_SIZEOF(void *, 4)
oCPPFLAGS=${CPPFLAGS}
oCFLAGS=${CFLAGS}
CPPFLAGS=''
CFLAGS="${CFLAGS} -Wall -Werror"
AC_MSG_CHECKING([print format for size_t])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdio.h>]
[#include <stddef.h>]
[#include <string.h>]],
[[char buf[24];]
[snprintf(buf, sizeof(buf), "%zu", (size_t)1);]
[return (strcmp("1", buf) == 0 && strlen(buf) == 1) ? ]
[0 : 1;]])],
[AC_DEFINE([HAVE_PRINT_FORMAT_FOR_SIZE_T], [], [ ])
AC_MSG_RESULT([available.])],
[AC_MSG_RESULT([not available.])],
[AC_MSG_RESULT([not checkable since cross-compilation.])])
CFLAGS=${oCFLAGS}
CPPFLAGS=${oCPPFLAGS}
# where the omni is.
tmpOmniDir=''
omniDir="${OMNI_HOME}"
omniBinDir=''
omniLibDir=''
omniEtcDir="${OM_DRIVER_CONF_DIR}/"
omniIncDir=''
if test -d "${tmpOmniDir}"; then
if test -x "${tmpOmniDir}/bin/F_Front"; then
omniDir="${tmpOmniDir}"
AC_MSG_RESULT([yes.])
else
omniDir=''
AC_MSG_RESULT([no. Assume every user sets path correctly.])
fi
fi
if test ! -z "${omniDir}"; then
# Don't delete the last slash.
omniBinDir="${omniDir}"/bin/
omniLibDir="${omniDir}"/lib/
omniIncDir="${omniDir}"/include
fi
AC_SUBST(omniDir)
AC_SUBST(omniBinDir)
AC_SUBST(omniLibDir)
AC_SUBST(omniEtcDir)
AC_SUBST(omniIncDir)
# cpp
cppCmd=${CPP}
if test -z "${CPP}"; then
AC_MSG_ERROR([Can't find any usable C preprosessor.])
fi
AC_SUBST(cppCmd)
HOSTARCH=`./buildutils/config.guess | grep -v Linking`
CPU=`echo $HOSTARCH | awk -F- '{ print $1 }' | sed 's/\./_/g'`
OS=`echo $HOSTARCH | awk -F- '{ print $3 }' | sed 's/\./_/g'`
case $CPU in
i*86)
CPU=i386;;
esac
OS_CPPFLAGS='-D_REENTRANT'
OS_LDFLAGS=''
OS_LIBS=''
OS_CFLAGS=''
if test -z "${MAKE}"; then
MAKE=make
fi
API_FLAVOR=OMNI_API_POSIX
TARGET_ARCH=POSIX
case $OS in
sunos*)
OS=sunos;;
solaris*)
OS=solaris;;
aix*)
MAKE=gmake;;
freebsd*)
OS=freebsd;;
linux*)
OS_CPPFLAGS="${OS_CPPFLAGS} -D_GNU_SOURCE"
OS_LIBS="-lrt -lpthread"
OS=linux;;
netbsd*)
MAKE=gmake
OS_CPPFLAGS="${OS_CPPFLAGS} -I/usr/pkg/include"
OS_LDFLAGS="-L/usr/pkg/lib"
OS_LIBS="-lpthread"
OS=netbsd;;
cygwin*)
OS=cygwin;;
mingw32ce)
OS=windowsce
TARGET_ARCH=WINDOWS
API_FLAVOR=OMNI_API_WIN32API;;
mingw32*)
case $CPU in
x86_64*)
OS=windows64;;
i*86)
OS=windows32;;
*)
OS=windows;;
esac
OS_LIBS="-lpthread -loleaut32 -lws2_32 -lwinmm"
TARGET_ARCH=WINDOWS
API_FLAVOR=OMNI_API_WIN32API;;
esac
OS_CXXFLAGS=${OS_CFLAGS}
AC_SUBST(MAKE)
AC_SUBST(OS_CPPFLAGS)
AC_SUBST(OS_CFLAGS)
AC_SUBST(OS_CXXFLAGS)
AC_SUBST(OS_LDFLAGS)
AC_SUBST(OS_LIBS)
changequote(<<, >>)