File: configure.ac

package info (click to toggle)
libint2 2.7.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 63,776 kB
  • sloc: ansic: 842,934; cpp: 47,846; sh: 3,139; makefile: 1,017; f90: 676; perl: 482; python: 334
file content (1541 lines) | stat: -rw-r--r-- 44,760 bytes parent folder | download | duplicates (2)
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
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
define([libint_mmm_version],[2.7.2])
define([libint_buildid],[])
define([libint_so_version],[2:3:0])

dnl --------- Begin ---------
dnl Process this file with autoconf to produce a configure script.
define([AC_CACHE_LOAD], )dnl for debugging configure.in
define([AC_CACHE_SAVE], )dnl for debugging configure.in
AC_PREREQ([2.68])
AC_INIT([Libint2],[libint_mmm_version],[libint@valeyev.net],[libint2])
AC_CONFIG_SRCDIR(src/bin/libint/rr.h)
AC_CONFIG_HEADERS(include/libint2/config.h)
AC_CONFIG_AUX_DIR(bin)
AC_CONFIG_MACRO_DIR([lib/autoconf])

dnl --- Compiling C++ only ---
AC_LANG(C++)

AC_CANONICAL_TARGET
AC_DEFINE_UNQUOTED(LIBINT_HOST_ARCH, "$host")
AC_DEFINE_UNQUOTED(LIBINT_TARGET_ARCH, "$target")

define([default_prefix_dash],ifelse(libint_buildid, ,[],[-]))
define([default_prefix],"/usr/local")

LIBINT_MMM_VERSION=libint_mmm_version
LIBINT_BUILDID=libint_buildid
AC_SUBST(LIBINT_MMM_VERSION)
AC_SUBST(LIBINT_BUILDID)
changequote(<<, >>)dnl
LIBINT_MAJOR_VERSION=`echo $LIBINT_MMM_VERSION|sed 's/\([0-9]*\)\.[0-9]*\.[0-9]*/\1/'`
LIBINT_MINOR_VERSION=`echo $LIBINT_MMM_VERSION|sed 's/[0-9]*\.\([0-9]*\)\.[0-9]*/\1/'`
LIBINT_MICRO_VERSION=`echo $LIBINT_MMM_VERSION|sed 's/[0-9]*\.[0-9]*\.\([0-9]*\)/\1/'`
changequote([, ])dnl
AC_DEFINE_UNQUOTED(LIBINT_MAJOR_VERSION,$LIBINT_MAJOR_VERSION)
AC_DEFINE_UNQUOTED(LIBINT_MINOR_VERSION,$LIBINT_MINOR_VERSION)
AC_DEFINE_UNQUOTED(LIBINT_MICRO_VERSION,$LIBINT_MICRO_VERSION)
AC_SUBST(LIBINT_MAJOR_VERSION)
AC_SUBST(LIBINT_MINOR_VERSION)
AC_SUBST(LIBINT_MICRO_VERSION)


LIBINT_SO_VERSION=libint_so_version
AC_SUBST(LIBINT_SO_VERSION)

dnl --------- Features ---------

AC_ARG_WITH(api-prefix,
AS_HELP_STRING([--with-api-prefix],[Prepend this string to every name in the library API (except for the types).]),
[
AC_DEFINE_UNQUOTED(LIBINT_API_PREFIX,"$withval")
echo Using API prefix: $withval
])

LIBINT_CGSHELL_ORDERING_STANDARD=1
LIBINT_CGSHELL_ORDERING_INTV3=2
LIBINT_CGSHELL_ORDERING_GAMESS=3
LIBINT_CGSHELL_ORDERING_ORCA=4
LIBINT_CGSHELL_ORDERING_BAGEL=5
libint_cgshell_ordering=standard
AC_ARG_WITH(cartgauss-ordering,
[  --with-cartgauss-ordering
                         Use one of the following known orderings for shells of cartesian Gaussians:
                           standard -- standard ordering (xxx, xxy, xxz, xyy, xyz, xzz, yyy, ...)
                           intv3  -- intv3 ordering (yyy, yyz, yzz, zzz, xyy, xyz, xzz, xxy, xxz, xxx)
                           gamess -- GAMESS ordering (xxx, yyy, zzz, xxy, xxz, yyx, yyz, zzx, zzy, xyz)
                           orca -- ORCA ordering (hydrid between GAMESS and standard)
                           bagel -- axis-permuted version of intv3 (xxx, xxy, xyy, yyy, xxz, xyz, yyz, xzz, yzz, zzz)
                         The default is standard.],
[
libint_cgshell_ordering=$withval
])
AC_MSG_RESULT([Using $libint_cgshell_ordering ordering of cartesian Gaussians])
case $libint_cgshell_ordering in
  standard)
    libint_cgshell_ordering=$LIBINT_CGSHELL_ORDERING_STANDARD
  ;;
  intv3)
    libint_cgshell_ordering=$LIBINT_CGSHELL_ORDERING_INTV3
  ;;
  gamess)
    libint_cgshell_ordering=$LIBINT_CGSHELL_ORDERING_GAMESS
  ;;
  orca)
    libint_cgshell_ordering=$LIBINT_CGSHELL_ORDERING_ORCA
  ;;
  bagel)
    libint_cgshell_ordering=$LIBINT_CGSHELL_ORDERING_BAGEL
  ;;
  *)
    AC_MSG_ERROR([Invalid value for --with-cartgauss-ordering ($withval)])
  ;;
esac
AC_DEFINE_UNQUOTED(LIBINT_CGSHELL_ORDERING,$libint_cgshell_ordering)
AC_DEFINE_UNQUOTED(LIBINT_CGSHELL_ORDERING_STANDARD,$LIBINT_CGSHELL_ORDERING_STANDARD)
AC_DEFINE_UNQUOTED(LIBINT_CGSHELL_ORDERING_INTV3,$LIBINT_CGSHELL_ORDERING_INTV3)
AC_DEFINE_UNQUOTED(LIBINT_CGSHELL_ORDERING_GAMESS,$LIBINT_CGSHELL_ORDERING_GAMESS)
AC_DEFINE_UNQUOTED(LIBINT_CGSHELL_ORDERING_ORCA,$LIBINT_CGSHELL_ORDERING_ORCA)
AC_DEFINE_UNQUOTED(LIBINT_CGSHELL_ORDERING_BAGEL,$LIBINT_CGSHELL_ORDERING_BAGEL)

LIBINT_SHGSHELL_ORDERING_STANDARD=1
LIBINT_SHGSHELL_ORDERING_GAUSSIAN=2
libint_shgshell_ordering=standard
AC_ARG_WITH(shgauss-ordering,
[  --with-shgauss-ordering
                         Use one of the following known orderings for shells of solid harmonic Gaussians:
                           standard -- standard ordering (-l, -l+1 ... l)
                           gaussian -- the Gaussian ordering (0, 1, -1, 2, -2, ... l, -l)
                         The default is standard.],
[
libint_shgshell_ordering=$withval
])
AC_MSG_RESULT([Using $libint_shgshell_ordering ordering of solid harmonic Gaussians])
case $libint_shgshell_ordering in
  standard)
    libint_shgshell_ordering=$LIBINT_SHGSHELL_ORDERING_STANDARD
  ;;
  gaussian)
    libint_shgshell_ordering=$LIBINT_SHGSHELL_ORDERING_GAUSSIAN
  ;;
  *)
    AC_MSG_ERROR([Invalid value for --with-solidharmgauss-ordering ($withval)])
  ;;
esac
AC_DEFINE_UNQUOTED(LIBINT_SHGSHELL_ORDERING,$libint_shgshell_ordering)
AC_DEFINE_UNQUOTED(LIBINT_SHGSHELL_ORDERING_STANDARD,$LIBINT_SHGSHELL_ORDERING_STANDARD)
AC_DEFINE_UNQUOTED(LIBINT_SHGSHELL_ORDERING_GAUSSIAN,$LIBINT_SHGSHELL_ORDERING_GAUSSIAN)

