-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
acinclude.m4
1549 lines (1436 loc) · 49.9 KB
/
acinclude.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
AC_DEFUN([KSW_IS_PROFILE],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(for profile)
AC_ARG_ENABLE([profile],
[ --enable-profile=yes/no/core Specify "yes" or "core" to enable profiling.])
is_profile=no
PROFILE=
CORE_PROFILE=
if test x"$enable_profile" = xyes; then
PROFILE=-pg
CORE_PROFILE=-pg
is_profile=yes
elif test x"$enable_profile" = xcore; then
CORE_PROFILE=-pg
is_profile="yes (core)"
fi
AC_DEFINE( [PROFILE], [], [Define to include profiling information] )
AC_DEFINE( [CORE_PROFILE], [], [Define to include core profiling information] )
AC_MSG_RESULT($is_profile)
])
AC_DEFUN([KSW_IS_DEBUG],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(for debug)
AC_ARG_ENABLE([debug],
[ --enable-debug=yes/no/cov Specify "yes" to enable a debug build.])
is_debug=no
enable_debug_save_COVFLAGS="${COVFLAGS}"
enable_debug_save_COVLFLAGS="${COVLFLAGS}"
enable_debug_save_CFLAGS="${CFLAGS}"
enable_debug_save_CXXFLAGS="${CXXFLAGS}"
enable_debug_save_LDFLAGS="${LDFLAGS}"
if test x"$enable_debug" = xyes; then
COVFLAGS=""
COVLFLAGS=""
COMMONFLAGS="-g -fPIC"
CFLAGS="${COMMONFLAGS} ${CFLAGS}"
CXXFLAGS="${COMMONFLAGS} -std=c++11 ${CXXFLAGS}"
LDFLAGS="${LDFLAGS}"
elif test x"$enable_debug" = xcov; then
COVFLAGS="-coverage"
COVLFLAGS="-lgcov"
COMMONFLAGS="-g -fPIC"
CFLAGS="${COMMONFLAGS} ${CFLAGS}"
CXXFLAGS="${COMMONFLAGS} -std=c++11 ${CXXFLAGS}"
LDFLAGS="${LDFLAGS}"
is_debug=coverage
else
omit_frame=
# FIXME?: Using -fomit-frame-pointer causes SEGFAULT at start up on macOS 10.11 using clang++.
#if test x"${CORE_PROFILE}" = "x"; then
# omit_frame="-fomit-frame-pointer"
#fi
COVFLAGS=""
COVLFLAGS=""
COMMONFLAGS="-O2 ${omit_frame} -fno-math-errno -fPIC"
CFLAGS="${COMMONFLAGS} ${CFLAGS}"
CXXFLAGS="${COMMONFLAGS} -std=c++11 ${CXXFLAGS}"
LDFLAGS="${omit_frame} -fno-math-errno ${LDFLAGS}"
fi
AC_TRY_LINK([#include <stdio.h>], , [
dnl Yay!
if test x"$enable_debug" = xyes; then
AC_DEFINE( [CODE_DEBUG], [], [Define to include debugging information] )
is_debug=yes
fi
], [
dnl Boo!
if test x"$enable_debug" != xyes; then
COVFLAGS="${enable_debug_save_COVFLAGS}"
COVLFLAGS="${enable_debug_save_COVLFLAGS}"
CFLAGS="${enable_debug_save_CFLAGS}"
CXXFLAGS="${enable_debug_save_CXXFLAGS}"
LDFLAGS="${enable_debug_save_LDFLAGS}"
AC_DEFINE( [CODE_DEBUG], [], [Define to include debugging information] )
is_debug=yes
else
COVFLAGS="${enable_debug_save_COVFLAGS}"
COVLFLAGS="${enable_debug_save_COVLFLAGS}"
CFLAGS="${enable_debug_save_CFLAGS}"
CXXFLAGS="${enable_debug_save_CXXFLAGS}"
LDFLAGS="${enable_debug_save_LDFLAGS}"
fi
])
AC_SUBST(COVFLAGS)
AC_SUBST(COVLFLAGS)
AC_MSG_RESULT($is_debug)
])
dnl for lua (KSW was here)
AC_DEFUN([KSW_HAVE_LUA],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(for lua)
AC_ARG_WITH([lua-dir],
[ --with-lua-dir=DIR DIR is equal to the install prefix of Lua.
Header files are in DIR/include, and Library
files are in DIR/lib])
AC_ARG_WITH([lua-include-dir],
[ --with-lua-include-dir=DIR
Lua header files are in DIR])
AC_ARG_WITH([lua-lib-dir],
[ --with-lua-lib-dir=DIR Lua libraries are in DIR])
AC_ARG_WITH([lua-lib],
[ --with-lua-lib=LIB Use -lLIB to link with the lua library])
if test x"$with_lua_dir" = x &&
test x"$with_lua_include_dir" = x &&
test x"$with_lua_lib_dir" = x &&
test x"$with_lua_lib" = x; then
# user did not request Lua support, disable it
have_lua="disabled"
else
# "yes" is a bogus option
if test x"$with_lua_dir" = xyes; then
with_lua_dir=
fi
if test x"$with_lua_include_dir" = xyes; then
with_lua_include_dir=
fi
if test x"$with_lua_lib_dir" = xyes; then
with_lua_lib_dir=
fi
if test x"$with_lua_lib" = xyes; then
with_lua_lib=
fi
# No lua unless we discover otherwise
have_lua=no
# Check whether we are requested to link with a specific version
if test x"$with_lua_lib" != x; then
ksw_lua_lib="$with_lua_lib"
fi
# Check whether we were supplied with an answer already
if test x"$with_lua_dir" != x; then
have_lua=yes
ksw_lua_dir="$with_lua_dir"
ksw_lua_include_dir="$with_lua_dir/include"
if test -d "$with_lua_dir/lib64" ; then
ksw_lua_lib_dir="$with_lua_dir/lib64"
else
ksw_lua_lib_dir="$with_lua_dir/lib"
fi
# Only search for the lib if the user did not define one already
if test x"$ksw_lua_lib" = x; then
ksw_lua_lib="`ls $ksw_lua_lib_dir/liblua5* 2> /dev/null | sed -n 1p |
sed s@$ksw_lua_lib_dir/lib@@ | [sed s@[.].*@@]`"
fi
if test x"$ksw_lua_lib" = x; then
ksw_lua_lib="`ls $ksw_lua_lib_dir/liblua.* 2> /dev/null | sed -n 1p |
sed s@$ksw_lua_lib_dir/lib@@ | [sed s@[.].*@@]`"
fi
ksw_lua_LIBS="-L$ksw_lua_lib_dir -l$ksw_lua_lib -lm -ldl"
else
# Use cached value or do search, starting with suggestions from
# the command line
AC_CACHE_VAL(ksw_cv_have_lua,
[
# We are not given a solution and there is no cached value.
ksw_lua_dir=
if test x"$ksw_lua_include_dir" = x; then
ksw_lua_include_dir="`ls -dr /usr/include/lua.h /usr/local/include/lua.h /usr/include/lua*/lua.h /usr/local/include/lua*/lua.h 2> /dev/null | sed -n 1p |
sed s@/lua.h@@`"
fi
if test x"$ksw_lua_lib" = x; then
ksw_lua_lib_dir="`ls -dr /usr/lib64/liblua5* /usr/lib64/liblua.* /usr/local/lib64/liblua5* /usr/local/lib64/liblua.* /usr/lib/liblua5* /usr/lib/liblua.* /usr/local/lib/liblua5* /usr/local/lib/liblua.* 2> /dev/null | sed -n 1p`"
ksw_lua_lib="`echo $ksw_lua_lib_dir | sed 's@/.*/@@' `"
ksw_lua_lib_dir="`echo $ksw_lua_lib_dir | sed s@/$ksw_lua_lib@@ `"
ksw_lua_lib="`echo $ksw_lua_lib | [sed s@[.].*@@] | sed s@^lib@@ `"
fi
if test x"$ksw_lua_lib" != x; then
if test x"$ksw_lua_lib_dir" = x; then
ksw_lua_LIBS="-l$ksw_lua_lib -lm -ldl"
else
ksw_lua_LIBS="-L$ksw_lua_lib_dir -l$ksw_lua_lib -lm -ldl"
fi
# Record where we found lua for the cache.
ksw_cv_have_lua="have_lua=yes \
ksw_lua_dir=$ksw_lua_dir \
ksw_lua_include_dir=$ksw_lua_include_dir \
ksw_lua_LIBS=\"$ksw_lua_LIBS\""
fi
])dnl
eval "$ksw_cv_have_lua"
fi # all $ksw_lua_* are set
fi # $have_lua reflects the system status
if test x"$have_lua" = xyes; then
LUA_CCFLAGS="-I$ksw_lua_include_dir"
LUA_DIR="$ksw_lua_dir"
LUA_LIBS="$ksw_lua_LIBS"
# All variables are defined, report the result
AC_DEFINE( [HAVE_LUA], [], [Define when you have Lua installed] )
AC_MSG_RESULT([$have_lua:
LUA_CCFLAGS=$LUA_CCFLAGS
LUA_DIR=$LUA_DIR
LUA_LIBS=$LUA_LIBS ])
else
# lua was not found
LUA_CCFLAGS=
LUA_DIR=
LUA_LIBS=
AC_MSG_RESULT($have_lua)
fi
AC_SUBST(LUA_CCFLAGS)
AC_SUBST(LUA_DIR)
AC_SUBST(LUA_LIBS)
#### Being paranoid:
if test x"$have_lua" = xyes; then
AC_MSG_CHECKING(correct functioning of lua installation)
AC_CACHE_VAL(ksw_cv_lua_test_result,
[
cat > ksw_lua_test.h << EOF
EOF
cat > ksw_lua_test.c << EOF
#include "ksw_lua_test.h"
#include <lua.h>
#include <lauxlib.h>
//#include <lualib.h>
int main( int argc, char **argv )
{
lua_State * L = luaL_newstate();
//luaopen_math( L );
lua_close( L );
return( 0 );
}
EOF
ksw_cv_lua_test_result="failure"
ksw_try_1="$CC $LUA_CCFLAGS $LUA_LIBS -o ksw_lua_test ksw_lua_test.c >/dev/null 2>ksw_lua_test_1.out"
AC_TRY_EVAL(ksw_try_1)
ksw_err_1=`grep -v '^ *+' ksw_lua_test_1.out | grep -v "^ksw_lua_test.{$ac_ext}\$"`
if test x"$ksw_err_1" != x; then
echo "$ksw_err_1" >&AC_FD_CC
echo "configure: could not compile:" >&AC_FD_CC
cat ksw_lua_test.c >&AC_FD_CC
else
ksw_cv_lua_test_result="success"
fi
])dnl AC_CACHE_VAL ksw_cv_lua_test_result
AC_MSG_RESULT([$ksw_cv_lua_test_result]);
if test x"$ksw_cv_lua_test_result" = "xfailure"; then
AC_MSG_ERROR([Failed to find matching components of a complete
lua installation. Try using more options,
see ./configure --help.])
fi
rm -f ksw_lua_test.h \
ksw_lua_test.c ksw_lua_test.o ksw_lua_test \
ksw_lua_test_1.out
fi
])
dnl for lualib (KSW was here)
AC_DEFUN([KSW_HAVE_LUALIB],
[
if test x"${LUA_LIBS}" != x; then
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([KSW_HAVE_LUA])
AC_MSG_CHECKING(for lualib)
AC_ARG_WITH([lualib-dir],
[ --with-lualib-dir=DIR DIR is equal to the install prefix of Lualib.
Header files are in DIR/include, and Library
files are in DIR/lib])
AC_ARG_WITH([lualib-include-dir],
[ --with-lualib-include-dir=DIR
Lua header files are in DIR])
AC_ARG_WITH([lualib-lib-dir],
[ --with-lualib-lib-dir=DIR Lua libraries are in DIR])
AC_ARG_WITH([lualib-lib],
[ --with-lualib-lib=LIB Use -lLIB to link with the lualib library])
if test x"$with_lualib_dir" = x"no" ||
test x"$with_lualib_include_dir" = x"no" ||
test x"$with_lualib_lib_dir" = x"no" ||
test x"$with_lualib_lib" = x"no"; then
# user disabled lualib. Leave cache alone.
have_lualib="User disabled lualib."
else
# "yes" is a bogus option
if test x"$with_lualib_dir" = xyes; then
with_lualib_dir=
fi
if test x"$with_lualib_include_dir" = xyes; then
with_lualib_include_dir=
fi
if test x"$with_lualib_lib_dir" = xyes; then
with_lualib_lib_dir=
fi
if test x"$with_lualib_lib" = xyes; then
with_lualib_lib=
fi
# No lualib unless we discover otherwise
have_lualib=no
# Check whether we are requested to link with a specific version
if test x"$with_lualib_lib" != x; then
ksw_lualib_lib="$with_lualib_lib"
fi
# Check whether we were supplied with an answer already
if test x"$with_lualib_dir" != x; then
have_lualib=yes
ksw_lualib_dir="$with_lualib_dir"
ksw_lualib_include_dir="$with_lualib_dir/include"
if test -d "$with_lualib_dir/lib64" ; then
ksw_lualib_lib_dir="$with_lualib_dir/lib64"
else
ksw_lualib_lib_dir="$with_lualib_dir/lib"
fi
# Only search for the lib if the user did not define one already
if test x"$ksw_lualib_lib" = x; then
ksw_lualib_lib="`ls $ksw_lualib_lib_dir/liblualib5* 2> /dev/null | sed -n 1p |
sed s@$ksw_lualib_lib_dir/lib@@ | [sed s@[.].*@@]`"
fi
if test x"$ksw_lualib_lib" = x; then
ksw_lualib_lib="`ls $ksw_lualib_lib_dir/liblualib.* 2> /dev/null | sed -n 1p |
sed s@$ksw_lualib_lib_dir/lib@@ | [sed s@[.].*@@]`"
fi
ksw_lualib_LIBS="-L$ksw_lualib_lib_dir -l$ksw_lualib_lib"
else
# Use cached value or do search, starting with suggestions from
# the command line
AC_CACHE_VAL(ksw_cv_have_lualib,
[
# We are not given a solution and there is no cached value.
ksw_lualib_dir=
if test x"$ksw_lualib_include_dir" = x; then
ksw_lualib_include_dir="`ls -dr /usr/include/lualib.h /usr/local/include/lualib.h /usr/include/lua*/lualib.h /usr/local/include/lua*/lualib.h 2> /dev/null | sed -n 1p |
sed s@/lualib.h@@`"
fi
if test x"$ksw_lualib_lib" = x; then
ksw_lualib_lib_dir="`ls -dr /usr/lib64/liblualib5* /usr/lib64/liblualib.* /usr/local/lib64/liblualib5* /usr/local/lib64/liblualib.* /usr/lib/liblualib5* /usr/lib/liblualib.* /usr/local/lib/liblualib5* /usr/local/lib/liblualib.* 2> /dev/null | sed -n 1p`"
ksw_lualib_lib="`echo $ksw_lualib_lib_dir | sed 's@/.*/@@' `"
ksw_lualib_lib_dir="`echo $ksw_lualib_lib_dir | sed s@/$ksw_lualib_lib@@ `"
ksw_lualib_lib="`echo $ksw_lualib_lib | [sed s@[.].*@@] | sed s@^lib@@ `"
fi
if test x"$ksw_lualib_lib" != x; then
if test x"$ksw_lualib_lib_dir" = x; then
ksw_lualib_LIBS="-l$ksw_lualib_lib"
else
ksw_lualib_LIBS="-L$ksw_lualib_lib_dir -l$ksw_lualib_lib"
fi
# Record where we found lualib for the cache.
ksw_cv_have_lualib="have_lualib=yes \
ksw_lualib_dir=$ksw_lualib_dir \
ksw_lualib_include_dir=$ksw_lualib_include_dir \
ksw_lualib_LIBS=\"$ksw_lualib_LIBS\""
fi
])dnl
eval "$ksw_cv_have_lualib"
fi # all $ksw_lualib_* are set
fi # $have_lualib reflects the system status
if test x"$have_lualib" = xyes; then
LUALIB_CCFLAGS="-I$ksw_lualib_include_dir"
LUALIB_DIR="$ksw_lualib_dir"
LUALIB_LIBS="-lm -ldl $LUA_LIBS $ksw_lualib_LIBS"
# All variables are defined, report the result
AC_DEFINE( [HAVE_LUALIB], [], [Define when you have Lua libs installed] )
AC_MSG_RESULT([$have_lualib:
LUALIB_CCFLAGS=$LUALIB_CCFLAGS
LUALIB_DIR=$LUALIB_DIR
LUALIB_LIBS=$LUALIB_LIBS ])
else
# lualib was not found
LUALIB_CCFLAGS=
LUALIB_DIR=
LUALIB_LIBS=
AC_MSG_RESULT($have_lualib)
fi
AC_SUBST(LUALIB_CCFLAGS)
AC_SUBST(LUALIB_DIR)
AC_SUBST(LUALIB_LIBS)
#### Being paranoid:
if test x"$have_lualib" = xyes; then
AC_MSG_CHECKING(correct functioning of lualib installation)
AC_CACHE_VAL(ksw_cv_lualib_test_result,
[
cat > ksw_lualib_test.h << EOF
EOF
cat > ksw_lualib_test.c << EOF
#include "ksw_lualib_test.h"
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
int main( int argc, char **argv )
{
lua_State * L = luaL_newstate();
luaopen_math( L );
lua_close( L );
return( 0 );
}
EOF
ksw_cv_lualib_test_result="failure"
ksw_try_1="$CC $LUALIB_CCFLAGS $LUALIB_LIBS -o ksw_lualib_test ksw_lualib_test.c >/dev/null 2>ksw_lualib_test_1.out"
AC_TRY_EVAL(ksw_try_1)
ksw_err_1=`grep -v '^ *+' ksw_lualib_test_1.out | grep -v "^ksw_lualib_test.{$ac_ext}\$"`
if test x"$ksw_err_1" != x; then
echo "$ksw_err_1" >&AC_FD_CC
echo "configure: could not compile:" >&AC_FD_CC
cat ksw_lualib_test.c >&AC_FD_CC
else
ksw_cv_lualib_test_result="success"
fi
])dnl AC_CACHE_VAL ksw_cv_lualib_test_result
AC_MSG_RESULT([$ksw_cv_lualib_test_result]);
if test x"$ksw_cv_lualib_test_result" = "xfailure"; then
AC_MSG_ERROR([Failed to find matching components of a complete
lualib installation. Try using more options,
see ./configure --help.])
fi
rm -f ksw_lualib_test.h \
ksw_lualib_test.c ksw_lualib_test.o ksw_lualib_test \
ksw_lualib_test_1.out
fi
fi
])
dnl for Qt (KSW was here)
AC_DEFUN([BNV_HAVE_QT],
[
dnl THANKS! This code includes bug fixes by:
dnl Tim McClarren.
AC_REQUIRE([AC_PROG_CXX])
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING(for Qt)
AC_ARG_WITH([Qt-dir],
[ --with-Qt-dir=DIR DIR is equal to \$QTDIR if you have followed the
installation instructions of Trolltech. Header
files are in DIR/include, binary utilities are
in DIR/bin, the library is in DIR/lib, and the
translations are in DIR/translations])
AC_ARG_WITH([Qt-include-dir],
[ --with-Qt-include-dir=DIR
Qt header files are in DIR])
AC_ARG_WITH([Qt-bin-dir],
[ --with-Qt-bin-dir=DIR Qt utilities such as moc and uic are in DIR])
AC_ARG_WITH([Qt-lib-dir],
[ --with-Qt-lib-dir=DIR The Qt library is in DIR])
AC_ARG_WITH([Qt-translations-dir],
[ --with-Qt-translations-dir=DIR The Qt translations are in DIR])
bnv_is_qt5=no
if test x"$is_osx" = xyes; then
bnv_qt5_libs="-framework QtCore -framework QtGui -framework QtWidgets"
else
bnv_qt5_libs="-lQt5Core -lQt5Gui -lQt5Widgets"
fi
if test x"$with_Qt_dir" = x"no" ||
test x"$with_Qt_include_dir" = x"no" ||
test x"$with_Qt_bin_dir" = x"no" ||
test x"$with_Qt_lib_dir" = x"no" ||
test x"$with_Qt_translations_dir" = x"no"; then
# user disabled Qt. Leave cache alone.
have_qt="User disabled Qt."
else
# "yes" is a bogus option
if test x"$with_Qt_dir" = xyes; then
with_Qt_dir=
fi
if test x"$with_Qt_include_dir" = xyes; then
with_Qt_include_dir=
fi
if test x"$with_Qt_bin_dir" = xyes; then
with_Qt_bin_dir=
fi
if test x"$with_Qt_lib_dir" = xyes; then
with_Qt_lib_dir=
fi
if test x"$with_Qt_translations_dir" = xyes; then
with_Qt_translations_dir=
fi
# No Qt unless we discover otherwise
have_qt=no
# Check whether we were supplied with an answer already
if test x"$with_Qt_dir" != x; then
have_qt=yes
bnv_qt_dir="$with_Qt_dir"
bnv_qt_include_dir="$with_Qt_dir/include"
bnv_qt_bin_dir="$with_Qt_dir/bin"
if test -d "$with_Qt_dir/lib64" ; then
bnv_qt_lib_dir="$with_Qt_dir/lib64"
else
bnv_qt_lib_dir="$with_Qt_dir/lib"
fi
bnv_qt_translations_dir="$with_Qt_dir/translations"
if test x"$is_osx" = xyes; then
bnv_qt_LIBS="-F$bnv_qt_dir/lib -L$bnv_qt_lib_dir $bnv_qt5_libs "
else
bnv_qt_LIBS="-L$bnv_qt_lib_dir $bnv_qt5_libs "
fi
else
# Use cached value or do search, starting with suggestions from
# the command line
AC_CACHE_VAL(bnv_cv_have_qt,
[
# We are not given a solution and there is no cached value.
bnv_qt_dir=NO
bnv_qt_include_dir=NO
bnv_qt_lib_dir=NO
bnv_qt_translations_dir=
BNV_PATH_QT_DIRECT
if test "$bnv_qt_dir" = NO ||
test "$bnv_qt_include_dir" = NO ||
test "$bnv_qt_lib_dir" = NO; then
# Problem with finding complete Qt. Cache the known absence of Qt.
bnv_cv_have_qt="have_qt=no"
else
# Record where we found Qt for the cache.
bnv_cv_have_qt="have_qt=yes \
bnv_qt_dir=$bnv_qt_dir \
bnv_qt_include_dir=$bnv_qt_include_dir \
bnv_qt_bin_dir=$bnv_qt_bin_dir \
bnv_qt_translations_dir=$bnv_qt_translations_dir \
bnv_is_qt5=$bnv_is_qt5 \
bnv_qt_LIBS=\"$bnv_qt_LIBS\""
fi
])dnl
eval "$bnv_cv_have_qt"
fi # all $bnv_qt_* are set
fi # $have_qt reflects the system status
if test x"$have_qt" = xyes; then
if test x"$is_osx" = xyes; then
QT_CXXFLAGS="-I$bnv_qt_include_dir -F$bnv_qt_dir/lib"
else
QT_CXXFLAGS="-I$bnv_qt_include_dir"
fi
QT_DIR="$bnv_qt_dir"
QT_TRANSLATIONS_DIR="$bnv_qt_translations_dir"
QT_LIBS="$bnv_qt_LIBS"
if test x"$bnv_qt_bin_dir" != x; then
# We were told where to look for the utilities?
# UIC detection
if test -x "$bnv_qt_bin_dir/uic"; then
QT_UIC="$bnv_qt_bin_dir/uic"
fi
# MOC detection
if test -x "$bnv_qt_bin_dir/moc"; then
QT_MOC="$bnv_qt_bin_dir/moc"
fi
# RCC detection
if test -x "$bnv_qt_bin_dir/rcc"; then
QT_RCC="$bnv_qt_bin_dir/rcc"
fi
# LRELEASE detection
if test -x "$bnv_qt_bin_dir/lrelease"; then
QT_LRELEASE="$bnv_qt_bin_dir/lrelease"
fi
# LCONVERT detection
if test -x "$bnv_qt_bin_dir/lconvert"; then
QT_LCONVERT="$bnv_qt_bin_dir/lconvert"
fi
# MACDEPLOYQT detection
if test -x "$bnv_qt_bin_dir/macdeployqt"; then
QT_MACDEPLOYQT="$bnv_qt_bin_dir/macdeployqt"
fi
elif test x"$bnv_qt_dir" != x; then
# If bnv_qt_dir is defined, utilities are expected to be in the
# bin subdirectory
# UIC detection
if test -x "$bnv_qt_dir/bin/uic"; then
QT_UIC="$bnv_qt_dir/bin/uic"
fi
# MOC detection
if test -x "$bnv_qt_dir/bin/moc"; then
QT_MOC="$bnv_qt_dir/bin/moc"
fi
# RCC detection
if test -x "$bnv_qt_dir/bin/rcc"; then
QT_RCC="$bnv_qt_dir/bin/rcc"
fi
# LRELEASE detection
if test -x "$bnv_qt_dir/bin/lrelease"; then
QT_LRELEASE="$bnv_qt_dir/bin/lrelease"
fi
# LCONVERT detection
if test -x "$bnv_qt_dir/bin/lconvert"; then
QT_LCONVERT="$bnv_qt_dir/bin/lconvert"
fi
# MACDEPLOYQT detection
if test -x "$bnv_qt_dir/bin/macdeployqt"; then
QT_MACDEPLOYQT="$bnv_qt_dir/bin/macdeployqt"
fi
fi
# If binaries are still not set, try /usr/lib/x86_64-linux-gnu/qt5/bin/
if test x"$host_alias" != x; then
# set by configure --host
bnv_qt_lib_host=$host_alias
else
bnv_qt_lib_host=`$SHELL "$srcdir/config.guess" | cut -d'-' -f 1,3-4`
fi
if test x"$QT_UIC" = x; then
# UIC detection
if test -x "/usr/lib/$bnv_qt_lib_host/qt5/bin/uic"; then
QT_UIC="/usr/lib/$bnv_qt_lib_host/qt5/bin/uic"
fi
fi
if test x"$QT_MOC" = x; then
# MOC detection
if test -x "/usr/lib/$bnv_qt_lib_host/qt5/bin/moc"; then
QT_MOC="/usr/lib/$bnv_qt_lib_host/qt5/bin/moc"
fi
fi
if test x"$QT_RCC" = x; then
# RCC detection
if test -x "/usr/lib/$bnv_qt_lib_host/qt5/bin/rcc"; then
QT_RCC="/usr/lib/$bnv_qt_lib_host/qt5/bin/rcc"
fi
fi
if test x"$QT_LRELEASE" = x; then
# LRELEASE detection
if test -x "/usr/lib/$bnv_qt_lib_host/qt5/bin/lrelease"; then
QT_LRELEASE="/usr/lib/$bnv_qt_lib_host/qt5/bin/lrelease"
fi
fi
if test x"$QT_LCONVERT" = x; then
# LCONVERT detection
if test -x "/usr/lib/$bnv_qt_lib_host/qt5/bin/lconvert"; then
QT_LCONVERT="/usr/lib/$bnv_qt_lib_host/qt5/bin/lconvert"
fi
fi
if test x"$QT_MACDEPLOYQT" = x; then
# MACDEPLOYQT detection
if test -x "/usr/lib/$bnv_qt_lib_host/qt5/bin/macdeployqt"; then
QT_MACDEPLOYQT="/usr/lib/$bnv_qt_lib_host/qt5/bin/macdeployqt"
fi
fi
# If binaries are still not set, try -qt5 suffix (Fedora)
if test x"$QT_UIC" = x; then
# UIC detection
if test `which uic-qt5 2> /dev/null`; then
QT_UIC="uic-qt5"
fi
fi
if test x"$QT_MOC" = x; then
# MOC detection
if test `which moc-qt5 2> /dev/null`; then
QT_MOC="moc-qt5"
fi
fi
if test x"$QT_RCC" = x; then
# RCC detection
if test `which rcc-qt5 2> /dev/null`; then
QT_RCC="rcc-qt5"
fi
fi
if test x"$QT_LRELEASE" = x; then
# LRELEASE detection
if test `which lrelease-qt5 2> /dev/null`; then
QT_LRELEASE="lrelease-qt5"
fi
fi
if test x"$QT_LCONVERT" = x; then
# LCONVERT detection
if test `which lconvert-qt5 2> /dev/null`; then
QT_LCONVERT="lconvert-qt5"
fi
fi
if test x"$QT_MACDEPLOYQT" = x; then
# MACDEPLOYQT detection
if test `which macdeployqt-qt5 2> /dev/null`; then
QT_MACDEPLOYQT="macdeployqt-qt5"
fi
fi
# If binaries are still not set, try qtchooser
qtchoosertoolsdir=
if test `which qtchooser 2> /dev/null`; then
# Example of "qtchooser -qt=5 -print-env" output:
# QT_SELECT="5"
# QTTOOLDIR="/usr/lib/qt5/bin"
# QTLIBDIR="/usr/lib/x86_64-linux-gnu"
qtchoosertoolsdir=$(qtchooser -qt=5 -print-env | grep QTTOOLDIR | cut -d\" -f2)
fi
if test x"$qtchoosertoolsdir" != x; then
if test x"$QT_UIC" = x; then
# UIC detection
if test -x "$qtchoosertoolsdir/uic"; then
QT_UIC="$qtchoosertoolsdir/uic"
fi
fi
if test x"$QT_MOC" = x; then
# MOC detection
if test -x "$qtchoosertoolsdir/moc"; then
QT_MOC="$qtchoosertoolsdir/moc"
fi
fi
if test x"$QT_RCC" = x; then
# RCC detection
if test -x "$qtchoosertoolsdir/rcc"; then
QT_RCC="$qtchoosertoolsdir/rcc"
fi
fi
if test x"$QT_LRELEASE" = x; then
# LRELEASE detection
if test -x "$qtchoosertoolsdir/lrelease"; then
QT_LRELEASE="$qtchoosertoolsdir/lrelease"
fi
fi
if test x"$QT_LCONVERT" = x; then
# LCONVERT detection
if test -x "$qtchoosertoolsdir/lconvert"; then
QT_LCONVERT="$qtchoosertoolsdir/lconvert"
fi
fi
if test x"$QT_MACDEPLOYQT" = x; then
# MACDEPLOYQT detection
if test -x "$qtchoosertoolsdir/macdeployqt"; then
QT_MACDEPLOYQT="$qtchoosertoolsdir/macdeployqt"
fi
fi
fi
# If binaries are still not set, try $PATH
if test x"$QT_UIC" = x; then
# UIC detection
if test `which uic 2> /dev/null`; then
QT_UIC=`which uic`
fi
fi
if test x"$QT_MOC" = x; then
# MOC detection
if test `which moc 2> /dev/null`; then
QT_MOC=`which moc`
fi
fi
if test x"$QT_RCC" = x; then
# RCC detection
if test `which rcc 2> /dev/null`; then
QT_RCC=`which rcc`
fi
fi
if test x"$QT_LRELEASE" = x; then
# LRELEASE detection
if test `which lrelease 2> /dev/null`; then
QT_LRELEASE=`which lrelease`
fi
fi
if test x"$QT_LCONVERT" = x; then
# LCONVERT detection
if test `which lconvert 2> /dev/null`; then
QT_LCONVERT=`which lconvert`
fi
fi
if test x"$QT_MACDEPLOYQT" = x; then
# MACDEPLOYQT detection
if test `which macdeployqt 2> /dev/null`; then
QT_MACDEPLOYQT=`which macdeployqt`
fi
fi
# If binaries are still not set, fail
QT_MISSING_TOOLS=
if test x"$QT_UIC" = x; then
have_qt=no
QT_MISSING_TOOLS="$QT_MISSING_TOOLS uic"
fi
if test x"$QT_MOC" = x; then
have_qt=no
QT_MISSING_TOOLS="$QT_MISSING_TOOLS moc"
fi
if test x"$QT_RCC" = x; then
have_qt=no
QT_MISSING_TOOLS="$QT_MISSING_TOOLS rcc"
fi
if test x"$QT_LRELEASE" = x; then
have_qt=no
QT_MISSING_TOOLS="$QT_MISSING_TOOLS lrelease"
fi
if test x"$QT_LCONVERT" = x; then
have_qt=no
QT_MISSING_TOOLS="$QT_MISSING_TOOLS lconvert"
fi
# Allow macdeployqt to be absent
if test x"$QT_MACDEPLOYQT" = x; then
QT_MACDEPLOYQT="macdeployqt"
fi
# All variables are defined, report the result
AC_MSG_RESULT([$have_qt:
QT_CXXFLAGS=$QT_CXXFLAGS
QT_DIR=$QT_DIR
QT_TRANSLATIONS_DIR=$QT_TRANSLATIONS_DIR
QT_LIBS=$QT_LIBS
QT_UIC=$QT_UIC
QT_MOC=$QT_MOC
QT_RCC=$QT_RCC
QT_LRELEASE=$QT_LRELEASE
QT_LCONVERT=$QT_LCONVERT
QT_MACDEPLOYQT=$QT_MACDEPLOYQT])
if test x"$QT_MISSING_TOOLS" != x; then
AC_MSG_ERROR([Failed to find Qt tool programs:$QT_MISSING_TOOLS.
Try using more options, see ./configure --help.])
fi
else
# Qt was not found
QT_CXXFLAGS=
QT_DIR=
QT_TRANSLATIONS_DIR=
QT_LIBS=
QT_UIC=
QT_MOC=
QT_RCC=
QT_LRELEASE=
QT_LCONVERT=
QT_MACDEPLOYQT=
AC_MSG_RESULT($have_qt)
fi
if test x"$bnv_is_qt5" = xyes; then
HAVE_QT5=1
AC_SUBST(HAVE_QT5)
AC_DEFINE( [HAVE_QT5], [], [Define when you have QT5 installed] )
fi
AC_SUBST(QT_CXXFLAGS)
AC_SUBST(QT_DIR)
AC_SUBST(QT_TRANSLATIONS_DIR)
AC_SUBST(QT_LIBS)
AC_SUBST(QT_UIC)
AC_SUBST(QT_MOC)
AC_SUBST(QT_RCC)
AC_SUBST(QT_LRELEASE)
AC_SUBST(QT_LCONVERT)
AC_SUBST(QT_MACDEPLOYQT)
#### Being paranoid:
if test x"$have_qt" = xyes; then
AC_MSG_CHECKING(correct functioning of Qt installation)
AC_CACHE_VAL(bnv_cv_qt_test_result,
[
cat > bnv_qt_test.h << EOF
#include <QtCore/QObject>
class Test : public QObject
{
Q_OBJECT
public:
Test() {}
~Test() {}
public slots:
void receive() {}
signals:
void send();
};
EOF
cat > bnv_qt_main.$ac_ext << EOF
#include "bnv_qt_test.h"
#include <QtWidgets/QApplication>
int main( int argc, char **argv )
{
QApplication app( argc, argv );
Test t;
QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) );
}
EOF
# Some versions of Clang or use of separate include directory causes
# a warning for unused macOS framework with no way to disable it.
ignore_warning="clang: warning: -framework .*: 'linker' input unused"
bnv_cv_qt_test_result="failure"
bnv_try_1="$QT_MOC bnv_qt_test.h -o moc_bnv_qt_test.$ac_ext >/dev/null 2>bnv_qt_test_1.out"
AC_TRY_EVAL(bnv_try_1)
bnv_err_1=`grep -v '^ *+' bnv_qt_test_1.out | grep -v "^bnv_qt_test.h\$"`
if test x"$bnv_err_1" != x; then
echo "$bnv_err_1" >&AC_FD_CC
echo "configure: could not run $QT_MOC on:" >&AC_FD_CC
cat bnv_qt_test.h >&AC_FD_CC
else
bnv_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -Wno-non-virtual-dtor -o moc_bnv_qt_test.o moc_bnv_qt_test.$ac_ext >/dev/null 2>bnv_qt_test_2.out"
AC_TRY_EVAL(bnv_try_2)
bnv_err_2=`grep -v '^ *+' bnv_qt_test_2.out | grep -v "^moc_bnv_qt_test.${ac_ext}\$" | grep -v "^${ignore_warning}\$"`
if test x"$bnv_err_2" != x; then
echo "$bnv_err_2" >&AC_FD_CC
echo "configure: could not compile:" >&AC_FD_CC
cat moc_bnv_qt_test.$ac_ext >&AC_FD_CC
else
bnv_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o bnv_qt_main.o bnv_qt_main.$ac_ext >/dev/null 2>bnv_qt_test_3.out"
AC_TRY_EVAL(bnv_try_3)
bnv_err_3=`grep -v '^ *+' bnv_qt_test_3.out | grep -v "^bnv_qt_main.${ac_ext}\$" | grep -v "^${ignore_warning}\$"`
if test x"$bnv_err_3" != x; then
echo "$bnv_err_3" >&AC_FD_CC
echo "configure: could not compile:" >&AC_FD_CC
cat bnv_qt_main.$ac_ext >&AC_FD_CC
else
bnv_try_4="$CXX $LDFLAGS -o bnv_qt_main bnv_qt_main.o moc_bnv_qt_test.o $QT_LIBS $LIBS >/dev/null 2>bnv_qt_test_4.out"
AC_TRY_EVAL(bnv_try_4)
bnv_err_4=`grep -v '^ *+' bnv_qt_test_4.out`
if test x"$bnv_err_4" != x; then
echo "$bnv_err_4" >&AC_FD_CC
else
bnv_cv_qt_test_result="success"
fi
fi
fi
fi
])dnl AC_CACHE_VAL bnv_cv_qt_test_result
AC_MSG_RESULT([$bnv_cv_qt_test_result]);
if test x"$bnv_cv_qt_test_result" = "xfailure"; then
AC_MSG_ERROR([Failed to find matching components of a complete
Qt installation. Try using more options,
see ./configure --help.])
fi
rm -f bnv_qt_test.h moc_bnv_qt_test.$ac_ext moc_bnv_qt_test.o \
bnv_qt_main.$ac_ext bnv_qt_main.o bnv_qt_main \
bnv_qt_test_1.out bnv_qt_test_2.out bnv_qt_test_3.out bnv_qt_test_4.out
fi
AC_LANG_RESTORE
])
dnl Internal subroutine of BNV_HAVE_QT
dnl Set bnv_qt_dir bnv_qt_include_dir bnv_qt_bin_dir bnv_qt_lib_dir
dnl Copyright 2001 Bastiaan N. Veelo <[email protected]>
dnl Modified in 2018 by Zack Middleton <zturtleman>
AC_DEFUN([BNV_PATH_QT_DIRECT],
[
if test x"$host_alias" != x; then
# set by configure --host
bnv_qt_host=$host_alias
else
bnv_qt_host=`$SHELL "$srcdir/config.guess" | cut -d'-' -f 1,3-4`
fi
## Binary utilities ##
if test x"$with_Qt_bin_dir" != x; then
bnv_qt_bin_dir=$with_Qt_bin_dir
fi
## Look for header files ##
if test x"$with_Qt_include_dir" != x; then
bnv_qt_include_dir="$with_Qt_include_dir"
else
# Before Qt 5.7.0 use QT_VERSION define in qglobal.h
# Qt 5.7.0 and later use QT_VERSION_* defines in qconfig.h (Debian) or qconfig-32.h and qconfig-64.h (Fedora)
# Look for the header files in a standard set of common directories.
bnv_include_path_list="
/usr/include/$bnv_qt_host/qt5
/usr/include/qt5
/usr/include/qt
/usr/qt5/include
/usr/include
/usr/local/include/$bnv_qt_host/qt5
/usr/local/include/qt5
/usr/local/qt5/include
/usr/local/include
`ls -dr /usr/local/Cellar/qt/5*/include 2>/dev/null`
"
# Now look for the newest in this list
bnv_prev_ver=0x04FFFF
for bnv_dir in $bnv_include_path_list; do
# Qt 5.7.0 and later
ztm_qconfig_list="
$bnv_dir/QtCore/qconfig.h
$bnv_dir/QtCore/qconfig-32.h
$bnv_dir/QtCore/qconfig-64.h
"
for ztm_qconfig in $ztm_qconfig_list; do
if test -r "$ztm_qconfig"; then
ztm_qt_ver_major=`egrep -w '^#define[[:space:]]*QT_VERSION_MAJOR[[:space:]]*' "$ztm_qconfig" | sed s/'^#define[[:space:]]*QT_VERSION_MAJOR[[:space:]]*'//`
ztm_qt_ver_minor=`egrep -w '^#define[[:space:]]*QT_VERSION_MINOR[[:space:]]*' "$ztm_qconfig" | sed s/'^#define[[:space:]]*QT_VERSION_MINOR[[:space:]]*'//`
ztm_qt_ver_patch=`egrep -w '^#define[[:space:]]*QT_VERSION_PATCH[[:space:]]*' "$ztm_qconfig" | sed s/'^#define[[:space:]]*QT_VERSION_PATCH[[:space:]]*'//`
if test x"$ztm_qt_ver_major" != x -a x"$ztm_qt_ver_minor" != x -a x"$ztm_qt_ver_patch" != x; then
bnv_this_ver=`printf "0x%02X%02X%02X" $ztm_qt_ver_major $ztm_qt_ver_minor $ztm_qt_ver_patch`
if expr $bnv_this_ver '>' $bnv_prev_ver > /dev/null; then
bnv_is_qt5=yes
bnv_qt_include_dir=$bnv_dir
bnv_prev_ver=$bnv_this_ver
fi