Add support for Exynos HDMI
[deb_libcec.git] / configure.ac
CommitLineData
6ea2515b 1AC_PREREQ(2.59)
9b56a19a 2AC_INIT([libcec], [2:1:0], [http://libcec.pulse-eight.com/])
2b44051c
LOK
3AC_CONFIG_HEADERS([config.h])
4AH_TOP([#pragma once])
5
6AM_INIT_AUTOMAKE([foreign])
e7752b88 7m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
2b44051c 8
abbca718
LOK
9AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10
2b44051c
LOK
11AC_CANONICAL_HOST
12
13cflags_reset="$CFLAGS"
14AC_LANG(C++)
abbca718
LOK
15AC_PROG_CXX
16AC_PROG_LIBTOOL
2b44051c
LOK
17AC_PROG_INSTALL
18AC_LIBTOOL_DLOPEN
19CFLAGS="$cflags_reset"
20
21msg_pkg_config_missing="'pkg-config' is missing - adapter detection will not be available"
22msg_pthread_missing="required library 'pthread' is missing"
23msg_dl_missing="required library 'dl' is missing"
24msg_udev_missing="library 'udev' is missing - adapter detection will not be available"
25msg_dirent_missing="dirent.h header is missing - adapter detection will not be available"
e2b8f1ca 26msg_lockdev_missing="library 'liblockdev' is missing"
29104708
LOK
27msg_rpi_api_missing="Raspberry Pi API not found or incompatible with libCEC"
28msg_rpi_will_check="will check for RPi support"
29msg_rpi_unsupported_target="will not check for RPi support (unsupported cpu: ${host_cpu})"
2b44051c
LOK
30msg_required_header_missing="required header is missing"
31
32## debugging symbols
33AC_ARG_ENABLE([debug],
34 [AS_HELP_STRING([--enable-debug],
35 [include debug symbols (default is no)])],
36 [use_debug=$enableval],
37 [use_debug=no])
38
39## optimisation
40AC_ARG_ENABLE([optimisation],
41 [AS_HELP_STRING([--enable-optimisation],
42 [optimisation flag (default is yes)])],
43 [use_optimisation=$enableval],
44 [use_optimisation=yes])
abbca718 45
79e50026 46## TDA995x support
4d3a7562 47AC_ARG_ENABLE([cubox],
79e50026
LOK
48 [AS_HELP_STRING([--enable-tda995x],
49 [enable support for the TDA995x (default is no)])],
51b611bc 50 [use_tda995x=$enableval],
51 [use_tda995x=no])
4d3a7562 52
51b611bc 53## Optional path to the tda995x dev toolkit
54AC_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"])
4d3a7562 59
5b6d8032
VM
60## Exynos support
61AC_ARG_ENABLE([exynos],
62 [AS_HELP_STRING([--enable-exynos],
63 [enable support for the Exynos (default is yes)])],
64 [use_exynos=$enableval],
65 [use_exynos=yes])
66
29104708
LOK
67## Raspberry Pi support
68AC_ARG_ENABLE([rpi],
69 [AS_HELP_STRING([--enable-rpi],
70 [enable support for the Raspberry Pi (default is auto)])],
71 [use_rpi=$enableval],
72 [use_rpi=auto])
73
74## Optional path to the RPi's dev headers
75AC_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)])],
36715692 78 [RPI_CFLAGS="-I$withval -I$withval/interface/vcos/pthreads -I$withval/interface/vmcs_host/linux"])
29104708
LOK
79
80## Optional path to libbcm_host.so
81AC_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"])
85
86## only check for the RPi API on ARM targets
87if test "x$use_rpi" != "xno"; then
88 case "${host_cpu}" in
89 arm*)
90 AC_MSG_NOTICE($msg_rpi_will_check)
91 ;;
92 *)
93 if test "x$use_rpi" = "xyes"; then
94 AC_MSG_ERROR($msg_rpi_unsupported_target)
95 else
96 AC_MSG_NOTICE($msg_rpi_unsupported_target)
97 fi
98 use_rpi="no"
99 ;;
100 esac
101fi
102
2b44051c
LOK
103## add the top dir and include to the include path, so we can include config.h and cec.h
104CPPFLAGS="$CPPFLAGS -I\$(abs_top_srcdir)/src -I\$(abs_top_srcdir)/include"
6ea2515b 105
2b44051c
LOK
106## search for pkg-config
107AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
108if test "x$HAVE_PKG_CONFIG" != "xyes" ; then
109 AC_MSG_WARN($msg_pkg_config_missing)
110fi
111
112## search for pthread, required by all targets
113AC_SEARCH_LIBS([pthread_create],[pthread],,AC_MSG_ERROR($msg_pthread_missing))
114AC_CHECK_FUNCS([pthread_mutexattr_init pthread_cond_init pthread_cond_destroy pthread_cond_signal pthread_cond_broadcast pthread_cond_wait pthread_cond_timedwait])
115
116## search for dlopen, required by all targets
6ea2515b
LOK
117AC_SEARCH_LIBS([dlopen], [dl],
118 [test "$ac_cv_search_dlopen" = "none required" || LIBS_DL=$ac_cv_search_dlopen],
2b44051c 119 AC_MSG_ERROR($msg_dl_missing))
ee2ee405 120AC_CHECK_FUNCS([dlopen dlclose dlsym])
6ea2515b 121
2b44051c 122## platform specific libs, required by all targets
6ea2515b
LOK
123case "${host}" in
124 *-*-linux*)
2b44051c 125 # for timeutils
994bcb97 126 AC_SEARCH_LIBS([clock_gettime], [rt])
6ea2515b
LOK
127 ;;
128 *-apple-darwin*)
2b44051c 129 LIBS="$LIBS -framework CoreVideo -framework IOKit"
6ea2515b
LOK
130 ;;
131esac
132
2b44051c
LOK
133## we found all the libs and headers that we need for the client applications
134libs_client="$LIBS"
6ea2515b 135
2b44051c
LOK
136## search for udev, lockdev and the RPi API, only required by libCEC
137use_udev="no"
138use_adapter_detection="yes"
e2b8f1ca 139use_lockdev="no"
7828b418 140SUPPRESS_MANGLING_WARNINGS=" -Wno-psabi"
3e703e8e 141case "${host}" in
142 *-*-linux*)
2b44051c
LOK
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))
146 fi
147
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)])
151 fi
6ea2515b 152
2b44051c
LOK
153 if test "$use_udev" != "yes"; then
154 use_adapter_detection="no"
155 fi
6ea2515b 156
2b44051c 157 ## search for lockdev
e2b8f1ca
LOK
158 use_lockdev="yes"
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)])
2b44051c
LOK
161
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))
29104708
LOK
164
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
167 ## correctly.
168 if test "x$use_rpi" != "xno"; then
169 CPPFLAGS="$CPPFLAGS $RPI_CFLAGS"
170 libs_pre_rpi="$LIBS"
171 LIBS="$LIBS $RPI_LIBS -lvcos -lvchiq_arm"
172
173 check_rpi_cec_service="yes"
174
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")
180
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])
184
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])])
190
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")
193 libs_tmp="$LIBS"
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")
207 LIBS="$libs_tmp"
208
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
212 use_rpi="no"
213 LIBS="$libs_pre_rpi"
214 fi
215 fi
3e703e8e 216 ;;
217 *-apple-darwin*)
2b44051c
LOK
218 AC_CHECK_HEADER(mach/mach_time.h,,AC_MSG_ERROR($msg_required_header_missing))
219 AC_CHECK_HEADER(CoreVideo/CVHostTime.h,,AC_MSG_ERROR($msg_required_header_missing))
3de59124 220 AC_DEFINE([TARGET_DARWIN], [1], [Darwin target])
7828b418 221 SUPPRESS_MANGLING_WARNINGS=""
5458fd77 222 ;;
3e703e8e 223esac
224
2b44051c
LOK
225## define the build info
226LIB_INFO="host: ${host}, features:"
227
228features="Configured features:\n Pulse-Eight CEC Adapter :\t\tyes"
229LIB_INFO="$LIB_INFO 'P8 USB'"
230AC_DEFINE([HAVE_P8_USB],[1],[Define to 1 to include support for the Pulse-Eight USB-CEC Adapter])
231AM_CONDITIONAL(USE_P8_USB, true)
232
e2b8f1ca
LOK
233if test "x$use_lockdev" = "xyes"; then
234 AC_DEFINE([HAVE_LOCKDEV],[1],[Define to 1 if liblockdev is installed])
235fi
236
2b44051c
LOK
237## mark adapter detection as available if the required deps were found
238if test "x$use_adapter_detection" = "xyes"; then
239 ## mark udev as available if it was found
240 if test "x$use_udev" = "xyes"; then
241 INCLUDES="$INCLUDES $UDEV_CFLAGS"
242 LIBS="$LIBS $UDEV_LIBS"
243 AC_DEFINE([HAVE_LIBUDEV],[1],[Define to 1 if libudev is installed])
244 REQUIRES="$REQUIRES udev"
245 fi
246
247 AC_DEFINE([HAVE_P8_USB_DETECT],[1],[Define to 1 to include autodetection support for the Pulse-Eight USB-CEC Adapter])
248 AM_CONDITIONAL(USE_P8_USB_DETECT, true)
249
250 features="$features\n Pulse-Eight CEC Adapter detection :\tyes"
251 LIB_INFO="$LIB_INFO 'P8 USB detect'"
252else
253 AM_CONDITIONAL(USE_P8_USB_DETECT, false)
254 features="$features\n Pulse-Eight CEC Adapter detection :\tno"
42c02563
LOK
255fi
256
29104708
LOK
257## mark RPi support as available if the required headers and libs were found
258if test "x$use_rpi" != "xno"; then
259 AC_DEFINE([HAVE_RPI_API],[1],[Define to 1 to include RPi support])
260 AM_CONDITIONAL(USE_RPI_API, true)
261 features="$features\n Raspberry Pi support :\t\tyes"
262 LIB_INFO="$LIB_INFO 'RPi'"
263else
264 AM_CONDITIONAL(USE_RPI_API, false)
265 features="$features\n Raspberry Pi support :\t\tno"
266fi
267
79e50026 268## mark TDA995x support as available
51b611bc 269if test "x$use_tda995x" != "xno"; then
270 AC_DEFINE([HAVE_TDA995X_API],[1],[Define to 1 to include CuBox support])
271 AM_CONDITIONAL(USE_TDA995X_API, true)
79e50026
LOK
272 features="$features\n TDA995x support :\t\t\tyes"
273 LIB_INFO="$LIB_INFO 'TDA995x'"
51b611bc 274 CPPFLAGS="$CPPFLAGS $TDA995X_CFLAGS"
4d3a7562 275else
51b611bc 276 AM_CONDITIONAL(USE_TDA995X_API, false)
79e50026 277 features="$features\n TDA995x support :\t\t\tno"
4d3a7562 278fi
279
5b6d8032
VM
280## mark Exynos support as available
281if test "x$use_exynos" != "xno"; then
282 AC_DEFINE([HAVE_EXYNOS_API],[1],[Define to 1 to include Exynos support])
283 AM_CONDITIONAL(USE_EXYNOS_API, true)
284 features="$features\n Exynos support :\t\t\tyes"
285 LIB_INFO="$LIB_INFO 'EXYNOS'"
286 CPPFLAGS="$CPPFLAGS $EXYNOS_CFLAGS"
287else
288 AM_CONDITIONAL(USE_EXYNOS_API, false)
289 features="$features\n EXYNOS support :\t\t\tno"
290fi
291
292
2b44051c
LOK
293## check if our build system is complete
294AC_CHECK_HEADER(algorithm,,AC_MSG_ERROR($msg_required_header_missing))
295AC_CHECK_HEADER(ctype.h,,AC_MSG_ERROR($msg_required_header_missing))
296AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR($msg_required_header_missing))
297AC_CHECK_HEADER(errno.h,,AC_MSG_ERROR($msg_required_header_missing))
298AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR($msg_required_header_missing))
299AC_CHECK_HEADER(functional,,AC_MSG_ERROR($msg_required_header_missing))
300AC_CHECK_HEADER(locale,,AC_DEFINE([SS_NO_LOCALE],[1],[Define to 1 to exclude locale support]))
301AC_CHECK_HEADER(map,,AC_MSG_ERROR($msg_required_header_missing))
302AC_CHECK_HEADER(netdb.h,,AC_MSG_ERROR($msg_required_header_missing))
303AC_CHECK_HEADER(poll.h,,AC_MSG_ERROR($msg_required_header_missing))
304AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR($msg_required_header_missing))
305AC_CHECK_HEADER(queue,,AC_MSG_ERROR($msg_required_header_missing))
306AC_CHECK_HEADER(semaphore.h,,AC_MSG_ERROR($msg_required_header_missing))
307AC_CHECK_HEADER(set,,AC_MSG_ERROR($msg_required_header_missing))
308AC_CHECK_HEADER(stdarg.h,,AC_MSG_ERROR($msg_required_header_missing))
309AC_CHECK_HEADER(stdint.h,,AC_MSG_ERROR($msg_required_header_missing))
310AC_CHECK_HEADER(stdio.h,,AC_MSG_ERROR($msg_required_header_missing))
311AC_CHECK_HEADER(stdlib.h,,AC_MSG_ERROR($msg_required_header_missing))
312AC_CHECK_HEADER(string,,AC_MSG_ERROR($msg_required_header_missing))
313AC_CHECK_HEADER(string.h,,AC_MSG_ERROR($msg_required_header_missing))
314AC_CHECK_HEADER(termios.h,,AC_MSG_ERROR($msg_required_header_missing))
315AC_CHECK_HEADER(unistd.h,,AC_MSG_ERROR($msg_required_header_missing))
316AC_CHECK_HEADER(vector,,AC_MSG_ERROR($msg_required_header_missing))
317AC_CHECK_HEADER(wchar.h,,AC_MSG_ERROR($msg_required_header_missing))
318AC_CHECK_HEADER(wctype.h,,AC_MSG_ERROR($msg_required_header_missing))
319AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR($msg_required_header_missing))
320AC_CHECK_HEADER(netinet/in.h,,AC_MSG_ERROR($msg_required_header_missing))
321AC_CHECK_HEADER(netinet/tcp.h,,AC_MSG_ERROR($msg_required_header_missing))
322AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR($msg_required_header_missing))
323AC_CHECK_HEADER(sys/time.h,,AC_MSG_ERROR($msg_required_header_missing))
324AC_CHECK_HEADER(sys/types.h,,AC_MSG_ERROR($msg_required_header_missing))
325AC_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])
abbca718 326
2b44051c
LOK
327## add the build date to LIB_INFO
328AC_CHECK_PROG(HAVE_GIT, git, yes)
329if test "x$HAVE_GIT" = "xyes"; then
330 revision=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h" HEAD)
331fi
332if test "x$revision" != "x"; then
333 LIB_INFO="$LIB_INFO, git revision: ${revision}"
334fi
335
336AC_CHECK_PROG(HAVE_DATE, date, yes)
337if test "x$HAVE_DATE" = "xyes"; then
338 LIB_INFO="$LIB_INFO, compiled on: `date -u`"
339else
340 LIB_INFO="$LIB_INFO, compiled on: (unknown date)"
341fi
342
343## add the name of the user who built libCEC to LIB_INFO
344AC_CHECK_PROG(HAVE_WHOAMI, whoami, yes)
345if test "x$HAVE_WHOAMI" = "xyes" ; then
346 LIB_INFO="$LIB_INFO by `whoami`"
347else
348 LIB_INFO="$LIB_INFO by (unknown user)"
349fi
350
351## add the hostname of the build host of libCEC to LIB_INFO
352AC_CHECK_PROG(HAVE_HOSTNAME, hostname, yes)
353if test "x$HAVE_HOSTNAME" = "xyes"; then
354 LIB_INFO="$LIB_INFO@`hostname -f`"
355fi
356
357## add the system info of the build host of libCEC to LIB_INFO
358AC_CHECK_PROG(HAVE_UNAME, uname, yes)
359if test "x$HAVE_UNAME" = "xyes"; then
360 LIB_INFO="$LIB_INFO on `uname -s` `uname -r` (`uname -m`)"
361fi
362
0c271bd0 363## redefine the LIBS, so cec-client isn't linked against things they don't need
2b44051c
LOK
364LIBS_LIBCEC="$LIBS"
365LIBS="$libs_client"
366
7828b418 367CXXFLAGS="$CXXFLAGS -fPIC -Wall -Wextra -Wno-missing-field-initializers $SUPPRESS_MANGLING_WARNINGS"
2b44051c
LOK
368
369if test "x$use_debug" = "xyes"; then
370 CXXFLAGS="$CXXFLAGS -g"
8cd2b85a 371 AC_DEFINE(CEC_DEBUGGING,"1", "generate libCEC debug output")
2b44051c
LOK
372fi
373
374if test "x$optimisation" = "xyes"; then
375 CXXFLAGS="$CXXFLAGS -O2"
376fi
377
378AC_DEFINE_UNQUOTED(LIB_INFO,"$LIB_INFO", "information about how libCEC was compiled")
7eb13cca 379
6ea2515b
LOK
380AC_SUBST([REQUIRES])
381AC_SUBST([LIBS])
382AC_SUBST([LIBS_LIBCEC])
2b44051c
LOK
383AC_SUBST([LIB_INFO])
384AC_SUBST([USE_P8_USB])
385AC_SUBST([USE_P8_USB_DETECT])
386AC_SUBST([USE_RPI_API])
abbca718 387AC_CONFIG_FILES([src/lib/libcec.pc])
0c271bd0 388AC_OUTPUT([Makefile src/lib/Makefile src/testclient/Makefile])
2b44051c
LOK
389
390cat <<EOB
391
392##############################################################################
393
394libCEC version $VERSION configured
395
396Compilation flags:
397 CXXFLAGS : $CXXFLAGS
398 libCEC LDFLAGS : $LIBS_LIBCEC
399 client LDFLAGS : $LIBS
400
401EOB
402
403echo -e "$features"
404
405cat <<EOB
406
407You can now build libCEC by running:
408 make
409
410##############################################################################
411
412EOB