LIBINT_SHELL_SET_STANDARD=1   AC_SUBST(LIBINT_SHELL_SET_STANDARD)
LIBINT_SHELL_SET_ORCA=2      AC_SUBST(LIBINT_SHELL_SET_ORCA)
libint_shell_set=standard
AC_ARG_WITH(shell-set,
[  --with-shell-set       The library will support computation of shell sets sets subject to these restrictions:
                           standard -- standard ordering:
                             for (ab|cd):
                               l(a) >= l(b),
                               l(c) >= l(d),
                               l(a)+l(b) <= l(c)+l(d)
                             for (b|cd):
                               l(c) >= l(d)
                           orca -- ORCA ordering:
                             for (ab|cd):
                               l(a) <= l(b),
                               l(c) <= l(d),
                               l(a) < l(c) || (l(a) == l(c) && l(b) < l(d))
                             for (b|cd):
                               l(c) <= l(d)
                          The default is standard.],
[
libint_shell_set=$withval
])
AC_MSG_RESULT([Will generate $libint_shell_set shell quartet sets])
case $libint_shell_set in
  standard)
    libint_shell_set=$LIBINT_SHELL_SET_STANDARD
  ;;
  orca)
    libint_shell_set=$LIBINT_SHELL_SET_ORCA
  ;;
  *)
    AC_MSG_ERROR([Invalid value for --with-shell-set ($withval)])
  ;;
esac
LIBINT_SHELL_SET=$libint_shell_set AC_SUBST(LIBINT_SHELL_SET)
AC_DEFINE_UNQUOTED(LIBINT_SHELL_SET,$libint_shell_set)
AC_DEFINE_UNQUOTED(LIBINT_SHELL_SET_STANDARD,$LIBINT_SHELL_SET_STANDARD)
AC_DEFINE_UNQUOTED(LIBINT_SHELL_SET_ORCA,$LIBINT_SHELL_SET_ORCA)

AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],[Compile with debugging options]),
[
case $enableval in
  yes)
    DEBUG=yes
  ;;
  no)
    DEBUG=no
  ;;
  opt)
    DEBUG=opt
  ;;
  *)
    AC_MSG_ERROR([Invalid value for --enable-debug ($enableval)])
  ;;
esac
],[
    DEBUG=no
]
)

# can be used in the future to exclude source directories
EXCLUDED_DIRS=

AC_ARG_ENABLE(1body,
AS_HELP_STRING([--enable-1body=N],[Compile with support for up to N-th derivatives of 1-body integrals]),
[
case $enableval in
  yes)
    INCLUDE_ONEBODY=0
  ;;
  no)
    INCLUDE_ONEBODY=no
  ;;
  *)
    if test $enableval -lt 0; then
      AC_MSG_ERROR([Invalid value for --enable-1body ($enableval)])
    fi
    INCLUDE_ONEBODY=$enableval
  ;;
esac
],[
    INCLUDE_ONEBODY=0
]
)

DISABLE_ONEBODY_PROPERTY_DERIVS=1
AC_ARG_ENABLE(1body-property-derivs,
AS_HELP_STRING([--enable-1body-property-derivs],[Enable geometric derivatives of 1-body property integrals (all but overlap, kinetic, elecpot). These derivatives are disabled by default to save compile time.]),
[
case $enableval in
  yes)
    DISABLE_ONEBODY_PROPERTY_DERIVS=0
  ;;
esac
])
if test X$DISABLE_ONEBODY_PROPERTY_DERIVS != 0; then
  AC_DEFINE(DISABLE_ONEBODY_PROPERTY_DERIVS)
fi

AC_ARG_ENABLE(eri,
AS_HELP_STRING([--enable-eri=N],[Compile with support for up to N-th derivatives of electron repulsion integrals]),
[
case $enableval in
  yes)
    INCLUDE_ERI=0
  ;;
  no)
    INCLUDE_ERI=no
  ;;
  *)
    if test $enableval -lt 0; then
      AC_MSG_ERROR([Invalid value for --enable-eri ($enableval)])
    fi
    INCLUDE_ERI=$enableval
  ;;
esac
],[
    INCLUDE_ERI=0
]
)

AC_ARG_ENABLE(eri3,
AS_HELP_STRING([--enable-eri3=N],[Compile with support for up to N-th derivatives of 3-center electron repulsion integrals]),
[
case $enableval in
  yes)
    INCLUDE_ERI3=0
  ;;
  no)
    INCLUDE_ERI3=no
  ;;
  *)
    if test $enableval -lt 0; then
      AC_MSG_ERROR([Invalid value for --enable-eri3 ($enableval)])
    fi
    INCLUDE_ERI3=$enableval
  ;;
esac
],[
    INCLUDE_ERI3=no
]
)

AC_ARG_ENABLE(eri2,
AS_HELP_STRING([--enable-eri2=N],[Compile with support for up to N-th derivatives of 2-center electron repulsion integrals]),
[
case $enableval in
  yes)
    INCLUDE_ERI2=0
  ;;
  no)
    INCLUDE_ERI2=no
  ;;
  *)
    if test $enableval -lt 0; then
      AC_MSG_ERROR([Invalid value for --enable-eri2 ($enableval)])
    fi
    INCLUDE_ERI2=$enableval
  ;;
esac
],[
    INCLUDE_ERI2=no
]
)

AC_ARG_ENABLE(g12,
AS_HELP_STRING([--enable-g12=N],[Compile with support for N-th derivatives of MP2-F12 energies with Gaussian factors]),
[
case $enableval in
  yes)
    INCLUDE_G12=0
  ;;
  no)
    INCLUDE_G12=no
  ;;
  *)
    if test $enableval -lt 0; then
      AC_MSG_ERROR([Invalid value for --enable-g12 ($enableval)])
    fi
    INCLUDE_G12=$enableval
  ;;
esac
],[
    INCLUDE_G12=no
]
)

AC_ARG_ENABLE(g12dkh,
AS_HELP_STRING([--enable-g12dkh=N],[Compile with support for N-th derivatives of DKH-MP2-F12 energies with Gaussian factors]),
[
case $enableval in
  yes)
    INCLUDE_G12DKH=0
  ;;
  no)
    INCLUDE_G12DKH=no
  ;;
  *)
    if test $enableval -lt 0; then
      AC_MSG_ERROR([Invalid value for --enable-g12dkh ($enableval)])
    fi
    INCLUDE_G12DKH=$enableval
  ;;
esac
],[
    INCLUDE_G12DKH=no
]
)

LIBINT_MAX_AM=4
AC_ARG_WITH(max-am,
AS_HELP_STRING([--with-max-am=N],[Support Gaussians of angular momentum up to N. Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      LIBINT_MAX_AM_LIST="$withval"
      AC_SUBST(LIBINT_MAX_AM_LIST)
      AC_DEFINE_UNQUOTED(LIBINT_MAX_AM_LIST, "$LIBINT_MAX_AM_LIST")
      LIBINT_MAX_AM=`echo $LIBINT_MAX_AM_LIST | tr , "\n" | sort -n | tail -n1`
    ;;
    *)
      if test $withval -le 0; then
        AC_MSG_ERROR([Invalid value for --with-max-am ($withval)])
      else
        LIBINT_MAX_AM=$withval
      fi
      if test $LIBINT_MAX_AM -ge 8; then
        AC_MSG_ERROR([Value for --with-max-am too high ($withval). Are you sure you know what you are doing?])
      fi
    ;;
  esac
]
)
AC_DEFINE_UNQUOTED(LIBINT_MAX_AM,$LIBINT_MAX_AM)

LIBINT_OPT_AM=$((($LIBINT_MAX_AM/2)+1))
AC_ARG_WITH(opt-am,
AS_HELP_STRING([--with-opt-am=N],[Optimize maximally for up to angular momentum N (N <= max-am).]),
[
  case $withval in 
    *,*)
      LIBINT_OPT_AM_LIST="$withval"
      AC_SUBST(LIBINT_OPT_AM_LIST)
      AC_DEFINE_UNQUOTED(LIBINT_OPT_AM_LIST, "$LIBINT_OPT_AM_LIST")
      LIBINT_OPT_AM=`echo $LIBINT_OPT_AM_LIST | tr , "\n" | sort -n | tail -n1`
    ;;
    *)
      if test $withval -le $LIBINT_MAX_AM; then
        LIBINT_OPT_AM=$withval
      fi
    ;;
  esac
]
)
AC_DEFINE_UNQUOTED(LIBINT_OPT_AM,$LIBINT_OPT_AM)

