-
Notifications
You must be signed in to change notification settings - Fork 24
/
configure.ac
2684 lines (2442 loc) · 83.5 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
dnl
dnl Configure template for GnuCOBOL
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc.
dnl Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch,
dnl Edward Hart
dnl
dnl This file is part of GnuCOBOL.
dnl
dnl The GnuCOBOL compiler is free software: you can redistribute it
dnl and/or modify it under the terms of the GNU General Public License
dnl as published by the Free Software Foundation, either version 3 of the
dnl License, or (at your option) any later version.
dnl
dnl GnuCOBOL is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with GnuCOBOL. If not, see <https://www.gnu.org/licenses/>.
dnl
# note: old environments only have autoconf 2.69 or even (old msys) 2.67
# just do a "make dist" on a modern system and get the taball back
# to the ancient one... (which would likely also not have the necessary
# automake package either)
AC_PREREQ([2.70])
AC_INIT([GnuCOBOL],
[3.3-dev],
[gnucobol],
[https://www.gnu.org/software/gnucobol/])
AC_REVISION([GnuCOBOL snapshot $Revision$])
AC_COPYRIGHT([This file is part of GnuCOBOL.
Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch,
Edward Hart
])
AC_CONFIG_SRCDIR([libcob.h])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_TESTDIR([tests])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build_aux])
AC_CONFIG_FILES([Makefile libcob/Makefile lib/Makefile cobc/Makefile
bin/Makefile po/Makefile.in doc/Makefile config/Makefile
copy/Makefile tests/Makefile tests/cobol85/Makefile
extras/Makefile])
AC_CONFIG_FILES([bin/cob-config], [chmod +x bin/cob-config])
AC_CONFIG_FILES([pre-inst-env:build_aux/pre-inst-env.in],
[chmod +x pre-inst-env])
AC_CONFIG_FILES([tests/atlocal], [chmod +x tests/atlocal])
AC_CONFIG_FILES([tests/run_prog_manual.sh],
[chmod +x tests/run_prog_manual.sh])
dnl Support the --with-pkgversion configure option,
dnl inspired from GCC's ACX_PKGVERSION.
AC_ARG_WITH([pkgversion],
[AS_HELP_STRING([--with-pkgversion=PKG],
[Use PKG in the version string in place of "$PACKAGE_NAME"])],
[case "$withval" in
yes) AC_MSG_ERROR([package version not specified]) ;;
no) PKGVERSION= ;;
*) PKGVERSION="($withval) " ;;
esac],
[PKGVERSION="($PACKAGE_NAME) "])
# AC_SUBST(PKGVERSION)
AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [PKG version string])
dnl Support the --with-bugurl configure option,
dnl inspired from GCC's ACX_BUGURL.
AC_ARG_WITH([bugurl],
[AS_HELP_STRING([--with-bugurl=URL],
[Direct users to URL to report a bug, instead of mailing list])],
[case "$withval" in
yes) AC_MSG_ERROR([bug URL not specified]) ;;
no) BUGURL= ;;
*) BUGURL="$withval" ;;
esac],
[ # BUGURL="$PACKAGE_BUGREPORT"
])
case ${BUGURL} in
"")
# REPORT_BUGS_TO=
# REPORT_BUGS_TEXI=
;;
*)
AC_DEFINE_UNQUOTED([PACKAGE_BUGREPORT_URL], ["<$BUGURL>"], [Bug URL instead of mailing list])
# REPORT_BUGS_TO="<$BUGURL>"
# REPORT_BUGS_TEXI=@uref{`echo "$BUGURL" | sed 's/@/@@/g'`}
;;
esac;
# AC_SUBST(REPORT_BUGS_TO)
# AC_SUBST(REPORT_BUGS_TEXI)
# In general: don't export/setenv but pass as option to configure
# this has the benefit that re-runs will take the same and "sudo"
# or later "make" (possibly as different user) will use the same
# set of tools
# Note for SUN Solaris (gcc)
# options to configure: CC="gcc -m64" --libdir=/usr/local/lib/sparcv9
# or:
# options to configure: CFLAGS=-m64 LDFLAGS="-m64 -L/usr/local/lib/sparcv9"
#
# Hack for AIX 64 bit (gcc)
# Required -
# options to configure: CC="gcc -maix64" / CC="xlc -q64"
# or:
# options to configure: CFLAGS=-maix64 and LDFLAGS=-maix64
# Note: AIX commonly uses -Lpath like GNU/Linux would use -Lpath -Rpath
if test "x$OBJECT_MODE" = x; then
echo "$CC $CFLAGS" | grep ' -maix32' 1>/dev/null 2>&1
check1=$?
echo "$CC $CFLAGS" | grep ' -q32' 1>/dev/null 2>&1
check2=$?
if test $check1 -eq 0 -o $check2 -eq 0; then
OBJECT_MODE=32 # for libtool
fi
echo "$CC $CFLAGS" | grep ' -maix64' 1>/dev/null 2>&1
check1=$?
echo "$CC $CFLAGS" | grep ' -q64' 1>/dev/null 2>&1
check2=$?
if test $check1 -eq 0 -o $check2 -eq 0; then
OBJECT_MODE=64 # for libtool
fi
unset check1
unset check2
fi
if test "$OBJECT_MODE" = "64"; then
if test "x$AR" = x; then
if test -f /usr/ccs/bin/ar; then
AR="/usr/ccs/bin/ar -X64"
else
AR="ar -X64"
fi
fi
if test "x$NM" = x; then
if test -f /usr/ccs/bin/nm; then
NM="/usr/ccs/bin/nm -X64 -B"
else
NM="nm -X64 -B"
fi
fi
elif test "$OBJECT_MODE" = "32"; then
if test "x$AR" = x; then
if test -f /usr/ccs/bin/ar; then
AR="/usr/ccs/bin/ar -X32"
else
AR="ar -X32"
fi
fi
if test "x$NM" = x; then
if test -f /usr/ccs/bin/nm; then
NM="/usr/ccs/bin/nm -X32 -B"
else
NM="nm -X32 -B"
fi
fi
fi
dnl We don't want to have the full list of automatic defines from automake,
dnl and take care of the one we want explicit AC_DEFINE_UNQUOTED.
dnl While we do care about portability we get a long list of false-positives
dnl because of code-coverage parts that are only part of the final Makefile if we
dnl actually do use GNU make, so skip those warnings here and manually check with
dnl "automake -Wall" before creating a release quality tarball.
AM_INIT_AUTOMAKE([gnu no-texinfo.tex no-define -Wno-portability])
AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) # used for bindtextdomain and in .rc-files
dnl Autoheader templates
AH_TEMPLATE([COB_DEBUG_LOG], [Enable internal logging (Developers only!)])
AH_TEMPLATE([COB_EXPERIMENTAL], [Enable experimental code (Developers only!)])
AH_TEMPLATE([COB_TREE_DEBUG], [Enable extra checks within the compiler (Developers only!)])
AH_TEMPLATE([COB_PARAM_CHECK], [Enable minimum parameter check for system libraries])
AH_TEMPLATE([PATCH_LEVEL], [Define a patch level (numeric, max. 8 digits)])
AH_TEMPLATE([MAX_CALL_FIELD_PARAMS], [Define maximum parameters for CALL])
AH_TEMPLATE([WITH_MATH], [Math multiple precision library])
AH_TEMPLATE([WITH_INDEX_EXTFH], [Compile with obsolete external INDEXED handler])
AH_TEMPLATE([WITH_SEQRA_EXTFH], [Compile with obsolete external SEQ/RAN handler])
AH_TEMPLATE([WITH_DB], [Use Berkeley DB library as INDEXED handler])
dnl FIXME: may be specified with different file version
dnl AH_TEMPLATE([COB_BDB_BAD_DUPNO], [Retain incorrect duplicate sequence for compatibility on little endian!])
AH_TEMPLATE([WITH_CISAM], [Use CISAM as INDEXED handler])
AH_TEMPLATE([WITH_DISAM], [Use DISAM as INDEXED handler])
AH_TEMPLATE([WITH_VBISAM], [Use VBISAM as INDEXED handler])
AH_TEMPLATE([WITH_XML2], [Use libxml2 as XML handler])
AH_TEMPLATE([WITH_JSON], [JSON handler])
AH_TEMPLATE([WITH_CJSON], [Use cJSON library/source as JSON handler])
AH_TEMPLATE([WITH_JSON_C], [Use JSON-C library as JSON handler])
AH_TEMPLATE([COB_EXPORT_DYN], [Compile/link option for exporting symbols])
AH_TEMPLATE([COB_PIC_FLAGS], [Compile/link option for PIC code])
AH_TEMPLATE([COB_DEBUG_FLAGS], [Compile/link option for debugging])
AH_TEMPLATE([COB_SHARED_OPT], [Compile/link option for shared code])
AH_TEMPLATE([COB_STRIP_CMD], [Strip command])
AH_TEMPLATE([USE_LIBDL], [Use system dynamic loader])
AH_TEMPLATE([WITH_VARSEQ], [Define variable sequential file format])
AH_TEMPLATE([HAVE_ATTRIBUTE_ALIGNED], [Has __attribute__((aligned))])
AH_TEMPLATE([HAVE_ATTRIBUTE_PURE], [Has __attribute__((pure))])
AH_TEMPLATE([HAVE_ATTRIBUTE_CONSTRUCTOR], [Has __attribute__((constructor))])
AH_TEMPLATE([HAVE_TIMEZONE], [Has timezone variable])
AH_TEMPLATE([COB_OBJECT_EXT], [Object extension])
AH_TEMPLATE([COB_MODULE_EXT], [Module extension])
AH_TEMPLATE([COB_EXE_EXT], [Executable extension])
AH_TEMPLATE([COB_KEYWORD_INLINE], [Keyword for inline])
AH_TEMPLATE([COB_NO_SELFOPEN], [Can not dlopen self])
AH_TEMPLATE([COB_COMPUTED_GOTO], [Compilation of computed gotos works])
AH_TEMPLATE([COB_32_BIT_LONG], [long int is 32 bits])
AH_TEMPLATE([COB_64_BIT_POINTER], [Pointers are longer than 32 bits])
AH_TEMPLATE([WITH_CURSES], [curses library for extended SCREEN I/O])
AH_TEMPLATE([HAVE_COLOR_SET], [curses has color_set function])
AH_TEMPLATE([HAVE_RESIZE_TERM], [curses has resize_term function])
AH_TEMPLATE([HAVE_DEFINE_KEY], [curses has define_key function])
AH_TEMPLATE([HAVE_MOUSEINTERVAL], [curses has mouseinterval function])
AH_TEMPLATE([HAVE_HAS_MOUSE], [curses has has_mouse function])
AH_TEMPLATE([HAVE_MOUSEMASK], [curses has mousemask function and mmask_t definition])
AH_TEMPLATE([HAVE_CURSES_FREEALL], [curses provides function to free all memory])
AH_TEMPLATE([HAVE_USE_LEGACY_CODING], [ncurses has use_legacy_coding function])
AH_TEMPLATE([HAVE_DESIGNATED_INITS], [Has designated initializers])
AH_TEMPLATE([HAVE_NANO_SLEEP], [Has nanosleep function])
AH_TEMPLATE([HAVE_CLOCK_GETTIME], [Has clock_gettime function and CLOCK_REALTIME])
AH_TEMPLATE([HAVE_ISFINITE], [Has isfinite function])
AH_TEMPLATE([HAVE_MP_GET_MEMORY_FUNCTIONS], [Do we have mp_get_memory_functions in GMP/MPIR])
dnl done via AC_CHECK_FUNCS: AH_TEMPLATE([HAVE_RAISE], [Has raise function])
AH_TEMPLATE([HAVE_FINITE_IEEEFP_H],
[Declaration of finite function in ieeefp.h instead of math.h])
dnl preparation for cross-compilation
AC_ARG_PROGRAM
dnl
dnl Configure options part I (not needing any compilation)
dnl
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[(GnuCOBOL) Enable -g C compiler debug option for cobc + libcob])],
[],
[enable_debug=no])
AC_ARG_ENABLE([hardening],
[AS_HELP_STRING([--enable-hardening, --disable-hardening],
[Enable GNU C "hardening" options: define _FORTIFY_SOURCE and use,
depending on the availability -fstack-protector-strong / -fstack-protector,
as well as -fstack-clash-protection.
If disabled, these are explicit removed from CFLAGS for building GnuCOBOL.
Defaults to "defined by CFLAGS".])],,
[enable_hardening="unset"])
AC_ARG_ENABLE([experimental],
[AS_HELP_STRING([--enable-experimental],
[(GnuCOBOL) Enable experimental code (Developers only!)])],
[if test "$enable_experimental" = yes; then
AC_DEFINE([COB_EXPERIMENTAL], [1])
fi],
[])
AC_ARG_ENABLE([cobc-internal-checks],
[AS_HELP_STRING([--enable-cobc-internal-checks],
[(GnuCOBOL) Enable extra checks within the compiler (Developers only!)])],
[if test "$enable_cobc_internal_checks" = yes; then
AC_DEFINE([COB_TREE_DEBUG], [1])
fi],
[])
AC_ARG_ENABLE([debuglog],
[AS_HELP_STRING([--enable-debuglog],
[(GnuCOBOL) Enable internal logging code (Developers only!)])],
[if test "$enable_debuglog" = yes; then
AC_DEFINE([COB_DEBUG_LOG], [1])
fi],
[])
AC_ARG_ENABLE([param-check],
[AS_HELP_STRING([--enable-param-check],
[(GnuCOBOL) Enable minimum parameter check for system libraries (default no)])],
[if test "$enable_param_check" = yes; then
AC_DEFINE([COB_PARAM_CHECK], [1])
fi],
[])
dnl FIXME: may be specified with different file version
dnl AC_ARG_ENABLE([bdbdupno],
dnl [AS_HELP_STRING([--enable-bdbdupno],
dnl [(GnuCOBOL) Retain old BDB duplicate sequence (Incorrect on little-endian!)])],
dnl [if test "$enable_bdbdupno" = yes; then
dnl AC_DEFINE([COB_BDB_BAD_DUPNO], [1])
dnl fi],
dnl [])
AC_ARG_WITH([patch-level],
[AS_HELP_STRING([--with-patch-level],
[(GnuCOBOL) Define a patch level (default 0), numeric, max. 8 digits])],
[case $with_patch_level in
yes) AC_MSG_ERROR([[--with-patch-level needs an argument]])
;;
no) AC_MSG_ERROR([[--without-patch-level not supported]])
;;
[[0-9]]*)
if test $with_patch_level -gt 99999999; then
AC_MSG_ERROR([[patch level must not contain more than 8 digits]])
fi
;;
*) AC_MSG_ERROR([[patch level must be numeric]])
;;
esac],
[with_patch_level=0])
AC_DEFINE_UNQUOTED([PATCH_LEVEL], [$with_patch_level])
AC_ARG_WITH([max-call-params],
[AS_HELP_STRING([--with-max-call-params],
[(GnuCOBOL) Define maximum number of parameters for CALL (default 192)])],
[case $with_max_call_params in
yes) AC_MSG_ERROR([[--with-max-call-params needs an argument]])
;;
no) AC_MSG_ERROR([[--without-max-call-params not supported]])
;;
16 | 36 | 56 | 76 | 96 | 192 | 252)
;;
*) AC_MSG_ERROR([[maximum number of parameters for CALL must be one of 16/36/56/76/96/192/252]])
;;
esac],
[with_max_call_params=192])
AC_DEFINE_UNQUOTED([MAX_CALL_FIELD_PARAMS], [$with_max_call_params])
# Basic capability tests
configured_make=""
if test -z "$MAKE"; then
AC_CHECK_PROGS([configured_make], [make gmake gnumake])
if test -z "$configured_make"; then
AC_MSG_ERROR([make not found])
else
MAKE=$configured_make
AC_SUBST(MAKE)
fi
else
AC_CHECK_PROG([configured_make], [$MAKE], [$MAKE])
if test -z "$configured_make"; then
AC_MSG_ERROR([make, configured as "$MAKE", was not found])
fi
fi
AC_MSG_CHECKING([whether ${MAKE} can handle common constructs])
rm -f confmake.out
cat > confmf.mk << 'END'
NOPROG = ${SHELL} './missing' no-prog
DEFAULTVAR = $${VAR-default}
command = \
somestrip=`echo "$(DEFAULTVAR)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
test_target:
@echo target executed > confmake.out
END
_am_result=no
AM_RUN_LOG([${MAKE} -f confmf.mk])
## redirecting via echo to remove special chars
__am_checkme=$(echo `cat confmake.out 2>/dev/null`)
AS_CASE([$?:${__am_checkme}],
['0:target executed'],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([make, configured as "$MAKE", does not work])])
rm -f confmake.out confmf.mk
AC_MSG_CHECKING([whether ${MAKE} supports order-only prerequisites])
rm -f confinc.* confprereq
cat > confmf.mk << 'END'
PREREQ := confprereq
am__doit: am__prereq | $(PREREQ)
@echo target am__doit. >>confinc.out
am__prereq:
@echo target am__prereq. >>confinc.out
$(PREREQ):
@touch $(PREREQ)
@echo target $(PREREQ). >>confinc.out
.PHONY: am__doit am__prereq
END
_am_result=no
AM_RUN_LOG([${MAKE} -f confmf.mk && ${MAKE-make} -f confmf.mk && cat confinc.out])
## redirecting via echo to remove special chars
__am_checkme=$(echo `cat confinc.out 2>/dev/null`)
AS_CASE([$?:${__am_checkme}],
['0:target am__prereq. target confprereq. target am__doit. target am__prereq. target am__doit.'],
[_am_result=yes])
rm -f confinc.* confmf.mk confprereq
AC_MSG_RESULT([${_am_result}])
AM_CONDITIONAL([MAKE_HAS_PREREQ_ONLY], [test "${_am_result}" = yes])
curr_libs="$LIBS"
dnl Checked before AC_PROG_CC and default flags are applied.
enable_cflags_setting=no
AC_MSG_CHECKING([whether CFLAGS -O can be modified])
# Enable setting if the user has not specified the optimisation in CFLAGS.
echo "$CFLAGS" | grep "\-O.*\( \|$\)" 1>/dev/null 2>/dev/null
if test $? != 0; then
enable_cflags_setting=yes
fi
AC_MSG_RESULT([$enable_cflags_setting])
dnl Default CFLAGS (removed -g set in AC_INIT for compatibility)
: ${CFLAGS="-O2"}
AC_PROG_CC([gcc icc xlc cc])
AC_USE_SYSTEM_EXTENSIONS
# Check for the compiler used
dnl COB_USES_GCC=no
COB_USES_GCC_NO_ICC=no
COB_USES_ICC_ONLY=no
COB_USES_CLANG_ONLY=no
COB_USES_XLC_ONLY=no
COB_USES_WATCOMC_ONLY=no
dnl AC_MSG_CHECKING([for __GNUC__])
dnl AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
dnl #ifndef __GNUC__
dnl # error macro not defined
dnl #endif]])],
dnl [COB_USES_GCC=yes
dnl AC_MSG_RESULT([yes])],
dnl [AC_MSG_RESULT([no])])
COB_USES_GCC=$GCC
AC_MSG_CHECKING([for __INTEL_COMPILER])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#ifndef __INTEL_COMPILER
# error macro not defined
#endif]])],
[COB_USES_ICC_ONLY=yes
AC_MSG_RESULT([yes])],
[if test "$COB_USES_GCC" = yes; then
COB_USES_GCC_NO_ICC=yes
fi
AC_MSG_RESULT([no])]
)
AC_MSG_CHECKING([for __clang__])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#ifndef __clang__
# error macro not defined
#endif]])],
[COB_USES_CLANG_ONLY=yes
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
AC_MSG_CHECKING([for __xlc__])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#ifndef __xlc__
# error macro not defined
#endif]])],
[COB_USES_XLC_ONLY=yes
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
AC_MSG_CHECKING([for __WATCOMC__])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#ifndef __WATCOMC__
# error macro not defined
#endif]])],
[COB_USES_WATCOMC_ONLY=yes
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
AC_MSG_CHECKING([for __SUNPRO_C])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#ifndef __SUNPRO_C
# error macro not defined
#endif]])],
[COB_USES_SUNPRO_C_ONLY=yes
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
curr_cflags="$CFLAGS"
AC_CACHE_CHECK([how to error on warnings during configure checks], gc_cv_err_warn, [
if test "$COB_USES_GCC" = yes -o "$COB_USES_WATCOMC_ONLY" = yes; then
# COB_USES_GCC is also set with clang and icc
ERRWARN="-Wall -Werror"
elif test "$COB_USES_XLC_ONLY" = yes; then
ERRWARN="-qhalt=w"
elif test "$COB_USES_SUNPRO_C_ONLY" = yes; then
ERRWARN="-errwarn=%all"
else
ERRWARN=""
fi
CFLAGS="$CFLAGS $ERRWARN"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],
[gc_cv_err_warn="$ERRWARN"],
[gc_cv_err_warn=""])
])
ERRWARN="$gc_cv_err_warn"
# save what we have so far as it is quite "constant"
AC_CACHE_SAVE
#
## general flags for compiler and linker and tests for those
#
CFLAGS="$curr_cflags $ERRWARN"
AC_ARG_VAR([COBC_CPPFLAGS], [see CPPFLAGS, but only applied during generation of cobc])
AS_IF([test "x$COBC_CPPFLAGS" != x], [
AC_MSG_CHECKING([whether compilation with COBC_CPPFLAGS works])
curr_cppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $COBC_CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[[return 0;]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([cannot compile with COBC_CPPFLAGS="$COBC_CPPFLAGS"])])
CPPFLAGS="$curr_cppflags"
])
AC_ARG_VAR([LIBCOB_CPPFLAGS], [see CPPFLAGS, but only applied during generation of libcob])
AS_IF([test "x$LIBCOB_CPPFLAGS" != x], [
AC_MSG_CHECKING([whether compilation with LIBCOB_CPPFLAGS works])
curr_cppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $LIBCOB_CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[[return 0;]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([cannot compile with LIBCOB_CPPFLAGS="$LIBCOB_CPPFLAGS"])])
CPPFLAGS="$curr_cppflags"
])
AS_IF([test "x$LDFLAGS" != "x" -o "x$LIBS" != "x"], [
AC_MSG_CHECKING([whether linking with LDFLAGS / LIBS works])
AC_LINK_IFELSE([AC_LANG_PROGRAM([],
[[return 0;]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([cannot link with LDFLAGS="$LDFLAGS", / LIBS="$LIBS"])])
])
curr_libs="$LIBS"
AC_ARG_VAR([LIBCOB_LIBS], [see LIBS, but only applied during generation of libcob])
AS_IF([test "x$LIBCOB_LIBS" != x], [
AC_MSG_CHECKING([whether linking with LIBCOB_LIBS works])
LIBS="$LIBS $LIBCOB_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([],
[[return 0;]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([cannot link with LIBCOB_LIBS="$LIBCOB_LIBS"])])
])
LIBCOB_LIBS_extern="$LIBCOB_LIBS"
AC_ARG_VAR([PROGRAMS_LIBS], [see LIBS, but only applied during generation of programs: cobc, cobcrun])
AS_IF([test "x$PROGRAMS_LIBS" != x], [
AC_MSG_CHECKING([whether linking with PROGRAMS_LIBS works])
LIBS="$LIBS $PROGRAMS_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([],
[[return 0;]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_FAILURE([cannot link with PROGRAMS_LIBS="$PROGRAMS_LIBS"])])
])
LIBS="$curr_libs"
CFLAGS="$curr_cflags"
dnl only needed until automake 1.14 - but we don't have a check for the
dnl minimal version, so leaving in
AM_PROG_CC_C_O
LT_PREREQ([2.2])
LT_PROG_RC
AM_PROG_AR
dnl CHECKME: do we want disable-static (mind libsupport)
dnl if yes then drop AM_PROG_AR + build_aux/ar-lib
LT_INIT([dlopen win32-dll])
dnl We declare %noyywrap in the lexer files so we use the noyywrap
dnl option here to skip the search for that function.
AC_PROG_LEX([noyywrap])
AX_PROG_FLEX
AX_PROG_BISON
AC_ARG_VAR(DIFF_FLAGS, arguments passed to diff)
AC_MSG_CHECKING([for diff arguments])
case "$DIFF_FLAGS" in
*--strip-trailing-cr*)
AC_MSG_RESULT([specified as $DIFF_FLAGS])
;;
*)
diff $DIFF_FLAGS --strip-trailing-cr --version 1>/dev/null 2>&1
if test $? -eq 0; then
if test -z "$DIFF_FLAGS"; then
DIFF_FLAGS="--strip-trailing-cr"
else
DIFF_FLAGS="$DIFF_FLAGS --strip-trailing-cr"
fi
AC_MSG_RESULT([$DIFF_FLAGS])
else
AC_MSG_RESULT([not supported])
fi
;;
esac
AC_SUBST(DIFF_FLAGS)
# Stop tests for C++ and Fortran
AC_DEFUN([AC_PROG_CXX], [])
AC_DEFUN([AC_PROG_F77], [])
AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_LIB_RPATH
# more things to save...
AC_CACHE_SAVE
# Checks for header files.
dnl entries only used from external includes -> likely no need to check here
dnl AC_CHECK_HEADERS([whcar.h malloc.h])
# mandatory:
AC_CHECK_HEADERS([sys/types.h signal.h stddef.h], [],
[AC_MSG_ERROR([mandatory header could not be found or included])])
# optional:
AC_CHECK_HEADERS([sys/time.h locale.h fcntl.h dlfcn.h stdint.h inttypes.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_CHECK_TYPES([sig_atomic_t], [], [], [[#include <signal.h>]])
dnl Note: Don't use AC_C_INLINE here. We need the value.
AC_CACHE_CHECK([for inline keyword], gc_cv_keyword_inline, [
for gc_cv_keyword_inline in __inline __inline__ inline ""
do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifndef __cplusplus
typedef int foo_t;
static $gc_cv_keyword_inline foo_t foo () { return 0; }
#endif]], [[
#ifndef __cplusplus
return foo ();
#else
choke me
#endif]])],
[break],
[],
[])
done]
)
AC_DEFINE_UNQUOTED([COB_KEYWORD_INLINE], [$gc_cv_keyword_inline])
# Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([memmove memset setlocale fcntl strerror strcasecmp \
strchr strrchr strdup strstr strtol gettimeofday localeconv \
getexecname canonicalize_file_name popen raise readlink realpath \
setenv strcoll flockfile])
# more things to save...
AC_CACHE_SAVE
# Check for timezone
AC_CACHE_CHECK([for timezone variable access], gc_cv_time_timezone, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]],
[[timezone = 3600;]])],
[gc_cv_time_timezone=yes],
[gc_cv_time_timezone=no]
)]
)
if test "$gc_cv_time_timezone" = yes; then
AC_DEFINE([HAVE_TIMEZONE], [1])
fi
# Check for designated initializers
AC_CACHE_CHECK([for designated initializers], gc_cv_designated_inits, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
[[static const unsigned char valid_char[256] = {
@<:@'0'@:>@ = 1,
@<:@'1'@:>@ = 1 };
]])],
[gc_cv_designated_inits=yes],
[gc_cv_designated_inits=no]
)]
)
if test "$gc_cv_designated_inits" = yes; then
AC_DEFINE([HAVE_DESIGNATED_INITS], [1])
fi
CFLAGS="$curr_cflags"
dnl Add --enable-code-coverage and test for code-coverage tools if enabled
AX_CODE_COVERAGE
if test "$COB_USES_GCC_NO_ICC" != yes -a "$enable_code_coverage" = yes; then
AC_MSG_ERROR([Code coverage checks are only usable with GCC!])
fi
dnl set PKG_CONFIG to use (cross-compile aware)
PKG_PROG_PKG_CONFIG
# more things to save...
AC_CACHE_SAVE
if test "x$COB_CC" = x; then
COB_CC="$CC"
fi
if test "x$COMMON_LIBS" != x; then
if test "x$LIBCOB_LIBS" != x; then
LIBCOB_LIBS="$LIBCOB_LIBS $COMMON_LIBS"
else
LIBCOB_LIBS="$COMMON_LIBS"
fi
case " $COMMON_LIBS " in
*" -L$libdir "*) COB_LIBS="$COMMON_LIBS -lcob" ;;
*) COB_LIBS="-L$libdir $COMMON_LIBS -lcob" ;;
esac
else
COB_LIBS="-L$libdir -lcob"
fi
if test "x$LDFLAGS" != x; then
if test "x$COB_LDFLAGS" != x; then
COB_LDFLAGS="$COB_LDFLAGS $LDFLAGS"
else
COB_LDFLAGS="$LDFLAGS"
fi
fi
# some math functions (fabs, isnan, isinf) are used in numeric.c
# (all other computations are used from GMP)
#
AC_MSG_NOTICE([Checks for math library ...])
# FIXME - Check for necessary math lib - in most cases they are part of the C library
# for now: explicit pass them to configure via MATH_LIBS
dnl if test "x$MATH_LIBS" = "x"; then
dnl if test "$COB_USES_ICC_ONLY" = yes; then
dnl MATH_LIBS="-limf -lm"
dnl else
dnl curr_libs=$LIBS
dnl AC_SEARCH_LIBS([cos], [m], [], [
dnl AC_MSG_ERROR([unable to find the cos() function])
dnl ])
dnl if test "x$curr_libs" = x; then
dnl MATH_LIBS=$LIBS
dnl else
dnl MATH_LIBS=$(echo "$LIBS" | sed 's#'"$curr_libs"'##')
dnl fi
dnl LIBS=$curr_libs
dnl fi
dnl fi
if test "x$MATH_LIBS" = x; then
AC_MSG_NOTICE([none needed])
else
AC_MSG_NOTICE([using $MATH_LIBS])
case " $LIBCOB_LIBS " in
*" $MATH_LIBS "*) ;;
*) LIBCOB_LIBS="$LIBCOB_LIBS $MATH_LIBS" ;;
esac
fi
# Checks for gmp.
AC_MSG_NOTICE([Checks for GMP/MPIR ...])
AC_ARG_WITH([math],
[AS_HELP_STRING([[--with-math[=ARG]]],
[(GnuCOBOL) Use math multiple precision library, where ARG may be:
check (default), gmp, mpir])],
[case "$with_math" in
gmp | mpir | check)
;;
yes)
with_math=check
;;
no)
AC_MSG_ERROR([cannot build GnuCOBOL without math multiple precision library)])
;;
*)
AC_MSG_ERROR([invalid value "$with_math" for --with-math,
must be one of the following:
gmp, mpir (use only the specified library)
check (use whatever library is usable)])
;;
esac],
[with_math=check])
curr_libs=$LIBS
curr_cppflags=$CPPFLAGS
AS_IF([test "$with_math" = gmp -o "$with_math" = check], [
curr_libs="$LIBS"; curr_cppflags="$CPPFLAGS"
PKG_CHECK_MODULES([GMP], [gmp], [], [
PKG_CHECK_MODULES([GMP], [libgmp], [], [#
])
])
# special case: as included by modules we don't want a single warning (breaks testsuite)
CPPFLAGS="$CPPFLAGS $GMP_CFLAGS $ERRWARN"
if test -z "${GMP_LIBS+x}"; then
GMP_LIBS="-lgmp"
fi
LIBS="$LIBS $LIBCOB_LIBS_extern $GMP_LIBS"
AC_CHECK_HEADERS([gmp.h], [
AC_MSG_CHECKING([whether linking against libgmp with "$GMP_LIBS" works])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]],
[[mpz_t integ; mpz_init (integ);]])],
[AC_MSG_RESULT([yes])
if test -n "$GMP_CFLAGS"; then
curr_cppflags="$curr_cppflags $GMP_CFLAGS" # for the include in cobc generated modules
fi
LIBCOB_LIBS="$LIBCOB_LIBS $GMP_LIBS"
with_math=gmp],
[AC_MSG_RESULT([no])
if test "$with_math" = gmp; then
AC_MSG_ERROR([[GMP is required for --with-math=gmp, you may adjust GMP_LIBS]])
fi
LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags"]
)
], [if test "$with_math" = gmp; then
AC_MSG_ERROR([gmp.h is required for --with-math=gmp, you may adjust GMP_CFLAGS])
fi
LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags"
])
])
AS_IF([test "$with_math" = mpir -o "$with_math" = check], [
# note: currently MPIR does not ship a .pc file, but is expected to follow GMP
curr_libs="$LIBS"; curr_cppflags="$CPPFLAGS"
PKG_CHECK_MODULES([MPIR], [mpir], [], [#
])
# special case: as included by modules we don't want a single warning (breaks testsuite)
CPPFLAGS="$CPPFLAGS $MPIR_CFLAGS $ERRWARN"
if test -z "${MPIR_LIBS+x}"; then
MPIR_LIBS="-lmpir"
fi
LIBS="$LIBS $LIBCOB_LIBS_extern $MPIR_LIBS"
AC_CHECK_HEADERS([mpir.h], [
AC_MSG_CHECKING([whether linking against libmpir with "$MPIR_LIBS" works])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpir.h>]],
[[mpz_t integ; mpz_init (integ);]])],
[AC_MSG_RESULT([yes])
if test -n "$MPIR_CFLAGS"; then
curr_cppflags="$curr_cppflags $MPIR_CFLAGS" # for the include in cobc generated modules
fi
LIBCOB_LIBS="$LIBCOB_LIBS $MPIR_LIBS"
with_math=mpir],
[AC_MSG_RESULT([no])
if test "$with_math" = mpir; then
AC_MSG_ERROR([[MPIR is required for --with-math=mpir, you may adjust MPIR_LIBS]])
fi
LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags"]
)
], [if test "$with_math" = mpir; then
AC_MSG_ERROR([mpir.h is required for --with-math=mpir, you may adjust MPIR_CFLAGS])
fi
LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags"
])
])
if test "$with_math" = check; then
AC_MSG_FAILURE([neither GMP nor MPIR library are found, but one of those is mandatory])
fi
CPPFLAGS="$CPPFLAGS $ERRWARN"
AC_MSG_CHECKING([matching GMP version])
# Check just major/minor levels between header and library
# get GMP version from lib
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#ifdef _WIN32
#ifndef __GMP_LIBGMP_DLL
#define __GMP_LIBGMP_DLL 1
#endif
#endif
#if defined HAVE_GMP_H
#include <gmp.h>
#elif defined HAVE_MPIR_H
#include <mpir.h>
#endif
int main (int argc, char **argv)
{
(void)argv;
if (argc > 1)
printf ("%s", gmp_version);
return 0;
}
]])],
[COB_GMP_LIB=$(./conftest$ac_exeext x)],
[AC_MSG_ERROR([unable to extract GMP version information from gmp_version])],
[AC_MSG_WARN([matching GMP version assumed])]
COB_GMP_LIB="cross")
if test "x$COB_GMP_LIB" = x; then
AC_MSG_ERROR([unable to extract GMP version information (library)])
fi
# get GMP version from header
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#if defined HAVE_GMP_H
#include <gmp.h>
#elif defined HAVE_MPIR_H
#include <mpir.h>
#endif
int main (int argc, char **argv)
{
(void)argv;
if (argc > 1)
printf ("%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR);
return 0;
}
]])],
[COB_GMP_HEADER=$(./conftest$ac_exeext x)],
[AC_MSG_ERROR([unable to extract GMP version information from header])],
[AC_MSG_WARN([cannot run test program while cross-compiling])
COB_GMP_HEADER="cross-compilation - assumed"])
if test "x$COB_GMP_HEADER" = x; then
AC_MSG_ERROR([unable to extract GMP version information (header)])
fi
COB_GMP_LIB_MAJOR=$(echo "$COB_GMP_LIB" | cut -d. -f1)
COB_GMP_LIB_MINOR=$(echo "$COB_GMP_LIB" | cut -d. -f2)
if test "$COB_GMP_HEADER" = "$COB_GMP_LIB_MAJOR.$COB_GMP_LIB_MINOR" -o "$COB_GMP_LIB" = "cross"; then
AC_MSG_RESULT([yes ($COB_GMP_HEADER)])
else
AC_MSG_RESULT([no (header: $COB_GMP_HEADER / library: $COB_GMP_LIB)])
AC_MSG_FAILURE([unable to use GMP])
fi
AC_CHECK_LIB([$with_math], [__gmp_get_memory_functions],
[AC_DEFINE([HAVE_MP_GET_MEMORY_FUNCTIONS], [1])], [], [])
LIBS="$curr_libs"
CPPFLAGS="$curr_cppflags"
# Checks for gettext.
case $host_os in
darwin* | rhapsody*)
;;
*)
gt_cv_func_CFPreferencesCopyAppValue=no
gt_cv_func_CFLocaleCopyCurrent=no
;;
esac
dnl Simon: removed, use --disable-nls instead
dnl # Disable for Cygwin
dnl AC_MSG_CHECKING([for __CYGWIN__])
dnl AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
dnl #ifndef __CYGWIN__
dnl # error macro not defined
dnl #endif]])],
dnl [enable_nls=no
dnl AC_MSG_RESULT([yes])],
dnl [AC_MSG_RESULT([no])])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.19.8])
if test "x$LTLIBINTL" != x; then
if test "x$PROGRAMS_LIBS" != x; then
PROGRAMS_LIBS="$PROGRAMS_LIBS $LTLIBINTL"
else
PROGRAMS_LIBS="$LTLIBINTL"
fi
LIBCOB_LIBS="$LIBCOB_LIBS $LTLIBINTL"
fi
# Checks for internationalization stuff
AM_LANGINFO_CODESET
AC_ARG_WITH([iconv],
[AS_HELP_STRING([--with-iconv],