Codebase list code-saturne / d8077bbd-68ef-4d18-8ec8-cac1dce8a968/main configure.ac
d8077bbd-68ef-4d18-8ec8-cac1dce8a968/main

Tree @d8077bbd-68ef-4d18-8ec8-cac1dce8a968/main (Download .tar.gz)

configure.ac @d8077bbd-68ef-4d18-8ec8-cac1dce8a968/mainraw · history · blame

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
# Process this file with autoconf to produce a configure script

#-------------------------------------------------------------------------------

# This file is part of Code_Saturne, a general-purpose CFD tool.
#
# Copyright (C) 1998-2020 EDF S.A.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
# Street, Fifth Floor, Boston, MA 02110-1301, USA.

#-------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# Initialization
#------------------------------------------------------------------------------

m4_define([cs_licence_c_comment],
[/*
  This file is part of Code_Saturne, a general-purpose CFD tool.

  Copyright (C) 1998-2020 EDF S.A.

  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.

  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
  Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/])

# Note: proper determination of the version string requires the NEWS file
#       to be maintained properly (as it should be anyways).

m4_define([cs_version_string],
	  [m4_normalize(esyscmd([build-aux/cs_version.py]))])

AC_INIT([code_saturne],[cs_version_string],[saturne-support@edf.fr],[],[https://code-saturne.org])
AC_CONFIG_SRCDIR([src/apps/cs_solver.c])

# Use the config directory for libtool stuff ...
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_MACRO_DIR(m4)

AC_CANONICAL_TARGET
AC_CONFIG_HEADERS([cs_config.h])

# Initialize automake with the following options:
# - foreign, so as to handle the absence of ChangeLog (automatically generated)
# - tar-pax, so as to handle long lines (> 99 characters) in tar archives
# Warnings can be activated at bootstrap with 'autoreconf -vi --warnings=all'
AM_INIT_AUTOMAKE([foreign tar-pax subdir-objects])

# Enable maintainer mode by default for a developer checkout
AS_IF([test -d ${srcdir}/.git],
      [AM_MAINTAINER_MODE([enable])],
      [AM_MAINTAINER_MODE([disable])])

# Enable silent rules with "./configure --enable-silent-rules" or "make V=0"
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])

#------------------------------------------------------------------------------
# Checks for programs.
#------------------------------------------------------------------------------

AC_ARG_WITH(shell-env,
	    [AS_HELP_STRING([--with-shell-env],
			    [source given or detected shell environment])],
	    [if test "x$with_shell_env" = "x"; then
	       shell_env=auto
	     elif test -f "$with_shell_env"; then
	       shell_env="$with_shell_env"
	     fi],
	    [shell_env=no]
)
AC_SUBST(shell_env)

AM_CONDITIONAL(HAVE_SHELL_LAUNCHER, [test "${shell_env}" != no])

# Check for environment modules
#------------------------------

CS_AC_TEST_ENV_MODULES

CS_AC_SALOME_ENV

# Check for C and Fortran compilers
#----------------------------------

user_CPPFLAGS=$CPPFLAGS
user_CFLAGS=$CFLAGS
user_CFLAGS_HOT=$CFLAGS_HOT
user_CXXFLAGS=$CXXFLAGS
user_FCFLAGS=$FCFLAGS
user_FCFLAGS_HOT=$FCFLAGS_HOT
user_LDFLAGS=$LDFLAGS
user_LIBS=$LIBS
user_CS_LD=$CS_LD

AC_PROG_CC
AC_PROG_CXX
AC_PROG_FC

AC_PROG_INSTALL
AC_PROG_LN_S
AM_PROG_CC_C_O
AC_PROG_SED

if test "x$CC" = "x" ; then
  AC_MSG_FAILURE([cannot find C compiler])
fi
if test "x$FC" = "x" ; then
  AC_MSG_FAILURE([cannot find Fortran compiler])
fi

# Needed to use Microsoft archiver lib.exe
# It copies the ar-lib script, similar to the compile script
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

# Debug or production compilation mode (debug by default) ?

AC_ARG_ENABLE(debug,
  [AS_HELP_STRING([--enable-debug], [enable debugging (reduces optimization)])],
  [
    case "${enableval}" in
      yes) debug=yes ;;
      no)  debug=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
    esac
  ],
  [ debug=no ]
)
AC_SUBST(debug)

AC_ARG_ENABLE(profile,
  [AS_HELP_STRING([--enable-profile], [enable profiling])],
  [
    case "${enableval}" in
      yes) profile=yes ;;
      no)  profile=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-profile]) ;;
    esac
  ],
  [ profile=no ]
)
AC_SUBST(profile)

# Optionally deactivate automatic determination of flags on known systems

AC_ARG_ENABLE(auto-flags,
  [AS_HELP_STRING([--disable-auto-flags], [do not define *FLAGS on known systems])],
  [
    case "${enableval}" in
      yes) auto_flags=yes ;;
      no)  auto_flags=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-auto-flags]) ;;
    esac
  ],
  [ auto_flags=yes ]
)

# Optionnaly install the code with relocatable features

AC_ARG_ENABLE(relocatable,
  [AS_HELP_STRING([--enable-relocatable], [enable relocatable installation])],
  [
    case "${enableval}" in
      yes) relocatable=yes ;;
      no)  relocatable=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-relocatable]) ;;
    esac
  ],
  [ relocatable=no ]
)
AC_SUBST(relocatable)
AM_CONDITIONAL(HAVE_RELOCATABLE, [test "${relocatable}" = yes])
if test "${relocatable}" = yes ; then
  AC_DEFINE([HAVE_RELOCATABLE], 1, [Relocatable installation])
fi

# Default compiler options (may be modified
# by defining CFLAGS in the environment)
#------------------------------------------

if test "x$auto_flags" = "xyes" ; then

  # Source associated recommended compiler options

  if test -f "$srcdir/config/cs_auto_flags.sh" ; then
    AC_MSG_NOTICE([sourcing config/cs_auto_flags.sh (test for known compilers)])
    . "$srcdir/config/cs_auto_flags.sh"
  else
    AC_MSG_WARN([config/cs_auto_flags.sh default configuration file not found])
  fi

  # Default flags
  CPPFLAGS="$cppflags_default $user_CPPFLAGS"
  CFLAGS="$cflags_default $user_CFLAGS"
  CXXFLAGS="$cxxflags_default $user_CXXFLAGS"
  CXXFLAGS_STD="$cxxflags_default_std"
  FCFLAGS="$fcflags_default $user_FCFLAGS"
  LDFLAGS="$ldflags_default $user_LDFLAGS"
  LIBS="$libs_default $user_LIBS"
  LDRPATH="$ldflags_rpath"

  if test "x$debug" = xyes; then
    # Debug flags
    CFLAGS_DBG="$cflags_default_dbg"
    CXXFLAGS_DBG="$cxxflags_default_dbg"
    FCFLAGS_DBG="$fcflags_default_dbg"
    # Add debug flags for linker
    LDFLAGS="$LDFLAGS $ldflags_default_dbg"
  else
    # Normal optimization flags
    CFLAGS_OPT="$cflags_default_opt"
    CXXFLAGS_OPT="$cxxflags_default_opt"
    FCFLAGS_OPT="$fcflags_default_opt"
    # Hot optimization flags
    CFLAGS_HOT="$cflags_default_hot $user_CFLAGS_HOT"
    CXXFLAGS_HOT="$cxxflags_default_hot"
    FCFLAGS_HOT="$fcflags_default_hot $user_FCFLAGS_HOT"
    # Add optimization flags for linker
    LDFLAGS="$LDFLAGS $ldflags_default_opt"
    if test "x$profile" = xyes; then
      # Profiling flags
      CFLAGS_DBG="$cflags_default_prf"
      CXXFLAGS_DBG="$cxxflags_default_prf"
      FCFLAGS_DBG="$fcflags_default_prf"
      # Add profiling flags for linker
      LDFLAGS="$LDFLAGS $ldflags_default_prf"
    fi
  fi

  AC_SUBST(CFLAGS_DBG)
  AC_SUBST(CFLAGS_OPT)
  AC_SUBST(CFLAGS_HOT)

  AC_SUBST(CXXFLAGS_DBG)
  AC_SUBST(CXXFLAGS_OPT)
  AC_SUBST(CXXFLAGS_HOT)
  AC_SUBST(CXXFLAGS_STD)

  AC_SUBST(FCFLAGS_DBG)
  AC_SUBST(FCFLAGS_OPT)
  AC_SUBST(FCFLAGS_HOT)

  AC_SUBST(LDRPATH)
  AC_SUBST(cs_cc_version_string, [${cs_ac_cc_version}])
  AC_SUBST(cs_cxx_version_string, [${cs_ac_cxx_version}])
  AC_SUBST(cs_fc_version_string, [${cs_ac_fc_version}])
  AC_SUBST(cs_nvcc_version_string, [${cs_ac_nvcc_version}])

  if test "x$cs_ac_cc_version" != "x" -a "x$cs_ac_cc_version" != "xunknown" ; then
    AC_DEFINE_UNQUOTED([CS_CC_VERSION_STRING], ["$cs_ac_cc_version"], [C compiler version string])
  fi
  if test "x$cs_ac_cxx_version" != "x" -a "x$cs_ac_cxx_version" != "xunknown" ; then
    AC_DEFINE_UNQUOTED([CS_CXX_VERSION_STRING], ["$cs_ac_cxx_version"], [C++ compiler version string])
  fi
  if test "x$cs_ac_fc_version" != "x" -a "x$cs_ac_fc_version" != "xunknown" ; then
    AC_DEFINE_UNQUOTED([CS_FC_VERSION_STRING], ["$cs_ac_fc_version"], [Fortran compiler version string])
  fi
  if test "x$cs_ac_nvcc_version" != "x" ; then
    AC_DEFINE_UNQUOTED([CS_NVCC_VERSION_STRING], ["$cs_ac_nvcc_version"], [CUDA compiler version string])
  fi

fi

# Add some preprocessor flags to include additional system features
#------------------------------------------------------------------

case "$host_os" in
  linux*)
    CPPFLAGS="${CPPFLAGS} -D_POSIX_C_SOURCE=200809L"
    ;;
  darwin*)
    CPPFLAGS="${CPPFLAGS} -D_DARWIN_C_SOURCE"
    ;;
  *)
    ;;
esac

# Preprocessor flags for debugging purposes

if test "x$debug" = "xyes"; then
  CPPFLAGS="${CPPFLAGS} -DDEBUG"
else
  CPPFLAGS="${CPPFLAGS} -DNDEBUG"
fi

# We may only turn on processing for libtool now that the basic compiler
# and linker flags are set (to avoid issues with linkers with different
# modes such as 32 and 64 bit which may be modified by compiler or
# linker flags).

# AC_DISABLE_SHARED may not be used inside a test, as it seems to
# take effect whether the result is true or not (maybe due to a bug),
# so we directly use autoconf's enable_shared variable.

if test "$host_os" = mingw64 ; then
   enable_shared=no
fi
AC_SUBST(enable_shared)

# Initialize libtool.

m4_pushdef([cs_lt_init_args], [disable-static, win32-dll, no-pic])
LT_INIT([disable-static, win32-dll])

# In static mode, multiple definitions must be allowed for the linker.
# On some systems, such as Mac OS X in static mode, limitations
# of the linker require special handling for user user subroutines
# (due to not handling multiple definitions in the case of Mac OS X).
# Detect this here, so as to transfer the name of a specific solution
# (if necessary) to the Python package.

cs_special_user_link=
if test "x$enable_shared" = "xno" ; then
  case "$host_os" in
    linux* | *bsd* | cnk* | mingw64 | cygwin* )
      if test "x$auto_flags" = "xyes" ; then
	LDFLAGS="${LDFLAGS} -Wl,--allow-multiple-definition"
      fi
      ;;
    darwin*)
      cs_special_user_link='ar_x'
      ;;
  esac
else
  case "$host_os" in
    linux* )
      if test "x$auto_flags" = "xyes" ; then
	case "$cs_ac_cc_version" in
	  Cray* )
	    CFLAGS="${CFLAGS} -fPIC"
	    ;;
	  *)
	    LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
	    ;;
	esac
	case "$cs_ac_cxx_version" in
	  Cray* )
	    CXXFLAGS="${CXXFLAGS} -fPIC"
	    ;;
	  *)
	    ;;
	esac
	case "$cs_ac_fc_version" in
	  Cray* )
	    FCFLAGS="${FCFLAGS} -fPIC"
	    ;;
	  *)
	    ;;
	esac
      fi
      ;;
  esac
fi
AC_SUBST(cs_special_user_link)

#------------------------------------------------------------------------------
# Checks for typedefs, structures, and compiler characteristics.
#------------------------------------------------------------------------------

AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_PID_T

AC_HEADER_TIME
AC_HEADER_STDBOOL

AC_CHECK_TYPES([long long, unsigned long long])
AC_CHECK_TYPES([int32_t])
AC_CHECK_TYPES([int64_t])
AC_CHECK_TYPES([uint32_t])
AC_CHECK_TYPES([uint64_t])
AC_CHECK_TYPES([ptrdiff_t])

AC_CHECK_SIZEOF([void *])
AC_CHECK_SIZEOF([short])
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long])
AC_CHECK_SIZEOF([float])
AC_CHECK_SIZEOF([double])

# Use long global numbers ?
AC_ARG_ENABLE(long-gnum,
  [AS_HELP_STRING([--enable-long-gnum],[use long global numbers])],
  [
    case "${enableval}" in
      yes) cs_have_long_gnum=yes ;;
      no)  cs_have_long_gnum=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-long-gnum]) ;;
    esac
  ],
  [ cs_have_long_gnum=yes ]
)

if test "x$cs_have_long_gnum" = "xyes"; then
  AC_DEFINE([HAVE_LONG_GNUM], 1, [Use 64-bit type for cs_gnum_t.])
fi
AC_SUBST(cs_have_long_gnum)

# Use long local numbers ?
AC_ARG_ENABLE(long-lnum,
  [AS_HELP_STRING([--enable-long-lnum],[use long local numbers])],
  [
    case "${enableval}" in
      yes) cs_have_long_lnum=yes ;;
      no)  cs_have_long_lnum=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-long-lnum]) ;;
    esac
  ],
  [ cs_have_long_lnum=no ]
)

if test "x$cs_have_long_lnum" = "xyes"; then
  AC_DEFINE([HAVE_LONG_LNUM], 1, [Use 64-bit type for cs_lnum_t.])
fi
AC_SUBST(cs_have_long_lnum)

# Check for Fortran module generation
CS_AC_TEST_FC_MOD

# First determination of Fortran libraries (before OpenMP test)
AC_FC_LIBRARY_LDFLAGS

#------------------------------------------------------------------------------
# Determine OpenMP support
#------------------------------------------------------------------------------

# It seems that we may not use AC_OPENMP both for C and Fortran, so
# we use our own method here, based on flags already set by default
# or by the user.

# From this point, no runtime tests should be run, so no issues should
# arise due to missing RPATH or LD_LIBRARY_PATH values in case of non-standard
# compiler install paths, such as may happen with gcc's libgomp.

cs_have_openmp=no
cs_have_openmp_f=no

AC_ARG_ENABLE(openmp,
  [AS_HELP_STRING([--disable-openmp], [disable OpenMP support])],
  [
    case "${enableval}" in
      yes) cs_have_openmp=yes ;;
      no)  cs_have_openmp=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-openmp]) ;;
    esac
  ],
  [ cs_have_openmp=yes ]
)

if test "x$cs_have_openmp" = "xyes" ; then

  saved_CFLAGS="$CFLAGS"
  saved_CXXFLAGS="$CFLAGS"
  saved_FCFLAGS="$FCFLAGS"
  saved_LDFLAGS="$LDFLAGS"

  CFLAGS="${CFLAGS} ${cflags_default_omp}"
  CXXFLAGS="${CXXFLAGS} ${cxxflags_default_omp}"
  FCFLAGS="${FCFLAGS} ${fcflags_default_omp}"
  LDFLAGS="${LDFLAGS} ${cflags_default_omp}"

  AC_MSG_CHECKING([for OpenMP (C)])
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <omp.h>]],
		 [[ omp_get_num_threads();]])],
		 [cs_have_openmp=yes],
		 [cs_have_openmp=no])
  AC_MSG_RESULT($cs_have_openmp)
  if test "x$cs_have_openmp" = "xyes" ; then
    AC_MSG_CHECKING([for OpenMP simd])
    # Note that as the m4 language does not allow escaping [ and ],
    # we use quadrigraphs @<:@ and @>:@ instead here.
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <omp.h>]],
		     [[double a@<:@128@:>@;
		      #pragma omp for simd safelen(4)
		      for (int i = 0; i < 128; i++) a@<:@i@:>@ = i;]])],
		     [cs_have_openmp_simd=yes],
		     [cs_have_openmp_simd=no])
    AC_MSG_RESULT($cs_have_openmp_simd)
    AC_LANG_PUSH([Fortran])
    AC_MSG_CHECKING([for OpenMP (Fortran)])
    AC_LINK_IFELSE([AC_LANG_PROGRAM([],
		   [[
      integer n
      n = omp_get_num_threads()
]])],
		   [cs_have_openmp_f=yes],
		   [cs_have_openmp_f=no])
    AC_MSG_RESULT($cs_have_openmp_f)
    AC_LANG_POP([Fortran])
  fi
  if test "x$cs_have_openmp" = "xyes" ; then
    AC_DEFINE([HAVE_OPENMP], 1, [openmp support])
    if test "x$cs_have_openmp_simd" = "xyes" ; then
      AC_DEFINE([HAVE_OPENMP_SIMD], 1, [openmp simd support])
    fi
    if test "x$cs_have_openmp_f" = "xno" ; then
      FCFLAGS="$saved_FCFLAGS"
    fi
  else
    cs_have_openmp=no
    CFLAGS="$saved_CFLAGS"
    CXXFLAGS="$saved_CXXFLAGS"
    FCFLAGS="$saved_FCFLAGS"
    LDFLAGS="$saved_LDFLAGS"
  fi
fi
AC_SUBST(cs_have_openmp)

# Now that compiler options are determined (relative notably to OpenMP),
# update Fortran libraries necessary to link.

if test "x$cs_have_openmp_f" = "xyes" ; then
  AC_FC_LIBRARY_LDFLAGS
fi

#------------------------------------------------------------------------------
# Determine CUDA support
#------------------------------------------------------------------------------

CS_AC_TEST_CUDA

if test "x$auto_flags" = "xyes" ; then
  if test "$cs_have_cuda" = "yes"; then
    $NVCCFLAGS="$NVCCFLAGS $nvccflags_default"
    if test "x$debug" = xyes; then
      $NVCCFLAGS_DBG="$nvccflags_default_dbg"
    else
      $NVCCFLAGS="$NVCCFLAGS $nvccflags_default_opt"
      if test "x$profile" = xyes; then
	$NVCCFLAGS="$NVCCFLAGS $nvccflags_default_prf"
      fi
    fi
    AC_SUBST(NVCCFLAGS_DBG)
    AC_SUBST(NVCCFLAGS_OPT)
    AC_SUBST(NVCCCFLAGS_HOT)
  fi
fi

#------------------------------------------------------------------------------
# Checks for Python support.
#------------------------------------------------------------------------------

AC_ARG_VAR([PYTHON], [the Python interpreter])
AM_PATH_PYTHON(["3.4"])

# On MinGW hosts, Automake/Python mixes Windows-style and GNU-style paths
# It seems better to use the standard way of installing Python modules,
# as it is on Unix systems (whichever is chosen, Python modules will be
# frozen by cx_freeze for Windows packaging).
# So, we choose to override some Python paths.
if test "$host_os" = mingw64 ; then

  AC_MSG_NOTICE([Overriding Python paths on MinGW hosts])

  am_cv_python_pythondir=\${prefix}/lib/python$PYTHON_VERSION/site-packages
  AC_MSG_CHECKING([for $PYTHON script directory])
  pythondir=$am_cv_python_pythondir
  pkgpythondir=\${pythondir}/$PACKAGE
  AC_MSG_RESULT([$pythondir])

  am_cv_python_pyexecdir=\${exec_prefix}/lib/python$PYTHON_VERSION/site-packages
  AC_MSG_CHECKING([for $PYTHON extension module directory])
  pyexecdir=$am_cv_python_pyexecdir
  pkgpyexecdir=\${pyexecdir}/$PACKAGE
  AC_MSG_RESULT([$pyexecdir])
  AC_SUBST(pythonversion, [${PYTHON_VERSION}])
fi

win_prefix=""
if test "$host_os" = mingw64 ; then
  win_prefix=`cygpath --path --windows "${prefix}"`
  AC_SUBST(win_prefix, [${win_prefix}])
fi

#------------------------------------------------------------------------------
# Checks for additional version information.
#------------------------------------------------------------------------------

# Define the different version number where needed
# (detailed version numbers are generated during the build step as a
# precaution, so that when switching revisions not requiring
# rebuild of the configure file / re-configure, the correct
# version number is used).

cs_version_short=`$PYTHON ${srcdir}/build-aux/cs_version.py --short`
AC_SUBST(cs_version_short)

#------------------------------------------------------------------------------
# Optional shared library and plugin support
#------------------------------------------------------------------------------

cs_have_dlloader=no

AC_ARG_ENABLE(dlloader,
  [AS_HELP_STRING([--disable-dlloader], [disable dynamic shared library loading])],
  [
    case "${enableval}" in
      yes) cs_have_dlloader=yes ;;
      no)  cs_have_dlloader=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-dlloader]) ;;
    esac
  ],
  [ cs_have_dlloader=yes ]
)

if test "x$cs_have_dlloader" = "xyes" ; then

  saved_LIBS="$LIBS"
  LIBS="$LIBS -ldl"

  AC_MSG_CHECKING([for dlopen])
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <dlfcn.h>]],
		 [[ dlopen("none.so", RTLD_LAZY);]])],
		 [cs_have_dlloader=dlopen],
		 [cs_have_dlloader=no])
  AC_MSG_RESULT($cs_have_dlloader)
  if test "x$cs_have_dlloader" = "xdlopen" ; then
    AC_DEFINE([HAVE_DLOPEN], 1, [dlopen support])
  else
    LIBS="$saved_LIBS"
    cs_have_dlloader=no
  fi

fi

# Use RTLD_GLOBAL for dlopen ?

# Note setting enable_dlopen_rtld_global in the last statement is not
# useful on modern systems but avoids error due to empty else on Centos 6...

AC_ARG_ENABLE(dlopen-rtld-global,
  [AS_HELP_STRING([--enable-dlopen-rtld-global], [add RTLD_GLOBAL to dlopen flags])],
  [
    case "${enableval}" in
      yes)  AC_DEFINE([CS_DLOPEN_USE_RTLD_GLOBAL], 1,
		       [use RTLD_GLOBAL in dlopen flags.]) ;;
      no) ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-dlopen-rtld-global]) ;;
    esac
  ],
  [ enable_dlopen_rtld_global=no ]
)

#------------------------------------------------------------------------------
# Checks for libraries.
#------------------------------------------------------------------------------

CS_AC_TEST_PLE(["2.0.0"])

AM_CONDITIONAL(HAVE_INTERNAL_PLE, test x$cs_have_internal_ple = xyes)
if test "x$cs_have_internal_ple" = xyes; then
  AC_CONFIG_SUBDIRS([libple])
fi

AM_CONDITIONAL(HAVE_SALOME, test x$with_salome != xno)
if test "x$with_salome" != xno; then
  AC_CONFIG_SUBDIRS([salome])
fi

CS_AC_TEST_BLAS([$cs_have_openmp])
CS_AC_TEST_MPI
CS_AC_TEST_METIS
CS_AC_TEST_SCOTCH
CS_AC_TEST_HDF5
CS_AC_TEST_CGNS
CS_AC_TEST_MED
CS_AC_TEST_CCM
CS_AC_TEST_EOS
CS_AC_TEST_FREESTEAM
CS_AC_TEST_COOLPROP
CS_AC_TEST_ZLIB
CS_AC_TEST_MEDCOUPLING
CS_AC_TEST_CATALYST
CS_AC_TEST_MELISSA
CS_AC_TEST_MUMPS
CS_AC_TEST_PETSC
CS_AC_TEST_AMGX

CS_AC_TEST_DOCS

cs_have_neptune_cfd=no
if test -f ${srcdir}/neptune_cfd/configure; then
  cs_have_neptune_cfd=yes
fi

# Check if we need to force link with C++
cs_have_link_cxx=no
if test x$cs_have_neptune_cfd = xyes ; then
  cs_have_link_cxx=yes
elif test x$cs_have_med_link_cxx = xyes ; then
  cs_have_link_cxx=yes
elif test x$cs_have_medcoupling = xyes -o x$cs_have_paramedmem = xyes ; then
  if test x$enable_shared = xno -o x$cs_have_plugin_medcoupling = xno ; then
    cs_have_link_cxx=yes
  fi
elif test x$cs_have_eos = xyes ; then
  cs_have_link_cxx=yes
elif test x$cs_have_coolprop = xyes ; then
  cs_have_link_cxx=yes
elif test x$cs_have_catalyst = xyes ; then
  if test x$enable_shared = xno -o x$cs_have_plugin_catalyst = xno ; then
    cs_have_link_cxx=yes
  fi
fi
if test x$user_CS_LD != "x" ; then
  CS_LD=$user_CS_LD
elif test $cs_have_link_cxx = yes ; then
  CS_LD=$CXX
else
  CS_LD=$CC
fi
AC_SUBST(CS_LD)
AM_CONDITIONAL(HAVE_LINK_CXX, test x$cs_have_link_cxx = xyes)

#------------------------------------------------------------------------------
# Enables Code_Saturne front-end
#------------------------------------------------------------------------------

AC_ARG_ENABLE(frontend, [AS_HELP_STRING([--disable-frontend],
					[disable front-end elements])],
  [
    case "${enableval}" in
      yes) cs_have_frontend=yes ;;
      no)  cs_have_frontend=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-frontend]) ;;
    esac
  ],
  [ cs_have_frontend=yes ]
)
AM_CONDITIONAL(HAVE_FRONTEND, test x$cs_have_frontend = xyes)
AC_SUBST(cs_have_frontend)

#------------------------------------------------------------------------------
# Enables Code_Saturne back-end
#------------------------------------------------------------------------------

AC_ARG_ENABLE(backend, [AS_HELP_STRING([--disable-backend],
					[disable back-end elements])],
  [
    case "${enableval}" in
      yes) cs_have_backend=yes ;;
      no)  cs_have_backend=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-backend]) ;;
    esac
  ],
  [ cs_have_backend=yes ]
)
AM_CONDITIONAL(HAVE_BACKEND, test x$cs_have_backend = xyes)
AC_SUBST(cs_have_backend)

#------------------------------------------------------------------------------
# Enables Code_Saturne graphical user interface
#------------------------------------------------------------------------------

AC_ARG_ENABLE(gui, [AS_HELP_STRING([--disable-gui],
				   [disable the Graphical User Interface])],
  [
    case "${enableval}" in
      yes) cs_have_gui=check ;;
      no)  cs_have_gui=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-gui]) ;;
    esac
  ],
  [ cs_have_gui=check ]
)

if test "x$cs_have_frontend" = "xno" ; then
  cs_have_gui=no
fi

#------------------------------------------------------------------------------
# Checks for PyQt support.
#------------------------------------------------------------------------------

# Test for PyQt4 or PyQt5
cs_have_gui_qt4=no
cs_have_gui_qt5=no

if test "x$cs_have_gui" = "xcheck" ; then

  if test "x$QT_SELECT" = "x" -o "x$QT_SELECT" = "x5" ; then

    AC_MSG_CHECKING([for PyQt5 version >= 5.0])

    prog="[import sys, string
try: import PyQt5
except ImportError: sys.exit(1)
from PyQt5.QtCore import *
if list(map(int, QT_VERSION_STR.split('.'))) < [5,0,0]: sys.exit(1)
if list(map(int, PYQT_VERSION_STR.split('.'))) < [5,0,0]: sys.exit(1)
sys.exit(0)]"

    ${PYTHON} -c "${prog}"
    retval=$?

    if test $retval -ne 0 ; then
      AC_MSG_RESULT([no])
    else
      AC_MSG_RESULT([yes])
      cs_have_gui=yes
      cs_have_gui_qt5=yes
    fi

  fi

fi

if test "x$cs_have_gui" = "xcheck" ; then

  cs_have_gui=no

  if test "x$QT_SELECT" = "x" -o "x$QT_SELECT" = "x4" ; then

    AC_MSG_CHECKING([for PyQt4 version >= 4.5])

    prog="[import sys, string
try: import PyQt4
except ImportError: sys.exit(1)
from PyQt4.QtCore import *
if list(map(int, QT_VERSION_STR.split('.'))) < [4,5,0]: sys.exit(1)
if list(map(int, PYQT_VERSION_STR.split('.'))) < [4,5,0]: sys.exit(1)
sys.exit(0)]"

    ${PYTHON} -c "${prog}"
    retval=$?

    if test $retval -ne 0 ; then
      AC_MSG_RESULT([no])
      AC_MSG_FAILURE([cannot find PyQt5 support (>= 5.0) or PyQt4 support (>= 4.5), Graphical User Interface cannot be installed])
    else
      AC_MSG_RESULT([yes])
      cs_have_gui=yes
      cs_have_gui_qt4=yes
    fi
  fi

fi

# Test for PyQt4 developer tools
if test "x$cs_have_gui_qt4" = "xyes" ; then

  # Try to find PyQt4 tools through Python interpreter
  prog="[import os, sys
from PyQt4.QtCore import QCoreApplication
app = QCoreApplication([])
path = app.applicationDirPath()
sys.stdout.write(path)]"

  PYPATH=`${PYTHON} -c "${prog}"`

  # On Cygwin hosts, the PATH does not seem to be correctly found
  if test "$host_os" = cygwin ; then
     PYPATH=/usr/lib/python$PYTHON_VERSION/site-packages/PyQt4
  fi

  AC_ARG_VAR([PYUIC4], [PyQt4 user interfaces compiler])
  AC_ARG_VAR([PYRCC4], [PyQt4 resources compiler])
  AC_ARG_VAR([LRELEASE], [Qt message files generator])

  # On MinGW (MSYS) or Cygwin (BASH) build systems, and for MinGW hosts,
  # pyuic4 is a batch file and cannot be run from the shell.
  # To bypass this issue, we launch pyuic4 through cmd.exe
  # with a "standard" PATH.
  # pyrcc4 does not need this trick as it is a standard executable.
  if test "$host_os" = mingw64 ; then
    if test "$build_os" = mingw64 ; then
      CMDPYUIC4="cmd //C $PYPATH/Lib/site-packages/PyQt4/pyuic4"
    elif test "$build_os" = cygwin ; then
      CMDPYUIC4="cmd /C $PYPATH/Lib/site-packages/PyQt4/pyuic4"
    fi
  fi

  if test "x$PYUIC4" = "x" ; then
    AC_PATH_PROG([PYUIC4], [pyuic4], [$CMDPYUIC4], [${PYPATH}:$PATH])
  fi
  if test "x$PYRCC4" = "x" ; then
    AC_PATH_PROG([PYRCC4], [pyrcc4], [],           [${PYPATH}:$PATH])
  fi

  if test "x$PYUIC4" = "x" -o "x$PYRCC4" = "x" ; then
    AC_MSG_FAILURE([cannot find PyQt4 dev tools, Graphical User Interface cannot be installed])
    cs_have_gui=no
  fi

fi

# Test for PyQt5 developer tools
if test "x$cs_have_gui_qt5" = "xyes" ; then

  # Try to find PyQt5 tools through Python interpreter
  prog="[import os, sys
from PyQt5.QtCore import QCoreApplication
app = QCoreApplication([])
path = app.applicationDirPath()
sys.stdout.write(path)]"

  PYPATH=`${PYTHON} -c "${prog}"`

  ## On Cygwin hosts, the PATH does not seem to be correctly found
  #if test "$host_os" = cygwin ; then
  #   PYPATH=/usr/lib/python$PYTHON_VERSION/site-packages/PyQt5
  #fi

  AC_ARG_VAR([PYUIC5], [PyQt5 user interfaces compiler])
  AC_ARG_VAR([PYRCC5], [PyQt5 resources compiler])
  AC_ARG_VAR([LRELEASE], [Qt message files generator])

  if test "x$PYUIC5" = "x" ; then
    AC_PATH_PROG([PYUIC5], [pyuic5], [$CMDPYUIC5], [${PYPATH}:$PATH])
  fi
  if test "x$PYRCC5" = "x" ; then
    AC_PATH_PROG([PYRCC5], [pyrcc5], [],           [${PYPATH}:$PATH])
  fi

  if test "x$LRELEASE" = "x" ; then
    AC_PATH_PROGS([LRELEASE], [lrelease-qt5 lrelease])
  fi

  # lrelease not currently used (except in SALOME CFD extension, with a separate
  # configure, so not an issue here

  if test "x$PYUIC5" = "x" -o "x$PYRCC5" = "x" ; then
    AC_MSG_FAILURE([cannot find PyQt5 dev tools, Graphical User Interface cannot be installed])
    cs_have_gui=no
  fi

fi

#------------------------------------------------------------------------------
# Checks for Qt tools.
#------------------------------------------------------------------------------

AM_CONDITIONAL(HAVE_GUI, [test "x$cs_have_gui" = "xyes"])
AC_SUBST(cs_have_gui)
AM_CONDITIONAL(HAVE_QT4, [test "x$cs_have_gui_qt4" = "xyes"])
AC_SUBST(cs_have_gui_qt4)
AM_CONDITIONAL(HAVE_QT5, [test "x$cs_have_gui_qt5" = "xyes"])
AC_SUBST(cs_have_gui_qt5)

#------------------------------------------------------------------------------
# Checks for header files.
#------------------------------------------------------------------------------

AC_HEADER_STDC
AC_CHECK_HEADERS([sys/types.h sys/utsname.h sys/stat.h dirent.h stddef.h])
AC_CHECK_HEADERS([unistd.h fcntl.h sys/types.h sys/signal.h])
AC_CHECK_HEADERS([sys/procfs.h sys/sysinfo.h sys/resource.h])
AC_CHECK_HEADERS([float.h string.h sys/time.h])

#------------------------------------------------------------------------------
# Checks for library functions.
#------------------------------------------------------------------------------

AC_CHECK_FUNCS([mkdir chdir stat dup2 access])
AC_CHECK_FUNCS([snprintf])
AC_CHECK_FUNCS([getcwd sleep])
AC_CHECK_FUNCS([getpwuid geteuid])
AC_CHECK_FUNCS([uname linkat])
AC_CHECK_FUNCS([clock_gettime clock_getcpuclockid])
AC_CHECK_FUNCS([getrusage gettimeofday sbrk sysinfo])
AC_CHECK_FUNCS([posix_memalign])
AC_CHECK_FUNCS([memset])
AC_CHECK_FUNCS([sigaction])
AC_CHECK_FUNCS([strtok_r])

saved_LIBS="$LIBS"
LIBS="${LIBS} -lm"
AC_CHECK_FUNCS([pow modf tgamma erf])
LIBS="$saved_LIBS"

AC_FUNC_STRTOD

#------------------------------------------------------------------------------
# Checks for system services.
#------------------------------------------------------------------------------

# Largefile support (may be disabled in case of conflicts)
#------------------

AC_SYS_LARGEFILE
AC_FUNC_FSEEKO

# Test for size of off_t once largefile support is activated

AC_CHECK_SIZEOF([off_t])

# Optional malloc hooks support (for glibc)
#------------------------------

cs_have_malloc_hooks=no

AC_ARG_ENABLE(malloc_hooks,
  [AS_HELP_STRING([--enable-malloc-hooks], [use malloc hooks when available])],
  [
    case "${enableval}" in
      yes) malloc_hooks=yes ;;
      no)  malloc_hooks=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-malloc-hooks]) ;;
    esac
  ],
  [ malloc_hooks=no ]
)

# If we use malloc hooks, we may need to add a -lmalloc link flag.

if test "x$malloc_hooks" = "xyes" ; then

  # Basic test
  AC_MSG_CHECKING([for malloc hooks])
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
		 [[ int __malloc_hook(); __malloc_hook(); ]])],
		 [cs_have_malloc_hooks=yes],
		 [cs_have_malloc_hooks=no])
  AC_MSG_RESULT($cs_have_malloc_hooks)

fi

if test "x$cs_have_malloc_hooks" = "xyes"; then
  AC_DEFINE(HAVE_MALLOC_HOOKS, 1, HAVE_MALLOC_HOOKS)
fi

# Backtrace support (for glibc)
#------------------

# Basic backtrace functionnality

cs_have_glibc_backtrace=no

AC_MSG_CHECKING([for glibc backtrace])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if defined(__GNUC__)
#define _GNU_SOURCE
#include <memory.h>
#include <execinfo.h>
#endif]],
	       [[ void *tr_array[10]; backtrace(tr_array, 10); ]])],
	       [cs_have_glibc_backtrace=yes],
	       [cs_have_glibc_backtrace=no])
AC_MSG_RESULT($cs_have_glibc_backtrace)

if test "x$cs_have_glibc_backtrace" = "xyes"; then
  AC_DEFINE(HAVE_GLIBC_BACKTRACE, 1, HAVE_GLIBC_BACKTRACE)
fi

# C++ demangling

cs_have_cplus_demangle=no

AC_MSG_CHECKING([for glibc cplus_demangle])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <demangle.h>]],
	       [[ const char *s; cplus_demangle(s, auto_demangling); ]])],
	       [cs_have_cplus_demangle=yes],
	       [cs_have_cplus_demangle=no])
AC_MSG_RESULT($cs_have_cplus_demangle)

if test "x$cs_have_cplus_demangle" = "xyes"; then
  AC_DEFINE(HAVE_CPLUS_DEMANGLE, 1, HAVE_CPLUS_DEMANGLE)
fi

# Optional socket support
#------------------------

have_socket=no

AC_ARG_ENABLE(sockets,
  [  --disable-sockets       disable communications through IP sockets],
  [
    case "${enableval}" in
      yes) have_socket=yes ;;
      no)  have_socket=no ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-sockets]) ;;
    esac
  ],
  [ have_socket=yes ]
)
if test "x$have_socket" = "xyes" ; then
  AC_DEFINE([HAVE_SOCKET], 1, [sockets support])
fi

# Plugin modules support
#-----------------------

cs_have_plugins=no
cs_py_have_plugins=False
if test "x$enable_shared" = "xyes" ; then
  if test "x$cs_have_dlloader" = "xdlopen" ; then
    # Test for different plugins here
    if test x$cs_have_plugin_medcoupling = xyes ; then
      cs_have_plugins=yes
    elif test x$cs_have_plugin_catalyst = xyes ; then
      cs_have_plugins=yes
    elif test x$cs_have_ccm = xyes ; then
      cs_have_plugins=yes
    fi
  fi
fi

if test "x$cs_have_plugins" = "xyes" ; then
  cs_py_have_plugins=True
  AC_DEFINE([HAVE_PLUGINS], 1, [plugins support])
fi

AC_SUBST(cs_py_have_plugins)
AM_CONDITIONAL(HAVE_PLUGINS, test x$cs_have_plugins = xyes)

#------------------------------------------------------------------------------
# Pass compiler options to automake files and cs_config.py
#------------------------------------------------------------------------------

AC_SUBST(CPPFLAGS)
AC_SUBST(CFLAGS)
AC_SUBST(CXXFLAGS)
AC_SUBST(FCFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)

#------------------------------------------------------------------------------
# Output
#------------------------------------------------------------------------------

NEPTUNE_CFD=
if test x$cs_have_neptune_cfd = xyes; then
  AC_CONFIG_SUBDIRS([neptune_cfd])
  NEPTUNE_CFD=neptune_cfd
  NEPTUNE_CFD_LIBS="-lneptune"
fi

AC_SUBST(HAVE_NEPTUNE_CFD)
AC_SUBST(NEPTUNE_CFD)

#------------------------------------------------------------------------------
# Output
#------------------------------------------------------------------------------

# Main configuration

AC_CONFIG_FILES([Makefile
		 preprocessor/Makefile
		 preprocessor/appli/Makefile preprocessor/base/Makefile
		 preprocessor/pre-post/Makefile preprocessor/util/Makefile
		 src/Makefile      src/apps/Makefile src/gui/Makefile
		 src/bft/Makefile  src/fvm/Makefile
		 src/base/Makefile src/atmo/Makefile src/cdo/Makefile
		 src/cfbl/Makefile src/cogz/Makefile src/ctwr/Makefile
		 src/darc/Makefile src/elec/Makefile src/comb/Makefile
		 src/pprt/Makefile src/lagr/Makefile src/rayt/Makefile
		 src/turb/Makefile src/alge/Makefile src/mesh/Makefile
		 src/user/Makefile src/user_examples/Makefile
		 src/meg/Makefile
		 gui/Makefile gui/Base/Makefile gui/Pages/Makefile
		 gui/studymanager_gui/Makefile gui/trackcvg/Makefile
		 docs/Makefile docs/doxygen/Makefile docs/style/csvers.tex
		 docs/refcard/Makefile docs/theory/Makefile
		 docs/user/Makefile
		 tests/Makefile
		 bin/cs_config.py
		 config/code_saturne_build.cfg.in])

#------------------------------------------------------------------------------

AC_OUTPUT

#------------------------------------------------------------------------------

# Libtool configuration bug workaround (problem encountered with compilers
# which do not recognize "-soname", so that "-Wl,-soname" is needed to pass
# flags to the linker; Manually setting $wl to "-Wl" in libtool corrects
# the problem, and so does this workaround borrowed from
# the HDF5 configure.in, which does it automatically).

if test "x$GCC" != "xyes"; then
  echo 'fixing $wl in libtool'
ed - libtool <<EOF 2> /dev/null
/^wl=""/s//wl="-Wl,"/
w
q
EOF
fi

# Copy modified version of libtool to avoid issues with " -fPIC -DPIC"
# insertion in CUDA compiler options. The -no-fpic option cannot be used
# as pic_mode propagates to sub-libraries.

if test "$cs_have_cuda" = "yes"; then
  sed -e "s/ -fPIC -DPIC//" libtool > libtool_cuda
  chmod +x libtool_cuda
fi

#------------------------------------------------------------------------------

echo
echo "Configuration options:"
if test x$cs_have_neptune_cfd = xyes ; then
  echo " NEPTUNE_CFD module support"
fi
echo " use debugging code: "$debug""
echo " use malloc hooks: "$cs_have_malloc_hooks""
if test x$cs_have_frontend = xno ; then
  echo " use frontend: no"
else
  echo " use graphical user interface: "$cs_have_gui""
  if test x$cs_have_gui_qt4 = xyes ; then
    echo "    Warning: using PyQt4 is deprecated"
  fi
fi
if test x$cs_have_backend = xno ; then
  echo " use backend: no"
fi
echo " use long global numbers: "$cs_have_long_gnum""
echo " Zlib (gzipped file) support: "$cs_have_zlib""
echo " MPI (Message Passing Interface) support: "$cs_have_mpi""
if (test x$cs_have_mpi = xyes) ; then
  echo "   MPI I/O support: "$cs_have_mpi_io""
  echo "   MPI2 one-sided communication support: "$cs_have_mpi_one_sided""
  echo "   MPI3 neighborhood collectives support: "$cs_have_mpi_one_sided""
  echo "   MPI3 nonblocking barrier support: "$cs_have_mpi_ibarrier""
fi
echo " OpenMP support: "$cs_have_openmp""
if test x$cs_have_openmp = xyes ; then
  echo " OpenMP Fortran support: "$cs_have_openmp_f""
fi
echo " CUDA support: "$cs_have_cuda""
echo " BLAS (Basic Linear Algebra Subprograms) support: "$cs_have_blas""
echo " ParMETIS (Parallel Graph Partitioning) support: "$cs_have_parmetis""
if test x$cs_have_parmetis = xno ; then
  echo " METIS (Graph Partitioning) support: "$cs_have_metis""
fi
echo " PT-SCOTCH (Parallel Graph Partitioning) support: "$cs_have_ptscotch""
if test x$cs_have_ptscotch = xno ; then
  echo " SCOTCH (Graph Partitioning) support: "$cs_have_scotch""
fi
echo " CCM support: "$cs_have_ccm""
echo " HDF (Hierarchical Data Format) support: "$cs_have_hdf5""
echo " CGNS (CFD General Notation System) support: "$cs_have_cgns""
echo " MED (Model for Exchange of Data) support: "$cs_have_med""
if (test x$cs_have_med = xyes) ; then
  echo "   MED MPI I/O support: "$cs_have_med_mpi""
fi
echo " MEDCoupling support: "$cs_have_medcoupling""
if test x$cs_have_medcoupling = xyes ; then
  echo "   MEDLoader support: "$cs_have_medcoupling_loader""
  echo "   ParaMEDMEM support: "$cs_have_paramedmem""
  echo "   MEDCoupling as plugin: "$cs_have_plugin_medcoupling""
fi
echo " Catalyst (ParaView co-processing) support: "$cs_have_catalyst""
if (test x$cs_have_catalyst = xyes) ; then
  echo "   Catalyst as plugin: "$cs_have_plugin_catalyst""
fi
echo " Melissa (in-situ statistics) support: "$cs_have_melissa""
if (test x$cs_have_melissa = xyes) ; then
  echo "   Melissa as plugin: "$cs_have_plugin_melissa""
fi
echo " EOS support: "$cs_have_eos""
echo " freesteam support: "$cs_have_freesteam""
echo " CoolProp support: "$cs_have_coolprop""
echo " PETSc support: "$cs_have_petsc""
echo " MUMPS support: "$cs_have_mumps""
echo " AMGX support: "$cs_have_amgx""
echo " Dynamic loader support: "$cs_have_dlloader""
if (test "x$cs_env_modules" != "x") ; then
  echo " Auto load environment modules: "$cs_env_modules""
fi
echo
echo " PdfLaTeX (document typesetting) available: "$cs_have_latex""
echo " Doxygen (document generation) available: "$cs_have_doxygen""
if (test x$cs_have_doxygen = xyes) ; then
  echo "   dot (Graphviz) available: "$cs_have_dot""
  echo "   MathJax enabled: "$cs_enable_mathjax""
fi
echo
echo "The package has been configured. Type:"
echo " make"
echo " make install"
echo
echo "To generate and install the Code_Saturne kernel"
echo