ERI_MAX_AM=$LIBINT_MAX_AM
AC_ARG_WITH(eri-max-am,
AS_HELP_STRING([--with-eri-max-am=N],[Support ERIs for Gaussians of angular momentum up to N. Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      ERI_MAX_AM_LIST="$withval"
      AC_SUBST(ERI_MAX_AM_LIST)
      AC_DEFINE_UNQUOTED(ERI_MAX_AM_LIST, "$ERI_MAX_AM_LIST")
    ;;
    *) 
     if test $withval -le 0; then
      AC_MSG_ERROR([Invalid value for --with-eri-max-am ($withval)])
     else
      ERI_MAX_AM=$withval
     fi
     if test $ERI_MAX_AM -ge 8; then
      AC_MSG_ERROR([Value for --with-eri-max-am too high ($withval). Are you sure you know what you are doing?])
     fi
     AC_SUBST(ERI_MAX_AM)
     AC_DEFINE_UNQUOTED(ERI_MAX_AM,$ERI_MAX_AM)
    ;; 
  esac
]
)

ERI_OPT_AM=$LIBINT_OPT_AM
AC_ARG_WITH(eri-opt-am,
AS_HELP_STRING([--with-eri-opt-am=N],[Optimize ERIs maximally for up to angular momentum N (N <= max-am).  Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      ERI_OPT_AM_LIST="$withval"
      AC_SUBST(ERI_OPT_AM_LIST)
      AC_DEFINE_UNQUOTED(ERI_OPT_AM_LIST, "$ERI_OPT_AM_LIST")  
    ;;
    *) 
     if test $withval -le $ERI_MAX_AM; then
       ERI_OPT_AM=$withval
       AC_SUBST(ERI_OPT_AM)
       AC_DEFINE_UNQUOTED(ERI_OPT_AM,$ERI_OPT_AM)  
     fi
    ;;
  esac
]
)

if test X$INCLUDE_ERI != Xno; then
  AC_DEFINE_UNQUOTED(INCLUDE_ERI,$INCLUDE_ERI)
  LIBINT_SUPPORTS_ERI=yes
  AC_SUBST(LIBINT_SUPPORTS_ERI)
  LIBINT_ERI_DERIV=$INCLUDE_ERI
  AC_SUBST(LIBINT_ERI_DERIV)  
fi

ONEBODY_MAX_AM=$LIBINT_MAX_AM
AC_ARG_WITH(1body-max-am,
AS_HELP_STRING([--with-1body-max-am=N],[Support 1-e ints for Gaussians of angular momentum up to N. Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      ONEBODY_MAX_AM_LIST="$withval"
      AC_SUBST(ONEBODY_MAX_AM_LIST)
      AC_DEFINE_UNQUOTED(ONEBODY_MAX_AM_LIST, "$ONEBODY_MAX_AM_LIST")
    ;;
    *) 
     if test $withval -le 0; then
      AC_MSG_ERROR([Invalid value for --with-1body-max-am ($withval)])
     else
      ONEBODY_MAX_AM=$withval
     fi
     if test $ONEBODY_MAX_AM -ge 8; then
      AC_MSG_ERROR([Value for --with-1body-max-am too high ($withval). Are you sure you know what you are doing?])
     fi
     AC_SUBST(ONEBODY_MAX_AM)
     AC_DEFINE_UNQUOTED(ONEBODY_MAX_AM,$ONEBODY_MAX_AM)
    ;; 
  esac
]
)

ONEBODY_OPT_AM=$LIBINT_OPT_AM
AC_ARG_WITH(1body-opt-am,
AS_HELP_STRING([--with-1body-opt-am=N],[Optimize 1-e ints maximally for up to angular momentum N (N <= max-am).  Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      ONEBODY_OPT_AM_LIST="$withval"
      AC_SUBST(ONEBODY_OPT_AM_LIST)
      AC_DEFINE_UNQUOTED(ONEBODY_OPT_AM_LIST, "$ONEBODY_OPT_AM_LIST")  
    ;;
    *) 
     if test $withval -le $ONEBODY_MAX_AM; then
       ONEBODY_OPT_AM=$withval
       AC_SUBST(ONEBODY_OPT_AM)
       AC_DEFINE_UNQUOTED(ONEBODY_OPT_AM,$ONEBODY_OPT_AM)  
     fi
    ;;
  esac
]
)

MULTIPOLE_MAX_ORDER=4
AC_ARG_WITH(multipole-max-order,
AS_HELP_STRING([--with-multipole-max-order=N],[Maximum order of spherical multipole integrals. The default is 4. There is no maximum]),
[
  case $withval in 
    *) 
      MULTIPOLE_MAX_ORDER=$withval
    ;;
  esac
]
)
AC_DEFINE_UNQUOTED(MULTIPOLE_MAX_ORDER,$MULTIPOLE_MAX_ORDER)  

if test X$INCLUDE_ONEBODY != Xno; then
  AC_DEFINE_UNQUOTED(INCLUDE_ONEBODY,$INCLUDE_ONEBODY)
  LIBINT_SUPPORTS_ONEBODY=yes
  AC_SUBST(LIBINT_SUPPORTS_ONEBODY)
  LIBINT_ONEBODY_DERIV=$INCLUDE_ONEBODY
  AC_SUBST(LIBINT_ONEBODY_DERIV)
fi

# check max am for 3-center ERIs, if needed
ERI3_MAX_AM=$LIBINT_MAX_AM
AC_ARG_WITH(eri3-max-am,
AS_HELP_STRING([--with-eri3-max-am=N],[Support 3-center ERIs for Gaussians of angular momentum up to N. Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      ERI3_MAX_AM_LIST="$withval"
      AC_SUBST(ERI3_MAX_AM_LIST)
      AC_DEFINE_UNQUOTED(ERI3_MAX_AM_LIST, "$ERI3_MAX_AM_LIST")
    ;;
    *) 
     if test $withval -le 0; then
      AC_MSG_ERROR([Invalid value for --with-eri3-max-am ($withval)])
     else
      ERI3_MAX_AM=$withval
     fi
     if test $ERI3_MAX_AM -ge 8; then
      AC_MSG_ERROR([Value for --with-eri3-max-am too high ($withval). Are you sure you know what you are doing?])
     fi
     AC_SUBST(ERI3_MAX_AM)
     AC_DEFINE_UNQUOTED(ERI3_MAX_AM,$ERI3_MAX_AM)
    ;; 
  esac
]
)

ERI3_OPT_AM=$LIBINT_OPT_AM
AC_ARG_WITH(eri3-opt-am,
AS_HELP_STRING([--with-eri3-opt-am=N],[Optimize 3-center ERIs maximally for up to angular momentum N (N <= max-am).  Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      ERI3_OPT_AM_LIST="$withval"
      AC_SUBST(ERI3_OPT_AM_LIST)
      AC_DEFINE_UNQUOTED(ERI3_OPT_AM_LIST, "$ERI3_OPT_AM_LIST")  
    ;;
    *) 
     if test $withval -le $ERI3_MAX_AM; then
       ERI3_OPT_AM=$withval
       AC_SUBST(ERI3_OPT_AM)
       AC_DEFINE_UNQUOTED(ERI3_OPT_AM,$ERI3_OPT_AM)  
     fi
    ;;
  esac
]
)

AC_ARG_ENABLE(eri3-pure-sh,
AS_HELP_STRING([--enable-eri3-pure-sh],[Assume the "unpaired" center of 3-center electron repulsion integrals will be transformed to pure solid harmonics]),
[
case $enableval in
  yes)
    ERI3_PURE_SH=yes
  ;;
  no)
    ERI3_PURE_SH=no
  ;;
esac
],[
    ERI3_PURE_SH=no
]
)

