-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcoin.m4
More file actions
4191 lines (3697 loc) · 150 KB
/
coin.m4
File metadata and controls
4191 lines (3697 loc) · 150 KB
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
# Copyright (C) 2006, 2009 International Business Machines.
# All Rights Reserved.
# This file is distributed under the Eclipse Public License.
#
## $Id: coin.m4 3273 2015-01-09 23:42:08Z tkr $
#
# Author: Andreas Wachter IBM 2006-04-14
# This file defines the common autoconf macros for COIN
#
# Check requirements
AC_PREREQ(2.59)
###########################################################################
# coin_foreach_w #
###########################################################################
# the autoconf version used by COIN-OR is so old that it does not have the M4 macro foreach_w.
# thus, we define our own one which applies the foreach macro to the same arguments but with
# all spaces replaced by ',' in the second argument.
# further, we run the loop only if the second argument is not empty
AC_DEFUN([coin_foreach_w], [m4_ifval([$2], [m4_foreach([$1], [m4_bpatsubsts([$2],[[ ]+],[, ])], [$3])])])
###########################################################################
# COIN_CHECK_FILE #
###########################################################################
# A simple replacement for AC_CHECK_FILE that works for cross compilation
AC_DEFUN([AC_COIN_CHECK_FILE],
[if test -r $1; then
$2
:
else
$3
:
fi
])
###########################################################################
# COIN_CHECK_VPATH #
###########################################################################
# This macro sets the variable coin_vpath_config to true if this is a
# VPATH configuration, otherwise it sets it to false.
AC_DEFUN([AC_COIN_CHECK_VPATH],
[
AC_MSG_CHECKING(whether this is a VPATH configuration)
if test `cd $srcdir; pwd` != `pwd`; then
coin_vpath_config=yes;
else
coin_vpath_config=no;
fi
AC_MSG_RESULT($coin_vpath_config)
]) # AC_COIN_CHECK_VPATH
###########################################################################
# COIN_PROJECTVERSION #
###########################################################################
# This macro is used by COIN_PROJECTDIR_INIT and sets up variables related
# to versioning numbers of the project.
AC_DEFUN([AC_COIN_PROJECTVERSION],
[m4_ifvaln([$1],[
AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION), ["$PACKAGE_VERSION"],[Version number of project])
[coin_majorver=`echo $PACKAGE_VERSION | sed -n -e 's/^\([0-9]*\).*/\1/gp'`]
[coin_minorver=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.\([0-9]*\).*/\1/gp'`]
[coin_releasever=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/gp'`]
if test "x$coin_majorver" = x ; then coin_majorver=9999 ; fi
if test "x$coin_minorver" = x ; then coin_minorver=9999 ; fi
if test "x$coin_releasever" = x ; then coin_releasever=9999 ; fi
AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MAJOR), [$coin_majorver], [Major Version number of project])
AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MINOR), [$coin_minorver], [Minor Version number of project])
AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_RELEASE), [$coin_releasever], [Release Version number of project])
# We use the following variable to have a string with the upper case
# version of the project name
COIN_PRJCT=m4_toupper($1)
# Set the project's SVN revision number. The complicated sed expression
# (made worse by quadrigraphs) ensures that things like 4123:4168MS end up
# as a single number.
AC_CHECK_PROG([have_svnversion],[svnversion],[yes],[no])
if test "x$have_svnversion" = xyes; then
AC_SUBST(m4_toupper($1_SVN_REV))
svn_rev_tmp=`LANG=en_EN svnversion $srcdir 2>/dev/null`
if test "x$svn_rev_tmp" != xexported -a "x$svn_rev_tmp" != x -a "x$svn_rev_tmp" != "xUnversioned directory"; then
m4_toupper($1_SVN_REV)=`echo $svn_rev_tmp | sed -n -e 's/^@<:@0-9@:>@*://' -e 's/\(@<:@0-9@:>@\)@<:@^0-9@:>@*$/\1/p'`
AC_DEFINE_UNQUOTED(m4_toupper($1_SVN_REV), $m4_toupper($1_SVN_REV), [SVN revision number of project])
fi
fi
])
# Capture libtool library version, if given.
m4_ifvaln([$2],[coin_libversion=$2],[])
])
###########################################################################
# COIN_PROJECTDIR_INIT #
###########################################################################
# This macro does everything that is required in the early part in the
# configure script, such as defining a few variables. This should only be used
# in the main directory of a project directory (the one which holds the src
# directory for the project). The first parameter is the project name. The
# second (optional) is the libtool library version (important for releases,
# less so for stable or trunk).
AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
[
# As backup, we make sure we don't loose an FLIBS if it has been set
# by the user
save_FLIBS="$FLIBS"
# A useful makefile conditional that is always false
AM_CONDITIONAL(ALWAYS_FALSE, false)
# We set the following variable so that we know later in AC_COIN_FINALIZE
# that we are in a project main directory
coin_projectdir=yes
# Set the project's version numbers
AC_COIN_PROJECTVERSION($1, $2)
]) # AC_COIN_PROJECTDIR_INIT
###########################################################################
# COIN_DEBUG_COMPILE #
###########################################################################
# enable the configure flags --enable-debug and --enable-debug-prjct
# (where prcjt is the name of the project in lower case) and set the
# variable coin_debug_compile to true or false This is used by
# COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77 to determine the
# compilation flags. This macro also makes the switches
# --with-prjct-verbosity and --with-prjct-checklevel available, which
# define the preprocessor macros COIN_PRJCT_VERBOSITY and
# COIN_PRJCT_CHECKLEVEL to the specified value (default is 0).
#
# The project specific flags are only made available, if one gives the
# name of the project as first argument to this macro.
AC_DEFUN([AC_COIN_DEBUG_COMPILE],
[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
AC_MSG_CHECKING([whether we want to compile in debug mode])
AC_ARG_ENABLE([debug],
[AC_HELP_STRING([--enable-debug],
[compile all projects with debug options tests (implies --disable-shared)])],
[case "${enableval}" in
yes) coin_debug_compile=true
if test "${enable_shared+set}" = set; then :; else
enable_shared=no
fi
;;
no) coin_debug_compile=false
;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
;;
esac],
[coin_debug_compile=false])
m4_ifvaln([$1],
[AC_ARG_ENABLE(debug-m4_tolower($1),
[AC_HELP_STRING([--enable-debug-m4_tolower($1)],
[compile project $1 with debug compiler flags])],
[case "${enableval}" in
yes) coin_debug_compile=true
;;
no) coin_debug_compile=false
;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
;;
esac],[:])
]) # m4_ifvaln([$1],
if test $coin_debug_compile = true; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
m4_ifvaln([$1],
[AC_ARG_WITH(m4_tolower($1)-verbosity,
AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
[specify the debug verbosity level for project $1]),
[if test "$withval" = yes; then
withval=1
fi
m4_tolower(coin_$1_verbosity)=$withval],
[m4_tolower(coin_$1_verbosity)=0])
AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
m4_tolower($coin_$1_verbosity),
[Define to the debug verbosity level (0 is no output)])
AC_ARG_WITH(m4_tolower($1)-checklevel,
AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
[specify the sanity check level for project $1]),
[if test "$withval" = yes; then
withval=1
fi
m4_tolower(coin_$1_checklevel)=$withval],
[m4_tolower(coin_$1_checklevel)=0])
AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
m4_tolower($coin_$1_checklevel),
[Define to the debug sanity check level (0 is no test)])
]) # m4_ifvaln([$1],
]) # AC_COIN_DEBUG_COMPILE
###########################################################################
# COIN_ENABLE_MSVC #
###########################################################################
# This macro is invoked by any PROG_compiler macro to establish the
# --enable-msvc option.
# The job of this macro is to make sure the option is correct and
# to set enable_msvc. Legal values are yes and no (disabled).
# If set, assume the presence of cl/link. It's the user's responsibility to
# make sure their PATH is correct. In particular, that MSVC link is found
# and not cygwin link (we want to do code linking, not file linking).
# It's the responsibility of individual PROG_compiler macros to ensure that
# they correctly set the compiler search list and preprocess, compile, and
# link flags. This is tied to compiler setup because in practice invocations
# of the preprocessor and linker are made through the compiler.
# For backward compatibility, we also check for --enable-doscompile=msvc.
AC_DEFUN([AC_COIN_ENABLE_MSVC],
[AC_REQUIRE([AC_CANONICAL_BUILD])
# for backward compatibility
AC_ARG_ENABLE([doscompile],,[enable_doscompile=$enableval],[enable_doscompile=no])
AC_ARG_ENABLE([msvc],
[AC_HELP_STRING([--enable-msvc],
[Prefer (i)cl/ifort/link over GNU on MinGW/Cygwin.])],
[enable_msvc=$enableval],
[enable_msvc=no
if test "$enable_doscompile" = msvc ; then
enable_msvc=yes
elif test "$enable_doscompile" != no ; then
AC_MSG_ERROR([--enable-doscompile=$enable_doscompile not supported anymore.])
fi
])
if test "$enable_msvc" = MD; then
enable_shared=yes
enable_msvc=yes
fi
if test "$enable_msvc" = yes; then
case $build in
*-cygwin* | *-mingw*) ;;
*) AC_MSG_ERROR([--enable-msvc option makes sense only under Cygwin or MinGW]) ;;
esac
fi
])
###########################################################################
# COIN_PROG_CXX #
###########################################################################
# Find the compile command by running AC_PROG_CXX (with compiler names for
# different operating systems) and put it into CXX (unless it was given by the
# user). Then find an appropriate value for CXXFLAGS. If either of CXXFLAGS or
# PRJCT_CXXFLAGS is defined, that value is used (replace PRJCT with the upper
# case name of this project). It is possible to provide additional -D flags
# in the variable CXXDEFS, and additional compilation flags with ADD_CXXFLAGS.
AC_DEFUN([AC_COIN_PROG_CXX],
[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
AC_REQUIRE([AC_COIN_ENABLE_MSVC])
AC_LANG_PUSH(C++)
AC_ARG_VAR(CXXDEFS,[Additional -D flags to be used when compiling C++ code.])
AC_ARG_VAR(ADD_CXXFLAGS,[Additional C++ compiler options])
AC_ARG_VAR(DBG_CXXFLAGS,[Debug C++ compiler options])
AC_ARG_VAR(OPT_CXXFLAGS,[Optimize C++ compiler options])
coin_has_cxx=yes
save_cxxflags="$CXXFLAGS"
# For *-*-solaris*, promote Studio/Workshop compiler to front of list.
case $build in
*-cygwin* | *-mingw*)
if test "$enable_msvc" = yes ; then
comps="icl cl g++"
else
comps="g++ icl cl"
fi ;;
*-*-solaris*)
comps="CC xlC_r aCC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
*-darwin*) comps="clang++ g++ c++ CC" ;;
*-linux-gnu*)
comps="g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC xlC_r aCC CC" ;;
*) comps="xlC_r aCC CC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
esac
# We delete the cached value, since the test might not have been
# performed with our choice of compilers earlier
$as_unset ac_cv_prog_CXX || test "${ac_cv_prog_CXX+set}" != set || { ac_cv_prog_CXX=; export ac_cv_prog_CXX; }
# AC_MSG_NOTICE([C++ compiler candidates: $comps])
AC_PROG_CXX([$comps])
#AC_PROG_CXX sets CXX to g++ if it cannot find a working C++ compiler
#thus, we test here whether $CXX is actually working
AC_LANG_PUSH(C++)
AC_MSG_CHECKING([whether C++ compiler $CXX works]);
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(, [int i=0;])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR(failed to find a C++ compiler or C++ compiler $CXX does not work)]
)
AC_LANG_POP(C++)
coin_cxx_is_cl=false
# It seems that we need to cleanup something here for the Windows
case "$CXX" in
clang* | */clang*) ;;
cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
sed -e 's/^void exit (int);//' confdefs.h >> confdefs.hh
mv confdefs.hh confdefs.h
coin_cxx_is_cl=true
;;
esac
# add automake conditional so we can recognize cl compiler in makefile
AM_CONDITIONAL(COIN_CXX_IS_CL, [test $coin_cxx_is_cl = true])
# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
case "$CXX" in
clang* ) ;;
cl* | */cl* | CL* | */CL* )
if test "$ac_cv_prog_cxx_g" = yes ; then
ac_cv_prog_cxx_g=no
AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
fi ;;
* )
if test x"$CYGPATH_W" = x ; then
CYGPATH_W=echo
fi
;;
esac
CXXFLAGS="$save_cxxflags"
# Check if a project specific CXXFLAGS variable has been set
if test x$COIN_PRJCT != x; then
eval coin_tmp=\${${COIN_PRJCT}_CXXFLAGS+set}
if test x$coin_tmp = xset; then
eval CXXFLAGS=\${${COIN_PRJCT}_CXXFLAGS}
fi
fi
if test x"$CXXFLAGS" = x; then
# ToDo decide whether we want -DNDEBUG for optimization
coin_add_cxxflags=
coin_opt_cxxflags=
coin_dbg_cxxflags=
coin_warn_cxxflags=
if test "$GXX" = "yes"; then
case "$CXX" in
icpc* | */icpc*)
;;
*)
# ToDo decide about unroll-loops
coin_opt_cxxflags="-O3"
coin_add_cxxflags="-pipe"
coin_dbg_cxxflags="-g -O0"
coin_warn_cxxflags="-Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long"
case $build in
*-darwin*)
;;
*)
coin_warn_cxxflags="-pedantic-errors $coin_warn_cxxflags"
;;
esac
esac
fi
# Note that we do not need to cover GCC in the following tests.
if test -z "$coin_opt_cxxflags"; then
case $build in
*-cygwin* | *-mingw*)
case "$CXX" in
clang* ) ;;
cl* | */cl* | CL* | */CL*)
# The MT and MTd options are mutually exclusive
if test "$coin_disable_shared" = yes || test "$enable_shared" = yes ; then
coin_opt_cxxflags='-MD -O2'
coin_dbg_cxxflags='-MDd'
else
coin_opt_cxxflags='-MT -O2'
coin_dbg_cxxflags='-MTd'
fi
coin_add_cxxflags='-nologo -EHsc -GR -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
;;
icl* | */icl* | ICL* | */ICL*)
# The MT and MTd options are mutually exclusive
if test "$coin_disable_shared" = yes || test "$enable_shared" = yes ; then
coin_opt_cxxflags='-MD -Ox'
coin_dbg_cxxflags='-MDd -debug'
else
coin_opt_cxxflags='-MT -Ox'
coin_dbg_cxxflags='-MTd -debug'
fi
coin_add_cxxflags='-nologo -EHsc -GR -D_CRT_SECURE_NO_DEPRECATE'
;;
esac
;;
*-linux-*)
case "$CXX" in
icpc* | */icpc*)
coin_opt_cxxflags="-O3 -ip -mp1"
coin_add_cxxflags=""
coin_dbg_cxxflags="-g"
# Check if -i_dynamic is necessary (for new glibc library)
CXXFLAGS=
AC_TRY_LINK(,[int i=0; i++;],[],
[coin_add_cxxflags="-i_dynamic $coin_add_cxxflags"])
;;
pgCC* | */pgCC*)
coin_opt_cxxflags="-fast"
coin_add_cxxflags="-Kieee -pc 64"
coin_dbg_cxxflags="-g"
;;
esac
;;
*-ibm-*)
case "$CXX" in
xlC* | */xlC* | mpxlC* | */mpxlC*)
coin_opt_cxxflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna -qsuppress=1500-036 -qsuppress=1500-029 -qsourcetype=c++"
coin_dbg_cxxflags="-g"
;;
esac
;;
*-hp-*)
case "$CXX" in
aCC* | */aCC* )
coin_opt_cxxflags="-O"
coin_add_cxxflags="-AA"
coin_dbg_cxxflags="-g"
;;
esac
;;
*-*-solaris*)
coin_opt_cxxflags="-O4"
coin_dbg_cxxflags="-g"
;;
esac
fi
# Generic flag settings. If these don't work, add a case above.
if test "$ac_cv_prog_cxx_g" = yes && test -z "$coin_dbg_cxxflags" ; then
coin_dbg_cxxflags="-g"
fi
if test -z "$coin_opt_cxxflags"; then
# Try if -O option works if nothing else is set
CXXFLAGS=-O
AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cxxflags="-O"])
fi
# if PM doesn't want the warning messages, take them out
if test x"$coin_skip_warn_cxxflags" = xyes; then
coin_warn_cxxflags=
fi
# Do final setup of flags based on values determined above.
if test x${DBG_CXXFLAGS+set} != xset; then
DBG_CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
fi
if test x${OPT_CXXFLAGS+set} != xset; then
OPT_CXXFLAGS="$coin_opt_cxxflags $coin_add_cxxflags -DNDEBUG $coin_warn_cxxflags"
fi
DBG_CXXFLAGS="$DBG_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
OPT_CXXFLAGS="$OPT_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
if test "$coin_debug_compile" = "true"; then
CXXFLAGS="$DBG_CXXFLAGS"
else
CXXFLAGS="$OPT_CXXFLAGS"
fi
# Handle the case where CXXFLAGS was set externally.
else
CXXFLAGS="$CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
if test x${DBG_CXXFLAGS+set} != xset; then
DBG_CXXFLAGS="$CXXFLAGS"
fi
if test x${OPT_CXXFLAGS+set} != xset; then
OPT_CXXFLAGS="$CXXFLAGS"
fi
fi
# add -DPROJECT_BUILD to signal compiler preprocessor which config header file to include
if test x$COIN_PRJCT != x; then
CXXFLAGS="$CXXFLAGS -D${COIN_PRJCT}_BUILD"
fi
# Try if CXXFLAGS works
save_CXXFLAGS="$CXXFLAGS"
AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
if test -z "$CXXFLAGS"; then
AC_MSG_WARN([The flags CXXFLAGS="$save_CXXFLAGS" do not work. I will now just try '-O', but you might want to set CXXFLAGS manually.])
CXXFLAGS='-O'
AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
if test -z "$CXXFLAGS"; then
AC_MSG_WARN([This value for CXXFLAGS does not work. I will continue with empty CXXFLAGS, but you might want to set CXXFLAGS manually.])
fi
fi
AC_MSG_NOTICE([C++ compiler options are: $CXXFLAGS])
AC_ARG_VAR(MPICXX,[C++ MPI Compiler])
if test x"$MPICXX" = x; then :; else
AC_MSG_NOTICE([Will use MPI C++ compiler $MPICXX])
CXX="$MPICXX"
fi
# correct the LD variable in a build with MS or intel compiler
case "$CXX" in
clang* ) ;;
cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
LD=link
;;
esac
AC_LANG_POP(C++)
]) # AC_COIN_PROG_CXX
###########################################################################
# COIN_CXXLIBS #
###########################################################################
# Determine the C++ runtime libraries required for linking a C++ library
# with a Fortran or C compiler. The result is available in CXXLIBS.
AC_DEFUN([AC_COIN_CXXLIBS],
[AC_REQUIRE([AC_PROG_CXX])dnl
AC_LANG_PUSH(C++)
AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with Fortran compiler])
if test -z "$CXXLIBS"; then
if test "$GXX" = "yes"; then
case "$CXX" in
icpc* | */icpc*)
CXXLIBS="-lstdc++"
;;
*)
# clang uses libc++ as the default standard C++ library, not libstdc++
# this test is supposed to recognize whether the compiler is clang
#
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ciso646>]], [[
#ifndef _LIBCPP_VERSION
choke me
#endif
]])],
[CXXLIBS="-lc++"],
[CXXLIBS="-lstdc++ -lm"])
;;
esac
else
case $build in
*-mingw32 | *-cygwin* )
case "$CXX" in
clang* ) ;;
cl* | */cl* | CL* | */CL*)
CXXLIBS=nothing;;
esac;;
*-linux-*)
case "$CXX" in
icpc* | */icpc*)
CXXLIBS="-lstdc++"
;;
pgCC* | */pgCC*)
CXXLIBS="-lstd -lC -lc"
;;
esac;;
*-ibm-*)
CXXLIBS="-lC -lc"
;;
*-hp-*)
CXXLIBS="-L/opt/aCC/lib -l++ -lstd_v2 -lCsup_v2 -lm -lcl -lc"
;;
*-*-solaris*)
CXXLIBS="-lCstd -lCrun"
esac
fi
fi
if test -z "$CXXLIBS"; then
AC_MSG_WARN([Could not automatically determine CXXLIBS (C++ link libraries; necessary if main program is in Fortran or C).])
else
AC_MSG_NOTICE([Assuming that CXXLIBS is \"$CXXLIBS\".])
fi
if test x"$CXXLIBS" = xnothing; then
CXXLIBS=
fi
AC_LANG_POP(C++)
]) # AC_COIN_CXXLIBS
###########################################################################
# COIN_CHECK_HEADER #
###########################################################################
# This macro checks for a header file, but it does so without the
# standard header. This avoids warning messages like:
#
# configure: WARNING: dlfcn.h: present but cannot be compiled
# configure: WARNING: dlfcn.h: check for missing prerequisite headers?
# configure: WARNING: dlfcn.h: see the Autoconf documentation
# configure: WARNING: dlfcn.h: section "Present But Cannot Be Compiled"
# configure: WARNING: dlfcn.h: proceeding with the preprocessor's result
# configure: WARNING: dlfcn.h: in the future, the compiler will take precedence
# My guess that the problem lay with CPPFLAGS seems to be correct. With this
# macro reduced to a direct call to AC_CHECK_HEADERS, there are no warnings
# now that CPPFLAGS contains -mno-cygwin when it needs it. -- lh, 061214 --
# AW 070609: I restored the previous version, since otherwise the warnings
# still pop up for the cl compiler
AC_DEFUN([AC_COIN_CHECK_HEADER],
[#if test x"$4" = x; then
# hdr="#include <$1>"
#else
# hdr="$4"
#fi
#AC_CHECK_HEADERS([$1],[$2],[$3],[$hdr])
AC_CHECK_HEADERS([$1],[$2],[$3],[$4])
]) # AC_COIN_CHECK_HEADER
###########################################################################
# COIN_CHECK_CXX_CHEADER #
###########################################################################
# This macro checks for C header files that are used from C++. For a give
# stub (e.g., math), it first checks if the C++ library (cmath) is available.
# If it is, it defines HAVE_CMATH (or whatever the stub is). If it is not
# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
# if that one exists.
AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
[AC_LANG_PUSH(C++)
AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
if test "$ac_cv_header_c$1" != "yes"; then
AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
fi
AC_LANG_POP(C++)
]) # AC_COIN_CHECK_CXX_CHEADER
###########################################################################
# COIN_PROG_CC #
###########################################################################
# Find the compile command by running AC_PROG_CC (with compiler names
# for different operating systems) and put it into CC (unless it was
# given my the user), and find an appropriate value for CFLAGS. It is
# possible to provide additional -D flags in the variable CDEFS.
AC_DEFUN([AC_COIN_PROG_CC],
[AC_REQUIRE([AC_COIN_ENABLE_MSVC])
AC_LANG_PUSH(C)
# For consistency, we set the C compiler to the same value of the C++
# compiler, if the C++ is set, but the C compiler isn't (only for CXX=cl)
if test x"$CXX" != x; then
case "$CXX" in
clang* ) ;;
cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
if test x"$CC" = x; then
CC="$CXX"
AC_MSG_WARN([C++ compiler name provided as $CXX, but CC is unset. Setting CC to $CXX])
fi
;;
esac
fi
AC_ARG_VAR(CDEFS,[Additional -D flags to be used when compiling C code.])
AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options])
AC_ARG_VAR(DBG_CFLAGS,[Debug C compiler options])
AC_ARG_VAR(OPT_CFLAGS,[Optimize C compiler options])
coin_has_cc=yes
save_cflags="$CFLAGS"
# For *-*-solaris*, promote Studio/Workshop cc compiler to front of list.
# Depending on the user's PATH, when Studio/Workshop cc is not present we may
# find /usr/ucb/cc, which is almost certainly not a good choice for the C
# compiler. In this case, put cc after gcc.
case $build in
*-cygwin* | *-mingw*)
if test "$enable_msvc" = yes ; then
comps="icl cl gcc"
else
comps="gcc icl cl"
fi ;;
*-*-solaris*)
AC_CHECK_PROG(sol_cc_compiler,cc,cc,[],[],/usr/ucb/cc)
if test "$sol_cc_compiler" = "cc" ; then
comps="cc xlc gcc pgcc icc"
else
comps="xlc gcc pgcc icc cc"
fi
;;
*-*-darwin*) comps="clang gcc cc" ;;
*-linux-gnu*) comps="gcc cc pgcc icc xlc" ;;
*-linux-*) comps="xlc gcc cc pgcc icc" ;;
*) comps="xlc_r xlc cc gcc pgcc icc" ;;
esac
# We delete the cached value, since the test might not have been
# performed with our choice of compilers earlier
$as_unset ac_cv_prog_CC || test "${ac_cv_prog_CC+set}" != set || { ac_cv_prog_CC=; export ac_cv_prog_CC; }
# AC_MSG_NOTICE([C compiler candidates: $comps])
AC_PROG_CC([$comps])
if test -z "$CC" ; then
AC_MSG_ERROR([Failed to find a C compiler!])
fi
# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
case "$CC" in
clang* ) ;;
cl* | */cl* | CL* | */CL* )
if test "$ac_cv_prog_cc_g" = yes ; then
ac_cv_prog_cc_g=no
AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
fi ;;
* )
if test x"$CYGPATH_W" = x ; then
CYGPATH_W=echo
fi
;;
esac
CFLAGS="$save_cflags"
# add automake conditional so we can recognize cl compiler in makefile
coin_cc_is_cl=false
case "$CC" in
clang* ) ;;
cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
coin_cc_is_cl=true
;;
esac
AM_CONDITIONAL(COIN_CC_IS_CL, [test $coin_cc_is_cl = true])
# Check if a project specific CFLAGS variable has been set
if test x$COIN_PRJCT != x; then
eval coin_tmp=\${${COIN_PRJCT}_CFLAGS+set}
if test x$coin_tmp = xset; then
eval CFLAGS=\${${COIN_PRJCT}_CFLAGS}
fi
fi
if test x"$CFLAGS" = x; then
coin_add_cflags=
coin_opt_cflags=
coin_dbg_cflags=
coin_warn_cflags=
if test "$GCC" = "yes"; then
case "$CC" in
icc* | */icc*)
;;
*)
coin_opt_cflags="-O3"
coin_add_cflags="-pipe"
coin_dbg_cflags="-g -O0"
coin_warn_cflags="-Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall -Wno-unknown-pragmas -Wno-long-long"
case $build in
*-darwin*)
;;
*)
coin_warn_cflags="-pedantic-errors $coin_warn_cflags"
;;
esac
esac
fi
if test -z "$coin_opt_cflags"; then
case $build in
*-cygwin* | *-mingw*)
case "$CC" in
clang* ) ;;
cl* | */cl* | CL* | */CL*)
if test "$coin_disable_shared" = yes || test "$enable_shared" = yes ; then
coin_opt_cflags='-MD -O2'
coin_dbg_cflags='-MDd'
else
coin_opt_cflags='-MT -O2'
coin_dbg_cflags='-MTd'
fi
coin_add_cflags='-nologo -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
;;
icl* | */icl* | ICL* | */ICL*)
if test "$coin_disable_shared" = yes || test "$enable_shared" = yes ; then
coin_opt_cflags='-MD -Ox'
coin_dbg_cflags='-MDd -debug'
else
coin_opt_cflags='-MT -Ox'
coin_dbg_cflags='-MTd -debug'
fi
coin_add_cflags='-nologo -D_CRT_SECURE_NO_DEPRECATE'
;;
esac
;;
*-linux-*)
case "$CC" in
icc* | */icc*)
coin_opt_cflags="-O3 -ip -mp1"
coin_add_cflags=""
coin_dbg_cflags="-g"
# Check if -i_dynamic is necessary (for new glibc library)
CFLAGS=
AC_TRY_LINK([],[int i=0; i++;],[],
[coin_add_cflags="-i_dynamic $coin_add_cflags"])
;;
pgcc* | */pgcc*)
coin_opt_cflags="-fast"
coin_add_cflags="-Kieee -pc 64"
coin_dbg_cflags="-g"
;;
esac
;;
*-ibm-*)
case "$CC" in
xlc* | */xlc* | mpxlc* | */mpxlc*)
coin_opt_cflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
coin_add_cflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
coin_dbg_cflags="-g"
;;
esac
;;
*-hp-*)
coin_opt_cflags="-O"
coin_add_cflags="-Ae"
coin_dbg_cflags="-g"
;;
*-*-solaris*)
coin_opt_cflags="-xO4"
coin_dbg_cflags="-g"
;;
*-sgi-*)
coin_opt_cflags="-O -OPT:Olimit=0"
coin_dbg_cflags="-g"
;;
esac
fi
if test "$ac_cv_prog_cc_g" = yes && test -z "$coin_dbg_cflags" ; then
coin_dbg_cflags="-g"
fi
if test -z "$coin_opt_cflags"; then
# Try if -O option works if nothing else is set
CFLAGS="-O"
AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cflags="-O"])
fi
# if PM doesn't want the warning messages, take them out
if test x"$coin_skip_warn_cflags" = xyes; then
coin_warn_cflags=
fi
if test x${DBG_CFLAGS+set} != xset; then
DBG_CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
fi
if test x${OPT_CFLAGS+set} != xset; then
OPT_CFLAGS="$coin_opt_cflags $coin_add_cflags -DNDEBUG $coin_warn_cflags"
fi
DBG_CFLAGS="$DBG_CFLAGS $ADD_CFLAGS $CDEFS"
OPT_CFLAGS="$OPT_CFLAGS $ADD_CFLAGS $CDEFS"
if test "$coin_debug_compile" = "true"; then
CFLAGS="$DBG_CFLAGS"
else
CFLAGS="$OPT_CFLAGS"
fi
else
CFLAGS="$CFLAGS $ADD_CFLAGS $CDEFS"
if test x${DBG_CFLAGS+set} != xset; then
DBG_CFLAGS="$CFLAGS"
fi
if test x${OPT_CFLAGS+set} != xset; then
OPT_CFLAGS="$CFLAGS"
fi
fi
# add -DPROJECT_BUILD to signal compiler preprocessor which config header file to include
if test x$COIN_PRJCT != x; then
CFLAGS="$CFLAGS -D${COIN_PRJCT}_BUILD"
fi
# Try if CFLAGS works
save_CFLAGS="$CFLAGS"
AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
if test -z "$CFLAGS"; then
AC_MSG_WARN([The value CFLAGS="$save_CFLAGS" do not work. I will now just try '-O', but you might want to set CFLAGS manually.])
CFLAGS='-O'
AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
if test -z "$CFLAGS"; then
AC_MSG_WARN([This value for CFLAGS does not work. I will continue with empty CFLAGS, but you might want to set CFLAGS manually.])
fi
fi
AC_MSG_NOTICE([C compiler options are: $CFLAGS])
AC_ARG_VAR(MPICC,[C MPI Compiler])
if test x"$MPICC" = x; then :; else
AC_MSG_NOTICE([Will use MPI C compiler $MPICC])
CC="$MPICC"
fi
# Correct the LD variable if we are using the MS or Intel-windows compiler
case "$CC" in
clang* ) ;;
cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
LD=link
;;
esac
AC_LANG_POP(C)
]) # AC_COIN_PROG_CC
###########################################################################
# COIN_PROG_F77 #
###########################################################################
# Find the compile command by running AC_PROG_F77 (with compiler names
# for different operating systems) and put it into F77 (unless it was
# given by the user), and find an appropriate value for FFLAGS
AC_DEFUN([AC_COIN_PROG_F77],
[AC_REQUIRE([AC_COIN_ENABLE_MSVC])
AC_REQUIRE([AC_COIN_PROG_CC])
AC_REQUIRE([AC_COIN_F77_COMPS])
AC_LANG_PUSH([Fortran 77])
AC_ARG_VAR(ADD_FFLAGS,[Additional Fortran compiler options])
AC_ARG_VAR(DBG_FFLAGS,[Debug Fortran compiler options])
AC_ARG_VAR(OPT_FFLAGS,[Optimize Fortran compiler options])
coin_has_f77=yes
save_fflags="$FFLAGS"
# We delete the cached value, since the test might not have been
# performed with our choice of compilers earlier
$as_unset ac_cv_prog_F77 || test "${ac_cv_prog_F77+set}" != set || { ac_cv_prog_F77=; export ac_cv_prog_F77; }
# This is a real belt-and-suspenders approach. AC_COIN_FIND_F77 will use
# coin_f77_comps to see if there's a program that matches one of the names.
# If there's no such program, F77 = unavailable. If we match the name,
# feed AC_PROG_F77 the same search list, just to be sure it's a functioning
# compiler.
# AC_MSG_NOTICE([Fortran compiler candidates: $coin_f77_comps])
AC_COIN_FIND_F77
if test "$F77" != "unavailable" ; then
AC_PROG_F77($coin_f77_comps)
else
AC_MSG_WARN([Failed to find a Fortran compiler!])
fi
FFLAGS="$save_fflags"
# Check if a project specific FFLAGS variable has been set
if test x$COIN_PRJCT != x; then
eval coin_tmp=\${${COIN_PRJCT}_FFLAGS+set}
if test x$coin_tmp = xset; then
eval FFLAGS=\${${COIN_PRJCT}_FFLAGS}
fi
fi
if test "$F77" != "unavailable" && test x"$FFLAGS" = x ; then
coin_add_fflags=
coin_opt_fflags=
coin_dbg_fflags=
coin_warn_fflags=
if test "$G77" = "yes"; then
coin_opt_fflags="-O3"
coin_add_fflags="-pipe"
coin_dbg_fflags="-g -O0"