forked from edrosten/libcvd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
1156 lines (937 loc) · 32.8 KB
/
configure.in
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_INIT(CVD,0.8)
AC_COPYRIGHT(Copyright foo)
AC_CONFIG_HEADERS
AC_HEADER_STDC
#Use builtin autoconf checks for all the programs we need.
AC_PROG_AWK
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_RANLIB
#Switch testing language to C++
AC_LANG(C++)
AC_REQUIRE_CPP
#Start the compiler
cvd_major=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $1}'`
cvd_minor=`echo $PACKAGE_VERSION | $AWK -F'\\\\.' '{print $2}'`
AC_DEFINE_UNQUOTED(CVD_MAJOR_VERSION,$cvd_major)
AC_SUBST(major, $cvd_major)
AC_DEFINE_UNQUOTED(CVD_MINOR_VERSION,$cvd_minor)
AC_SUBST(minor, $cvd_minor)
################################################################################
#
#Lists of optional components
#
all_options="pthread videodisplay jpeg tiff png ffmpeg toon lapack glob memalign shared_ptr assembler inline_asm posix_rt"
dodginess_options=
options=
simd_all_options=
simd_options=
os_all_options=
################################################################################
#
# Useful macros
#
dnl APPEND(var, value)
dnl This appends vale to a shell variable var
define(APPEND, [$1="$$1 $2"])
dnl TEST_AND_SET_CXXFLAG(flag, [program], [run])
dnl
dnl This attempts to compile a and run program with a certain compiler flag.
dnl If no program is given, then the minimal C++ program is compiled, and
dnl this tests just the validity of the compiler flag.
dnl
define([TEST_AND_SET_CXXFLAG],[
if test "$3" == ""
then
AC_MSG_CHECKING([if compiler flag $1 works])
else
AC_MSG_CHECKING([$3])
fi
save_CXXFLAGS="$CXXFLAGS"
APPEND(CXXFLAGS, [$1])
m4_if([$2],[],[pushdef(prog, [int main(){}])], [pushdef(prog, [$2])])
m4_if([$4],[run],
[AC_RUN_IFELSE([AC_LANG_SOURCE([prog])], [cvd_conf_test=1],[cvd_conf_test=0], [cvd_conf_test=0])],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([prog])], [cvd_conf_test=1],[cvd_conf_test=0])]
)
popdef([prog])
if test $cvd_conf_test = 1
then
AC_MSG_RESULT(yes)
ts_success=yes
else
AC_MSG_RESULT(no)
CXXFLAGS="$save_CXXFLAGS"
ts_success=no
fi
])
dnl CHECK_FOR_OPTION(option, code, [success], [fail])
dnl option corresponds to the first parameter for the corresponding
dnl AC_ARG_WITH. If the library is present, then have_option and CVD_HAVE_OPTION
dnl are set. If with_option is "", it will be set to yes.
dnl
dnl The test code shall do nothing on success, and set the shell variable a
dnl on failure. For convenience, LIBS and CXXFLAGS are checkpointed
dnl automatically. On failure, they are restored automatically.
dnl
dnl On success, "option" is appended to options, and the code "success" is run
dnl On failure including --without) fail is run.
define(CHECK_FOR_OPTION,[
if test "$with_$1" != no && test "$have_$1" != yes
then
if test "$with_$1" == ""
then
with_$1=yes
fi
save_LIBS="$LIBS"
save_CXXFLAGS="$CXXFLAGS"
a=
$2
if test x$a == x
then
AC_DEFINE(CVD_HAVE_[]m4_toupper($1), 1)
AC_SUBST(have_$1, yes)
APPEND(options, $1)
$3
else
LIBS="$save_LIBS"
CXXFLAGS="$save_CXXFLAGS"
fi
fi
if test "$have_$1" != yes
then
:
$4
fi
])
dnl SIMD_TEST(name, flag, code)
dnl This tests for SIMD code (with name), using the compiler flag "flag"
dnl and the provided test code. It respects with_simd and with_name
dnl
dnl On success, "name" is appended to simd_options
define(SIMD_TEST, [
if test "$with_simd" != no
then
if test "$with_[]m4_tolower($1)" == "yes"
then
have_[]m4_tolower($1)=yes
elif test "$with_[]m4_tolower($1)" != "no"
then
TEST_AND_SET_CXXFLAG([$2], [$3], [for $1 support],run)
have_[]m4_tolower($1)="$ts_success"
fi
if test "$have_[]m4_tolower($1)" == yes
then
AC_DEFINE(CVD_HAVE_$1, 1)
AC_SUBST(have_[]m4_tolower($1), yes)
APPEND(simd_options, m4_tolower($1))
fi
fi])
#Host detection
AC_CANONICAL_HOST
################################################################################
#
# Compiler flags and optimization
#
#
TEST_AND_SET_CXXFLAG(-Wall)
TEST_AND_SET_CXXFLAG(-Wextra)
TEST_AND_SET_CXXFLAG(-pipe)
APPEND(CPPFLAGS, [-I"$(eval echo $includedir)"])
########################################
#
# Remove -O2 from CXXFLAGS
#
CXXFLAGS="$(echo "$CXXFLAGS" | sed -e's/-O2//')"
########################################
#
# Always use ggdb if possible
#
AC_ARG_ENABLE(ggdb, [ --disable-ggdb do not use ggdb flag])
if test "$enable_ggdb" != no
then
TEST_AND_SET_CXXFLAG(-ggdb)
fi
########################################
#
# Debug build
#
AC_ARG_ENABLE(debug, [ --disable-debug disable debug build])
if test "$enable_debug" != no
then
AC_MSG_CHECKING([if -D_GLIBCXX_DEBUG can works...])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
int main()
{}
])], [debug=yes],[debug=no])]
AC_MSG_RESULT([$debug])
if test "$debug" == yes
then
AC_SUBST(STLDEBUG, [-D_GLIBCXX_DEBUG])
fi
AC_SUBST(debug_build, yes)
else
AC_SUBST(debug_build, no)
fi
########################################
#
# Position independent code
#
# MinGW is always PIC
if ! echo $host | grep mingw && test "$host_os" != "cygwin"
then
TEST_AND_SET_CXXFLAG(-fPIC)
if test $ts_success == no
then
AC_MSG_WARN(["I don't know how to compile position independent code."])
fi
fi
########################################
#
# CPU type detection and optimization
#
noopt_CXXFLAGS="$CXXFLAGS"
CXXFLAGS=
AC_ARG_WITH(optimize, [ --without-optimize compile without optimizations ],[optimize=no],[])
AC_ARG_WITH(optimize, [ --with-optimize=flags compile with optimization flags],[optimize="$withval"], [optimize=-O3])
if test "$optimize" != no
then
TEST_AND_SET_CXXFLAG(-O3)
if test $ts_success == no
then
AC_MSG_WARN([I do not know how to switch on optimizing for this compiler])
fi
fi
OFLAGS="$CXXFLAGS"
CXXFLAGS="$noopt_CXXFLAGS"
################################################################################
#
# Processor/Platform specific parts
#
echo
echo ------------------------------------
echo Checking processor specific features
echo ------------------------------------
echo
AC_C_BIGENDIAN
if test x$ac_cv_c_bigendian = xno
then
AC_DEFINE(CVD_ARCH_LITTLE_ENDIAN)
else
AC_DEFINE(CVD_ARCH_BIG_ENDIAN)
fi
AC_ARG_WITH(simd, [ --without-simd disable SIMD code. Use --without- or --with-
to force presence/absence and disable autodetection.])
AC_ARG_WITH(mmx, [ --with-mmx force presence or absence of MMX (x86 only)])
AC_ARG_WITH(mmxext, [ --with-mmxext force presence or absence of MMXEXT (x86 only) ])
AC_ARG_WITH(sse, [ --with-sse force presence or absence of SSE (x86 only)])
AC_ARG_WITH(sse2, [ --with-sse2 force presence or absence of SSE2 (x86 only)])
AC_ARG_WITH(assembler, [ --with-assembler force presence or absence of asm])
AC_ARG_WITH(inline_asm, [ --with-inline_asm force presence or absence of inline asm])
case "$host" in
*86*)
AC_SUBST(have_x86, yes)
simd_all_options="mmx mmxext sse sse2 sse3"
SIMD_TEST(MMX, -mmmx, [
#include <mmintrin.h>
int main()
{
__m64 a;
a = _mm_setzero_si64();
a = _mm_and_si64(a, a);
return 0;
}], [for MMX support])
SIMD_TEST(MMXEXT, -msse,[
#include <xmmintrin.h>
int main()
{
__m64 a;
a = _mm_setzero_si64();
a = _mm_shuffle_pi16(a, 0);
return 0;}], [for MMXEXT support])
SIMD_TEST(SSE, -msse, [
#include <xmmintrin.h>
int main()
{
__m128 a;
a = _mm_setzero_ps();
a = _mm_add_ps(a, a);
return 0;
}], [for SSE spport])
SIMD_TEST(SSE2, -msse2, [
#include <emmintrin.h>
int main()
{
__m128d a;
a = _mm_setzero_pd();
a = _mm_add_pd(a, a);
return 0;
}], [for SSE2 support])
SIMD_TEST(SSE3, -msse3, [
#include <pmmintrin.h>
int main()
{
__m128 a;
a = _mm_setzero_ps();
a = _mm_hadd_ps(a, a);
return 0;
}], [for SSE3 support])
;;
esac
AC_CHECK_SIZEOF([void*])
if test "$ac_cv_sizeof_voidp" == 4
then
AC_SUBST(have_32bit,yes)
fi
CHECK_FOR_OPTION(inline_asm, [
AC_MSG_CHECKING([for inline asm statement])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() { asm(""); }])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no);a=1])
])
CHECK_FOR_OPTION(assembler, [
AC_MSG_CHECKING([assembler supports .type pseudo-op])
AS_IF([echo '.globl test
.type test, @function' | as &> /dev/null],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no);a=1])
])
################################################################################
#
# Operating system specific parts
#
########################################
#
# An OSX specific hack to get at stuff in /sw automatically
#
echo
echo -----------------------------------------------
echo Checking for operating system specific features
echo -----------------------------------------------
AC_ARG_ENABLE(gpl, [ --enable-gpl Allow the use of GPL libraries.])
AC_ARG_WITH(dc1394v1v2,[ --with-dc1394v1v2 Force libDC1394 v1 and v2 co-exist. This will break FORMAT_7.])
AC_ARG_WITH(dc1394v1, [ --without-dc1394v1 do not use libDC1394v1 (use try v2 instead) for dvbuffer3 (Linux/OSX). Disable dvbuffer (Linux).])
AC_ARG_WITH(dc1394v2, [ --without-dc1394v2 do not use libDC1394v2 (use try v1 instead) for dvbuffer3 (Linux/OSX). ])
AC_ARG_WITH(v4l1buffer,[ --without-v4l1buffer compile without v4l1bffer (Video4Linux) support (Linux only)])
AC_ARG_WITH(v4l2buffer,[ --without-v4l2buffer compile without v4l2buffer (Video4Linux2) support (Linux only)])
AC_ARG_WITH(o2buffer, [ --without-o2buffer compile without sgi video (IRIX only)])
AC_ARG_WITH(qtbuffer, [ --without-qtbuffer compile without quicktime buffer support (MacOSX only)])
if test "$host_vendor" == apple
then
AC_CHECK_FILE(/opt/local, [
APPEND(CPPFLAGS, [-I/opt/local/include])
APPEND(LIBS, [-L/opt/local/lib])],
[])
AC_CHECK_FILE(/sw, [
APPEND(CPPFLAGS, [-I/sw/include])
APPEND(LIBS, [-L/sw/lib])],
[])
APPEND(CPPFLAGS, [-I/usr/X11R6/include])
AC_MSG_NOTICE([Adding /usr/X11R6/include to the build path.])
AC_SUBST(osx_hacks,yes)
os_all_options="qtbuffer dc1394v2"
fi
CHECK_FOR_OPTION(dc1394v2, [
AC_CHECK_HEADERS(dc1394/dc1394.h, [], [a=1])
AC_CHECK_LIB(dc1394, main,[],[a=1])
])
case "$host" in
*linux*)
os_all_options="dc1394v2 dc1394v1 v4l2buffer v4l1buffer"
if test "$have_dc1394v2" != yes || test "$with_dc1394v1v2" == "yes"
then
CHECK_FOR_OPTION(dc1394v1, [
AC_CHECK_HEADERS(libraw1394/raw1394.h libdc1394/dc1394_control.h, [], [a=1])
AC_CHECK_LIB(raw1394, main,[],[a=1])
AC_CHECK_LIB(dc1394_control, main,[],[a=1])
])
fi
CHECK_FOR_OPTION(v4l2buffer,[
AC_MSG_CHECKING(for v4l2)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include <sys/types.h>
#include <linux/types.h>
#include <linux/videodev2.h>
int main(){V4L2_PIX_FMT_GREY;return 0;}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no); a=1])
if test x$a = x1
then
a=
AC_MSG_CHECKING(for strange v4l2)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include <sys/types.h>
#include <linux/types.h>
#include <videodevx/videodev.h>
int main(){V4L2_PIX_FMT_GREY;return 0;}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no); a=1])
if test x$a = x
then
APPEND(dodginess_options, strange_v4l2)
strange_v4l2=yes
AC_DEFINE(CVD_INTERNAL_HAVE_STRANGE_V4L2, 1)
fi
fi
])
if test x$strange_v4l2 != xyes
then
CHECK_FOR_OPTION(v4l1buffer, [AC_CHECK_HEADERS(linux/videodev.h,[], [a=1])])
else
CHECK_FOR_OPTION(v4l1buffer, [
AC_MSG_CHECKING(for strange v4l)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include <videodevx/videodev.h>
int main(){VIDEO_PALETTE_GREY;return 0;}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no); a=1])])
fi
;;
*windows*)
AC_SUBST(have_windows, yes)
;;
*cygwin*)
AC_SUBST(cygwin_hacks,yes)
;;
esac
if test "$host_vendor" == apple
then
CHECK_FOR_OPTION(qtbuffer,[
APPEND(LIBS, [-framework Carbon -framework QuickTime])
AC_MSG_CHECKING(Carbon and QuickTime framework)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([ #include <Carbon/Carbon.h>
#include <QuickTime/QuickTime.h>
int main(){InitCursor();EnterMovies();return 0;}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no); a=1])
])
fi
#Check for POSIX clock_getres
AC_ARG_WITH(posix_rt, [ --without-posix_rt compile without POSIX-RT (better cvd_timer) support])
CHECK_FOR_OPTION(posix_rt, [
AC_CHECK_LIB(rt, clock_getres, [], [a=1])
])
CHECK_FOR_OPTION(pthread, [
if test "$host_os" != cygwin
then
APPEND(CXXFLAGS, -pthread)
APPEND(LIBS, -pthread)
else
APPEND(LIBS, -lpthread)
fi
AC_MSG_CHECKING(for working pthreads)
AC_RUN_IFELSE([AC_LANG_SOURCE([#include <pthread.h>
void*foo(void*){}
pthread_t th;
int main(){pthread_create(&th,NULL,foo,NULL);return 0;}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no); a=1])
], [
# check for existence of pthread_yield
# Mac OS X only has pthread_yield_np
a=
AC_CHECK_FUNC(sched_yield, AC_SUBST(have_sched_yield, yes), a=sy)
if test x$a != x
then
AC_CHECK_FUNC(pthread_yield, AC_SUBST(have_pthread_yield, yes),a=py)
fi
if test x$a != x
then
AC_CHECK_FUNC(pthread_yield_np, AC_SUBST(have_pthread_yield_np, yes),a=pyn)
fi
if test x$a = xpyn
then
APPEND(dodginess_options, no_pthread_yield)
APPEND(dodginess_options, no_sched_yield)
elif test x$a = py
then
APPEND(dodginess_options, no_sched_yield)
fi
])
################################################################################
#
#Check for optional libraries
#
echo
echo -------------------------------
echo Checking for optional libraries
echo -------------------------------
AC_ARG_WITH(videodisplay, [ --without-videodisplay compile without videodisplay support])
AC_ARG_WITH(pthread, [ --without-pthread compile without PThread support])
AC_ARG_WITH(jpeg, [ --without-jpeg compile without JPEG support])
AC_ARG_WITH(jpegbuffer, [ --with-jpegbuffer=N Set JPEG read buffer size. N>1 will not be able to read multiple JPEGS from a stream.])
AC_ARG_WITH(tiff, [ --without-tiff compile without TIFF support])
AC_ARG_WITH(tiff, [ --with-tiff=forceold Debug/wierd build environment only. Force use of older library facilities.])
AC_ARG_WITH(png, [ --without-png compile without PNG support])
AC_ARG_WITH(ffmpeg, [ --without-ffmpeg compile without FFMPEG support.])
AC_ARG_WITH(oldffmpeg, [ --with-oldffmpeg compile with old FFMPEG support.])
AC_ARG_WITH(toon, [ --without-toon Compile without TooN support])
AC_ARG_WITH(shared_ptr, [ --without-shared_ptr Compile without shared_ptr support])
AC_ARG_WITH(lapack, [ --without-lapack Disable BLAS and LAPACK.])
AC_ARG_WITH(acml, [ --with-acml[[=directory]] Use BLAS and LAPACK routines from the ACML library [[located in the specified directory]] ], [opt_acml_dir=$withval])
CHECK_FOR_OPTION(videodisplay,[
if test "$host_vendor" == apple
then
save_LIBS="$LIBS"
APPEND(LIBS, [ -framework OpenGL /usr/X11R6/lib/libX11.dylib /usr/X11R6/lib/libGLU.dylib /usr/X11R6/lib/libGL.dylib])
# all of the following is already covered in the framework
# AC_CHECK_LIB(GL,glDrawPixels, [], [a=1])
# AC_CHECK_HEADERS(GL/glu.h, [], [a=1])
# AC_CHECK_LIB(GLU,gluGetString, [], [a=1])
AC_MSG_CHECKING([for X11 using dubious methods...])
a=0
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <X11/Xlib.h>
int main()
{
XOpenDisplay(NULL);
}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=1])
if test x$a == x1
then
LIBS="$save_LIBS"
fi
else
AC_PATH_X
if test x"$x_includes" != x
then
APPEND(CXXFLAGS, -I$x_includes)
fi
if test "$x_libraries" != ""
then
APPEND(LIBS, [-L$x_libraries])
fi
APPEND(LIBS, [-lX11 -lXext])
AC_CHECK_LIB(GL,glDrawPixels, [], [a=1])
AC_CHECK_HEADERS(GL/glu.h, [], [a=1])
AC_CHECK_LIB(GLU,gluGetString, [], [a=1])
fi
])
CHECK_FOR_OPTION(shared_ptr, [
AC_MSG_CHECKING([for shared_ptr])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <memory>
int main(){std::shared_ptr<int> i; return 0;}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=1])
if test x$a == x1
then
a=0
AC_MSG_CHECKING([for tr1::shared_ptr])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <tr1/memory>
int main(){std::tr1::shared_ptr<int> i; return 0;}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=1])
AC_DEFINE(CVD_INTERNAL_NEED_TR1)
APPEND(dodginess_options, tr1_shared_ptr)
fi
])
CHECK_FOR_OPTION(toon, [
AC_MSG_CHECKING([for TooN])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <TooN/TooN.h>
int main(){TooN::Vector<2, double> v=TooN::Zeros;return 0;}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=1])
if test x$a = x1
then
AC_MSG_CHECKING([for old TooN])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <TooN/TooN.h>
int main(){TooN::Vector<2> v;return 0;}])], [AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no); a=2])
if test x$a = x1
then
AC_MSG_WARN([Your version of TooN is too old. You need version 2.0-beta3 or later.])
fi
a=1
fi
])
CHECK_FOR_OPTION(lapack, [
if test "$with_acml" != no
then
if test "$with_acml" != yes & test "$with_acml" != ""
then
APPEND(LIBS, -L $with_acml)
else
APPEND(LIBS, -L/opt/acml/gnu64/lib)
fi
APPEND(LIBS, -lacml_mv)
AC_CHECK_LIB(acml, dgesvd_, [], [a=1])
else
a=1
fi
])
CHECK_FOR_OPTION(lapack, [
AC_MSG_CHECKING(if Accelerate framework is needed for LAPACK)
AC_MSG_RESULT()
APPEND(LIBS, -framework Accelerate)
AC_CHECK_FUNC(dgesvd_, [], [a=1])
])
CHECK_FOR_OPTION(lapack, [
AC_CHECK_LIB(lapack, dgesvd_, [], [a=1])
])
CHECK_FOR_OPTION(lapack, [
AC_MSG_CHECKING(if blas is needed for LAPACK)
AC_MSG_RESULT()
APPEND(LIBS, -lblas)
AC_CHECK_LIB(lapack, zupmtr_, [], [a=1])
])
CHECK_FOR_OPTION(lapack, [
AC_MSG_CHECKING(if f2c is needed for LAPACK)
AC_MSG_RESULT()
APPEND(LIBS, -lf2c)
AC_CHECK_LIB(lapack, dpotrf_, [], [a=1])
])
CHECK_FOR_OPTION(lapack, [
AC_MSG_CHECKING(if g2c is needed for LAPACK)
AC_MSG_RESULT()
APPEND(LIBS, -lg2c)
AC_CHECK_LIB(lapack, dpotrs_, [], [a=1])
])
CHECK_FOR_OPTION(lapack, [
AC_MSG_CHECKING(if gfortran is needed for LAPACK)
AC_MSG_RESULT()
APPEND(LIBS, -lgfortran)
AC_CHECK_LIB(lapack, dpotri_, [], [a=1])
])
CHECK_FOR_OPTION(png, [
AC_CHECK_HEADERS(png.h, [], [a=1])
AC_CHECK_LIB(png, png_init_io, [], [a=1])
oldpng=0
AC_CHECK_LIB(png, png_set_expand_gray_1_2_4_to_8, [], [oldpng=1])
if test $oldpng == 1
then
APPEND(dodginess_options, oldpng)
AC_DEFINE(CVD_INTERNAL_HAVE_OLD_PNG, 1)
fi
])
CHECK_FOR_OPTION(jpeg, [
AC_CHECK_HEADERS(jpeglib.h, [], [a=1])
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress, [], [a=1])
],[
AC_MSG_CHECKING([JPEG read buffer size])
jpegbuffersize="`echo $with_jpegbuffer | awk '$1 = ($1+0<= 0)?1:$1'`"
if test "$jpegbuffersize" -gt 1
then
AC_MSG_RESULT([$jpegbuffersize (unsafe reading)]);
APPEND(dodginess_options, unsafe_jpeg)
else
jpegbuffersize=1
AC_MSG_RESULT([1 (safe reading)]);
fi
AC_DEFINE_UNQUOTED(CVD_INTERNAL_JPEG_BUFFER_SIZE, $jpegbuffersize)
])
CHECK_FOR_OPTION(tiff, [
AC_CHECK_HEADERS(tiffio.h,[],[a=1])
AC_CHECK_LIB(tiff, TIFFReadRGBAImage,[],[a=1])
])
CHECK_FOR_OPTION(tiff, [
AC_MSG_CHECKING([if perhaps libtiff requires zlib])
AC_MSG_RESULT([])
unset ac_cv_lib_tiff_TIFFReadRGBAImage
AC_CHECK_HEADERS(tiffio.h,[],[a=1])
AC_CHECK_LIB(z, deflate,[],[a=1])
AC_CHECK_LIB(tiff, TIFFReadRGBAImage,[],[a=1])
],[
APPEND(dodginess_options, tiff_needs_zlib)
])
if test "$have_tiff" == yes
then
a=
if test "$with_tiff" != forceold
then
AC_CHECK_LIB(tiff, TIFFReadRGBAImageOriented, a=1)
fi
if test x$a = x
then
APPEND(dodginess_options, oldtiff)
else
AC_DEFINE(CVD_INTERNAL_HAVE_TIFF_ORIENTED, 1)
fi
fi
CHECK_FOR_OPTION(ffmpeg, [
if test "$enable_gpl" != no && test "$enable_gpl" != ""
then
AC_MSG_CHECKING([for ffmpeg headers])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#define __STDC_CONSTANT_MACROS
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
int main(){}
])], [ ffmpeg_new_headers=1], [])
if test "$ffmpeg_new_headers" == 1
then
AC_CHECK_LIB(avutil, main, [], [a=1])
AC_CHECK_LIB(avformat, avformat_open_input, [], [a=1])
AC_CHECK_LIB(avformat, av_read_frame, [ffmpeg_recent=yes], [a=1]) #only in >= 0.4.9
AC_CHECK_LIB(avcodec, avcodec_open2, [], [a=1])
AC_CHECK_LIB(swscale, sws_getContext, [], [a=1])
if test "$with_oldffmpeg" == yes
then
AC_SUBST(have_oldffmpeg, yes)
fi
have_avcodec_decode_video2=0
AC_CHECK_LIB(avcodec, avcodec_decode_video2, [have_avcodec_decode_video2=1])
if test $have_avcodec_decode_video2==1
then
AC_DEFINE(CVD_INTERNAL_FFMPEG_USE_AVCODEC_DECODE_VIDEO2)
fi
else
a=1
fi
else
a=1
AC_MSG_WARN([FFMPEG currently requires the use of --enable-gpl])
fi
])
AC_CHECK_PROG(docs, doxygen, docs, no)
################################################################################
#
# platform compatibility
# All of these ought to be yes
echo
echo -----------------------------------
echo Checking for platform compatibility
echo -----------------------------------
AC_ARG_WITH(glob, [ --without-glob Compile without diskbuffer glob matching (for debugging only) ])
AC_ARG_WITH(memalign, [ --without-memalign Compile without posix_memalign (for debugging only) ])
CHECK_FOR_OPTION(glob, [
AC_CHECK_HEADERS(glob.h,[], [a=1])
AC_CHECK_FUNC(glob,[], [a=1])
],[
AC_MSG_CHECKING([for GLOB_BRACE and GLOB_TILDE in glob.h])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <glob.h>
int main(){glob(0, GLOB_BRACE|GLOB_TILDE,0,0);}])],
[AC_MSG_RESULT(yes)],
[
AC_MSG_RESULT(no)
AC_DEFINE(CVD_INTERNAL_GLOB_IS_BAD)
APPEND(dodginess_options, broken_glob)
])
], [
APPEND(dodginess_options, no_glob)
])
a=
AC_CHECK_DECL(feenableexcept, [a=1], [a= ], [#include <fenv.h>])
if test x$a = x1
then
AC_DEFINE(CVD_HAVE_FENV_H)
else
dodginess_options="$dodginess_options missing_c99_feenableexcept"
fi
CHECK_FOR_OPTION(memalign, [
AC_CHECK_FUNC(posix_memalign, [], [a=1])
], [], [APPEND(dodginess_options, no_posix_memalign)])
################################################################################
#
# Extra build options
echo
echo --------------------------------
echo Checking for extra build options
echo --------------------------------
AC_ARG_ENABLE(ssefast9, [ --disable-ssefast9 Disable the probably OK SSE FAST-9 detector (debgging only)])
AC_ARG_ENABLE(ssefast10, [ --disable-ssefast10 Disable the probably OK SSE FAST-10 detector (debgging only)])
AC_ARG_ENABLE(ssefast12, [ --disable-ssefast12 Disable the probably OK SSE FAST-12 detector (debgging only)])
AC_ARG_ENABLE(fast7, [ --disable-fast7 compile without the FAST-7 detector (use on low memory systems). ])
AC_ARG_ENABLE(fast8, [ --disable-fast8 compile without the FAST-8 detector (use on low memory systems). ])
AC_ARG_ENABLE(fast9, [ --disable-fast9 compile without the FAST-9 detector (use on low memory systems). ])
AC_ARG_ENABLE(fast10, [ --disable-fast10 compile without the FAST-10 detector (use on low memory systems). ])
AC_ARG_ENABLE(fast11, [ --disable-fast11 compile without the FAST-11 detector (use on low memory systems). ])
AC_ARG_ENABLE(fast12, [ --disable-fast12 compile without the FAST-12 detector (use on low memory systems). ])
test "$enable_fast7" != no && AC_SUBST(have_fast7, yes)
test "$enable_fast8" != no && AC_SUBST(have_fast8, yes)
test "$enable_fast9" != no && AC_SUBST(have_fast9, yes)
test "$enable_fast10" != no && AC_SUBST(have_fast10, yes)
test "$enable_fast11" != no && AC_SUBST(have_fast11, yes)
test "$enable_fast12" != no && AC_SUBST(have_fast12, yes)
test "$enable_ssefast9" != no && AC_SUBST(have_ssefast9, yes)
test "$enable_ssefast10" != no && AC_SUBST(have_ssefast10, yes)
test "$enable_ssefast12" != no && AC_SUBST(have_ssefast12, yes)
################################################################################
#
# Compute dependencies
#
#First, extract all the have_* variables
for i in `echo $ac_subst_vars | tr ' ' '\n' | grep have_`
do
eval echo $i \$$i
done > config.have_bits
#The dependency list
#The file format is as follows:
#
# have_feature1 [yes]
#
# dependee_list_1 dependency_list_1
# dependee_list_2 dependency_list_2
# ...
# dependee_list_N dependee_list_N END
#
#
# dependee_list is comma separated. dependency_list is whitespace separated.
# If all the dependencies in dependency list are present (have_* is yes), then
# dependee list is buildable. The lowest numbered dependee list is selected.
#
# The dependee list has a comma separated list of object files (minus the .o)
# to be build. If a `file' is all caps, it is treated as a define, instead.
#
# Blank lines, and those starting with # are ignored
cat config.have_bits - <<ENDDEPS | awk -f make/compile_deps.awk > config.dep_tmp
#SIMD dependencies
i686/yuv411_to_stuff_MMX inline_asm mmxext 32bit x86
i686/yuv411_to_stuff_MMX_64 inline_asm mmxext x86
yuv411_to_stuff END
SSE2/half_sample sse2
i686/halfsample,MMX/half_sample mmx 32bit x86 assembler
noarch/half_sample END
i686/rgb_to_gray,i686/convert_rgb_to_y 32bit mmxext x86 assembler
noarch/convert_rgb_to_y END
i686/convolve_gaussian sse2
noarch/convolve_gaussian END
i686/gradient sse2
noarch/gradient END
i686/yuv420p_to_rgb,i686/yuv420p_to_rgb_runner mmx 32bit x86 assembler
noarch/yuv420p_to_rgb_runner END
i686/yuv422_to_rgb,i686/yuv422_to_grey,i686/yuv422_wrapper mmxext 32bit x86 assembler
noarch/yuv422_wrapper END
i686/median_3x3 sse2
noarch/median_3x3 END
i686/utility_float sse
noarch/utility_float END
i686/utility_byte_differences mmx
noarch/utility_byte_differences END
i686/utility_double_int sse2
noarch/utility_double_int END
SSE2/two_thirds_sample sse2
noarch/two_thirds_sample END
#FAST corner detection specifics
fast/fast_7_detect,fast/fast_7_score,slower_corner_7 fast7 END
fast/fast_8_detect,fast/fast_8_score,slower_corner_8 fast8 END
fast/fast_9_detect,fast/fast_9_score,fast_corner_9_nonmax fast9 END
fast/fast_10_detect,fast/fast_10_score fast10 END
fast/fast_11_detect,fast/fast_11_score,slower_corner_11 fast11 END
fast/fast_12_detect,fast/fast_12_score fast12 END
SSE2/faster_corner_9 sse2 ssefast9 fast9
noarch/slower_corner_9 fast9 END
SSE2/faster_corner_10 sse2 ssefast10 fast10
noarch/slower_corner_10 fast10 END
SSE2/faster_corner_12 sse2 ssefast12 fast12
noarch/slower_corner_12 fast12 END
#General OS specific bits
Linux/dvbuffer3_dc1394v2,Linux/dvbuffer,videosource_dvbuffer,DVBUFFER3 dc1394v2 dc1394v1 dc1394v1v2
Linux/dvbuffer3_dc1394v2,videosource_dvbuffer,DVBUFFER3 dc1394v2
Linux/dvbuffer3_dc1394v1,Linux/dvbuffer,videosource_dvbuffer,DVBUFFER dc1394v1
videosource_nodvbuffer END