if test X$INCLUDE_ERI3 != Xno; then
  AC_DEFINE_UNQUOTED(INCLUDE_ERI3,$INCLUDE_ERI3)
  if test X$ERI3_PURE_SH != Xno; then
    AC_DEFINE(ERI3_PURE_SH)
  fi
fi

# check max am for 2-center ERIs, if needed
ERI2_MAX_AM=$LIBINT_MAX_AM
AC_ARG_WITH(eri2-max-am,
AS_HELP_STRING([--with-eri2-max-am=N],[Support 2-center ERIs for Gaussians of angular momentum up to N. Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      ERI2_MAX_AM_LIST="$withval"
      AC_SUBST(ERI2_MAX_AM_LIST)
      AC_DEFINE_UNQUOTED(ERI2_MAX_AM_LIST, "$ERI2_MAX_AM_LIST")
    ;;
    *) 
     if test $withval -le 0; then
      AC_MSG_ERROR([Invalid value for --with-eri2-max-am ($withval)])
     else
      ERI2_MAX_AM=$withval
     fi
     if test $ERI2_MAX_AM -ge 8; then
      AC_MSG_ERROR([Value for --with-eri2-max-am too high ($withval). Are you sure you know what you are doing?])
     fi
     AC_SUBST(ERI2_MAX_AM)
     AC_DEFINE_UNQUOTED(ERI2_MAX_AM,$ERI2_MAX_AM)
    ;; 
  esac
]
)

ERI2_OPT_AM=$LIBINT_OPT_AM
AC_ARG_WITH(eri2-opt-am,
AS_HELP_STRING([--with-eri2-opt-am=N],[Optimize 2-center ERIs maximally for up to angular momentum N (N <= max-am).  Can specify values for each derivative levels as a list N0,N1,N2...]),
[
  case $withval in 
    *,*)
      ERI2_OPT_AM_LIST="$withval"
      AC_SUBST(ERI2_OPT_AM_LIST)
      AC_DEFINE_UNQUOTED(ERI2_OPT_AM_LIST, "$ERI2_OPT_AM_LIST")  
    ;;
    *) 
     if test $withval -le $ERI2_MAX_AM; then
       ERI2_OPT_AM=$withval
       AC_SUBST(ERI2_OPT_AM)
       AC_DEFINE_UNQUOTED(ERI2_OPT_AM,$ERI2_OPT_AM)  
     fi
    ;;
  esac
]
)

AC_ARG_ENABLE(eri2-pure-sh,
AS_HELP_STRING([--enable-eri2-pure-sh],[Assume the 2-center electron repulsion integrals will be transformed to pure solid harmonics]),
[
case $enableval in
  yes)
    ERI2_PURE_SH=yes
  ;;
  no)
    ERI2_PURE_SH=no
  ;;
esac
],[
    ERI2_PURE_SH=no
]
)

if test X$INCLUDE_ERI2 != Xno; then
  AC_DEFINE_UNQUOTED(INCLUDE_ERI2,$INCLUDE_ERI2)
  if test X$ERI2_PURE_SH != Xno; then
    AC_DEFINE(ERI2_PURE_SH)
  fi
fi

# check max am for G12 integrals, if needed
G12_MAX_AM=$LIBINT_MAX_AM
AC_ARG_WITH(g12-max-am,
AS_HELP_STRING([--with-g12-max-am=N],[Support integrals for G12 methods of angular momentum up to N.]),
if test $withval -le 0; then
  AC_MSG_ERROR([Invalid value for --with-g12-max-am ($withval)])
else
  G12_MAX_AM=$withval
fi
)

G12_OPT_AM=$LIBINT_OPT_AM
AC_ARG_WITH(g12-opt-am,
AS_HELP_STRING([--with-g12-opt-am=N],[Optimize G12 integrals for up to angular momentum N (N <= max-am).]),
if test $withval -le $G12_MAX_AM; then
  G12_OPT_AM=$withval
fi
)

AC_ARG_ENABLE(t1g12-support,
AS_HELP_STRING([--disable-t1g12-support],[Libint will not support [Ti,G12] integrals]),
[
case $enableval in
  yes)
    SUPPORT_T1G12=1
  ;;
  no)
    SUPPORT_T1G12=0
  ;;
  *)
    SUPPORT_T1G12=$enableval
  ;;
esac
],[
    SUPPORT_T1G12=1
]
)

AC_ARG_ENABLE(composite-evaluators,
AS_HELP_STRING([--disable-composite-evaluators],[Libint will not use composite evaluators (i.e. every evaluator wil compute one integral type only)]),
[
case $enableval in
  yes)
    LIBINT_USE_COMPOSITE_EVALUATORS=1
    AC_MSG_RESULT([Will generate composite evaluators for multiple integral types])
  ;;
  no)
    LIBINT_USE_COMPOSITE_EVALUATORS=0
    AC_MSG_RESULT([Will generate separate evaluators for each integral type])
  ;;
  *)
    LIBINT_USE_COMPOSITE_EVALUATORS=$enableval
  ;;
esac
],[
    LIBINT_USE_COMPOSITE_EVALUATORS=1
    AC_MSG_RESULT([Will generate composite evaluators for multiple integral types])
]
)
AC_DEFINE_UNQUOTED(LIBINT_USE_COMPOSITE_EVALUATORS,$LIBINT_USE_COMPOSITE_EVALUATORS)

if test "X$INCLUDE_G12" != "Xno"; then
  AC_DEFINE_UNQUOTED(INCLUDE_G12,$INCLUDE_G12)
  AC_SUBST(G12_MAX_AM)
  AC_SUBST(G12_OPT_AM)
  AC_SUBST(SUPPORT_T1G12)
  AC_DEFINE_UNQUOTED(G12_MAX_AM,$G12_MAX_AM)
  AC_DEFINE_UNQUOTED(G12_OPT_AM,$G12_OPT_AM)
  AC_DEFINE_UNQUOTED(SUPPORT_T1G12,$SUPPORT_T1G12)
fi

# check max am for G12DKH integrals, if needed
G12DKH_MAX_AM=$LIBINT_MAX_AM
AC_ARG_WITH(g12dkh-max-am,
AS_HELP_STRING([--with-g12dkh-max-am=N],[Support integrals for relativistic G12 methods of angular momentum up to N.]),
if test $withval -le 0; then
  AC_MSG_ERROR([Invalid value for --with-g12dkh-max-am ($withval)])
else
  G12DKH_MAX_AM=$withval
fi
)

G12DKH_OPT_AM=$LIBINT_OPT_AM
AC_ARG_WITH(g12dkh-opt-am,
AS_HELP_STRING([--with-g12dkh-opt-am=N],[Optimize G12DKH integrals for up to angular momentum N (N <= max-am).]),
if test $withval -le $G12DKH_MAX_AM; then
  G12DKH_OPT_AM=$withval
fi
)

if test "X$INCLUDE_G12DKH" != "Xno"; then
  AC_DEFINE_UNQUOTED(INCLUDE_G12DKH,$INCLUDE_G12DKH)
  AC_SUBST(G12DKH_MAX_AM)
  AC_SUBST(G12DKH_OPT_AM)
  AC_DEFINE_UNQUOTED(G12DKH_MAX_AM,$G12DKH_MAX_AM)
  AC_DEFINE_UNQUOTED(G12DKH_OPT_AM,$G12DKH_OPT_AM)
fi

LIBINT_UNROLLING_THRESHOLD=100
AC_ARG_ENABLE(unrolling,
AS_HELP_STRING([--enable-unrolling],[Unroll shell sets into integrals (--enable-unrolling=S will unroll shell sets larger than S).]),
[
case $enableval in
  yes)
  LIBINT_UNROLLING_THRESHOLD=1000000000
  ;;
  no)
  LIBINT_UNROLLING_THRESHOLD=
  AC_MSG_RESULT([Shell sets will not be unrolled])
  ;;
  *)
  LIBINT_UNROLLING_THRESHOLD=$enableval
  ;;
