2 AC_INIT([libcec], [2:1:0], [http://libcec.pulse-eight.com/])
3 AC_CONFIG_HEADERS([config.h])
6 AM_INIT_AUTOMAKE([foreign])
7 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
9 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
13 cflags_reset="$CFLAGS"
19 CFLAGS="$cflags_reset"
21 msg_pkg_config_missing="'pkg-config' is missing - adapter detection will not be available"
22 msg_pthread_missing="required library 'pthread' is missing"
23 msg_dl_missing="required library 'dl' is missing"
24 msg_udev_missing="library 'udev' is missing - adapter detection will not be available"
25 msg_dirent_missing="dirent.h header is missing - adapter detection will not be available"
26 msg_lockdev_missing="library 'liblockdev' is missing"
27 msg_rpi_api_missing="Raspberry Pi API not found or incompatible with libCEC"
28 msg_rpi_will_check="will check for RPi support"
29 msg_rpi_unsupported_target="will not check for RPi support (unsupported cpu: ${host_cpu})"
30 msg_required_header_missing="required header is missing"
33 AC_ARG_ENABLE([debug],
34 [AS_HELP_STRING([--enable-debug],
35 [include debug symbols (default is no)])],
36 [use_debug=$enableval],
40 AC_ARG_ENABLE([optimisation],
41 [AS_HELP_STRING([--enable-optimisation],
42 [optimisation flag (default is yes)])],
43 [use_optimisation=$enableval],
44 [use_optimisation=yes])
47 AC_ARG_ENABLE([cubox],
48 [AS_HELP_STRING([--enable-tda995x],
49 [enable support for the TDA995x (default is no)])],
50 [use_tda995x=$enableval],
53 ## Optional path to the tda995x dev toolkit
54 AC_ARG_WITH([tda995x-toolkit-path],
55 [AS_HELP_STRING([--with-tda995x-toolkit-path],
56 [location of the TDA995x driver toolkit (default is ./nxp_hdmi)])],
57 [TDA995X_CFLAGS="-I$withval/inc"],
58 [TDA995X_CFLAGS="-I\$(abs_top_srcdir)/nxp_hdmi/inc"])
61 AC_ARG_ENABLE([exynos],
62 [AS_HELP_STRING([--enable-exynos],
63 [enable support for the Exynos (default is yes)])],
64 [use_exynos=$enableval],
67 ## Raspberry Pi support
69 [AS_HELP_STRING([--enable-rpi],
70 [enable support for the Raspberry Pi (default is auto)])],
74 ## Optional path to the RPi's dev headers
75 AC_ARG_WITH([rpi-include-path],
76 [AS_HELP_STRING([--with-rpi-include-path],
77 [location of the Raspberry Pi headers (location of /opt/vc/include, default is auto)])],
78 [RPI_CFLAGS="-I$withval -I$withval/interface/vcos/pthreads -I$withval/interface/vmcs_host/linux"])
80 ## Optional path to libbcm_host.so
81 AC_ARG_WITH([rpi-lib-path],
82 [AS_HELP_STRING([--with-rpi-lib-path],
83 [location of the Raspberry Pi libraries (location of libbcm_host.so, default is auto)])],
84 [RPI_LIBS="-L$withval"])
86 ## only check for the RPi API on ARM targets
87 if test "x$use_rpi" != "xno"; then
90 AC_MSG_NOTICE($msg_rpi_will_check)
93 if test "x$use_rpi" = "xyes"; then
94 AC_MSG_ERROR($msg_rpi_unsupported_target)
96 AC_MSG_NOTICE($msg_rpi_unsupported_target)
103 ## add the top dir and include to the include path, so we can include config.h and cec.h
104 CPPFLAGS="$CPPFLAGS -I\$(abs_top_srcdir)/src -I\$(abs_top_srcdir)/include"
106 ## search for pkg-config
107 AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
108 if test "x$HAVE_PKG_CONFIG" != "xyes" ; then
109 AC_MSG_WARN($msg_pkg_config_missing)
112 ## search for pthread, required by all targets
113 AC_SEARCH_LIBS([pthread_create],[pthread],,AC_MSG_ERROR($msg_pthread_missing))
114 AC_CHECK_FUNCS([pthread_mutexattr_init pthread_cond_init pthread_cond_destroy pthread_cond_signal pthread_cond_broadcast pthread_cond_wait pthread_cond_timedwait])
116 ## search for dlopen, required by all targets
117 AC_SEARCH_LIBS([dlopen], [dl],
118 [test "$ac_cv_search_dlopen" = "none required" || LIBS_DL=$ac_cv_search_dlopen],
119 AC_MSG_ERROR($msg_dl_missing))
120 AC_CHECK_FUNCS([dlopen dlclose dlsym])
122 ## platform specific libs, required by all targets
126 AC_SEARCH_LIBS([clock_gettime], [rt])
129 LIBS="$LIBS -framework CoreVideo -framework IOKit"
133 ## we found all the libs and headers that we need for the client applications
136 ## search for udev, lockdev and the RPi API, only required by libCEC
138 use_adapter_detection="yes"
140 SUPPRESS_MANGLING_WARNINGS=" -Wno-psabi"
143 ## search for udev if pkg-config was found
144 if test "x$HAVE_PKG_CONFIG" = "xyes" ; then
145 PKG_CHECK_MODULES([UDEV],[libudev],use_udev="yes",AC_MSG_WARN($msg_udev_missing))
148 ## we need dirent.h on linux too
149 if test "$use_udev" = "yes"; then
150 AC_CHECK_HEADER(dirent.h,,[use_udev="no";AC_MSG_WARN($msg_dirent_missing)])
153 if test "$use_udev" != "yes"; then
154 use_adapter_detection="no"
157 ## search for lockdev
159 AC_CHECK_HEADER(lockdev.h,,[use_lockdev="no";AC_MSG_WARN($msg_lockdev_missing)])
160 AC_CHECK_LIB(lockdev,dev_unlock,,[use_lockdev="no";AC_MSG_WARN($msg_lockdev_missing)])
162 AC_CHECK_HEADER(time.h,,AC_MSG_ERROR($msg_required_header_missing))
163 AC_CHECK_HEADER(sys/prctl.h,,AC_MSG_ERROR($msg_required_header_missing))
165 ## search for the RPi API. we need to check a couple of things to see if
166 ## it's recent enough and contains the calls needed for libCEC to operate
168 if test "x$use_rpi" != "xno"; then
169 CPPFLAGS="$CPPFLAGS $RPI_CFLAGS"
171 LIBS="$LIBS $RPI_LIBS -lvcos -lvchiq_arm"
173 check_rpi_cec_service="yes"
175 ## check for headers we need
176 AC_CHECK_HEADER(interface/vmcs_host/vc_cec.h,,check_rpi_cec_service="no")
177 AC_CHECK_HEADER(interface/vmcs_host/vc_cecservice.h,,check_rpi_cec_service="no")
178 AC_CHECK_HEADER(interface/vchiq_arm/vchiq_if.h,,check_rpi_cec_service="no")
179 AC_CHECK_HEADER(bcm_host.h,,check_rpi_cec_service="no")
181 ## check if the headers contain support for libCEC.
182 ## VC_CECSERVICE_VER needs to be defined
183 AC_MSG_CHECKING([interface/vmcs_host/vc_cec.h compatibility])
185 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <interface/vmcs_host/vc_cecservice.h>
186 #include <interface/vchiq_arm/vchiq_if.h>
187 #if !defined(VC_CECSERVICE_VER)
188 #error RPi headers does not contain libCEC support
189 #endif]], [[]])],[AC_MSG_RESULT([yes])],[check_rpi_cec_service="no"; AC_MSG_RESULT([no])])
191 ## check if the methods we're using can be found in libbcm_host.so, so we don't use an incompatible version
192 AC_CHECK_LIB(bcm_host,vchi_initialise,,check_rpi_cec_service="no")
194 AC_CHECK_LIB(bcm_host,vc_vchi_cec_init,,check_rpi_cec_service="no")
195 AC_CHECK_LIB(bcm_host,vc_cec_get_logical_address,,check_rpi_cec_service="no")
196 AC_CHECK_LIB(bcm_host,vc_cec_get_physical_address,,check_rpi_cec_service="no")
197 AC_CHECK_LIB(bcm_host,vc_cec_param2message,,check_rpi_cec_service="no")
198 AC_CHECK_LIB(bcm_host,vc_cec_poll_address,,check_rpi_cec_service="no")
199 AC_CHECK_LIB(bcm_host,vc_cec_register_callback,,check_rpi_cec_service="no")
200 AC_CHECK_LIB(bcm_host,vc_cec_release_logical_address,,check_rpi_cec_service="no")
201 AC_CHECK_LIB(bcm_host,vc_cec_set_passive,,check_rpi_cec_service="no")
202 AC_CHECK_LIB(bcm_host,vcos_init,,check_rpi_cec_service="no")
203 AC_CHECK_LIB(bcm_host,vchiq_initialise,,check_rpi_cec_service="no")
204 AC_CHECK_LIB(bcm_host,vchi_initialise,,check_rpi_cec_service="no")
205 AC_CHECK_LIB(bcm_host,vchi_create_connection,,check_rpi_cec_service="no")
206 AC_CHECK_LIB(bcm_host,bcm_host_init,,check_rpi_cec_service="no")
209 if test "x$check_rpi_cec_service" != "xyes" && test "x$use_rpi" = "xyes"; then
210 AC_MSG_ERROR($msg_rpi_api_missing)
211 elif test "x$check_rpi_cec_service" != "xyes"; then
216 ## search for X11/xrandr
219 AC_CHECK_HEADER(X11/Xlib.h,,[use_x11_xrandr="no"])
220 AC_CHECK_HEADER(X11/Xatom.h,,[use_x11_xrandr="no"])
221 AC_CHECK_HEADER(X11/extensions/Xrandr.h,,[use_x11_xrandr="no"])
222 AC_CHECK_LIB(X11,XOpenDisplay,,[use_x11_xrandr="no"])
223 AC_CHECK_LIB(Xrandr,XRRGetScreenResources,,[use_x11_xrandr="no"])
224 if test "x$use_x11_xrandr" = "xyes"; then
225 AC_DEFINE([HAVE_RANDR],[1],[Define to 1 to include support for the X11 randr extension])
226 AM_CONDITIONAL(USE_X11_RANDR, true)
228 AM_CONDITIONAL(USE_X11_RANDR, false)
233 AC_CHECK_HEADER(mach/mach_time.h,,AC_MSG_ERROR($msg_required_header_missing))
234 AC_CHECK_HEADER(CoreVideo/CVHostTime.h,,AC_MSG_ERROR($msg_required_header_missing))
235 AC_DEFINE([TARGET_DARWIN], [1], [Darwin target])
236 SUPPRESS_MANGLING_WARNINGS=""
240 ## define the build info
241 LIB_INFO="host: ${host}, features:"
243 features="Configured features:\n Pulse-Eight CEC Adapter :\t\tyes"
244 LIB_INFO="$LIB_INFO 'P8 USB'"
245 AC_DEFINE([HAVE_P8_USB],[1],[Define to 1 to include support for the Pulse-Eight USB-CEC Adapter])
246 AM_CONDITIONAL(USE_P8_USB, true)
248 if test "x$use_lockdev" = "xyes"; then
249 AC_DEFINE([HAVE_LOCKDEV],[1],[Define to 1 if liblockdev is installed])
252 ## mark adapter detection as available if the required deps were found
253 if test "x$use_adapter_detection" = "xyes"; then
254 ## mark udev as available if it was found
255 if test "x$use_udev" = "xyes"; then
256 INCLUDES="$INCLUDES $UDEV_CFLAGS"
257 LIBS="$LIBS $UDEV_LIBS"
258 AC_DEFINE([HAVE_LIBUDEV],[1],[Define to 1 if libudev is installed])
259 REQUIRES="$REQUIRES udev"
262 AC_DEFINE([HAVE_P8_USB_DETECT],[1],[Define to 1 to include autodetection support for the Pulse-Eight USB-CEC Adapter])
263 AM_CONDITIONAL(USE_P8_USB_DETECT, true)
265 features="$features\n Pulse-Eight CEC Adapter detection :\tyes"
266 LIB_INFO="$LIB_INFO 'P8 USB detect'"
268 AM_CONDITIONAL(USE_P8_USB_DETECT, false)
269 features="$features\n Pulse-Eight CEC Adapter detection :\tno"
272 ## mark RPi support as available if the required headers and libs were found
273 if test "x$use_rpi" != "xno"; then
274 AC_DEFINE([HAVE_RPI_API],[1],[Define to 1 to include RPi support])
275 AM_CONDITIONAL(USE_RPI_API, true)
276 features="$features\n Raspberry Pi support :\t\tyes"
277 LIB_INFO="$LIB_INFO 'RPi'"
279 AM_CONDITIONAL(USE_RPI_API, false)
280 features="$features\n Raspberry Pi support :\t\tno"
283 ## mark TDA995x support as available
284 if test "x$use_tda995x" != "xno"; then
285 AC_DEFINE([HAVE_TDA995X_API],[1],[Define to 1 to include CuBox support])
286 AM_CONDITIONAL(USE_TDA995X_API, true)
287 features="$features\n TDA995x support :\t\t\tyes"
288 LIB_INFO="$LIB_INFO 'TDA995x'"
289 CPPFLAGS="$CPPFLAGS $TDA995X_CFLAGS"
291 AM_CONDITIONAL(USE_TDA995X_API, false)
292 features="$features\n TDA995x support :\t\t\tno"
295 ## mark Exynos support as available
296 if test "x$use_exynos" != "xno"; then
297 AC_DEFINE([HAVE_EXYNOS_API],[1],[Define to 1 to include Exynos support])
298 AM_CONDITIONAL(USE_EXYNOS_API, true)
299 features="$features\n Exynos support :\t\t\tyes"
300 LIB_INFO="$LIB_INFO 'EXYNOS'"
301 CPPFLAGS="$CPPFLAGS $EXYNOS_CFLAGS"
303 AM_CONDITIONAL(USE_EXYNOS_API, false)
304 features="$features\n EXYNOS support :\t\t\tno"
308 ## check if our build system is complete
309 AC_CHECK_HEADER(algorithm,,AC_MSG_ERROR($msg_required_header_missing))
310 AC_CHECK_HEADER(ctype.h,,AC_MSG_ERROR($msg_required_header_missing))
311 AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR($msg_required_header_missing))
312 AC_CHECK_HEADER(errno.h,,AC_MSG_ERROR($msg_required_header_missing))
313 AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR($msg_required_header_missing))
314 AC_CHECK_HEADER(functional,,AC_MSG_ERROR($msg_required_header_missing))
315 AC_CHECK_HEADER(locale,,AC_DEFINE([SS_NO_LOCALE],[1],[Define to 1 to exclude locale support]))
316 AC_CHECK_HEADER(map,,AC_MSG_ERROR($msg_required_header_missing))
317 AC_CHECK_HEADER(netdb.h,,AC_MSG_ERROR($msg_required_header_missing))
318 AC_CHECK_HEADER(poll.h,,AC_MSG_ERROR($msg_required_header_missing))
319 AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR($msg_required_header_missing))
320 AC_CHECK_HEADER(queue,,AC_MSG_ERROR($msg_required_header_missing))
321 AC_CHECK_HEADER(semaphore.h,,AC_MSG_ERROR($msg_required_header_missing))
322 AC_CHECK_HEADER(set,,AC_MSG_ERROR($msg_required_header_missing))
323 AC_CHECK_HEADER(stdarg.h,,AC_MSG_ERROR($msg_required_header_missing))
324 AC_CHECK_HEADER(stdint.h,,AC_MSG_ERROR($msg_required_header_missing))
325 AC_CHECK_HEADER(stdio.h,,AC_MSG_ERROR($msg_required_header_missing))
326 AC_CHECK_HEADER(stdlib.h,,AC_MSG_ERROR($msg_required_header_missing))
327 AC_CHECK_HEADER(string,,AC_MSG_ERROR($msg_required_header_missing))
328 AC_CHECK_HEADER(string.h,,AC_MSG_ERROR($msg_required_header_missing))
329 AC_CHECK_HEADER(termios.h,,AC_MSG_ERROR($msg_required_header_missing))
330 AC_CHECK_HEADER(unistd.h,,AC_MSG_ERROR($msg_required_header_missing))
331 AC_CHECK_HEADER(vector,,AC_MSG_ERROR($msg_required_header_missing))
332 AC_CHECK_HEADER(wchar.h,,AC_MSG_ERROR($msg_required_header_missing))
333 AC_CHECK_HEADER(wctype.h,,AC_MSG_ERROR($msg_required_header_missing))
334 AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR($msg_required_header_missing))
335 AC_CHECK_HEADER(netinet/in.h,,AC_MSG_ERROR($msg_required_header_missing))
336 AC_CHECK_HEADER(netinet/tcp.h,,AC_MSG_ERROR($msg_required_header_missing))
337 AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR($msg_required_header_missing))
338 AC_CHECK_HEADER(sys/time.h,,AC_MSG_ERROR($msg_required_header_missing))
339 AC_CHECK_HEADER(sys/types.h,,AC_MSG_ERROR($msg_required_header_missing))
340 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])
342 ## add the build date to LIB_INFO
343 AC_CHECK_PROG(HAVE_GIT, git, yes)
344 if test "x$HAVE_GIT" = "xyes"; then
345 revision=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h" HEAD)
347 if test "x$revision" != "x"; then
348 LIB_INFO="$LIB_INFO, git revision: ${revision}"
351 AC_CHECK_PROG(HAVE_DATE, date, yes)
352 if test "x$HAVE_DATE" = "xyes"; then
353 LIB_INFO="$LIB_INFO, compiled on: `date -u`"
355 LIB_INFO="$LIB_INFO, compiled on: (unknown date)"
358 ## add the name of the user who built libCEC to LIB_INFO
359 AC_CHECK_PROG(HAVE_WHOAMI, whoami, yes)
360 if test "x$HAVE_WHOAMI" = "xyes" ; then
361 LIB_INFO="$LIB_INFO by `whoami`"
363 LIB_INFO="$LIB_INFO by (unknown user)"
366 ## add the hostname of the build host of libCEC to LIB_INFO
367 AC_CHECK_PROG(HAVE_HOSTNAME, hostname, yes)
368 if test "x$HAVE_HOSTNAME" = "xyes"; then
369 LIB_INFO="$LIB_INFO@`hostname -f`"
372 ## add the system info of the build host of libCEC to LIB_INFO
373 AC_CHECK_PROG(HAVE_UNAME, uname, yes)
374 if test "x$HAVE_UNAME" = "xyes"; then
375 LIB_INFO="$LIB_INFO on `uname -s` `uname -r` (`uname -m`)"
378 ## redefine the LIBS, so cec-client isn't linked against things they don't need
382 CXXFLAGS="$CXXFLAGS -fPIC -Wall -Wextra -Wno-missing-field-initializers $SUPPRESS_MANGLING_WARNINGS"
384 if test "x$use_debug" = "xyes"; then
385 CXXFLAGS="$CXXFLAGS -g"
386 AC_DEFINE(CEC_DEBUGGING,"1", "generate libCEC debug output")
389 if test "x$optimisation" = "xyes"; then
390 CXXFLAGS="$CXXFLAGS -O2"
393 AC_DEFINE_UNQUOTED(LIB_INFO,"$LIB_INFO", "information about how libCEC was compiled")
397 AC_SUBST([LIBS_LIBCEC])
399 AC_SUBST([USE_P8_USB])
400 AC_SUBST([USE_P8_USB_DETECT])
401 AC_SUBST([USE_RPI_API])
402 AC_CONFIG_FILES([src/lib/libcec.pc])
403 AC_OUTPUT([Makefile src/lib/Makefile src/testclient/Makefile])
407 ##############################################################################
409 libCEC version $VERSION configured
413 libCEC LDFLAGS : $LIBS_LIBCEC
414 client LDFLAGS : $LIBS
422 You can now build libCEC by running:
425 ##############################################################################