forked from xbianonpi/xbian-sources-libcec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
447 lines (380 loc) · 16.4 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
AC_PREREQ(2.59)
AC_INIT([libcec], [2:1:0], [http://libcec.pulse-eight.com/])
AC_CONFIG_HEADERS([config.h])
AH_TOP([#pragma once])
AM_INIT_AUTOMAKE([foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_CANONICAL_HOST
cflags_reset="$CFLAGS"
AC_LANG(C++)
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_PROG_INSTALL
AC_LIBTOOL_DLOPEN
CFLAGS="$cflags_reset"
msg_pkg_config_missing="'pkg-config' is missing - adapter detection will not be available"
msg_pthread_missing="required library 'pthread' is missing"
msg_dl_missing="required library 'dl' is missing"
msg_udev_missing="library 'udev' is missing - adapter detection will not be available"
msg_dirent_missing="dirent.h header is missing - adapter detection will not be available"
msg_lockdev_missing="library 'liblockdev' is missing"
msg_rpi_api_missing="Raspberry Pi API not found or incompatible with libCEC"
msg_rpi_will_check="will check for RPi support"
msg_rpi_unsupported_target="will not check for RPi support (unsupported cpu: ${host_cpu})"
msg_required_header_missing="required header is missing"
## debugging symbols
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[include debug symbols (default is no)])],
[use_debug=$enableval],
[use_debug=no])
## optimisation
AC_ARG_ENABLE([optimisation],
[AS_HELP_STRING([--enable-optimisation],
[optimisation flag (default is yes)])],
[use_optimisation=$enableval],
[use_optimisation=yes])
## TDA995x support
AC_ARG_ENABLE([cubox],
[AS_HELP_STRING([--enable-tda995x],
[enable support for the TDA995x (default is no)])],
[use_tda995x=$enableval],
[use_tda995x=no])
## Optional path to the tda995x dev toolkit
AC_ARG_WITH([tda995x-toolkit-path],
[AS_HELP_STRING([--with-tda995x-toolkit-path],
[location of the TDA995x driver toolkit (default is ./nxp_hdmi)])],
[TDA995X_CFLAGS="-I$withval/inc"],
[TDA995X_CFLAGS="-I\$(abs_top_srcdir)/nxp_hdmi/inc"])
## Exynos support
AC_ARG_ENABLE([exynos],
[AS_HELP_STRING([--enable-exynos],
[enable support for the Exynos (default is yes)])],
[use_exynos=$enableval],
[use_exynos=yes])
## Raspberry Pi support
AC_ARG_ENABLE([rpi],
[AS_HELP_STRING([--enable-rpi],
[enable support for the Raspberry Pi (default is auto)])],
[use_rpi=$enableval],
[use_rpi=auto])
## Optional path to the RPi's dev headers
AC_ARG_WITH([rpi-include-path],
[AS_HELP_STRING([--with-rpi-include-path],
[location of the Raspberry Pi headers (location of /opt/vc/include, default is auto)])],
[RPI_CFLAGS="-I$withval -I$withval/interface/vcos/pthreads -I$withval/interface/vmcs_host/linux"])
## Optional path to libbcm_host.so
AC_ARG_WITH([rpi-lib-path],
[AS_HELP_STRING([--with-rpi-lib-path],
[location of the Raspberry Pi libraries (location of libbcm_host.so, default is auto)])],
[RPI_LIBS="-L$withval"])
## only check for the RPi API on ARM targets
if test "x$use_rpi" != "xno"; then
case "${host_cpu}" in
arm*)
AC_MSG_NOTICE($msg_rpi_will_check)
;;
*)
if test "x$use_rpi" = "xyes"; then
AC_MSG_ERROR($msg_rpi_unsupported_target)
else
AC_MSG_NOTICE($msg_rpi_unsupported_target)
fi
use_rpi="no"
;;
esac
fi
## i.MX6 support
AC_ARG_ENABLE([imx6],
[AS_HELP_STRING([--enable-imx6],
[enable support for freescale i.MX6 (default is no)])],
[use_imx6=$enableval],
[use_imx6=no])
## add the top dir and include to the include path, so we can include config.h and cec.h
CPPFLAGS="$CPPFLAGS -I\$(abs_top_srcdir)/src -I\$(abs_top_srcdir)/include"
## search for pkg-config
AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
if test "x$HAVE_PKG_CONFIG" != "xyes" ; then
AC_MSG_WARN($msg_pkg_config_missing)
fi
## search for pthread, required by all targets
AC_SEARCH_LIBS([pthread_create],[pthread],,AC_MSG_ERROR($msg_pthread_missing))
AC_CHECK_FUNCS([pthread_mutexattr_init pthread_cond_init pthread_cond_destroy pthread_cond_signal pthread_cond_broadcast pthread_cond_wait pthread_cond_timedwait])
## search for dlopen, required by all targets
AC_SEARCH_LIBS([dlopen], [dl],
[test "$ac_cv_search_dlopen" = "none required" || LIBS_DL=$ac_cv_search_dlopen],
AC_MSG_ERROR($msg_dl_missing))
AC_CHECK_FUNCS([dlopen dlclose dlsym])
## platform specific libs, required by all targets
case "${host}" in
*-*-linux*)
# for timeutils
AC_SEARCH_LIBS([clock_gettime], [rt])
;;
*-apple-darwin*)
LIBS="$LIBS -framework CoreVideo -framework IOKit"
;;
esac
## we found all the libs and headers that we need for the client applications
libs_client="$LIBS"
## search for udev, lockdev and the RPi API, only required by libCEC
use_udev="no"
use_adapter_detection="yes"
use_lockdev="no"
SUPPRESS_MANGLING_WARNINGS=" -Wno-psabi"
case "${host}" in
*-*-linux*)
## search for udev if pkg-config was found
if test "x$HAVE_PKG_CONFIG" = "xyes" ; then
PKG_CHECK_MODULES([UDEV],[libudev],use_udev="yes",AC_MSG_WARN($msg_udev_missing))
fi
## we need dirent.h on linux too
if test "$use_udev" = "yes"; then
AC_CHECK_HEADER(dirent.h,,[use_udev="no";AC_MSG_WARN($msg_dirent_missing)])
fi
if test "$use_udev" != "yes"; then
use_adapter_detection="no"
fi
## search for lockdev
use_lockdev="yes"
AC_CHECK_HEADER(lockdev.h,,[use_lockdev="no";AC_MSG_WARN($msg_lockdev_missing)])
AC_CHECK_LIB(lockdev,dev_unlock,,[use_lockdev="no";AC_MSG_WARN($msg_lockdev_missing)])
AC_CHECK_HEADER(time.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(sys/prctl.h,,AC_MSG_ERROR($msg_required_header_missing))
## search for the RPi API. we need to check a couple of things to see if
## it's recent enough and contains the calls needed for libCEC to operate
## correctly.
if test "x$use_rpi" != "xno"; then
CPPFLAGS="$CPPFLAGS $RPI_CFLAGS"
libs_pre_rpi="$LIBS"
LIBS="$LIBS $RPI_LIBS -lvcos -lvchiq_arm"
check_rpi_cec_service="yes"
## check for headers we need
AC_CHECK_HEADER(interface/vmcs_host/vc_cec.h,,check_rpi_cec_service="no")
AC_CHECK_HEADER(interface/vmcs_host/vc_cecservice.h,,check_rpi_cec_service="no")
AC_CHECK_HEADER(interface/vchiq_arm/vchiq_if.h,,check_rpi_cec_service="no")
AC_CHECK_HEADER(bcm_host.h,,check_rpi_cec_service="no")
## check if the headers contain support for libCEC.
## VC_CECSERVICE_VER needs to be defined
AC_MSG_CHECKING([interface/vmcs_host/vc_cec.h compatibility])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <interface/vmcs_host/vc_cecservice.h>
#include <interface/vchiq_arm/vchiq_if.h>
#if !defined(VC_CECSERVICE_VER)
#error RPi headers does not contain libCEC support
#endif]], [[]])],[AC_MSG_RESULT([yes])],[check_rpi_cec_service="no"; AC_MSG_RESULT([no])])
## check if the methods we're using can be found in libbcm_host.so, so we don't use an incompatible version
AC_CHECK_LIB(bcm_host,vchi_initialise,,check_rpi_cec_service="no")
libs_tmp="$LIBS"
AC_CHECK_LIB(bcm_host,vc_vchi_cec_init,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vc_cec_get_logical_address,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vc_cec_get_physical_address,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vc_cec_param2message,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vc_cec_poll_address,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vc_cec_register_callback,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vc_cec_release_logical_address,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vc_cec_set_passive,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vcos_init,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vchiq_initialise,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vchi_initialise,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,vchi_create_connection,,check_rpi_cec_service="no")
AC_CHECK_LIB(bcm_host,bcm_host_init,,check_rpi_cec_service="no")
LIBS="$libs_tmp"
if test "x$check_rpi_cec_service" != "xyes" && test "x$use_rpi" = "xyes"; then
AC_MSG_ERROR($msg_rpi_api_missing)
elif test "x$check_rpi_cec_service" != "xyes"; then
use_rpi="no"
LIBS="$libs_pre_rpi"
fi
fi
## search for X11/xrandr
libs_tmp="$LIBS"
use_x11_xrandr="yes"
AC_CHECK_HEADER(X11/Xlib.h,,[use_x11_xrandr="no"])
AC_CHECK_HEADER(X11/Xatom.h,,[use_x11_xrandr="no"])
AC_CHECK_HEADER(X11/extensions/Xrandr.h,,[use_x11_xrandr="no"])
AC_CHECK_LIB(X11,XOpenDisplay,,[use_x11_xrandr="no"])
AC_CHECK_LIB(Xrandr,XRRGetScreenResources,,[use_x11_xrandr="no"])
if test "x$use_x11_xrandr" = "xyes"; then
AC_DEFINE([HAVE_RANDR],[1],[Define to 1 to include support for the X11 randr extension])
AM_CONDITIONAL(USE_X11_RANDR, true)
else
AM_CONDITIONAL(USE_X11_RANDR, false)
LIBS="$libs_tmp"
fi
;;
*-apple-darwin*)
AC_CHECK_HEADER(mach/mach_time.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(CoreVideo/CVHostTime.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_DEFINE([TARGET_DARWIN], [1], [Darwin target])
AM_CONDITIONAL(USE_X11_RANDR, false)
SUPPRESS_MANGLING_WARNINGS=""
;;
esac
## define the build info
LIB_INFO="host: ${host}, features:"
features="Configured features:\n Pulse-Eight CEC Adapter :\t\tyes"
LIB_INFO="$LIB_INFO 'P8 USB'"
AC_DEFINE([HAVE_P8_USB],[1],[Define to 1 to include support for the Pulse-Eight USB-CEC Adapter])
AM_CONDITIONAL(USE_P8_USB, true)
if test "x$use_lockdev" = "xyes"; then
AC_DEFINE([HAVE_LOCKDEV],[1],[Define to 1 if liblockdev is installed])
fi
## mark adapter detection as available if the required deps were found
if test "x$use_adapter_detection" = "xyes"; then
## mark udev as available if it was found
if test "x$use_udev" = "xyes"; then
INCLUDES="$INCLUDES $UDEV_CFLAGS"
LIBS="$LIBS $UDEV_LIBS"
AC_DEFINE([HAVE_LIBUDEV],[1],[Define to 1 if libudev is installed])
REQUIRES="$REQUIRES udev"
fi
AC_DEFINE([HAVE_P8_USB_DETECT],[1],[Define to 1 to include autodetection support for the Pulse-Eight USB-CEC Adapter])
AM_CONDITIONAL(USE_P8_USB_DETECT, true)
features="$features\n Pulse-Eight CEC Adapter detection :\tyes"
LIB_INFO="$LIB_INFO 'P8 USB detect'"
else
AM_CONDITIONAL(USE_P8_USB_DETECT, false)
features="$features\n Pulse-Eight CEC Adapter detection :\tno"
fi
## mark RPi support as available if the required headers and libs were found
if test "x$use_rpi" != "xno"; then
AC_DEFINE([HAVE_RPI_API],[1],[Define to 1 to include RPi support])
AM_CONDITIONAL(USE_RPI_API, true)
features="$features\n Raspberry Pi support :\t\tyes"
LIB_INFO="$LIB_INFO 'RPi'"
else
AM_CONDITIONAL(USE_RPI_API, false)
features="$features\n Raspberry Pi support :\t\tno"
fi
## mark TDA995x support as available
if test "x$use_tda995x" != "xno"; then
AC_DEFINE([HAVE_TDA995X_API],[1],[Define to 1 to include CuBox support])
AM_CONDITIONAL(USE_TDA995X_API, true)
features="$features\n TDA995x support :\t\t\tyes"
LIB_INFO="$LIB_INFO 'TDA995x'"
CPPFLAGS="$CPPFLAGS $TDA995X_CFLAGS"
else
AM_CONDITIONAL(USE_TDA995X_API, false)
features="$features\n TDA995x support :\t\t\tno"
fi
## mark i.MX6 support as available
if test "x$use_imx6" != "xno"; then
AC_DEFINE([HAVE_IMX_API],[1],[Define to 1 to include i.MX6 support])
AM_CONDITIONAL(USE_IMX_API, true)
features="$features\n i.MX6 support :\t\t\tyes"
LIB_INFO="$LIB_INFO 'i.MX6'"
else
AM_CONDITIONAL(USE_IMX_API, false)
features="$features\n i.MX6 support :\t\t\tno"
fi
## mark Exynos support as available
if test "x$use_exynos" != "xno"; then
AC_DEFINE([HAVE_EXYNOS_API],[1],[Define to 1 to include Exynos support])
AM_CONDITIONAL(USE_EXYNOS_API, true)
features="$features\n Exynos support :\t\t\tyes"
LIB_INFO="$LIB_INFO 'EXYNOS'"
CPPFLAGS="$CPPFLAGS $EXYNOS_CFLAGS"
else
AM_CONDITIONAL(USE_EXYNOS_API, false)
features="$features\n EXYNOS support :\t\t\tno"
fi
## check if our build system is complete
AC_CHECK_HEADER(algorithm,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(ctype.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(errno.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(functional,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(locale,,AC_DEFINE([SS_NO_LOCALE],[1],[Define to 1 to exclude locale support]))
AC_CHECK_HEADER(map,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(netdb.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(poll.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(queue,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(semaphore.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(set,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(stdarg.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(stdint.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(stdio.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(stdlib.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(string,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(string.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(termios.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(unistd.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(vector,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(wchar.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(wctype.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(netinet/in.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(netinet/tcp.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(sys/time.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_HEADER(sys/types.h,,AC_MSG_ERROR($msg_required_header_missing))
AC_CHECK_FUNCS([close fcntl select write read shutdown send recv memset sprintf getaddrinfo getsockopt setsockopt connect poll sched_yield open strerror tcsetattr tcgetattr cfsetispeed cfsetospeed bind freeaddrinfo listen accept socket])
## add the build date to LIB_INFO
AC_CHECK_PROG(HAVE_GIT, git, yes)
if test "x$HAVE_GIT" = "xyes"; then
revision=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h" HEAD)
fi
if test "x$revision" != "x"; then
LIB_INFO="$LIB_INFO, git revision: ${revision}"
fi
AC_CHECK_PROG(HAVE_DATE, date, yes)
if test "x$HAVE_DATE" = "xyes"; then
LIB_INFO="$LIB_INFO, compiled on: `date -u`"
else
LIB_INFO="$LIB_INFO, compiled on: (unknown date)"
fi
## add the name of the user who built libCEC to LIB_INFO
AC_CHECK_PROG(HAVE_WHOAMI, whoami, yes)
if test "x$HAVE_WHOAMI" = "xyes" ; then
LIB_INFO="$LIB_INFO by `whoami`"
else
LIB_INFO="$LIB_INFO by (unknown user)"
fi
## add the hostname of the build host of libCEC to LIB_INFO
AC_CHECK_PROG(HAVE_HOSTNAME, hostname, yes)
if test "x$HAVE_HOSTNAME" = "xyes"; then
LIB_INFO="$LIB_INFO@`hostname -f`"
fi
## add the system info of the build host of libCEC to LIB_INFO
AC_CHECK_PROG(HAVE_UNAME, uname, yes)
if test "x$HAVE_UNAME" = "xyes"; then
LIB_INFO="$LIB_INFO on `uname -s` `uname -r` (`uname -m`)"
fi
## redefine the LIBS, so cec-client isn't linked against things they don't need
LIBS_LIBCEC="$LIBS"
LIBS="$libs_client"
CXXFLAGS="$CXXFLAGS -fPIC -Wall -Wextra -Wno-missing-field-initializers $SUPPRESS_MANGLING_WARNINGS"
if test "x$use_debug" = "xyes"; then
CXXFLAGS="$CXXFLAGS -g"
AC_DEFINE(CEC_DEBUGGING,"1", "generate libCEC debug output")
fi
if test "x$optimisation" = "xyes"; then
CXXFLAGS="$CXXFLAGS -O2"
fi
AC_DEFINE_UNQUOTED(LIB_INFO,"$LIB_INFO", "information about how libCEC was compiled")
AC_SUBST([REQUIRES])
AC_SUBST([LIBS])
AC_SUBST([LIBS_LIBCEC])
AC_SUBST([LIB_INFO])
AC_SUBST([USE_P8_USB])
AC_SUBST([USE_P8_USB_DETECT])
AC_SUBST([USE_RPI_API])
AC_CONFIG_FILES([src/lib/libcec.pc])
AC_OUTPUT([Makefile src/lib/Makefile src/testclient/Makefile])
cat <<EOB
##############################################################################
libCEC version $VERSION configured
Compilation flags:
CXXFLAGS : $CXXFLAGS
libCEC LDFLAGS : $LIBS_LIBCEC
client LDFLAGS : $LIBS
EOB
echo -e "$features"
cat <<EOB
You can now build libCEC by running:
make
##############################################################################
EOB