esac
])
if test X$LIBINT_UNROLLING_THRESHOLD != X; then
  if test X$LIBINT_UNROLLING_THRESHOLD = X1000000000; then
    AC_MSG_RESULT([All shell sets will be unrolled])
  else
    AC_MSG_RESULT([Shell sets will be unrolled up to size $LIBINT_UNROLLING_THRESHOLD])
  fi
  AC_DEFINE_UNQUOTED(LIBINT_ENABLE_UNROLLING, $LIBINT_UNROLLING_THRESHOLD)
fi

AC_ARG_ENABLE(generic-code,
AS_HELP_STRING([--enable-generic-code],[Use manually-written generic code.]),
[
case $enableval in
  yes)
  AC_DEFINE(LIBINT_ENABLE_GENERIC_CODE)
  AC_MSG_RESULT([Generic RR code will be used])
  ;;
  no)
  AC_MSG_RESULT([Generic RR code will not be used])
  ;;
esac
])

LIBINT_VECTOR_LENGTH=1
AC_ARG_WITH(vector-length,
AS_HELP_STRING([--with-vector-length=N],[Compute integrals in vectors of length N.]),
[
if test $withval -gt 0; then
  LIBINT_VECTOR_LENGTH=$withval
  AC_DEFINE_UNQUOTED(LIBINT_VECTOR_LENGTH,$withval)
  AC_MSG_RESULT([Using vector length: $withval])
fi
])

if test $LIBINT_VECTOR_LENGTH -gt 1; then
  LIBINT_VECTOR_METHOD=block
  AC_ARG_WITH(vector-method,
  AS_HELP_STRING([--with-vector-method],[Specifies how to vectorize integrals. Allowed values are 'block' (default), and 'line'.]),
  [
  LIBINT_VECTOR_METHOD=$withval
  ])
  case $LIBINT_VECTOR_METHOD in
    block)
    ;;
    line)
    ;;
    *)
    AC_MSG_ERROR([Unrecognized vector method: $LIBINT_VECTOR_METHOD])
    ;;
  esac
  AC_DEFINE_UNQUOTED(LIBINT_VECTOR_METHOD,"$LIBINT_VECTOR_METHOD")
  AC_MSG_RESULT([Using vector method: $LIBINT_VECTOR_METHOD])
fi

AC_ARG_ENABLE(single-evaltype,
 AS_HELP_STRING([--enable-single-evaltype],[Generate single evaluator type (i.e. all tasks use the same evaluator)]),
 [
  if test X$enableval = Xyes; then
    enable_single_evaltype=1
  else
    enable_single_evaltype=0
  fi
 ],
 [
  enable_single_evaltype=1
 ]
)
if test X$enable_single_evaltype = X1; then
  AC_DEFINE(LIBINT_SINGLE_EVALTYPE)
  AC_MSG_RESULT([Will generate single evaluator type])
else
  AC_MSG_RESULT([Will generate specialized evaluator types for each task])
  AC_MSG_ERROR([Cannot generate specialized evaluator types yet])
fi

libint_generate_gma=0
AC_ARG_ENABLE(fma,
AS_HELP_STRING([--enable-fma],[Generate FMA (fused multiply-add) instructions (CXXGEN must support C++11; to benefit must have FMA-capable hardware and compiler)]),
[
case $enableval in
  yes)
    libint_generate_gma=1
    AC_DEFINE(LIBINT_GENERATE_FMA)
    AC_MSG_RESULT([Will generate FMA instructions])
  ;;
  no)
    AC_MSG_RESULT([Will not generate FMA instructions])
  ;;
esac
],
[
    AC_MSG_RESULT([Will not generate FMA instructions])
])

AC_ARG_ENABLE(accum-ints,
AS_HELP_STRING([--enable-accum-ints],[Accumulate integrals to the buffer, rather than copy.]),
[
case $enableval in
  yes)
    AC_DEFINE(LIBINT_ACCUM_INTS)
    AC_MSG_RESULT([Will accumulate integrals to the buffer])
  ;;
  no)
    AC_MSG_RESULT([Will copy integrals to the buffer])
  ;;
esac
],
[
AC_MSG_RESULT([Will copy integrals to the buffer])
])

AC_ARG_ENABLE(flop-counter,
AS_HELP_STRING([--enable-flop-counter],[Support (approximate) FLOP counting by the library. CXXGEN must support C++11!]),
[
case $enableval in
  yes)
    AC_DEFINE(LIBINT_FLOP_COUNT)
    AC_MSG_RESULT([FLOP counter will be supported])
  ;;
  no)
    AC_MSG_RESULT([FLOP counter will not be supported])
  ;;
esac
],
[
    AC_MSG_RESULT([FLOP counter will not be supported])
])

AC_ARG_ENABLE(profile,
AS_HELP_STRING([--enable-profile],[Turn on profiling instrumentation of the library. CXXGEN must support C++11!]),
[
case $enableval in
  yes)
    AC_DEFINE(LIBINT_PROFILE)
    AC_MSG_RESULT([Profiling instrumentation enabled (generated code will require C++11)])
  ;;
  no)
    AC_MSG_RESULT([Profiling instrumentation disabled])
  ;;
esac
],
[
    AC_MSG_RESULT([Profiling instrumentation disabled])
])

acx_contracted_ints=yes
AC_ARG_ENABLE(contracted-ints,
AS_HELP_STRING([--enable-contracted-ints],[Turn on support for contracted integrals.]),
[
case $enableval in
  no)
    acx_contracted_ints=no
  ;;
esac
])
if test "X$acx_contracted_ints" = Xyes; then
  AC_DEFINE(LIBINT_CONTRACTED_INTS)
  AC_MSG_RESULT([Will support contracted integrals])
else
  AC_MSG_RESULT([Will not support contracted integrals])
fi
AC_SUBST(LIBINT_CONTRACTED_INTS, $acx_contracted_ints)


dnl
dnl Preferred strategies for evaluation
dnl
AC_ARG_WITH(eri-strategy,
AS_HELP_STRING([--with-eri-strategy],[Compute ERIs using the following strategy. This option is for experts ONLY.]),
[
  case $withval in
    OS)
      AC_DEFINE_UNQUOTED(LIBINT_ERI_STRATEGY,0)
    ;;
    HGP)
      AC_DEFINE_UNQUOTED(LIBINT_ERI_STRATEGY,1)
    ;;
    HL)
      AC_DEFINE_UNQUOTED(LIBINT_ERI_STRATEGY,2)
    ;;
  esac
AC_MSG_RESULT([Using ERI strategy: $withval])
],
[AC_DEFINE(LIBINT_ERI_STRATEGY,1)]
)


BUILDID="libint_buildid"
AC_ARG_WITH(build-id,
AS_HELP_STRING([--with-build-id],[Gives an identifier for the build.]),
BUILDID=$withval
)
AC_SUBST(BUILDID)
AC_DEFINE_UNQUOTED(LIBINT_BUILDID,"$BUILDID")

if test "$BUILDID"; then
  LIBINT_VERSION="$LIBINT_MMM_VERSION-$BUILDID"
else
  LIBINT_VERSION="$LIBINT_MMM_VERSION"
fi

AC_DEFINE_UNQUOTED(LIBINT_VERSION, "$LIBINT_VERSION")
AC_SUBST(LIBINT_VERSION)

ac_default_prefix="/usr/local/libint/$LIBINT_VERSION"

AC_ARG_WITH(cxx,
AS_HELP_STRING([--with-cxx],[Gives the name of the C++ compiler to use.]),
CXX=$withval
)

CXXFLAGS_OPT=
AC_ARG_WITH(cxx-optflags,
AS_HELP_STRING([--with-cxx-optflags],[Gives optimization flags for the C++ compiler.]),
if test "X$withval" != "Xyes" -a "X$withval" != "Xno"; then
  CXXFLAGS_OPT=$withval
fi
)

AC_ARG_WITH(cxxgen,
AS_HELP_STRING([--with-cxxgen],[Gives the name of the C++ compiler to compile generated code.]),
CXXGEN=$withval
)

