-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfigure.ac
839 lines (722 loc) · 25.5 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
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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
m4_define([pkg_version], [0.2]) ]
#
# Autotools setup
#
AC_PREREQ([2.60])
AC_INIT([Astra SM], [pkg_version], [bugs@3phase.pw], [astra-sm], [https://3phase.pw/])
AC_DEFINE([PACKAGE_VENDOR], ["3phase.pw"], [Define package's vendor string])
AC_CONFIG_SRCDIR([src/astra/astra.h])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])
AC_CANONICAL_SYSTEM
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([1.11 foreign dist-xz subdir-objects nostdinc -Wall -Werror])
AM_MAINTAINER_MODE([enable])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_PRESERVE_HELP_ORDER
# Checks for programs
AC_LANG(C)
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_PROG_SED
# Initialize libtool
LT_INIT([disable-shared static no-pic])
LT_LIB_DLLOAD
LT_LIB_M
# Set build compiler options
AX_PROG_CC_FOR_BUILD
AM_PROG_CC_C_O
AM_CONDITIONAL([CROSS_COMPILING],
[test "x${cross_compiling}" = "xyes"])
# Check C99 support
found_c99="no"
case "${host_os}" in
mingw*|cygwin*)
AX_CHECK_CFLAG([-std=gnu99], [STD_CFLAGS], [found_c99=yes])
;;
*)
AX_CHECK_CFLAG([-std=c99], [STD_CFLAGS], [found_c99=yes], [
AX_CHECK_CFLAG([-std=iso9899:1999], [STD_CFLAGS], [found_c99=yes], [
AX_CHECK_CFLAG([-std=gnu99], [STD_CFLAGS], [found_c99=yes]) ]) ])
;;
esac
AS_IF([test "x${found_c99}" != "xyes"], [
AC_MSG_ERROR([$CC doesn't support C99]) ])
CFLAGS="$CFLAGS $STD_CFLAGS"
CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD $STD_CFLAGS"
#
# Checks for typedefs, structures, and compiler characteristics
#
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_INT64_T
# use 64 bit file offsets on 32 bit systems
AC_SYS_LARGEFILE
#
# Platform-dependent options
#
AC_ARG_WITH([winver], AC_HELP_STRING([--with-winver=VER], [
minimum Windows version that the build will support
(2k or vista; defaults to vista)
]))
case "${host_os}" in
mingw*)
SYS=win32
# set Windows-specific linker flags
AX_CHECK_LDFLAG([-Wl,--no-seh])
AX_CHECK_LDFLAG([-Wl,--nxcompat])
AX_CHECK_LDFLAG([-Wl,--tsaware])
AX_CHECK_LDFLAG([-Wl,--dynamicbase,--pic-executable], [], [
AX_CHECK_LDFLAG([-Wl,--high-entropy-va], [], [
# high-entropy ASLR is only supported on 64-bit builds
AX_CHECK_LDFLAG([-Wl,--image-base,0x140000000])
AX_CHECK_LDFLAG([-Wl,--entry,mainCRTStartup])
], [
AX_CHECK_LDFLAG([-Wl,--large-address-aware])
AX_CHECK_LDFLAG([-Wl,--entry,_mainCRTStartup])
])
])
# choose value for _WIN32_WINNT
AS_IF([test "x${with_winver}" = "x"], [
# default version
with_winver="vista"
])
windows_version=""
AS_IF([test "x${with_winver}" = "xvista"],
[ windows_version="_WIN32_WINNT_VISTA" ])
AS_IF([test "x${with_winver}" = "x2k"],
[ windows_version="_WIN32_WINNT_WIN2K" ])
AS_IF([test "x${windows_version}" != "x"], [
AC_DEFINE_UNQUOTED([_WIN32_WINNT],
[$windows_version], [Define target Windows version])
], [
AC_MSG_ERROR([invalid value for --with-winver])
])
# add required libraries to linker flags
# timer APIs
AC_CHECK_LIB([winmm], [main],
[], AC_MSG_ERROR([cannot link with winmm.dll]) )
# networking
AC_CHECK_LIB([ws2_32], [main],
[], AC_MSG_ERROR([cannot link with ws2_32.dll]) )
# COM interfaces
AC_CHECK_LIB([ole32], [main],
[], AC_MSG_ERROR([cannot link with ole32.dll]) )
# SysAllocString() and friends
AC_CHECK_LIB([oleaut32], [main],
[], AC_MSG_ERROR([cannot link with oleaut32.dll]) )
# AMGetErrorText()
AC_CHECK_LIB([quartz], [main],
[], AC_MSG_ERROR([cannot link with quartz.dll]) )
# look for resource tools
LT_LANG([Windows Resource])
AS_IF([test "x${RC}" = "x"],
[ AC_MSG_ERROR([couldn't find windres]) ])
AC_CHECK_TOOL([ICOTOOL], [icotool], [no])
AS_IF([test "x${ICOTOOL}" = "xno"],
[ AC_MSG_ERROR([couldn't find icotool]) ])
;;
*)
SYS=posix
# require POSIX threads support
AX_PTHREAD([
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
], [
AC_MSG_ERROR([missing pthread support])
])
# OS headers and functions
AC_CHECK_DECLS([environ])
AC_CHECK_MEMBERS([struct sockaddr_in.sin_len], [], [], [[
#include <sys/types.h>
#include <netinet/in.h>
]])
AC_CHECK_HEADERS([ifaddrs.h netinet/sctp.h])
AC_CHECK_FUNCS([posix_memalign accept4 mkostemp mkstemp pthread_mutex_timedlock])
# getifaddrs(): used by utils.c
AC_CHECK_FUNCS([getifaddrs],
[], [ AC_MSG_WARN([no getifaddrs(); utils.ifaddrs() will be unavailable]) ])
# clock_gettime(): used by clock.c
LIBRT=""
ac_cv_func_clock_gettime="no"
AX_SAVE_FLAGS
AC_SEARCH_LIBS([clock_gettime], [rt], [
AS_IF([test "$LIBS" != "$SAVED_LIBS"], [ LIBRT="-lrt" ])
ac_cv_func_clock_gettime="yes"
AC_DEFINE([HAVE_CLOCK_GETTIME],
[1], [Define to 1 if you have the `clock_gettime' function.])
])
AX_RESTORE_FLAGS
# POSIX AIO: used by `file'
have_aio="no"
AX_SAVE_FLAGS
AC_CHECK_HEADERS([aio.h], [
AC_SEARCH_LIBS([aio_write], [rt], [
AS_IF([test "$LIBS" != "$SAVED_LIBS"], [ LIBRT="-lrt" ])
have_aio="yes"
AC_DEFINE([HAVE_AIO], [1],
[Define to 1 if you have the POSIX AIO interface.])
])
])
AX_RESTORE_FLAGS
AC_SUBST(LIBRT)
;;
esac
AM_CONDITIONAL(HAVE_WIN32, [test "${SYS}" = "win32"])
AM_CONDITIONAL(HAVE_POSIX, [test "${SYS}" = "posix"])
#
# Choose event mechanism
#
event_mechanism=""
# TODO: add option to set this manually
# epoll (Linux-specific)
AS_IF([test "x${event_mechanism}" = "x"], [
epoll_failed="no"
AC_CHECK_HEADER([sys/epoll.h], [
AC_CHECK_FUNCS([epoll_create epoll_ctl epoll_wait], [],
[ epoll_failed="yes" ])
], [
epoll_failed="yes"
])
AS_IF([test "x${epoll_failed}" = "xno"], [
event_mechanism="epoll"
AC_CHECK_FUNCS([epoll_create1])
AC_DEFINE([WITH_EVENT_EPOLL], [1],
[Define to 1 if using epoll for event notification])
])
])
AM_CONDITIONAL([WITH_EPOLL],
[test "x${event_mechanism}" = "xepoll"])
# kqueue (various BSD)
AS_IF([test "x${event_mechanism}" = "x"], [
kqueue_failed="no"
AC_CHECK_HEADER([sys/event.h], [
AC_CHECK_FUNCS([kqueue kevent], [],
[ kqueue_failed="yes" ])
], [
kqueue_failed="yes"
])
AS_IF([test "x${kqueue_failed}" = "xno"], [
event_mechanism="kqueue"
AC_CHECK_FUNCS([kqueue1])
AC_DEFINE([WITH_EVENT_KQUEUE], [1],
[Define to 1 if using kqueue for event notification])
])
])
AM_CONDITIONAL([WITH_KQUEUE],
[test "x${event_mechanism}" = "xkqueue"])
# poll
AS_IF([test "x${event_mechanism}" = "x"], [
poll_failed="no"
AC_CHECK_HEADERS([poll.h])
AC_CHECK_FUNCS([poll], [], [
# Windows Vista introduced its own poll() version
AC_CHECK_DECL([WSAPoll], [
AC_DEFINE([HAVE_WSAPOLL],
[1], [Define to 1 if you have the `WSAPoll' function.])
], [
poll_failed="yes"
], [[
#include <winsock2.h>
]])
])
AS_IF([test "x${poll_failed}" = "xno"], [
event_mechanism="poll"
AC_DEFINE([WITH_EVENT_POLL], [1],
[Define to 1 if using poll() for event notification])
])
])
AM_CONDITIONAL([WITH_POLL],
[test "x${event_mechanism}" = "xpoll"])
# select
AS_IF([test "x${event_mechanism}" = "x"], [
# no need to check the function, it's present on every system
AC_CHECK_HEADERS([sys/select.h])
event_mechanism="select"
AC_DEFINE([WITH_EVENT_SELECT], [1],
[Define to 1 if using select() for event notification])
])
AM_CONDITIONAL([WITH_SELECT],
[test "x${event_mechanism}" = "xselect"])
AC_MSG_NOTICE([using ${event_mechanism} for event notification])
#
# Checks for headers and functions common to all platforms
#
# optional functions
# pread(), strndup(), strnlen(): replaceables
# mktemp(): used for creating pidfiles
AC_CHECK_FUNCS([pread strndup strnlen mktemp])
#
# Checks for external libraries
#
AX_HELP_SECTION([External libraries:])
# lua
AX_EXTLIB_PARAM(lua,
[use external Lua library instead of the bundled version])
AC_ARG_VAR([LUAC], [Lua compiler command])
AC_ARG_WITH([lua-compiler],
AC_HELP_STRING([--with-lua-compiler=PATH], [path to Lua compiler (luac)]))
AS_IF([test "x${with_lua_compiler}" = "xyes" -o -z "${with_lua_compiler}"], [
AS_IF([test -z "${LUAC}"], [
# default value
LUAC="luac luac53 luac52"
])
], [
AS_IF([test "x${with_lua_compiler}" != "xno"], [
# custom compiler path
LUAC="${with_lua_compiler}"
], [
# disabled explicitly
LUAC=""
])
])
have_lua="no"
AS_IF([test "x${with_lua}" != "xno"], [
AX_SAVE_FLAGS
CFLAGS="$CFLAGS $LUA_CFLAGS"
# lua wants -lm on linux
LIBS="$LIBS $LIBM $LUA_LIBS"
AC_CHECK_HEADERS([lua.h], [
AC_SEARCH_LIBS([luaL_len], [lua lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2], [
have_lua="yes"
LUA_LIBS="${LUA_LIBS} ${LIBM} ${LIBADD_DLOPEN} ${ac_res}"
AS_IF([test "x${with_lua_compiler}" != "xno"], [
AC_PATH_PROGS([LUAC], [${LUAC}])
AS_IF([test -z "${LUAC}"], [
AC_MSG_ERROR([Couldn't find Lua compiler; pass --without-lua-compiler to disable this check]) ])
])
])
])
AX_RESTORE_FLAGS
AS_IF([test "x${have_lua}" = "xno"], [
AC_MSG_WARN([Astra requires Lua library version 5.2 or higher])
AS_IF([test "x${with_lua}" != "xyes"], [
AC_MSG_WARN([Bundled version will be built and statically linked])
], [
AC_MSG_ERROR([Pass --without-lua to build bundled version])
])
])
])
AS_IF([test "x${have_lua}" = "xno"], [
LUA_CFLAGS="-I\$(top_srcdir)/lua"
LUA_LIBS="\$(top_builddir)/lua/liblua.la"
AS_IF([test "x${with_lua_compiler}" != "xno"], [
LUAC="\$(top_builddir)/lua/luac\$(EXEEXT)"
])
])
AS_IF([test "x${cross_compiling}" = "xyes" -a -n "${LUAC}"], [
AS_IF([test -z "${with_lua_compiler}"], [
AC_MSG_WARN([Cross compilation detected; disabling Lua syntax checking])
LUAC=""
], [
AC_MSG_ERROR([Cannot cross-compile Lua scripts; pass --without-lua-compiler to disable this check])
])
])
AM_CONDITIONAL([HAVE_INTERNAL_LUA], [test "x${have_lua}" = "xno"])
AM_CONDITIONAL([HAVE_LUA_COMPILER], [test -n "${LUAC}"])
# ffmpeg
AC_ARG_VAR([FFMPEG], [path to ffmpeg program])
AC_ARG_WITH([ffmpeg],
AC_HELP_STRING([--with-ffmpeg=PATH], [path to ffmpeg program]))
AS_IF([test "x${with_ffmpeg}" != "xno"], [
AS_IF([test "x${with_ffmpeg}" = "xyes" -o -z "${with_ffmpeg}"], [
AS_IF([test -z "${FFMPEG}"], [ FFMPEG="ffmpeg" ])
], [
FFMPEG="${with_ffmpeg}"
])
AC_PATH_PROGS([FFMPEG], [${FFMPEG}])
AS_IF([test -z "${FFMPEG}"], [
AS_IF([test -n "${with_ffmpeg}"],
[ AC_MSG_ERROR([Couldn't find ffmpeg program; pass --without-ffmpeg to disable this check]) ],
[ AC_MSG_WARN([Couldn't find ffmpeg program; test patterns will not be built]) ]) ])
], [
FFMPEG=""
])
AM_CONDITIONAL([HAVE_FFMPEG], [test -n "${FFMPEG}"])
# libaio
AX_EXTLIB_PARAM(libaio,
[enable libaio for file I/O (Linux only)] )
have_libaio="no"
AS_IF([test "x${have_aio}" = "xyes"], [
AS_IF([test "x${with_libaio}" != "xno"], [
AX_SAVE_FLAGS
CFLAGS="$CFLAGS $LIBAIO_CFLAGS"
LIBS="$LIBS $LIBAIO_LIBS"
AC_CHECK_HEADERS([libaio.h], [
AC_CHECK_LIB([aio], [io_queue_init], [
AC_DEFINE([HAVE_LIBAIO], [1], [Define to 1 if you have libaio])
have_libaio="yes"
LIBAIO_LIBS="${LIBAIO_LIBS} -laio"
])
])
AX_RESTORE_FLAGS
AS_IF([test "x${have_libaio}" = "xno"], [
AS_IF([test "x${with_libaio}" = "xyes"],
[ AC_MSG_ERROR([could not find libaio; pass --disable-libaio to disable this check]) ],
[ AC_MSG_WARN([could not find libaio; Linux AIO support will be unavailable]) ]) ])
])
], [
AS_IF([test "x${with_libaio}" = "xyes"], [
AC_MSG_ERROR([libaio is not supported on this platform]) ])
])
AM_CONDITIONAL([HAVE_LIBAIO], [test "x${have_libaio}" = "xyes"])
# libdvbcsa
AX_EXTLIB_PARAM(dvbcsa,
[enable CSA (de)scrambling using libdvbcsa])
have_dvbcsa="no"
AS_IF([test "x${with_dvbcsa}" != "xno"], [
AX_SAVE_FLAGS
CFLAGS="$CFLAGS $DVBCSA_CFLAGS"
LIBS="$LIBS $DVBCSA_LIBS"
AC_CHECK_HEADERS([dvbcsa/dvbcsa.h], [
AC_CHECK_LIB([dvbcsa], [dvbcsa_bs_key_alloc], [
AC_DEFINE([HAVE_DVBCSA], [1], [Define to 1 if you have libdvbcsa])
have_dvbcsa="yes"
DVBCSA_LIBS="${DVBCSA_LIBS} -ldvbcsa"
])
])
AX_RESTORE_FLAGS
AS_IF([test "x${have_dvbcsa}" = "xno"], [
AS_IF([test "x${with_dvbcsa}" = "xyes"],
[ AC_MSG_ERROR([could not find dvbcsa; pass --disable-dvbcsa to disable this check]) ],
[ AC_MSG_WARN([could not find dvbcsa; CSA support will be unavailable]) ]) ])
])
AM_CONDITIONAL([HAVE_DVBCSA], [test "x${have_dvbcsa}" = "xyes"])
# OpenSSL (libcrypto)
AX_EXTLIB_OPTIONAL(libcrypto,
[enable linking with OpenSSL crypto library])
AS_IF([test "x${with_libcrypto_includes}" != "xno"],
[LIBCRYPTO_CFLAGS="-I${with_libcrypto_includes}"])
AS_IF([test "x${with_libcrypto_libs}" != "xno"],
[LIBCRYPTO_LIBS="-L${with_libcrypto_libs} -lcrypto"])
have_libcrypto="no"
AS_IF([test "x${with_libcrypto}" != "xno"], [
AX_SAVE_FLAGS
PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto], [
CFLAGS="$CFLAGS $LIBCRYPTO_CFLAGS"
LIBS="$LIBS $LIBCRYPTO_LIBS"
AC_CHECK_HEADERS([openssl/des.h], [
AC_CHECK_LIB([crypto], [DES_random_key], [
AC_DEFINE([HAVE_LIBCRYPTO], [1],
[Define to 1 if you have OpenSSL libcrypto])
have_libcrypto="yes"
], [
# linking check failed
LIBCRYPTO_PKG_ERRORS="could not link with libcrypto"
])
], [
# header check failed
LIBCRYPTO_PKG_ERRORS="could not find libcrypto headers"
])
], [
# pkgconfig call failed
LIBCRYPTO_PKG_ERRORS="could not find libcrypto; refer to config.log for details"
])
AX_RESTORE_FLAGS
AS_IF([test "x${have_libcrypto}" = "xno"], [
AS_IF([test "x${with_libcrypto}" = "xyes"],
[ AC_MSG_ERROR([${LIBCRYPTO_PKG_ERRORS}]) ],
[ AC_MSG_WARN([${LIBCRYPTO_PKG_ERRORS}]) ]) ])
])
AM_CONDITIONAL([HAVE_LIBCRYPTO], [test "x${have_libcrypto}" = "xyes"])
# Check
AX_EXTLIB_OPTIONAL(check, [enable unit testing using Check])
AS_IF([test "x${with_check_includes}" != "xno"],
[CHECK_CFLAGS="-I${with_check_includes}"])
AS_IF([test "x${with_check_libs}" != "xno"],
[CHECK_LIBS="-L${with_check_libs} -lcheck"])
have_check="no"
AS_IF([test "x${with_check}" != "xno"], [
AX_SAVE_FLAGS
PKG_CHECK_MODULES([CHECK], [check], [
CFLAGS="$CFLAGS $CHECK_CFLAGS"
# libcheck may need -lm -lrt if it's compiled statically
LIBS="$LIBS $LIBM $LIBRT $CHECK_LIBS"
AC_CHECK_HEADERS([check.h], [
AC_CHECK_LIB([check], [tcase_set_timeout], [
have_check="yes"
], [
# linking check failed
CHECK_PKG_ERRORS="could not link with libcheck"
])
], [
# header check failed
CHECK_PKG_ERRORS="could not find check headers"
])
], [
# pkgconfig call failed
CHECK_PKG_ERRORS="could not find check; refer to config.log for details"
])
AX_RESTORE_FLAGS
AS_IF([test "x${have_check}" = "xno"], [
AS_IF([test "x${with_check}" = "xyes"],
[ AC_MSG_ERROR([${CHECK_PKG_ERRORS}]) ],
[ AC_MSG_WARN([${CHECK_PKG_ERRORS}]) ]) ])
])
AM_CONDITIONAL([HAVE_CHECK], [test "x${have_check}" = "xyes"])
#
# Optional features
#
AX_HELP_SECTION([Optional features:])
# Linux DVB API
AC_ARG_ENABLE([dvbapi], AC_HELP_STRING([--disable-dvbapi],
[disable DVB receive functionality on Linux (auto)]))
have_dvbapi="no"
AS_IF([test "x${enable_dvbapi}" != "xno" -a "x${SYS}" = "xposix"], [
AX_DVBAPI([have_dvbapi="yes"])
AS_IF([test "x${have_dvbapi}" = "xno"], [
AS_IF([test "x${enable_dvbapi}" = "xyes"],
[ AC_MSG_ERROR([no DVB API found; pass --disable-dvbapi to disable this check ]) ],
[ AC_MSG_WARN([no DVB API found; DVB reception will be unavailable]) ]) ])
])
AM_CONDITIONAL([HAVE_DVBAPI], [test "x${have_dvbapi}" = "xyes"])
# Built-in scripts
AC_ARG_ENABLE([inscript], AC_HELP_STRING([--disable-inscript],
[don't build Lua scripts into binary (enabled)]))
AS_IF([test "x${enable_inscript}" != "xno"], [
AC_DEFINE([HAVE_INSCRIPT], [1],
[Define to 1 if built-in script module is enabled])
])
AM_CONDITIONAL([HAVE_INSCRIPT], [test "x${enable_inscript}" != "xno"])
# IGMP emulation
AC_ARG_ENABLE([igmp-emulation], AC_HELP_STRING([--enable-igmp-emulation],
[send IGMP using raw sockets (disabled, needs CAP_NET_RAW)]))
AS_IF([test "x${enable_igmp_emulation}" = "xyes"], [
AC_DEFINE([IGMP_EMULATION], [1],
[Define to 1 to use IGMP emulation via raw sockets])
])
AM_CONDITIONAL([IGMP_EMULATION], [test "x${enable_igmp_emulation}" != "xno"])
#
# Developer options
#
AX_HELP_SECTION([Developer options:])
kill_optflags="no"
# Debug version
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug], [build a debug version]))
AS_IF([test "x${enable_debug}" = "xyes"], [
AC_DEFINE([DEBUG], [1], [Define when building a debug version])
# add debug info
AX_CHECK_CFLAG([-g3], [], [], [
# try to fall back to -g
AX_CHECK_CFLAG([-g], [], [], [
AC_MSG_ERROR([$CC doesn't support required debug flag; pass --disable-debug to disable this check])
])
])
# non-essential debug flags
AX_CHECK_CFLAG([-ggdb])
AX_CHECK_CFLAG([-ggdb3])
AX_CHECK_CFLAG([-fno-builtin])
kill_optflags="yes"
])
# Test coverage
AC_ARG_ENABLE([gcov],
AC_HELP_STRING([--enable-gcov], [enable test coverage analysis]))
AS_IF([test "x${enable_gcov}" = "xyes"], [
have_gcov="no"
AX_CHECK_CFLAG([-ftest-coverage], [],
[ AX_CHECK_CFLAG([-fprofile-arcs], [], [have_gcov="yes"]) ])
AS_IF([test "x${have_gcov}" != "xyes"], [
AC_MSG_ERROR([$CC doesn't support gcov; pass --disable-gcov to disable this check])
])
LIBS="$LIBS -lgcov"
kill_optflags="yes"
])
# Profiling
AC_ARG_ENABLE([gprof],
AC_HELP_STRING([--enable-gprof], [enable profiling with gprof]))
AS_IF([test "x${enable_gprof}" = "xyes"], [
AX_CHECK_CFLAG([-pg], [], [], [
AC_MSG_ERROR([$CC doesn't support gprof; pass --disable-gprof to disable this check])
])
])
# Remove optimization flags
AS_IF([test "x${kill_optflags}" = "xyes"], [
CFLAGS=$(echo "$CFLAGS" | $SED -r -e 's/@<:@ @:>@*(-O@<:@^ @:>@*)@<:@ @:>@*/ /g')
AX_CHECK_CFLAG([-O0])
], [
AX_CHECK_CFLAG([-fomit-frame-pointer])
AX_CHECK_CFLAG([-funsafe-loop-optimizations])
AX_CHECK_CFLAG([-ffast-math])
])
# Lots of warnings
WARN_CFLAGS=""
AC_ARG_ENABLE([warnings],
AC_HELP_STRING([--enable-warnings], [turn on additional compiler warnings]))
# these are always on
AX_CHECK_CFLAG([-Wall], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wextra], [WARN_CFLAGS])
AS_IF([test "x${enable_warnings}" = "xyes"], [
# older GCC versions don't support -Wpedantic
AX_CHECK_CFLAG([-Wpedantic], [WARN_CFLAGS], [],
[ AX_CHECK_CFLAG([-pedantic], [WARN_CFLAGS]) ])
AX_CHECK_CFLAG([-Waggregate-return], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wbad-function-cast], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wclobbered], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wdouble-promotion], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wfloat-equal], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Winit-self], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wmissing-declarations], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wmissing-include-dirs], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wmissing-prototypes], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wmissing-variable-declarations], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wnested-externs], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wold-style-definition], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wpointer-arith], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wstack-protector], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wstrict-prototypes], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wsync-nand], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wtrampolines], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wundef], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wuninitialized], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wunused], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wuseless-cast], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wvector-operation-performance], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wwrite-strings], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wformat=2], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wc++-compat], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wdisabled-optimization], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Winvalid-pch], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wshadow], [WARN_CFLAGS])
# OS-specific
case "$host_os" in
openbsd*)
;;
*)
AX_CHECK_CFLAG([-Wredundant-decls], [WARN_CFLAGS])
esac
# GCC-specific
AX_CHECK_CFLAG([-Wjump-misses-init], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wlogical-op], [WARN_CFLAGS])
# Clang-specific
AX_CHECK_CFLAG([-Wgnu], [WARN_CFLAGS], [
AX_CHECK_CFLAG([-Wno-gnu-zero-variadic-macro-arguments], [WARN_CFLAGS]) ])
])
# Less important warnings
AC_ARG_ENABLE([suggestions],
AC_HELP_STRING([--enable-suggestions], [turn on non-vital warnings (e.g. -Wsuggest-*)]))
AS_IF([test "x${enable_suggestions}" = "xyes"], [
AX_CHECK_CFLAG([-Wsuggest-attribute=noreturn], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wsuggest-attribute=format], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wmissing-format-attribute], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wunsafe-loop-optimizations], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wstrict-overflow=5], [WARN_CFLAGS])
AX_CHECK_CFLAG([-Wcast-align], [WARN_CFLAGS])
AX_CHECK_CFLAG([-fipa-pure-const], [WARN_CFLAGS])
])
# -Werror build
AC_ARG_ENABLE([werror],
AC_HELP_STRING([--enable-werror], [turn on -Werror]))
AS_IF([test "x${enable_werror}" = "xyes"], [
AX_CHECK_CFLAG([-Werror], [WARN_CFLAGS])
])
AC_SUBST(WARN_CFLAGS)
# Other flags
AX_CHECK_CFLAG([-fno-strict-aliasing])
AX_CHECK_CFLAG([-fwrapv])
#
# Makefile generation
#
AC_CONFIG_FILES([
Makefile
lua/Makefile
scripts/Makefile
tools/Makefile
icons/Makefile
src/Makefile
testcards/Makefile
])
AC_OUTPUT
# Print configuration summary
echo
echo "Configuration summary"
echo "-----------------------"
echo "Version: ${PACKAGE_STRING}"
echo
echo "Compiler: ${CC}"
echo -n "Building for: ${host_os}"
AS_IF([test "x${SYS}" = "xwin32"], [
echo -n ", ${with_winver} (${windows_version})"
])
echo
echo "Event mechanism: ${event_mechanism}"
# large file support
echo -n "Large files: "
AS_IF([test "x${enable_largefile}" != "xno"], [echo "yes"], [echo "no"])
echo
# lua (lib/compiler)
echo -n "Lua library: "
AS_IF([test "x${have_lua}" = "xyes"], [echo "external"], [echo "internal"])
echo -n "Lua compiler: "
AS_IF([test -n "${LUAC}"], [echo "${LUAC}"], [echo "no"])
# ffmpeg
echo -n "ffmpeg program: "
AS_IF([test -n "${FFMPEG}"], [echo "${FFMPEG}"], [echo "no"])
# libdvbcsa
echo -n "libdvbcsa: "
AS_IF([test "x${have_dvbcsa}" = "xyes"], [echo "yes"], [echo "no"])
# libcrypto
echo -n "libcrypto: "
AS_IF([test "x${have_libcrypto}" = "xyes"], [echo "yes"], [echo "no"])
# aio (linux/posix)
echo -n "Asynchronous I/O: "
AS_IF([test "x${have_aio}" = "xyes"], [
AS_IF([test "x${have_libaio}" = "xyes"],
[echo "yes (Linux)"], [echo "yes (POSIX)"])
], [
echo "no"
])
# check
echo -n "Check (unit tests): "
AS_IF([test "x${have_check}" = "xyes"],
[echo "yes"], [echo "no"])
# dvb api
echo
AS_IF([test "x${SYS}" = "xposix"], [
echo -n "Linux DVB API: "
AS_IF([test "x${have_dvbapi}" = "xyes"], [echo "yes"], [echo "no"])
])
# inscript
echo -n "Built-in scripts: "
AS_IF([test "x${enable_inscript}" != "xno"], [echo "yes"], [echo "no"])
# igmp emulation
echo -n "IGMP emulation: "
AS_IF([test "x${enable_igmp_emulation}" = "xyes"],
[echo "yes"], [echo "no"])
# debug build
echo
echo -n "Debug build: "
AS_IF([test "x${enable_debug}" = "xyes"], [echo "yes"], [echo "no"])
# extra warnings
echo -n "Extra warnings: "
AS_IF([test "x${enable_warnings}" = "xyes"], [
echo -n "yes"
AS_IF([test "x${enable_suggestions}" = "xyes"], [
echo -n " (w/suggestions)"
])
echo
], [
echo "no"
])
# test coverage
echo -n "Test coverage: "
AS_IF([test "x${enable_gcov}" = "xyes"], [echo "yes"], [echo "no"])
# profiling
echo -n "Profiling: "
AS_IF([test "x${enable_gprof}" = "xyes"], [echo "yes"], [echo "no"])