-
Notifications
You must be signed in to change notification settings - Fork 7
/
coin.m4
1658 lines (1410 loc) · 66 KB
/
coin.m4
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) 2020 COIN-OR Foundation
# All Rights Reserved.
# This file is distributed under the Eclipse Public License 2.0.
# See LICENSE for details.
#
# This file defines the common autoconf macros for COIN-OR
# Check requirements
AC_PREREQ([2.71])
###########################################################################
# 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. `VPATH' just means we're
# following best practices and not building in the source directory.
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)
])
###########################################################################
# COIN_VPATH_LINK #
###########################################################################
# This macro ensures that the given files are available in a VPATH
# configuration, using the same name and relative path as in the source
# tree. It expects a white-space separated list of files.
# This macro is a small wrapper around AC_CONFIG_LINKS.
AC_DEFUN([AC_COIN_VPATH_LINK],
[
m4_foreach_w(linkvar,[$1],[AC_CONFIG_LINKS(linkvar:linkvar)])
])
###########################################################################
# COIN_PROJECTVERSION #
###########################################################################
# This macro is used by COIN_INITIALIZE and sets up variables related to
# versioning numbers of the project.
# COIN_PROJECTVERSION([libtool_version_string])
#
# If libtool_version_string is given, then defines AC_COIN_LIBTOOL_VERSIONINFO,
# which will be picked up by AC_COIN_PROG_LIBTOOL to set libtools -version-info flag.
#
# Further, breaks up AC_PACKAGE_VERSION into AC_PACKAGE_VERSION_MAJOR,
# AC_PACKAGE_VERSION_MINOR, AC_PACKAGE_VERSION_RELEASE, assuming it has
# the form major.minor.release, but use 9999 for missing values.
# AC_PACKAGE_VERSION is defined by AC_INIT
AC_DEFUN([AC_COIN_PROJECTVERSION],
[
m4_define(AC_PACKAGE_VERSION_MAJOR, m4_bregexp(AC_PACKAGE_VERSION, [^\([0-9]*\).*], [\1]))
m4_define(AC_PACKAGE_VERSION_MINOR, m4_bregexp(AC_PACKAGE_VERSION, [^[0-9]*\.\([0-9]*\).*], [\1]))
m4_define(AC_PACKAGE_VERSION_RELEASE, m4_bregexp(AC_PACKAGE_VERSION, [^[0-9]*\.[0-9]*\.\([0-9]*\).*], [\1]))
AC_DEFINE_UNQUOTED(m4_toupper(AC_PACKAGE_NAME)_VERSION,
"AC_PACKAGE_VERSION",
[Version number of project])
AC_DEFINE_UNQUOTED(m4_toupper(AC_PACKAGE_NAME)_VERSION_MAJOR,
m4_ifnblank(AC_PACKAGE_VERSION_MAJOR,AC_PACKAGE_VERSION_MAJOR,9999),
[Major version number of project.])
AC_DEFINE_UNQUOTED(m4_toupper(AC_PACKAGE_NAME)_VERSION_MINOR,
m4_ifnblank(AC_PACKAGE_VERSION_MINOR,AC_PACKAGE_VERSION_MINOR,9999),
[Minor version number of project.])
AC_DEFINE_UNQUOTED(m4_toupper(AC_PACKAGE_NAME)_VERSION_RELEASE,
m4_ifnblank(AC_PACKAGE_VERSION_RELEASE,AC_PACKAGE_VERSION_RELEASE,9999),
[Release version number of project.])
m4_define(AC_COIN_LIBTOOL_VERSIONINFO,$1)
])
###########################################################################
# COIN_ENABLE_MSVC #
###########################################################################
# This macro is invoked by any PROG_compiler macro to establish the
# --enable-msvc option.
# If unset but we have a Windows environment, look for some known C compilers
# and set enable_msvc if (i)cl is picked up (or has been set via CC by user)
AC_DEFUN([AC_COIN_ENABLE_MSVC],
[
AC_CANONICAL_BUILD
AC_ARG_ENABLE([msvc],
[AS_HELP_STRING([--enable-msvc],[look for and allow only Intel/Microsoft compilers on MinGW/MSys/Cygwin])],
[enable_msvc=$enableval],
[enable_msvc=no
case $build in
*-mingw* | *-cygwin* | *-msys* )
AC_CHECK_PROGS(CC, [gcc clang icl cl])
case "$CC" in *cl ) enable_msvc=yes ;; esac
;;
esac])
])
###########################################################################
# COIN_COMPFLAGS_DEFAULTS #
###########################################################################
# Overwrite default compiler flags, since the autoconf defaults don't work
# well for cl/icl and we want to take --enable-debug and --enable-msvc into
# account:
# - debugging enabled: enable debug symbols (-g/-Z7)
# - debugging disabled: disable debug code (-DNDEBUG); enable (more) optimization (-O2)
# - enable exceptions for (i)cl
# - enable bugfix to get correct value for __cplusplus for (i)cl
AC_DEFUN([AC_COIN_COMPFLAGS_DEFAULTS],
[
dnl We want --enable-msvc setup and checked
AC_REQUIRE([AC_COIN_ENABLE_MSVC])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],[build debugging symbols and turn off compiler optimization])],
[enable_debug=$enableval],
[enable_debug=no])
dnl This macro should run before the compiler checks (does not seem to be sufficient for CFLAGS)
AC_BEFORE([$0],[AC_PROG_CXX])
AC_BEFORE([$0],[AC_PROG_CC])
AC_BEFORE([$0],[AC_PROG_F77])
AC_BEFORE([$0],[AC_PROG_FC])
if test "$enable_debug" = yes ; then
if test "$enable_msvc" = yes ; then
: ${FFLAGS:="-nologo -fpp -Z7 -MDd $ADD_FFLAGS"}
: ${FCFLAGS:="-nologo -fpp -Z7 -MDd $ADD_FCFLAGS"}
: ${CFLAGS:="-nologo -Z7 -MDd $ADD_CFLAGS"}
: ${CXXFLAGS:="-nologo -EHs -Z7 -MDd -Zc:__cplusplus $ADD_CXXFLAGS"}
else
: ${FFLAGS:="-g $ADD_FFLAGS"}
: ${FCFLAGS:="-g $ADD_FCFLAGS"}
: ${CFLAGS:="-g $ADD_CFLAGS"}
: ${CXXFLAGS:="-g $ADD_CXXFLAGS"}
fi
else
if test "$enable_msvc" = yes ; then
: ${FFLAGS:="-nologo -fpp -O2 -MD $ADD_FFLAGS"}
: ${FCFLAGS:="-nologo -fpp -O2 -MD $ADD_FCFLAGS"}
: ${CFLAGS:="-nologo -DNDEBUG -O2 -MD $ADD_CFLAGS"}
: ${CXXFLAGS:="-nologo -EHs -DNDEBUG -O2 -MD -Zc:__cplusplus $ADD_CXXFLAGS"}
else
: ${FFLAGS:="-O2 $ADD_FFLAGS"}
: ${FCFLAGS:="-O2 $ADD_FCFLAGS"}
: ${CFLAGS:="-O2 -DNDEBUG $ADD_CFLAGS"}
: ${CXXFLAGS:="-O2 -DNDEBUG $ADD_CXXFLAGS"}
fi
fi
])
###########################################################################
# COIN_DEBUGLEVEL #
###########################################################################
# This macro 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).
AC_DEFUN([AC_COIN_DEBUGLEVEL],
[
AC_ARG_WITH(m4_tolower(AC_PACKAGE_NAME)-verbosity,
AS_HELP_STRING([--with-m4_tolower(AC_PACKAGE_NAME)-verbosity],[specify the debug verbosity level]),
[if test "$withval" = yes; then withval=1 ; fi
coin_verbosity=$withval],
[coin_verbosity=0])
AC_DEFINE_UNQUOTED(m4_toupper(AC_PACKAGE_NAME)_VERBOSITY,
$coin_verbosity,
[Define to the debug verbosity level (0 is no output)])
AC_ARG_WITH(m4_tolower(AC_PACKAGE_NAME)-checklevel,
AS_HELP_STRING([--with-m4_tolower(AC_PACKAGE_NAME)-checklevel],[specify the sanity check level]),
[if test "$withval" = yes; then withval=1 ; fi
coin_checklevel=$withval],
[coin_checklevel=0])
AC_DEFINE_UNQUOTED(m4_toupper(AC_PACKAGE_NAME)_CHECKLEVEL,
$coin_checklevel,
[Define to the debug sanity check level (0 is no test)])
])
###########################################################################
# COIN_INITIALIZE #
###########################################################################
# AC_COIN_INITIALIZE(version)
# This macro does everything that is required in the early part of the
# configure script, such as defining a few variables.
# version (optional): the libtool library version
# project version number is used if not available
# - enforces the required autoconf version
# - sets the project's version numbers
# - changes the default compiler flags
# - get and patch the build and host types
# - Make silent build rules the default (https://www.gnu.org/software/automake/
# manual/html_node/Automake-Silent-Rules.html)
# - disable automake maintainer mode
# - Initialize automake
# - do not be as strict as for GNU projects
# - don't AC_DEFINE PACKAGE or VERSION (but there're still defined as shell
# variables in configure, and as make variables).
# - disable dist target
# - place objects from sources in subdirs into corresponding subdirs
# - enable all automake warnings
# - Figure out the path where libraries are installed.
# - Add a configure flag to indicate whether .pc files should be made relocatable.
# This is off by default, as it creates libtool warnings and doesn't account for
# cases where --libdir is used.
AC_DEFUN([AC_COIN_INITIALIZE],
[
AC_PREREQ([2.71])
AC_COIN_PROJECTVERSION($1)
AC_REQUIRE([AC_COIN_COMPFLAGS_DEFAULTS])
dnl this needs to used before AC_CANONICAL_BUILD
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
# libtool has some magic for host_os and build_os being mingw, but doesn't know about msys
if test $host_os = msys ; then
host_os=mingw
host=`echo $host | sed -e 's/msys/mingw/'`
fi
if test $build_os = msys ; then
build_os=mingw
build=`echo $build | sed -e 's/msys/mingw/'`
fi
dnl this needs to be used before AM_INIT_AUTOMAKE
AM_SILENT_RULES([yes])
dnl without this, automake adds targets that may try to rerun the autotools
dnl on the users side, which asks for trouble
AM_MAINTAINER_MODE([disable])
AM_INIT_AUTOMAKE([foreign no-define no-dist subdir-objects -Wall])
# Figure out the path where libraries are installed.
# Unless the user specifies --prefix, prefix is set to NONE until the
# end of configuration, at which point it will be set to $ac_default_prefix.
# Unless the user specifies --exec-prefix, exec-prefix is set to NONE until
# the end of configuration, at which point it's set to '${prefix}'.
# Sheesh. So do the expansion, then back it out.
save_prefix=$prefix
save_exec_prefix=$exec_prefix
if test "x$prefix" = xNONE ; then
prefix=$ac_default_prefix
fi
if test "x$exec_prefix" = xNONE ; then
exec_prefix=$prefix
fi
expanded_libdir=$libdir
while expr "$expanded_libdir" : '.*$.*' >/dev/null 2>&1 ; do
eval expanded_libdir=$expanded_libdir
done
prefix=$save_prefix
exec_prefix=$save_exec_prefix
AC_ARG_ENABLE([relocatable],
[AS_HELP_STRING([--enable-relocatable],[whether prefix in installed .pc files should be setup relative to pcfiledir])],
[coin_enable_relocatable=$enableval],
[coin_enable_relocatable=no])
AM_CONDITIONAL([COIN_RELOCATABLE], [test $coin_enable_relocatable = yes])
])
###########################################################################
# COIN_PROG_LIBTOOL #
###########################################################################
# Set up libtool parameters and create and patchup libtool
# (https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html)
# Pass no-win32-dll to omit passing win32-dll to LT_INIT.
# Checks whether ar-lib wrapper needs to be used.
#
# Set up LT_LDFLAGS variable, which user can initialize and configure augments:
# - Add version info flag using the libtool library info, if defined,
# otherwise use the project version if a full major.minor.release number is available.
# - Add -no-undefined as shared libraries should have no undefined symbols.
# For Windows DLLs, it is mandatory to add this.
#
# Defines automake conditional COIN_STATIC_BUILD on whether we build
# shared or static. Used in .pc files.
#
# Patch libtool to circumvent some issues when using MSVC and MS lib.
# This needs to be run after config.status has created libtool.
# 1. Relax check which libraries can be used when linking a DLL.
# libtool's func_mode_link() would reject linking a .lib file when building a DLL,
# even though this .lib file may just be the one that eventually loads a depending DLL,
# e.g., mkl_core_dll.lib. Setting deplibs_check_method=pass_all will still print a
# warning, but the .lib is still passed to the linker.
# 2. Ensure always_export_symbols=no if win32-dll. Even when we pass win32-dll,
# libtool forces always_export_symbols=yes for --tag=CXX if using MS compiler.
# This leads to a nm call that collects ALL C-functions from a library
# and explicitly dll-exporting them, leading to warnings about duplicates
# regarding those that are properly marked for dll-export in the source.
# 3. Do not add mkl_*.lib to old_deplibs, which can result in trying to unpack and repack
# the MKL libraries (which are pretty big). Instead, treat them like other -l<...> libs.
# 4. Add MKL libraries to dependency_libs in .la file, which I guess should be
# the case due to point 5.
#
# Patch libtool also to circumvent some issues when using MinGW (Msys+GCC).
# 1. Relax check which libraries can be used when linking a DLL.
# libtool's func_mode_link() would reject linking MinGW system libraries,
# e.g., -lmingw32, when building a DLL, because it does not find this
# library in the installation path, and then falls back to build only
# static libraries. Setting deplibs_check_method=pass_all will avoid
# this faulty check.
AC_DEFUN([AC_COIN_PROG_LIBTOOL],
[
dnl checkout AR and decide whether to use ar-lib wrapper
AM_PROG_AR
dnl create libtool
LT_INIT(disable-static pic-only m4_bmatch($1,no-win32-dll,,win32-dll))
case "$am_cv_ar_interface" in
lib )
AC_CONFIG_COMMANDS([libtoolclpatch],
[sed -e '/^deplibs_check_method/s/.*/deplibs_check_method="pass_all"/g' \
m4_bmatch($1,no-win32-dll,,[-e 's|always_export_symbols=yes|always_export_symbols=no|g']) \
-e '/func_append old_deplibs/s/\(.*\)/case $arg in *mkl_*.lib) ;; *) \1 ;; esac/g' \
-e '/static library .deplib is not portable/a case $deplib in *mkl_*.lib) newdependency_libs="$deplib $newdependency_libs" ;; esac' \
libtool > libtool.tmp
mv libtool.tmp libtool
chmod 755 libtool])
;;
* )
case $build in
*-mingw* )
AC_CONFIG_COMMANDS([libtoolmingwpatch],
[sed -e '/^deplibs_check_method/s/.*/deplibs_check_method="pass_all"/g' libtool > libtool.tmp
mv libtool.tmp libtool
chmod 755 libtool])
;;
esac
;;
esac
AC_ARG_VAR(LT_LDFLAGS,[Flags passed to libtool when building libraries or executables that are installed])
m4_ifnblank(AC_COIN_LIBTOOL_VERSIONINFO,
LT_LDFLAGS="$LT_LDFLAGS -version-info AC_COIN_LIBTOOL_VERSIONINFO"
AC_MSG_NOTICE(libtool version info: -version-info AC_COIN_LIBTOOL_VERSIONINFO),
m4_ifnblank(AC_PACKAGE_VERSION_MAJOR,
m4_ifnblank(AC_PACKAGE_VERSION_MINOR,
m4_ifnblank(AC_PACKAGE_VERSION_RELEASE,
LT_LDFLAGS="$LT_LDFLAGS -version-number AC_PACKAGE_VERSION_MAJOR:AC_PACKAGE_VERSION_MINOR:AC_PACKAGE_VERSION_RELEASE"
AC_MSG_NOTICE(libtool version info: -version-number AC_PACKAGE_VERSION_MAJOR:AC_PACKAGE_VERSION_MINOR:AC_PACKAGE_VERSION_RELEASE)
))))
LT_LDFLAGS="$LT_LDFLAGS -no-undefined"
AM_CONDITIONAL([COIN_STATIC_BUILD],[test "$enable_shared" = no])
])
###########################################################################
# COIN_PROG_CC COIN_PROG_CXX #
###########################################################################
# Macros to find C and C++ compilers according to specified lists of compiler
# names. For Fortran compilers, see coin_fortran.m4.
#
# If enable-msvc, then test for Intel (on Windows) and MS C/C++ compiler
# explicitly and add the compile wrapper before AC_PROG_CC/CXX. The compile
# wrapper works around issues related to finding MS link.exe. (Unix link.exe
# occurs first in PATH, which causes compile and link checks to fail.) For
# the same reason, set LD to use the compile wrapper. If CC/CXX remains unset
# (neither icl or cl was found, and CC was not set by the user), stop with
# an error.
#
# Declares ADD_C(XX)FLAGS variables for additional compiler flags.
#
# Note that automake redefines AC_PROG_CC to invoke _AM_PROG_CC_C_O (an
# equivalent to AC_PROG_CC_C_O, plus wrap CC in the compile script if needed)
# and _AM_DEPENDENCIES (`dependency style'). Look in aclocal.m4 to see this.
AC_DEFUN_ONCE([AC_COIN_PROG_CC],
[
AC_REQUIRE([AC_COIN_ENABLE_MSVC])
dnl Setting up libtool with LT_INIT will AC_REQUIRE AC_PROG_CC, but we want
dnl to invoke it from this macro first so that we can supply a parameter.
AC_BEFORE([$0],[LT_INIT])
if test $enable_msvc = yes ; then
AC_CHECK_PROGS(CC, [icl cl])
if test -n "$CC" ; then
CC="$am_aux_dir/compile $CC"
ac_cv_prog_CC="$CC"
LD="$CC"
: ${AR:=lib}
else
AC_MSG_ERROR([Neither MS nor Intel C compiler found in PATH and CC is unset.])
fi
fi
dnl Look for some C compiler and check that it works. If the user has set CC
dnl or we found icl/cl above, this should not overwrite CC. Unlike the macros
dnl that establish C++ or Fortran compilers, PROG_CC also takes care of adding
dnl the compile wrapper if needed.
AC_PROG_CC([gcc clang cc icc icl cl cc xlc xlc_r pgcc])
AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options (if not overwriting CFLAGS)])
])
# Note that automake redefines AC_PROG_CXX to invoke _AM_DEPENDENCIES
# (`dependency style') but does not add an equivalent for AC_PROG_CXX_C_O,
# hence we need an explicit call.
AC_DEFUN_ONCE([AC_COIN_PROG_CXX],
[
AC_REQUIRE([AC_COIN_ENABLE_MSVC])
AC_REQUIRE([AC_COIN_PROG_CC])
if test $enable_msvc = yes ; then
AC_CHECK_PROGS(CXX, [icl cl])
if test -n "$CXX" ; then
CXX="$am_aux_dir/compile $CXX"
ac_cv_prog_CXX="$CXX"
LD="$CXX"
: ${AR:=lib}
else
AC_MSG_ERROR([Neither MS nor Intel C++ compiler found in PATH and CXX is unset.])
fi
fi
dnl Look for some C++ compiler and check that it works. If the user has set
dnl CXX or we found icl/cl above, this should not overwrite CXX.
AC_PROG_CXX([g++ clang++ c++ pgCC icpc gpp cxx cc++ icl cl FCC KCC RCC xlC_r aCC CC])
dnl If the compiler does not support -c -o, wrap it with the compile script.
AC_PROG_CXX_C_O
if test $ac_cv_prog_cxx_c_o = no ; then
CXX="$am_aux_dir/compile $CXX"
fi
AC_ARG_VAR(ADD_CXXFLAGS,[Additional C++ compiler options (if not overwriting CXXFLAGS)])
])
###########################################################################
# 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_COIN_PROG_CXX])dnl
AC_LANG_PUSH(C++)
AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with non-C++ 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"]) dnl The -lm works around an issue with libtool removing -lm from the dependency_libs in an .la file (look for postdeps= in libtool)
;;
esac
else
case $build in
*-mingw* | *-cygwin* | *-msys* )
if test "$enable_msvc" = yes ; then
CXXLIBS=nothing
fi;;
*-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_RPATH_FLAGS #
###########################################################################
# This macro, in case shared objects are used, defines a variable
# RPATH_FLAGS that can be used by the linker to hardwire the library
# search path for the given directories. This is useful for example
# Makefiles
AC_DEFUN([AC_COIN_RPATH_FLAGS],
[RPATH_FLAGS=
if test $enable_shared = yes; then
case $build in
*-linux-*)
if test "$GCC" = "yes"; then
RPATH_FLAGS=
for dir in $1; do
RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
done
fi ;;
*-darwin*)
RPATH_FLAGS=nothing ;;
*-ibm-*)
case "$CC" in
xlc* | */xlc* | mpxlc* | */mpxlc*)
RPATH_FLAGS=nothing ;;
esac ;;
*-hp-*)
RPATH_FLAGS=nothing ;;
*-mingw* | *-msys* )
RPATH_FLAGS=nothing ;;
*-*-solaris*)
RPATH_FLAGS=
for dir in $1; do
RPATH_FLAGS="$RPATH_FLAGS -R$dir"
done
esac
if test "$RPATH_FLAGS" = ""; then
AC_MSG_WARN([Could not automatically determine how to tell the linker about automatic inclusion of the path for shared libraries. The test examples might not work if you link against shared objects. You will need to set the LD_LIBRARY_PATH, DYLP_LIBRARY_PATH, or LIBDIR variable manually.])
fi
if test "$RPATH_FLAGS" = "nothing"; then
RPATH_FLAGS=
fi
fi
AC_SUBST(RPATH_FLAGS)
]) # AC_COIN_RPATH_FLAGS
###########################################################################
# COIN_DEFINENAMEMANGLING #
###########################################################################
# COIN_DEFINENAMEMANGLING (name,namemangling)
# -------------------------------------------------------------------------
# Determine C/C++ name mangling to allow linking with header-less libraries.
# name ($1) an identifier to prefix C macro names
# namemangling ($2) the name mangling scheme as determined by COIN_NAMEMANGLING
# or COIN_TRY_LINK
#
# Defines the C macros $1_FUNC and $1_FUNC_ (in uppercase) to be used for
# declaring functions from library $1.
# -------------------------------------------------------------------------
AC_DEFUN([AC_COIN_DEFINENAMEMANGLING],
[
AH_TEMPLATE($1_FUNC, [Define to a macro mangling the given C identifier (in lower and upper case).])
AH_TEMPLATE($1_FUNC_, [As $1_FUNC, but for C identifiers containing underscores.])
case "$2" in
"lower case, no underscore, no extra underscore")
AC_DEFINE($1_FUNC[(name,NAME)], [name])
AC_DEFINE($1_FUNC_[(name,NAME)], [name]) ;;
"lower case, no underscore, extra underscore")
AC_DEFINE($1_FUNC[(name,NAME)], [name])
AC_DEFINE($1_FUNC_[(name,NAME)], [name [##] _]) ;;
"lower case, underscore, no extra underscore")
AC_DEFINE($1_FUNC[(name,NAME)], [name [##] _])
AC_DEFINE($1_FUNC_[(name,NAME)], [name [##] _]) ;;
"lower case, underscore, extra underscore")
AC_DEFINE($1_FUNC[(name,NAME)], [name [##] _])
AC_DEFINE($1_FUNC_[(name,NAME)], [name [##] __]) ;;
"upper case, no underscore, no extra underscore")
AC_DEFINE($1_FUNC[(name,NAME)], [NAME])
AC_DEFINE($1_FUNC_[(name,NAME)], [NAME]) ;;
"upper case, no underscore, extra underscore")
AC_DEFINE($1_FUNC[(name,NAME)], [NAME])
AC_DEFINE($1_FUNC_[(name,NAME)], [NAME [##] _]) ;;
"upper case, underscore, no extra underscore")
AC_DEFINE($1_FUNC[(name,NAME)], [NAME [##] _])
AC_DEFINE($1_FUNC_[(name,NAME)], [NAME [##] _]) ;;
"upper case, underscore, extra underscore")
AC_DEFINE($1_FUNC[(name,NAME)], [NAME [##] _])
AC_DEFINE($1_FUNC_[(name,NAME)], [NAME [##] __]) ;;
*)
AC_MSG_WARN([Unsupported or unknown name-mangling scheme: $2])
;;
esac
])
###########################################################################
# COIN_TRY_LINK #
###########################################################################
# This is a helper macro for checking if a library can be linked based on
# a function name only.
# COIN_TRY_LINK(func,lflags,pcfiles,action-if-success,action-if-failed,msg)
# func ($1) the name of the function to try to link
# lflags ($2) linker flags to use
# pcfiles ($3) pc files to query for additional linker flags
# action-if-success ($4) commands to execute if any linking was successful
# action-if-failed ($5) commands to execute if no linking was successful
# msg ($6) 'no' to suppress 'checking for' messages
#
# The macro tries different name mangling schemes and expands into
# action-if-success for the first one that succeeds.
# It sets variable func_namemangling according to the found name mangling
# scheme, which can be used as input for COIN_DEFINENAMEMANGLING.
AC_DEFUN([AC_COIN_TRY_LINK],
[
dnl setup LIBS by adding $2 and those from $3
ac_save_LIBS="$LIBS"
m4_ifnblank([$2], [LIBS="$2 $LIBS"])
m4_ifnblank([$3],
[ AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
if test -n "$3" ; then
temp_LFLAGS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --libs $pkg_static $3`
LIBS="$temp_LFLAGS $LIBS"
fi
])
$1_namemangling=unknown
for ac_extra in "no extra underscore" "extra underscore" ; do
for ac_case in "lower case" "upper case" ; do
for ac_trail in "underscore" "no underscore" ; do
case $ac_case in
"lower case")
ac_name=m4_tolower($1)
;;
"upper case")
ac_name=m4_toupper($1)
;;
esac
if test "$ac_trail" = "underscore" ; then
ac_name=${ac_name}_
fi
if test "$ac_extra" = "extra underscore" ; then
ac_name=${ac_name}_
fi
m4_if([$6],[no],[],[AC_MSG_CHECKING([for function $ac_name in $LIBS])])
AC_TRY_LINK_FUNC([$ac_name],
[$1_namemangling="${ac_case}, ${ac_trail}, ${ac_extra}"
ac_success=yes],
[ac_success=no])
m4_if([$6],[no],[],[AC_MSG_RESULT([$ac_success])])
if test $ac_success = yes ; then
break 3
fi
done
done
done
LIBS=$ac_save_LIBS
if test $ac_success = yes ; then
m4_ifblank([$4],[:],[$4])
m4_ifnblank([$5],[else $5])
fi
])
###########################################################################
# COIN_HAS_PKGCONFIG #
###########################################################################
# Check whether a suitable pkg-config tool is available. pkgconf is the
# up-and-coming thing, replacing pkg-config, so it is preferred. The default
# minimal version number is 0.16.0 because COIN-OR .pc files include a
# URL field which breaks pkg-config version <= 0.15. A more recent minimum
# version can be specified as a parameter. Portions of the macro body are
# derived from macros in pkg.m4.
# If a pkg-config tool is found, then the variable PKGCONFIG is set
# to its path, otherwise it is set to "". Further, the AM_CONDITIONAL
# COIN_HAS_PKGCONFIG is set and PKGCONFIG is AC_SUBST'ed.
# Finally, the search path for .pc files is assembled from the value of
# $prefix and $PKG_CONFIG_PATH in a variable COIN_PKG_CONFIG_PATH, which is
# also AC_SUBST'ed. The search path will include the installation directory
# for .pc files for COIN-OR packages. COIN-OR .pc files are installed
# in ${libdir}/pkgconfig and COIN_INITIALIZE takes care of setting up
# $expanded_libdir based on $libdir.
# Of course, this whole house of cards balances on the shaky assumption that
# the user is sane and has installed all packages in the same place and does
# not change that place when make executes. If not, well, it's their
# responsibility to augment PKG_CONFIG_PATH in the environment.
AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
[
AC_ARG_VAR([PKG_CONFIG],[path to pkg-config utility])
dnl This is a modified version of PKG_PROG_PKG_CONFIG from pkg.m4.
if test -z "$PKG_CONFIG" ; then
AC_CHECK_TOOLS([PKG_CONFIG],[pkgconf pkg-config])
fi
if test -n "$PKG_CONFIG" ; then
pkg_min_version=m4_default([$1],[0.16.0])
AC_MSG_CHECKING([$PKG_CONFIG is at least version $pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $pkg_min_version ; then
pkg_version=`$PKG_CONFIG --version`
AC_MSG_RESULT([yes: $pkg_version])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi
dnl Check if PKG_CONFIG supports the short-errors flag.
dnl This is a modified version of _PKG_SHORT_ERRORS_SUPPORTED from pkg.m4.
if test -n "$PKG_CONFIG" &&
$PKG_CONFIG --atleast-pkgconfig-version 0.20 ; then
pkg_short_errors=" --short-errors "
else
pkg_short_errors=""
fi
dnl Check whether -static option of pkg-config should be used when requesting
dnl libs
pkg_static=
if test -n "$PKG_CONFIG" ; then
case "$LDFLAGS" in "-static" | "* -static*" ) pkg_static=--static ;; esac
fi
dnl Create a automake conditional and PKG_CONFIG variable
AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
AC_SUBST(PKG_CONFIG)
COIN_PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"
AC_SUBST(COIN_PKG_CONFIG_PATH)
COIN_PKG_CONFIG_PATH="${expanded_libdir}/pkgconfig:${COIN_PKG_CONFIG_PATH}"
if test -n "$PKG_CONFIG"; then
AC_MSG_NOTICE([$PKG_CONFIG path is "$COIN_PKG_CONFIG_PATH"])
fi
]) # COIN_HAS_PKGCONFIG
###########################################################################
# COIN_CHK_MOD_EXISTS #
###########################################################################
# COIN_CHK_MOD_EXISTS(MODULE, PACKAGES,
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# Check to see whether a particular module (set of packages) exists. Derived
# from PKG_CHECK_MODULES() from pkg.m4, but set only the variables $1_VERSIONS
# and $1_PKG_ERRORS. PACKAGES ($2) is a space-separated list of .pc file names
# (without the .pc suffix). Note that variable values will have one line per
# package (embedded newlines) if more than one package is given in PACKAGES.
AC_DEFUN([AC_COIN_CHK_MOD_EXISTS],
[
AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
if test -n "$PKG_CONFIG" ; then
if PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --exists "$2" ; then
m4_toupper($1)_VERSIONS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`
$3
else
m4_toupper($1)_PKG_ERRORS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
$4
fi
else
AC_MSG_ERROR("Cannot check for existence of module $1 without pkgconf")
fi
])
###########################################################################
# COIN_CHK_HERE #
###########################################################################
# COIN_CHK_HERE([prim],[client packages],[pcfile])
# Augment the _LFLAGS, _CFLAGS, and _PCFILES variables of the client
# packages with the values from PRIM_LFLAGS_PUB, PRIM_CFLAGS_PUB, and
# PRIM_PCFILES_PUB. This macro is intended for the case where a single project
# builds several objects and one object includes another. For example,
# the various OsiXxxLib solvers, which depend on OsiLib. We can't consult
# osi.pc (it's not installed yet) but the relevant variables are ready at
# hand. The name of prim is often different from the name of the .pc file
# ($3), hence the separate parameter. If $3 is not given, it defaults to
# tolower($1).
# This macro should be called after FINALIZE_FLAGS is invoked for the
# client packages, for two reasons: First, COIN-OR packages tend to use
# .pc files, so we're probably adding a package to _PCFILES that isn't yet
# installed. Also, FINALIZE_FLAGS will have accessed the .pc files already
# in _PCFILES and expanded them into _LIBS and _CFLAGS, saving the original
# _LIBS and _CFLAGS in _LIBS_NOPC and _CFLAGS_NOPC.
AC_DEFUN([AC_COIN_CHK_HERE],
[
dnl Make sure the necessary variables exist for each client package.
m4_foreach_w([myvar],[$2],
[AC_SUBST(m4_toupper(myvar)_LFLAGS)
AC_SUBST(m4_toupper(myvar)_CFLAGS)
AC_SUBST(m4_toupper(myvar)_PCFILES)
])
dnl Add the .pc file and augment LFLAGS and CFLAGS.
dnl From the CFLAGS of $1, remove the -D$1_BUILD, though.
m4_foreach_w([myvar],[$2],
[m4_toupper(myvar)_PCFILES="$m4_toupper(myvar)_PCFILES m4_default($3,m4_tolower($1))"
m4_toupper(myvar)_LFLAGS="$m4_toupper(myvar)_LFLAGS $m4_toupper($1)_LFLAGS"
m4_toupper(myvar)_CFLAGS="$m4_toupper(myvar)_CFLAGS `echo $m4_toupper($1)_CFLAGS | sed -e s/-D[]m4_toupper($1)_BUILD//`"
# Define BUILDTOOLS_DEBUG to enable debugging output
if test "$BUILDTOOLS_DEBUG" = 1 ; then
AC_MSG_NOTICE([CHK_HERE adding $1 to myvar:])
AC_MSG_NOTICE([m4_toupper(myvar)_PCFILES: "${m4_toupper(myvar)_PCFILES}"])
AC_MSG_NOTICE([m4_toupper(myvar)_LFLAGS: "${m4_toupper(myvar)_LFLAGS}"])
AC_MSG_NOTICE([m4_toupper(myvar)_CFLAGS: "${m4_toupper(myvar)_CFLAGS}"])
fi
])
]) # COIN_CHK_HERE
###########################################################################
# COIN_DEF_PRIM_ARGS #
###########################################################################
# COIN_DEF_PRIM_ARGS([prim],[base],[lflags],[cflags],[dflags],[build])
# This is a utility macro to handle the standard arguments that COIN-OR
# configuration files supply for a component (package or library):
# --with-prim: use primitive (yes / no / special)
# --with-prim-lflags: linker flags for the primitive
# --with-prim-cflags: preprocessor & compiler flags for the primitive
# --with-prim-data: data directory for the primitive
# These arguments allow the user to override default macro behaviour from the
# configure command line.
# The string prim, lower-cased, is used in the flag name.
# The parameters base, lflags, cflags, and dflags have the value yes or no and
# determine whether a --with option will be defined for prim, lflags, cflags,
# and data, respectively. They must be literals, as the macro uses them to cut
# out unused options. To use the results, construct the name of the shell
# variable as specified in the autoconf doc'n for ARG_WITH.
# Setting the final parameter to 'default_build' will cause the phrase
# "'build' will look for a COIN ThirdParty package" to be inserted in the
# documentation for --with-prim.
AC_DEFUN([AC_COIN_DEF_PRIM_ARGS],
[
m4_define([extraHelp],[
m4_normalize(Do not use $1. [If an argument is given to --with-m4_tolower($1), then]
['yes' is equivalent to --with-m4_tolower($1),]
m4_case($6,[default_build],
['no' is equivalent to --without-m4_tolower($1)[,]
'build' will look for a COIN-OR ThirdParty package.],
['no' is equivalent to --without-m4_tolower($1)])
m4_case($3$4$5,nonono,,
nonoyes,
and any other argument is applied as for --with-m4_tolower($1)-data,
noyesno,
and any other argument is applied as for --with-m4_tolower($1)-cflags,
noyesyes,
and any other argument is applied as for --with-m4_tolower($1)-cflags,
and any other argument is applied as for --with-m4_tolower($1)-lflags)[.])])
m4_if($2,yes,
[AC_ARG_WITH([m4_tolower($1)],
AS_HELP_STRING([--without-m4_tolower($1)],extraHelp))])
m4_if($3,yes,
[AC_ARG_WITH([m4_tolower($1)-lflags],
AS_HELP_STRING([--with-m4_tolower($1)-lflags],
[Linker flags for $1 appropriate for your environment.
(Most often, -l specs for libraries.)]))])
m4_if($4,yes,
[AC_ARG_WITH([m4_tolower($1)-cflags],
AS_HELP_STRING([--with-m4_tolower($1)-cflags],
[Compiler flags for $1 appropriate for your environment.
(Most often, -I specs for header file directories.)]))])
m4_if($5,yes,
[AC_ARG_WITH([m4_tolower($1)-data],
AS_HELP_STRING([--with-m4_tolower($1)-data],
[A data directory specification for $1 appropriate for your
environment.]))])
]) # COIN_DEF_PRIM_ARGS
###########################################################################
# FIND_PRIM_LIB (obsolete) #
###########################################################################
# COIN_FIND_PRIM_LIB([prim],[lflgs],[cflgs],[dflgs],
# [func],[other libraries],
# [dfltaction],[cmdlineopts])
# Determine whether we can use primary library prim ($1) and assemble
# information on the required linker flags (prim_lflags), compiler flags
# (prim_cflags), and data directories (prim_data) as specified by cmdlineopts.
# Run a link check if the user provides [func]. Linker flags for the link are
# the concatenation of [lflgs] and [other libraries].
# cmdlineopts ($8) specifies the set of configure command line options
# defined and processed: 'nodata' produces --with-prim, --with-prim-lflags,
# and --with-prim-cflags; 'dataonly' produces only --with-prim and
# --with-prim-data; anything else ('all' works well) produces all four
# command line options. Shell code produced by the macro is tailored based
# on cmdlineopts. `nodata' is the default.
# --with-prim is interpreted as follows:
# * --with-prim=no is equivalent to --without-prim.
# * --with-prim or --with-prim=yes is equivalent to
# --with-prim-lflags=-lprim
# --with-prim-data=/usr/local/share
# * --with-prim=build attempts to invent something that will find a COIN
# ThirdParty library or data
# --with-prim-lflags="-L\$(libdir) -lcoinprim"
# --with-prim-cflgs="-I\$(pkgincludedir)/ThirdParty"
# --with-prim-data="\$(pkgdatadir)"
# * Any other value is taken as equivalent to
# --with-prim-data=value (dataonly) or
# --with-prim-lflags=value (anything else)
# The algorithm first checks for a user-specified value of --with-prim;
# if this is no, prim is skipped. Next, it looks for user specified values
# given with command line parameters --with-prim-lflags, --with-prim-cflags,
# and --with-prim-data. If none of these are specified, it will use the values
# passed as parameters. It's all or none: any command line options disable all
# parameters.
# Default action ($7) (no, yes, build) is the default value of --with-prim
# if the user offers no guidance via command line parameters. The (hardwired)
# default is yes. `build' doesn't have a hope of working except for COIN
# ThirdParty packages, and even then it's pretty shaky. You should be
# using CHK_PKG, because COIN packaging for ThirdParty software creates a .pc
# file.
# The macro doesn't test that the specified values actually work unless
# [func] is given as a parameter. This is deliberate --- there's no guarantee
# that the specified library can be accessed just yet with the specified
# flags. Except for the link check, all we're doing here is filling in
# variables using a complicated algorithm.
AC_DEFUN([AC_COIN_FIND_PRIM_LIB_OBS],
[
dflt_action=m4_default([$7],[yes])
# Initialize variables for the primary library.
m4_tolower(coin_has_$1)=noInfo
m4_tolower($1_lflags)=
m4_tolower($1_cflags)=
m4_tolower($1_data)=
# --with-prim is always present.
dnl If the client specified dataonly, its value is assigned to prim_data.
withval="$m4_tolower(with_$1)"
if test -n "$withval" ; then
case "$withval" in
no )