CXXGENFLAGS_OPT=
AC_ARG_WITH(cxxgen-optflags,
AS_HELP_STRING([--with-cxxgen-optflags],[Gives optimization flags for the C++ compiler for generated source.]),
if test "X$withval" != "Xyes" -a "X$withval" != "Xno"; then
  CXXGENFLAGS_OPT=$withval
fi
)

AC_ARG_WITH(cxxdepend,
AS_HELP_STRING([--with-cxxdepend],[Gives the name of the C++ compiler with which to extract dependency information.]),
CXXDEPEND=$withval
)

AC_ARG_WITH(ranlib,
AS_HELP_STRING([--with-ranlib],[Gives the name of the ranlib program.]),
RANLIB=$withval
)

AC_ARG_WITH(ar,
AS_HELP_STRING([--with-ar],[Names the archive creator.]),
AR=$withval
)

ARFLAGS=r
AC_ARG_WITH(ar-flags,
AS_HELP_STRING([--with-ar-flags],[Flags for the the archive creator.]),
ARFLAGS=$withval
)
AC_SUBST(ARFLAGS)

AC_ARG_WITH(ld,
AS_HELP_STRING([--with-ld],[Names the object linker.]),
LD=$withval
)

libintincludedir=$includedir
AC_ARG_WITH(libint-includedir,
AS_HELP_STRING([--with-libint-includedir],[Specifies include file install subdir.]),
libintincludedir=$withval
)
AC_SUBST(libintincludedir)

EXPORTDIR=libint-$LIBINT_VERSION
AC_ARG_WITH(libint-exportdir,
AS_HELP_STRING([--with-libint-exportdir],[Specifies export directory name. Default is libint-<version>.]),
EXPORTDIR=$withval
)
AC_SUBST(EXPORTDIR)

AC_ARG_WITH(incdirs,
AS_HELP_STRING([--with-incdirs],[Specifies include directories (-Idir1 -Idir2).]),
EXTRAINCDIRS=$withval
CPPFLAGS=$withval
echo Using extra include directories: $withval
)

AC_ARG_WITH(libs,
AS_HELP_STRING([--with-libs],[Specifies libraries (-llib1 -llib2).]),
LIBS=$withval
echo Using extra libraries: $withval
)

AC_ARG_WITH(libdirs,
AS_HELP_STRING([--with-libdirs],[Specifies library directories (-Ldir1 -Ldir2).]),
LIBDIRS=$withval
LDFLAGS=$withval
echo Using extra library directories: $withval
)

SCRATCHDIR=tmp
AC_ARG_WITH(scratchdir,
AS_HELP_STRING([--with-scratchdir],[Specifies the location for the machine-generated library source and object files.]),
SCRATCHDIR=$withval
)
AC_SUBST(SCRATCHDIR)

PKGCONFIGDIR='$(libdir)/pkgconfig'
AC_ARG_WITH(pkgconfigdir,
AS_HELP_STRING([--with-pkgconfigdir],[Specifies the location to put pkg-config's data file. Default is $(libdir)/pkgconfig.]),
PKGCONFIGDIR=$withval
)
AC_SUBST(PKGCONFIGDIR)

dnl --------- Want absolute path for srcdir, not relative. ---------

if test X$ac_srcdir_defaulted = Xyes; then
  case $srcdir in
    ..*)
      srcdir=`(cd $srcdir; pwd)`
      #srcdir=`(cd $srcdir; echo $PWD)`
      ;;
  esac
fi

dnl --------- Checks for programs. ---------
AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_PROG_INSTALL

# if not given a C++ compiler
if test "X$CXX" = "X"; then
  AC_CHECK_PROGS(CXX, clang++ icpc xlC_r g++ c++ CC, c++)
fi

# if not given a C++ compiler for generated source, use CXX
if test "X$CXXGEN" = X; then
  CXXGEN=$CXX
fi
AC_SUBST(CXXGEN)

# discard CXXFLAGS provided by the C++ detection macros
initial_CXXFLAGS="$CXXFLAGS"
AC_PROG_CXX
AC_PROG_CXXCPP
CXXFLAGS="$initial_CXXFLAGS"

AC_CHECK_PROG(AR,ar,ar)
AC_CHECK_PROG(PERL,perl,perl)
AC_CHECK_PROGS(TAR,gnutar tar,tar)
AC_CHECK_PROGS(PYTHON,python python3 python2 python2.7,python)
AC_PATH_PROG(DOXYGEN,doxygen,,$PATH:/usr/local/bin:/opt/local/bin)
AC_PATH_PROG(PDFLATEX,pdflatex,,$PATH:/usr/local/bin:/opt/local/bin)
AC_PATH_PROG(PSLATEX,pslatex,,$PATH:/usr/local/bin:/opt/local/bin)
AC_PATH_PROG(DVIPS,dvips,,$PATH:/usr/local/bin:/opt/local/bin)
AC_PATH_PROG(LATEX,latex,,$PATH:/usr/local/bin:/opt/local/bin)
AC_PATH_PROG(LATEX2HTML,latex2html,,$PATH:/usr/local/bin:/opt/local/bin)
AC_PATH_PROG(BIBTEX,bibtex,,$PATH:/usr/local/bin:/opt/local/bin)

dnl The lack of certain tools is a show stopper

changequote(<<, >>)dnl

if [ X$PERL = X ]; then
  echo "Could not find program: perl"
  exit 1
fi
if [ X$PYTHON = X ]; then
  echo "Could not find program: python"
  exit 1
fi

changequote([, ])dnl

dnl -------- Checks for compiler/linker options. ----------

# set the optimization default if neither CXXFLAGS or --with-*-optflags were given
if test "X$CXXFLAGS_OPT" = X -a "X$CXXFLAGS" = X; then
  CXXFLAGS_OPT=-O2
fi
if test "X$CXXGENFLAGS_OPT" = X -a "X$CXXGENFLAGS" = X; then
  AC_MSG_WARN([C++ optimization options are not given! For optimum performance give CXXGENFLAGS or use --with-cxxgen-optflags configure option])
  CXXGENFLAGS_OPT="-O2 -DNDEBUG"
fi
# options needed only for debugging
CXXFLAGS_DBG=-g
# options that are always needed
CXXFLAGS_MISC=

# now form CXXGENFLAGS ...
if test "X$CXXGENFLAGS" = X; then
  CXXGENFLAGS=$CXXFLAGS
fi
if test $DEBUG = yes; then
 CXXGENFLAGS="$CXXGENFLAGS $CXXFLAGS_DBG $CXXFLAGS_MISC"
 LDFLAGS="$LDFLAGS -g"
elif test $DEBUG = opt; then
 CXXGENFLAGS="$CXXGENFLAGS $CXXFLAGS_DBG $CXXGENFLAGS_OPT $CXXFLAGS_MISC"
 LDFLAGS="$LDFLAGS -g"
else
 CXXGENFLAGS="$CXXGENFLAGS $CXXGENFLAGS_OPT $CXXFLAGS_MISC"
fi

# ... and CXXFLAGS
if test $DEBUG = yes; then
 CXXFLAGS="$CXXFLAGS $CXXFLAGS_DBG $CXXFLAGS_MISC"
 LDFLAGS="$LDFLAGS -g"
elif test $DEBUG = opt; then
 CXXFLAGS="$CXXFLAGS $CXXFLAGS_DBG $CXXFLAGS_OPT $CXXFLAGS_MISC"
 LDFLAGS="$LDFLAGS -g"
else
 CXXFLAGS="$CXXFLAGS $CXXFLAGS_OPT $CXXFLAGS_MISC"
fi

OBJSUF=o
LIBSUF=a

dnl -- check how dependency information is built --

# The GNU compilers work with:
CXXDEPENDSUF=none
CXXDEPENDFLAGS=-M

/bin/rm -f depcheck.u depcheck.c depcheck.o

# Check for an IBM visual age C++ compiler
echo "#include <iostream>" > depcheck.cc
$CXX $CPPFLAGS $CXXFLAGS -M -E depcheck.cc > /dev/null 2>&1
if test -f depcheck.u; then
  CXXDEPENDSUF=u
  CXXDEPENDFLAGS="-M -E"
fi
/bin/rm -f depcheck.u depcheck.c depcheck.o

if test "X$CXXDEPEND" = X; then
  CXXDEPEND=$CXX
fi
AC_SUBST(CXXDEPEND)
AC_SUBST(CXXDEPENDSUF)
AC_SUBST(CXXDEPENDFLAGS)

dnl -- special architecture options --

# nothing so far

AC_SUBST(EXTRAINCLUDE)
AC_SUBST(EXTRADEFINES)

AC_SUBST(CXXFLAGS)
AC_SUBST(CXXGENFLAGS)
AC_SUBST(LIBDIRS)
AC_SUBST(LD)
AC_SUBST(LDFLAGS)
AC_SUBST(OBJSUF)
AC_SUBST(LIBSUF)


dnl ---------- Checks for "standard" header files. -----------
AC_CHECK_HEADERS(limits.h stdint.h)

dnl ---------- Check for posix_memalign ----------------------
AC_CHECK_FUNC(posix_memalign,[have_posix_memalign=1 AC_DEFINE(HAVE_POSIX_MEMALIGN)],[have_posix_memalign=0])
if test "X$have_posix_memalign" != "X0"; then
 # control memory alignment if posix_memalign is found 
 # if vectorization is off (default) then let the default alignment be determined by the system
 # if vectorization is on then the default alignment is veclen * sizeof(LIBINT2_REALTYPE)
 # see default_params.cc to see this logic in action
 LIBINT_ALIGN_SIZE=default  # this will be interpreted as "use the default alignment"
 AC_ARG_WITH(align-size,
 AS_HELP_STRING([--with-align-size],[(EXPERT) if posix_memalign is available, this will specify alignment of Libint data, in units of sizeof(LIBINT2_REALTYPE). Default is to use built-in heuristics.]),
  [
   if test "X$withval" != "Xdefault"; then
    LIBINT_ALIGN_SIZE=$withval
    if test $LIBINT_ALIGN_SIZE -lt 1; then
     AC_MSG_ERROR([Invalid alignment: $LIBINT_ALIGN_SIZE])
    fi
   fi
  ]
 )
 if test "X$LIBINT_ALIGN_SIZE" != "Xdefault"; then
  AC_MSG_RESULT([will use custom memory alignment: $LIBINT_ALIGN_SIZE * sizeof(LIBINT2_REALTYPE)])
 else
  LIBINT_ALIGN_SIZE=0
 fi
 AC_DEFINE_UNQUOTED(LIBINT_ALIGN_SIZE, $LIBINT_ALIGN_SIZE)
else # no posix_memalign = death
 echo "did not find posix_memalign ... this SHOULD NOT happen. Cannot proceed."
 exit 1
fi

dnl ------------------ Check for support for C++11 standard features --------------

enable_cpptr1=no   # TR1's array seems to be broken on OS X
acx_with_boost=yes
ACX_CHECK_CPP11

if test "X$acx_have_cxx11" = "Xno"; then
  AC_MSG_ERROR([C++11 support is required to compile the Libint compiler. Obtain a recent C++ compiler that supports C++11 and set CXX to the its path.])
fi

# to support FMA CXXGEN must be able to compile C++11
# NB -std=c++11 is not added to CXXGENFLAGS automatically!
ACX_CHECK_CPP11_CXXGEN
if test "X$CXXGEN_SUPPORTS_CPP11" = "Xno"; then
  AC_MSG_ERROR([C++11 support is required to compile the Libint library. Obtain a recent C++ compiler that supports C++11 and set CXXGEN to the its path.])
fi

dnl ------------------ Check for gmp C++ interface -----------------------
ACX_CHECK_GMPXX

if test "X$acx_have_gmpxx" = "Xno"; then
  AC_MSG_ERROR([cannot link against GMP C++ library. Please get the latest GMP with support for C++. It can be obtained at gmplib.org .])
fi

dnl ---------- Check for optional MPFR library (needed for high-precision testing) --------
AC_ARG_ENABLE(mpfr,
 AS_HELP_STRING([--enable-mpfr],[Use MPFR library to test Libint integrals in high precision.]),
 [
  case $enableval in
   yes)
    AC_CHECK_HEADER(mpfr.h,[
     AC_MSG_CHECKING([if MPFR library is usable])
      LIBS="-lmpfr $LIBS"
      AC_LINK_IFELSE(
       [AC_LANG_PROGRAM(
       [[#include <mpfr.h>
       ]],
       [[
        mpfr_t x;  mpfr_init(x);
       ]]
      )
     ],
     [AC_MSG_RESULT([yes])
      AC_DEFINE(LIBINT_HAS_MPFR)
     ],
     [
      AC_MSG_RESULT([no])
     ]
    )
    ]
   )
   ;;
  esac
 ]
)

