forked from Motion-Project/motion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
809 lines (741 loc) · 26.7 KB
/
configure.ac
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
# Process this file with autoconf to produce a configure script
AC_INIT(motion, esyscmd(['./version.sh']))
AC_GNU_SOURCE
AC_CONFIG_SRCDIR([motion.c])
AC_CONFIG_HEADERS(config.h)
AC_PROG_CC
AC_HEADER_STDC
AC_C_CONST
###############################################################################
### Host system
###############################################################################
AC_MSG_CHECKING(for Darwin/BSD)
DISTRO=""
DISTRO=`uname -a | grep -i "Darwin"`
if test "x${DISTRO}" = "x"; then
DISTRO=`uname -s | grep -i "FreeBSD"`
fi
if test "x${DISTRO}" = "x"; then
DISTRO=`uname -s | grep -i "NetBSD"`
fi
if test "x${DISTRO}" = "x"; then
DISTRO=`uname -s | grep -i "OpenBSD"`
fi
if test "x${DISTRO}" = "x"; then
DISTRO="Linux"
AC_MSG_RESULT(no)
else
AC_MSG_RESULT($DISTRO)
fi
AC_SUBST(DISTRO)
###############################################################################
### Host specific paths
###############################################################################
TEMP_LIBS=""
TEMP_CFLAGS=""
TEMP_CPPFLAGS=""
TEMP_LDFLAGS=""
if test "${DISTRO}" = "Darwin"; then
TEMP_CFLAGS="${CFLAGS} -I/sw/include"
TEMP_CPPFLAGS="${CPPFLAGS} -I/sw/include"
TEMP_LDFLAGS="${LDFLAGS} -L/sw/lib"
TEMP_LIBS="-L/sw/lib"
else
if test "${DISTRO}" != "Linux"; then
TEMP_CFLAGS="${CFLAGS} -I/usr/local/include"
TEMP_CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
TEMP_LDFLAGS="${LDFLAGS} -L/usr/local/lib"
TEMP_LIBS="-L/usr/local/lib"
fi
fi
TEMP_LIBS="-lm ${TEMP_LIBS}"
TEMP_CFLAGS="${TEMP_CFLAGS} ${CFLAGS}"
TEMP_CPPFLAGS="${TEMP_CPPFLAGS} ${CPPFLAGS}"
TEMP_LDFLAGS="${TEMP_LDFLAGS} ${LDFLAGS}"
AC_SUBST(CFLAGS, "${TEMP_CFLAGS}")
AC_SUBST(CPPFLAGS, "${TEMP_CPPFLAGS}")
AC_SUBST(LDFLAGS, "${TEMP_LDFLAGS}")
###############################################################################
### Host search paths for MYSQL/PGSQL
###############################################################################
#dpkg-architecture may not be available so manually list
SEARCH_INC="/usr/include/x86_64-linux-gnu"
SEARCH_INC=$SEARCH_INC" /usr/include/i386-linux-gnu"
SEARCH_INC=$SEARCH_INC" /usr"
SEARCH_INC=$SEARCH_INC" /usr/include"
SEARCH_INC=$SEARCH_INC" /usr/local"
SEARCH_INC=$SEARCH_INC" /usr/local/include"
SEARCH_INC=$SEARCH_INC" /opt"
SEARCH_LIB="/usr/lib/x86_64-linux-gnu"
SEARCH_LIB=$SEARCH_LIB" /usr/lib/i386-linux-gnu"
SEARCH_LIB=$SEARCH_LIB" /usr"
SEARCH_LIB=$SEARCH_LIB" /usr/lib64"
SEARCH_LIB=$SEARCH_LIB" /usr/lib"
SEARCH_LIB=$SEARCH_LIB" /usr/local"
SEARCH_LIB=$SEARCH_LIB" /usr/local/lib"
SEARCH_LIB=$SEARCH_LIB" /opt"
###############################################################################
### Video System
###############################################################################
BKTR="yes"
AC_ARG_WITH(bktr,
AS_HELP_STRING([--without-bktr],
[Exclude to use bktr subsystem for BSD]),
BKTR="$withval")
V4L2="yes"
AC_ARG_WITH(v4l2,
AS_HELP_STRING([--without-v4l2],[Disable V4L2 devices]),
V4L2="$withval")
if test "x${BKTR}" = "xyes"; then
if test "${DISTRO}" = "FreeBSD"; then
AC_CHECK_HEADERS(dev/bktr/ioctl_meteor.h dev/bktr/ioctl_bt848.h,[BKTR="yes"],[BKTR="no"])
elif test "${DISTRO}" = "OpenBSD" || test "${DISTRO}" = "NetBSD"; then
AC_CHECK_HEADERS(dev/ic/bt8xx.h,[BKTR="yes"],[BKTR="no"])
else
BKTR="no"
fi
fi
if test "${V4L2}" = "yes"; then
AC_CHECK_HEADERS(linux/videodev2.h,[V4L2="yes"],[V4L2="no"])
fi
if test "x${V4L2}" = "xyes"; then
AC_DEFINE([HAVE_V4L2], 1, [Define to 1 if V4L2 is around])
fi
if test "x${BKTR}" = "xyes"; then
AC_DEFINE([HAVE_BKTR], 1, [Define to 1 if BKTR is around])
fi
##############################################################################
### Check for threading
##############################################################################
THREADS="yes"
if test "${DISTRO}" = "FreeBSD"; then
AC_CHECK_HEADERS(pthread_np.h,[THREADS="yes"],[THREADS="no"])
AC_MSG_CHECKING(for threads)
AC_MSG_RESULT($THREADS)
fi
if test x$THREADS = xyes; then
TEMP_LIBS="$TEMP_LIBS -pthread"
TEMP_CFLAGS="${TEMP_CFLAGS} -D_THREAD_SAFE"
##############################################################################
### Check for pthread_setname_np (nonstandard GNU extension)
##############################################################################
AC_MSG_CHECKING([for pthread_setname_np])
HOLD_LIBS="$LIBS"
LIBS="$TEMP_LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <pthread.h>], [pthread_setname_np(pthread_self(), "name")])],
[AC_DEFINE([HAVE_PTHREAD_SETNAME_NP], [1], [Define if you have pthread_setname_np function.])
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])] )
##############################################################################
### Check for pthread_getname_np (nonstandard GNU extension)
##############################################################################
AC_MSG_CHECKING([for pthread_getname_np])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <pthread.h>], [pthread_getname_np(pthread_self(), NULL, 0)])],
[AC_DEFINE([HAVE_PTHREAD_GETNAME_NP], [1], [Define if you have pthread_getname_np function.])
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])] )
LIBS="$HOLD_LIBS"
fi
##############################################################################
### Check for XSI strerror_r
##############################################################################
AC_MSG_CHECKING([for XSI strerror_r])
HOLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_LINK_IFELSE(
[AC_LANG_SOURCE[
#include <string.h>
#include <errno.h>
int main(int argc, char** argv) {
char buf[1024];
int ret = strerror_r(ENOMEM, buf, sizeof(buf));
return ret;
}
]],
[AC_DEFINE([XSI_STRERROR_R], [1], [Define if you have XSI strerror_r function.])
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])] )
CFLAGS="$HOLD_CFLAGS"
##############################################################################
### Check for full gettext support (lib and required programs)
##############################################################################
LANGCDS=""
AC_CHECK_HEADERS(libintl.h,[INTL="yes"],[INTL="no"])
if (test "x${INTL}" = "xyes"); then
HOLD_CFLAGS=$CFLAGS
HOLD_LIBS=$LIBS
# Check without a lib
CFLAGS=""
LIBS=""
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <libintl.h>], [bindtextdomain ("motion", "/")])],
[INTL="yes"],[INTL="no"])
# If it has flipped to no after our test, try it with a lib
if (test "x${INTL}" = "xno"); then
LIBS=" -lintl"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <libintl.h>], [bindtextdomain ("motion", "/")])],
[INTL="yes"],[INTL="no"])
# If it now a yes, then we needed the lib, add it to temp_libs
# HAVE_INTL still may turn off based upon below so the lib May not be needed.
if (test "x${INTL}" = "xyes"); then
TEMP_LIBS="$TEMP_LIBS -lintl"
fi
fi
CFLAGS=$HOLD_CFLAGS
LIBS=$HOLD_LIBS
fi
MSGFMT=`msgfmt --version 2>/dev/null`
GETTXT=`gettext --version 2>/dev/null`
# Get the langs from what po files exist
for f in ./po/*.po; do
TMP=`basename $f`
TMP=`echo $TMP | sed -e 's/\.po$//'`
if test "x$TMP" != "x*.po"; then
LANGCDS=$LANGCDS" "$TMP
fi
done
if (test "x${INTL}" = "xyes" &&
test "x${MSGFMT}" != "x" &&
test "x${GETTXT}" != "x" &&
test "x${LANGCDS}" != "x" ); then
AC_DEFINE([HAVE_INTL], 1, [Define to 1 if libintl is around])
else
INTL="no"
fi
AC_MSG_CHECKING(Native language support)
AC_MSG_RESULT($INTL)
AC_SUBST(INTL)
AC_SUBST(LANGCDS)
##############################################################################
### Check for JPG
##############################################################################
AC_CHECK_HEADERS(setjmp.h jerror.h jpeglib.h,[JPGS="yes"],[JPGS="no"])
AC_MSG_CHECKING(jpg libraries)
AC_MSG_RESULT($JPGS)
if test x$JPGS = xyes ; then
TEMP_LIBS="$TEMP_LIBS -ljpeg"
else
AC_MSG_ERROR([Required package libjpeg-dev not found, please check motion_guide.html and install necessary dependencies])
fi
##############################################################################
### Check for libmicrohttpd
##############################################################################
AC_CHECK_HEADERS(microhttpd.h,[MHTTP="yes"],[MHTTP="no"])
AC_MSG_CHECKING(libmicrohttpd libraries)
AC_MSG_RESULT($MHTTP)
if test x$MHTTP = xyes ; then
TEMP_LIBS="$TEMP_LIBS -lmicrohttpd "
else
AC_MSG_ERROR([Required package libmicrohttpd-dev not found, please check motion_guide.html and install necessary dependencies])
fi
##############################################################################
### pkg-config
##############################################################################
AC_CHECK_PROG([PKGCONFIG],[pkg-config],[yes],[no])
AM_CONDITIONAL([FOUND_PKGCONFIG], [test "x$PKGCONFIG" = xyes])
AM_COND_IF([FOUND_PKGCONFIG],,[AC_MSG_ERROR([Required package 'pkg-config' not found, please check motion_guide.html and install necessary dependencies.])])
##############################################################################
### Webp Image Format
##############################################################################
AC_ARG_WITH([webp],
AS_HELP_STRING([--with-webp],
[Compile with Webp image support]),
WEBP="$withval",
WEBP="yes")
HAVE_WEBP=""
if test "${WEBP}" = "yes"; then
AC_MSG_CHECKING(for libwebp)
WEBP_DEPS="libwebp"
if pkg-config $WEBP_DEPS; then
AC_MSG_RESULT(found)
AC_DEFINE([HAVE_WEBP], 1, [Define to 1 if WEBP is around])
HAVE_WEBP="yes"
TEMP_LIBS="$TEMP_LIBS -lwebpmux -lwebp"
else
AC_MSG_RESULT(not found)
fi
fi
##############################################################################
### raspberry pi mmal
##############################################################################
WITHOUT_MMAL="no"
AC_ARG_WITH([mmal],
AS_HELP_STRING([--without-mmal],
[Compile without RaspberyPi mmal camera support]),
WITHOUT_MMAL="yes",
WITHOUT_MMAL="no")
AC_ARG_WITH([mmal-lib],
AS_HELP_STRING([--with-mmal-lib[=DIR]],
[Use this command to tell configure where mmal libs directory is.]),
MMAL_LIBS_DIR="$withval",
MMAL_LIBS_DIR="/opt/vc/lib"
)
AC_ARG_WITH([mmal-include],
AS_HELP_STRING([--with-mmal-include[=DIR]],
[Use this command to tell configure where mmal include installation root directory is.]),
MMAL_HEADERS="$withval",
MMAL_HEADERS="/opt/vc/include"
)
if test "${WITHOUT_MMAL}" = "no"; then
HAVE_MMAL=""
if test "${DISTRO}" = "FreeBSD" ; then
LIBRASPBERRYPIDEVPATH="/usr/local/include/interface/mmal"
else
LIBRASPBERRYPIDEVPATH="/opt/vc/include/interface/mmal"
fi
if test -d ${LIBRASPBERRYPIDEVPATH}; then
HAVE_MMAL="yes"
elif test -d ${MMAL_HEADERS}/interface/mmal; then
HAVE_MMAL="yes"
fi
AS_IF([test "${HAVE_MMAL}" = "yes" ], [
AC_SUBST(MMAL_CFLAGS)
AC_SUBST(MMAL_OBJ)
AC_SUBST(MMAL_LIBS)
MMAL_OBJ="mmalcam.o raspicam/RaspiCamControl.o raspicam/RaspiCLI.o"
MMAL_CFLAGS="-std=gnu99 -DHAVE_MMAL -Irasppicam -I${MMAL_HEADERS}"
AS_IF([test "${DISTRO}" = "FreeBSD" ], [
MMAL_CFLAGS="${MMAL_CFLAGS} -I/usr/local/include -I/usr/local/include/interface/vcos -I/usr/local/include/interface/vcos/pthreads/ -I/usr/local/include/interface/vmcs_host/linux"
])
MMAL_LIBS="-L${MMAL_LIBS_DIR} -lmmal_core -lmmal_util -Wl,--push-state,--no-as-needed -lmmal_vc_client -Wl,--pop-state -lvcos -lvchostif -lvchiq_arm"
AC_DEFINE([HAVE_MMAL], 1, [Define to 1 if we want MMAL])
])
fi
##############################################################################
### ffmpeg
##############################################################################
AC_ARG_WITH([ffmpeg],
AS_HELP_STRING([--with-ffmpeg[=DIR]],
[Build with FFMPEG support]),
[with_ffmpeg=$withval],
[with_ffmpeg=yes])
AS_IF([test "x$with_ffmpeg" != "xno"], [
AS_IF([test "x$with_ffmpeg" != "xyes"], [
PKG_CONFIG_PATH=${with_ffmpeg}/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH
])
FFMPEG_DEPS="libavutil libavformat libavcodec libswscale libavdevice"
if pkg-config $FFMPEG_DEPS; then
FFMPEG_CFLAGS=`pkg-config --cflags $FFMPEG_DEPS`
FFMPEG_LIBS=`pkg-config --libs $FFMPEG_DEPS`
FFMPEG_VER=`pkg-config --modversion libavformat`
AC_MSG_CHECKING(for libavformat)
AC_MSG_RESULT(yes $FFMPEG_VER)
HAVE_FFMPEG="yes"
else
AC_MSG_ERROR([Required ffmpeg packages 'libavutil-dev libavformat-dev libavcodec-dev libswscale-dev libavdevice-dev' were not found. Please check motion_guide.html and install necessary dependencies or use the '--without-ffmpeg' configuration option.])
fi
AC_SUBST(FFMPEG_LIBS)
AC_SUBST(FFMPEG_CFLAGS)
])
AS_IF([test "${HAVE_FFMPEG}" = "yes" ], [
AC_DEFINE([HAVE_FFMPEG], 1, [Define to 1 if FFMPEG is around])
])
##############################################################################
### Check SQLITE3
##############################################################################
SQLITE_OBJ=""
SQLITE3_SUPPORT="no"
AC_ARG_WITH(sqlite3,
AS_HELP_STRING([--without-sqlite3],
[Disable sqlite3 support in motion.]),
[SQLITE3="$withval"])
if test "${SQLITE3}" = "no"; then
AC_MSG_CHECKING(for sqlite3)
AC_MSG_RESULT(skipping)
else
# first we check to see if the sqlite3 amalgamation (sqlite3.c), is in with our source
# this is the preferred way to use sqlite
if test -f sqlite3.c; then
SQLITE3_SUPPORT="yes"
SQLITE_OBJ="sqlite3.o"
TEMP_LIBS="$TEMP_LIBS -ldl"
AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3])
AC_DEFINE([HAVE_SQLITE3_EMBEDDED],1,[Define to 1 if you have SQLITE3 embedded support])
else
# if sqlite3.c is not found then we look for the shared library
AC_CHECK_HEADERS(sqlite3.h,
[
TEMP_LIBS="$TEMP_LIBS -lsqlite3"
SQLITE3_SUPPORT="yes"
AC_DEFINE([HAVE_SQLITE3],1,[Define to 1 if you have SQLITE3 shared library support])
]
)
fi
fi
AC_SUBST(SQLITE_OBJ)
##############################################################################
### Check mysql
##############################################################################
MYSQL="yes"
MYSQL_SUPPORT="no"
MYSQL_HEADERS="yes"
MYSQL_LIBS="yes"
MYSQL_INCDIR=""
MYSQL_LIBDIR=""
AC_ARG_WITH(mysql,
AS_HELP_STRING([--without-mysql],[Disable mysql support]),
[MYSQL="$withval"])
AC_ARG_WITH(mysql-lib,
AS_HELP_STRING([--with-mysql-lib[=DIR]],[Specify the library path for mysql]),
[MYSQL_LIBS="$withval"])
AC_ARG_WITH(mysql-include,
AS_HELP_STRING([--with-mysql-include[=DIR]],[Specify the include path for mysql]),
[MYSQL_HEADERS="$withval"])
if test "${MYSQL}" = "no"; then
AC_MSG_CHECKING(for mysql support)
AC_MSG_RESULT(skipped)
else
AC_MSG_CHECKING(for db package config)
if pkg-config mariadb; then
AC_MSG_RESULT(mariadb found)
MYSQL_INCDIR=`pkg-config --cflags mariadb`
MYSQL_LIBDIR=`pkg-config --libs mariadb`
elif pkg-config mysqlclient; then
AC_MSG_RESULT(mysqlclient found)
MYSQL_INCDIR=`pkg-config --cflags mysqlclient`
MYSQL_LIBDIR=`pkg-config --libs mysqlclient`
else
AC_MSG_RESULT(not found)
if test "${MYSQL_HEADERS}" = "yes"; then
AC_MSG_CHECKING(for mysql headers)
for w in $SEARCH_INC; do
if test -f $w/mysql.h; then
MYSQL_INCDIR=$w
break
fi
if test -f $w/mysql/mysql.h; then
MYSQL_INCDIR=$w/mysql
break
fi
if test -f $w/mysql/include/mysql.h; then
MYSQL_INCDIR=$w/mysql/include
break
fi
done
elif test "${MYSQL_HEADERS}" = "no"; then
AC_MSG_CHECKING(for mysql headers)
else
AC_MSG_CHECKING(for mysql headers in $MYSQL_HEADERS)
if test -f $MYSQL_HEADERS/mysql.h; then
MYSQL_INCDIR=$MYSQL_HEADERS
fi
fi
if test -z "$MYSQL_INCDIR" ; then
MYSQL_HEADERS="no"
AC_MSG_RESULT(not found)
else
AC_MSG_RESULT($MYSQL_INCDIR yes)
MYSQL_HEADERS="yes"
fi
# ******* Search mysql libs *********
if test "${MYSQL_LIBS}" = "yes"; then
AC_MSG_CHECKING(for mysql libs)
for w in $SEARCH_LIB; do
if test -f $w/libmysqlclient.a -o -f $w/libmysqlclient.so; then
MYSQL_LIBDIR=$w
break
fi
if test -f $w/mysql/libmysqlclient.a -o -f $w/mysql/libmysqlclient.so; then
MYSQL_LIBDIR=$w/mysql
break
fi
if test -f $w/mysql/lib/libmysqlclient.a -o -f $w/mysql/lib/libmysqlclient.so; then
MYSQL_LIBDIR=$w/mysql/lib
break
fi
done
AC_MSG_RESULT($MYSQL_LIBDIR)
elif test "${MYSQL_LIBS}" = "no"; then
AC_MSG_CHECKING(for mysql libs)
AC_MSG_RESULT(skipped)
else
AC_MSG_CHECKING(for mysql libs in $MYSQL_LIBS)
if test -f $MYSQL_LIBS/libmysqlclient.a -o -f $MYSQL_LIBS/libmysqlclient.so; then
MYSQL_LIBDIR=$MYSQL_LIBS
fi
AC_MSG_RESULT($MYSQL_LIBS)
fi
if test "x$MYSQL_INCDIR" != "x"; then MYSQL_INCDIR="-I$MYSQL_INCDIR"; fi
if test "x$MYSQL_LIBDIR" != "x"; then
MYSQL_LIBDIR=" -L$MYSQL_LIBDIR -lmysqlclient -lz";
else
MYSQL_LIBDIR=" -lmysqlclient -lz"
fi
fi
# ******* Validate MYSQL *********
HOLD_CFLAGS=$CFLAGS
HOLD_LIBS=$LIBS
CFLAGS=$MYSQL_INCDIR
LIBS=$MYSQL_LIBDIR
AC_CHECK_LIB(mysqlclient,mysql_init,[
TEMP_CFLAGS="$TEMP_CFLAGS $MYSQL_INCDIR"
TEMP_LIBS="$TEMP_LIBS $MYSQL_LIBDIR"
MYSQL_SUPPORT="yes"
AC_DEFINE([HAVE_MYSQL],1,[Define to 1 if you have MYSQL support])])
CFLAGS=$HOLD_CFLAGS
LIBS=$HOLD_LIBS
fi
##############################################################################
### Check PostgreSQL
##############################################################################
PGSQL="yes"
PGSQL_SUPPORT="no"
PGSQL_HEADERS="yes"
PGSQL_LIBS="yes"
PGSQL_INCDIR=""
PGSQL_LIBDIR=""
AC_ARG_WITH(pgsql,
AS_HELP_STRING([--without-pgsql],[Disable pgsql support]),
[PGSQL="$withval"])
AC_ARG_WITH(pgsql-lib,
AS_HELP_STRING([--with-pgsql-lib[=DIR]],[Specify the library path for pgsql]),
[PGSQL_LIBS="$withval"])
AC_ARG_WITH(pgsql-include,
AS_HELP_STRING([--with-pgsql-include[=DIR]],[Specify the include path for pgsql]),
[PGSQL_HEADERS="$withval"])
if test "${PGSQL}" = "no"; then
AC_MSG_CHECKING(for pgsql support)
AC_MSG_RESULT(skipped)
else
AC_MSG_CHECKING(for pgsql package config)
if pkg-config libpq; then
AC_MSG_RESULT(found)
PGSQL_INCDIR=`pkg-config --cflags libpq`
PGSQL_LIBDIR=`pkg-config --libs libpq`
else
AC_MSG_RESULT(not found)
if test "${PGSQL_HEADERS}" = "yes"; then
AC_MSG_CHECKING(for pgsql headers)
for w in $SEARCH_INC; do
if test -f $w/libpq-fe.h; then
PGSQL_INCDIR=$w
break
fi
if test -f $w/postgresql/libpq-fe.h; then
PGSQL_INCDIR=$w/postgresql
break
fi
if test -f $w/postgresql/include/libpq-fe.h; then
PGSQL_INCDIR=$w/postgresql/include
break
fi
done
elif test "${PGSQL_HEADERS}" = "no"; then
AC_MSG_CHECKING(for pgsql headers)
AC_MSG_RESULT(skipped)
else
AC_MSG_CHECKING(for pgsql headers in $PGSQL_HEADERS)
if test -f $PGSQL_HEADERS/libpq-fe.h; then
PGSQL_INCDIR=$PGSQL_HEADERS
fi
fi
if test -z "$PGSQL_INCDIR" ; then
PGSQL_HEADERS="no"
AC_MSG_RESULT(not found)
else
AC_MSG_RESULT($PGSQL_INCDIR yes)
PGSQL_HEADERS="yes"
fi
# ******* Search pgsql libs *********
if test "${PGSQL_LIBS}" = "yes"; then
AC_MSG_CHECKING(for pgsql libs)
for w in $SEARCH_LIB; do
if test -f $w/libpq.a -o -f $w/libpq.so; then
PGSQL_LIBDIR=$w
break
fi
if test -f $w/postgresql/libpq.a -o -f $w/postgresql/libpq.so; then
PGSQL_LIBDIR=$w/postgresql
break
fi
if test -f $w/postgresql/lib/libpq.a -o -f $w/postgresql/lib/libpq.so; then
PGSQL_LIBDIR=$w/postgresql/lib
break
fi
done
AC_MSG_RESULT($PGSQL_LIBDIR)
elif test "${PGSQL_LIBS}" = "no"; then
AC_MSG_CHECKING(for pgsql libs)
AC_MSG_RESULT(skipped)
else
AC_MSG_CHECKING(for pgsql libs in $PGSQL_LIBS)
if test -f $PGSQL_LIBS/libpq.a -o -f $PGSQL_LIBS/libpq.so; then
PGSQL_LIBDIR=$PGSQL_LIBS
fi
AC_MSG_RESULT($PGSQL_LIBDIR)
fi
if test "x$PGSQL_INCDIR" != "x"; then PGSQL_INCDIR="-I$PGSQL_INCDIR"; fi
if test "x$PGSQL_LIBDIR" != "x"; then
PGSQL_LIBDIR=" -L$PGSQL_LIBS -lpq";
else
PGSQL_LIBDIR=" -lpq"
fi
fi
# ******* Validate PGSQL *********
HOLD_CFLAGS=$CFLAGS
HOLD_LIBS=$LIBS
CFLAGS=$PGSQL_INCDIR
LIBS=$PGSQL_LIBDIR
AC_CHECK_LIB(pq, PQconnectStart, [
TEMP_CFLAGS="$TEMP_CFLAGS $PGSQL_INCDIR"
TEMP_LIBS="$TEMP_LIBS $PGSQL_LIBDIR"
PGSQL_SUPPORT="yes"
AC_DEFINE([HAVE_PGSQL],1,[Define to 1 if you have PGSQL support])])
CFLAGS=$HOLD_CFLAGS
LIBS=$HOLD_LIBS
fi
##############################################################################
### Optimize compiler
##############################################################################
AC_ARG_WITH([optimizecpu],
AS_HELP_STRING([--without-optimizecpu],
[Exclude autodetecting platform and cpu type. This will disable the compilation of gcc optimizing code by platform and cpu.]),
[OPTIMIZECPU=$withval],
[OPTIMIZECPU=no])
CPU_OPTIONS=""
if test "${OPTIMIZECPU}" = "yes"; then
if test -e "/proc/device-tree/model"; then
# explicit test for RPI3 as /proc/cpuinfo reports armv7 even though it is armv8
RPI3=`grep "Raspberry Pi 3 Model" /proc/device-tree/model`
if test "x${RPI3}" != "x"; then
CPU_OPTIONS="-mcpu=cortex-a53 -mfpu=neon-fp-armv8"
fi
fi
fi
##############################################################################
### Developer Flags
##############################################################################
AC_ARG_WITH([developer-flags],
AS_HELP_STRING([--with-developer-flags],
[Causes practically all of the possible gcc warning flags to be set. This may produce a large amount of warnings.]),
[DEVELOPER_FLAGS=$withval],
[DEVELOPER_FLAGS=no])
if test "${DEVELOPER_FLAGS}" = "yes"; then
TEMP_CFLAGS="${TEMP_CFLAGS} -W -Werror -Wall -Wextra -Wformat -Wshadow -Wpointer-arith -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wno-long-long -ggdb -g3"
fi
CFLAGS="${TEMP_CFLAGS} $CPU_OPTIONS"
LIBS="${TEMP_LIBS}"
LDFLAGS="${TEMP_LDFLAGS}"
##############################################################################
### exec paths
##############################################################################
if test $prefix = "NONE";then
BIN_PATH="$ac_default_prefix"
if test $exec_prefix = "NONE"; then
BIN_PATH="$BIN_PATH/bin"
else
BIN_PATH="$BIN_PATH/$bindir"
fi
else
if test $exec_prefix = "NONE";then
BIN_PATH="$prefix/bin"
else
BIN_PATH="$prefix/$bindir"
fi
fi
AC_SUBST(BIN_PATH)
AC_CHECK_HEADERS(stdio.h unistd.h stdint.h fcntl.h time.h signal.h sys/ioctl.h sys/mman.h sys/param.h sys/types.h)
AC_CONFIG_FILES([
camera1-dist.conf
camera2-dist.conf
camera3-dist.conf
camera4-dist.conf
motion-dist.conf
motion.init-FreeBSD.sh
motion.init-Debian
motion.service
motion.spec
Makefile
])
AC_OUTPUT
##############################################################################
### Report results to user
##############################################################################
echo ""
echo " **************************"
echo " Configure status "
echo " ${PACKAGE_NAME} ${PACKAGE_VERSION}"
echo " **************************"
echo
if test "${DISTRO}" = "Darwin"; then
echo "OS : Darwin"
elif test "${DISTRO}" != "Linux"; then
echo "OS : *BSD"
else
echo "OS : Linux"
fi
if test "${THREADS}" = "yes"; then
echo "pthread support: Yes"
else
echo "pthread support: No"
echo "**********************************************"
echo "** Fatal Error YOU MUST HAVE pthread Support *"
echo "**********************************************"
fi
if test "${JPGS}" = "yes"; then
echo "jpeg support: Yes"
else
echo "jpeg support: No"
echo "**********************************************"
echo "** Fatal Error YOU MUST HAVE jpeg Support ***"
echo "**********************************************"
fi
if test "${HAVE_WEBP}" = "yes"; then
echo "webp support: Yes"
else
echo "webp support: No"
fi
if test "$V4L2" = "yes"; then
echo "V4L2 support: Yes"
else
echo "V4L2 support: No"
fi
if test "${BKTR}" = "yes"; then
echo "BKTR support: Yes"
else
echo "BKTR support: No"
fi
if test "${HAVE_MMAL}" = "yes"; then
echo "MMAL support: Yes"
echo " ... MMAL_CFLAGS: $MMAL_CFLAGS"
echo " ... MMAL_OBJ: $MMAL_OBJ"
echo " ... MMAL_LIBS: $MMAL_LIBS"
elif test "${WITHOUT_MMAL}" = "yes"; then
echo "MMAL support: disabled"
else
echo "MMAL support: No"
echo " ... libraspberrypi-dev package not installed"
fi
if test "${HAVE_FFMPEG}" = "yes"; then
echo "FFmpeg support: Yes"
echo " ... FFMPEG_CFLAGS: $FFMPEG_CFLAGS"
echo " ... FFMPEG_LIBS: $FFMPEG_LIBS"
else
echo "FFmpeg support: No"
fi
if test "${SQLITE3_SUPPORT}" = "yes"; then
echo "SQLite3 support: Yes"
else
echo "SQLite3 support: No"
fi
if test "${MYSQL_SUPPORT}" = "yes"; then
echo "MYSQL support: Yes"
else
echo "MYSQL support: No"
fi
if test "${PGSQL_SUPPORT}" = "yes"; then
echo "PostgreSQL support: Yes"
else
echo "PostgreSQL support: No"
fi
echo
echo "CFLAGS: $CFLAGS"
echo "LIBS: $LIBS"
echo "LDFLAGS: $LDFLAGS"
echo
echo "Install prefix: $prefix"
echo