dnl ------------------ Check for Boost library -----------------------

dnl Boost.Preprocessor requires 1.57
AX_BOOST_BASE([1.57],, [AC_MSG_ERROR([libint compiler needs Boost 1.57 or later (needs Boost 1.57 if don't want to use bundled Boost.Preprocessor and be able to use clang), download from https://www.boost.org/users/download/ , unpack (no need to install), and add -I/path/to/boost to CPPFLAGS])])
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
# no need to update LDFLAGS: we are not using precompoiled boost

AC_MSG_CHECKING([for variadic macro support in Boost.Preprocessor])
AC_COMPILE_IFELSE(
  [AC_LANG_PROGRAM(
    [[#include <boost/preprocessor.hpp>
      #if not BOOST_PP_VARIADICS  // no variadic macros? your compiler is out of date! (should not be possible since variadic macros are part of C++11)
      #  error "your compiler does not provide variadic macros (but does support C++11), something is seriously broken, please create an issue at https://github.com/evaleev/libint/issues"
      #endif
    ]],
    [[
    ]]
   )
  ],
  [AC_MSG_RESULT([yes])
   AC_DEFINE(LIBINT_HAS_SYSTEM_BOOST_PREPROCESSOR_VARIADICS)
   HAVE_SYSTEM_BOOST_PREPROCESSOR_VARIADICS=1
  ],
  [
    AC_MSG_RESULT([no])
    HAVE_SYSTEM_BOOST_PREPROCESSOR_VARIADICS=0
    AC_MSG_WARN([Boost.Preprocessor with variadic macro support not detected. Will use the bundled Boost.Preprocessor. Download latest boost from https://www.boost.org/users/download/ , unpack (no need to install), and add -I/path/to/boost to CPPFLAGS])
  ]
)
AC_SUBST(HAVE_SYSTEM_BOOST_PREPROCESSOR_VARIADICS)

AC_MSG_CHECKING([for Boost::mpl::for_each])
AC_COMPILE_IFELSE(
  [AC_LANG_PROGRAM(
    [[#include <boost/mpl/list.hpp>
      #include <boost/mpl/for_each.hpp>
      #include <iostream>
      struct P {
      template <class T> void operator()(T x) const { std::cout << x << std::endl; }
      };
    ]],
    [[
      typedef boost::mpl::list<int,double,char> tlist;
      boost::mpl::for_each<tlist>(P());
    ]]
   )
  ],
  [AC_MSG_RESULT([yes])
  ],
  [
    AC_MSG_RESULT([no])
    AC_MSG_ERROR([Boost::mpl is required. Download latest boost from https://www.boost.org/users/download/ , unpack (no need to install), and add -I/path/to/boost to CPPFLAGS])
  ]
)

dnl ------------------ Check for shared_ptr -----------------------

HAVE_SHARED_PTR=no
AC_MSG_CHECKING([for std::shared_ptr])
AC_COMPILE_IFELSE(
  [AC_LANG_PROGRAM(
      [[#include <memory>
      ]],
      [[
        std::shared_ptr<int> a(new int);
        std::shared_ptr<int> b = a;
      ]]
     )
    ],
    [AC_MSG_RESULT([yes])
     HAVE_SHARED_PTR=std
    ],
    [
      AC_MSG_RESULT([no])
    ]
  )

if test "X$HAVE_SHARED_PTR" = "Xno"; then
  AC_MSG_CHECKING([for Boost::shared_ptr])
  AC_COMPILE_IFELSE(
    [AC_LANG_PROGRAM(
      [[#include <boost/shared_ptr.hpp>
      ]],
      [[
       boost::shared_ptr<int> a(new int);
       boost::shared_ptr<int> b = a;
      ]]
     )
    ],
    [AC_MSG_RESULT([yes])
     HAVE_SHARED_PTR=boost
     AC_DEFINE(HAVE_SHARED_PTR_IN_BOOST)
    ],
    [
      AC_MSG_RESULT([no])
      AC_MSG_ERROR([shared_ptr is required. Please download Boost from boost.org or use C++ compiler that supports std::shared_ptr.])
    ]
  )
fi

dnl ------------------ Check for Eigen library -----------------------

ACX_CHECK_EIGEN
if test "X$acx_have_eigen" = "Xyes"; then
  AC_SUBST(LIBINT_HAS_EIGEN,$acx_have_eigen)
fi

dnl -- Checks for typedefs, structures, and compiler characteristics. --
AC_TYPE_SIZE_T
``
CPPFLAGS="$CPPFLAGS" CXX="$CXX" CXXFLAGS="$CXXFLAGS" \
LD="$LD" LDFLAGS="$LDFLAGS" LIBS="-lm $LIBS $FLIBS" \
LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB"

dnl --------- expand some variables -----------
DATADIR_ABSOLUTE=`eval echo $datarootdir`/libint/$LIBINT_VERSION
AC_SUBST(DATADIR_ABSOLUTE)

dnl Check if sources compiled with CXX and CXXGEN can be linked together
CXX_COMPATIBLE_WITH_CXXGEN=yes
if test "X$CXX" != "X$CXXGEN"; then
AC_MSG_CHECKING([[for compatible cxx and cxxgen compilers]])
echo "extern void func1(); int main(int argc, char**argv) { func1(); } " > linkcheck1.cc
echo "void func1() {}" > linkcheck2.cc
$CXX $CPPFLAGS $CXXFLAGS -c linkcheck1.cc > /dev/null 2>&1
$CXXGEN $CPPFLAGS $CXXGENFLAGS -c linkcheck2.cc > /dev/null 2>&1
$LD $LDFLAGS -o linkcheck1 linkcheck1.o linkcheck2.o > /dev/null 2>&1
$CXX $LDFLAGS -o linkcheck2 linkcheck1.o linkcheck2.o > /dev/null 2>&1
$CXXGEN $LDFLAGS -o linkcheck3 linkcheck1.o linkcheck2.o > /dev/null 2>&1
if test -f linkcheck1 -a -f linkcheck2 -a -f linkcheck3; then
  AC_MSG_RESULT([[yes]])
else
  AC_MSG_RESULT([[no]])
  AC_MSG_WARN([[Compilers cxx and cxxgen produce incompatible code! You will not be able to test generated code.]])
  CXX_COMPATIBLE_WITH_CXXGEN=no
fi
/bin/rm -f linkcheck1 linkcheck2 linkcheck3  linkcheck1.cc linkcheck2.cc linkcheck1.o linkcheck2.o
fi

AC_SUBST(CXX_COMPATIBLE_WITH_CXXGEN)

dnl ------------------ Check if real type is given and is usable with CXXGEN -----------------------

AC_ARG_WITH(real-type,
AS_HELP_STRING([--with-real-type],[Compute all integrals using the given real type (default: double).]),
[
AC_DEFINE_UNQUOTED(LIBINT_USER_DEFINED_REAL,"$withval")
libint_user_defined_real=$withval
AC_MSG_RESULT([Using real type: $withval])
])

# extra includes may be needed in that case!
if test "X$libint_user_defined_real" != "X"; then
 copy_CXX=$CXX
 copy_CXXFLAGS=$CXXFLAGS
 CXX=$CXXGEN
 CXXFLAGS=$CXXGENFLAGS
 
 AC_ARG_WITH(real-type-includes,
  AS_HELP_STRING([--with-real-type-includes],[Additional includes necessary to use the real type (default: none).]),
  [
   AC_DEFINE_UNQUOTED(LIBINT_USER_DEFINED_REAL_INCLUDES,"$withval")
   libint_user_defined_real_includes=$withval
  ]
 )

 AC_MSG_CHECKING([if $libint_user_defined_real is usable])
 # by default should look for SIMD vector types in src/lib/libint
 copy2_CXXFLAGS=$CXXFLAGS
 CXXFLAGS="$CXXFLAGS -I$srcdir/include -Iinclude -I$srcdir/src/lib/libint"
 AC_COMPILE_IFELSE(
  [AC_LANG_PROGRAM(
    [[#include <libint2/util/vector.h>
      $libint_user_defined_real_includes
      
    ]],
    [[
     $libint_user_defined_real x1;
     $libint_user_defined_real x2 = 2.0;
     $libint_user_defined_real x3 = x2;
     $libint_user_defined_real x4 = x2 + x3;
     $libint_user_defined_real x5 = x2 - x3;
     $libint_user_defined_real x6 = x2 * x3;
     $libint_user_defined_real x7 = 2 * x2;
     $libint_user_defined_real x8 = x2 * 3;
     x6 += x2 * x3;
     x7 -= 3 * x3;
    ]]
   )
  ],
  [AC_MSG_RESULT([yes])
   CXXFLAGS=$copy2_CXXFLAGS
  ],
  [AC_MSG_RESULT([no])
   AC_MSG_ERROR([[real type $libint_user_defined_real is not usable, perhaps extra -I directories or extra #include's are needed?]])
  ]
 )
 
 # CXXFLAGS may have changed
 CXXGENFLAGS=$CXXFLAGS
 CXX=$copy_CXX
 CXXFLAGS=$copy_CXXFLAGS
fi

dnl --------- Shared library configuration. ---------

dnl by default make only static libraries
LT_INIT([disable-shared])
LT_LANG([C++])
OBJSUF=lo
LIBSUF=la
ENABLESHARED=yes
AC_SUBST(ENABLESHARED)

dnl -- configure tester --
TESTER_ARGS="(\"1 0 1 0 0\", \"1 0 1 0 10000\", \"1 1 1 1 0\", \"1 1 1 1 10000\", \"2 0 2 0 0\", \"2 1 2 0 10000\", \"1 1 1 1 10000 16 0\", \"1 1 1 1 10000 16 1\", \"1 1 1 1 10000 1 1\", \"1 1 1 1 0 16 0\", \"1 1 1 1 0 16 1\", \"1 1 1 1 10000 16 0 1\")"
TESTER_ARGS_LONG="(\"3 0 3 0 10000\", \"4 0 4 0 10000\", \"2 2 2 2 0\", \"2 2 2 2 10000\")"
AC_SUBST(TESTER_ARGS)
AC_SUBST(TESTER_ARGS_LONG)

dnl -- make Makefiles in object tree --
$PERL $srcdir/bin/objectdir.pl $EXCLUDED_DIRS $srcdir

AC_CONFIG_FILES([src/bin/test_eri/test_eri.pl],[chmod +x src/bin/test_eri/test_eri.pl])
AC_CONFIG_FILES([src/bin/test_eri/time_eri.pl],[chmod +x src/bin/test_eri/time_eri.pl])
AC_CONFIG_FILES([src/bin/test_eri/run_time_eri.pl],[chmod +x src/bin/test_eri/run_time_eri.pl])
AC_CONFIG_FILES([src/bin/test_eri/stdtests.pl],[chmod +x src/bin/test_eri/stdtests.pl])
AC_CONFIG_FILES([src/bin/test_eri/run_timing_suite.pl],[chmod +x src/bin/test_eri/run_timing_suite.pl])
AC_CONFIG_FILES(src/bin/MakeVars src/lib/MakeVars src/lib/MakeRules src/lib/libint/MakeVars.features
                tests/MakeVars
                doc/MakeVars doc/MakeRules doc/progman/macros.tex doc/classdoc/doxygen.cfg
                include/libint2/basis.h libint2.pc)

dnl --------- Done! ---------
AC_OUTPUT