sharp: check whether the 'auto power on' option is disabled and tell the user how...
[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
29104708
LOK
60## Raspberry Pi support
61AC_ARG_ENABLE([rpi],
62 [AS_HELP_STRING([--enable-rpi],
63 [enable support for the Raspberry Pi (default is auto)])],
64 [use_rpi=$enableval],
65 [use_rpi=auto])
66
67## Optional path to the RPi's dev headers
68AC_ARG_WITH([rpi-include-path],
69 [AS_HELP_STRING([--with-rpi-include-path],
70 [location of the Raspberry Pi headers (location of /opt/vc/include, default is auto)])],
36715692 71 [RPI_CFLAGS="-I$withval -I$withval/interface/vcos/pthreads -I$withval/interface/vmcs_host/linux"])
29104708
LOK
72
73## Optional path to libbcm_host.so
74AC_ARG_WITH([rpi-lib-path],
75 [AS_HELP_STRING([--with-rpi-lib-path],
76 [location of the Raspberry Pi libraries (location of libbcm_host.so, default is auto)])],
77 [RPI_LIBS="-L$withval"])
78
79## only check for the RPi API on ARM targets
80if test "x$use_rpi" != "xno"; then
81 case "${host_cpu}" in
82 arm*)
83 AC_MSG_NOTICE($msg_rpi_will_check)
84 ;;
85 *)
86 if test "x$use_rpi" = "xyes"; then
87 AC_MSG_ERROR($msg_rpi_unsupported_target)
88 else
89 AC_MSG_NOTICE($msg_rpi_unsupported_target)
90 fi
91 use_rpi="no"
92 ;;
93 esac
94fi
95
2b44051c
LOK
96## add the top dir and include to the include path, so we can include config.h and cec.h
97CPPFLAGS="$CPPFLAGS -I\$(abs_top_srcdir)/src -I\$(abs_top_srcdir)/include"
6ea2515b 98
2b44051c
LOK
99## search for pkg-config
100AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
101if test "x$HAVE_PKG_CONFIG" != "xyes" ; then
102 AC_MSG_WARN($msg_pkg_config_missing)
103fi
104
105## search for pthread, required by all targets
106AC_SEARCH_LIBS([pthread_create],[pthread],,AC_MSG_ERROR($msg_pthread_missing))
107AC_CHECK_FUNCS([pthread_mutexattr_init pthread_cond_init pthread_cond_destroy pthread_cond_signal pthread_cond_broadcast pthread_cond_wait pthread_cond_timedwait])
108
109## search for dlopen, required by all targets
6ea2515b
LOK
110AC_SEARCH_LIBS([dlopen], [dl],
111 [test "$ac_cv_search_dlopen" = "none required" || LIBS_DL=$ac_cv_search_dlopen],
2b44051c 112 AC_MSG_ERROR($msg_dl_missing))
ee2ee405 113AC_CHECK_FUNCS([dlopen dlclose dlsym])
6ea2515b 114
2b44051c 115## platform specific libs, required by all targets
6ea2515b
LOK
116case "${host}" in
117 *-*-linux*)
2b44051c 118 # for timeutils
994bcb97 119 AC_SEARCH_LIBS([clock_gettime], [rt])
6ea2515b
LOK
120 ;;
121 *-apple-darwin*)
2b44051c 122 LIBS="$LIBS -framework CoreVideo -framework IOKit"
6ea2515b
LOK
123 ;;
124esac
125
2b44051c
LOK
126## we found all the libs and headers that we need for the client applications
127libs_client="$LIBS"
6ea2515b 128
2b44051c
LOK
129## search for udev, lockdev and the RPi API, only required by libCEC
130use_udev="no"
131use_adapter_detection="yes"
e2b8f1ca 132use_lockdev="no"
3e703e8e 133case "${host}" in
134 *-*-linux*)
2b44051c
LOK
135 ## search for udev if pkg-config was found
136 if test "x$HAVE_PKG_CONFIG" = "xyes" ; then
137 PKG_CHECK_MODULES([UDEV],[libudev],use_udev="yes",AC_MSG_WARN($msg_udev_missing))
138 fi
139
140 ## we need dirent.h on linux too
141 if test "$use_udev" = "yes"; then
142 AC_CHECK_HEADER(dirent.h,,[use_udev="no";AC_MSG_WARN($msg_dirent_missing)])
143 fi
6ea2515b 144
2b44051c
LOK
145 if test "$use_udev" != "yes"; then
146 use_adapter_detection="no"
147 fi
6ea2515b 148
2b44051c 149 ## search for lockdev
e2b8f1ca
LOK
150 use_lockdev="yes"
151 AC_CHECK_HEADER(lockdev.h,,[use_lockdev="no";AC_MSG_WARN($msg_lockdev_missing)])
152 AC_CHECK_LIB(lockdev,dev_unlock,,[use_lockdev="no";AC_MSG_WARN($msg_lockdev_missing)])
2b44051c
LOK
153
154 AC_CHECK_HEADER(time.h,,AC_MSG_ERROR($msg_required_header_missing))
155 AC_CHECK_HEADER(sys/prctl.h,,AC_MSG_ERROR($msg_required_header_missing))
29104708
LOK
156
157 ## search for the RPi API. we need to check a couple of things to see if
158 ## it's recent enough and contains the calls needed for libCEC to operate
159 ## correctly.
160 if test "x$use_rpi" != "xno"; then
161 CPPFLAGS="$CPPFLAGS $RPI_CFLAGS"
162 libs_pre_rpi="$LIBS"
163 LIBS="$LIBS $RPI_LIBS -lvcos -lvchiq_arm"
164
165 check_rpi_cec_service="yes"
166
167 ## check for headers we need
168 AC_CHECK_HEADER(interface/vmcs_host/vc_cec.h,,check_rpi_cec_service="no")
169 AC_CHECK_HEADER(interface/vmcs_host/vc_cecservice.h,,check_rpi_cec_service="no")
170 AC_CHECK_HEADER(interface/vchiq_arm/vchiq_if.h,,check_rpi_cec_service="no")
171 AC_CHECK_HEADER(bcm_host.h,,check_rpi_cec_service="no")
172
173 ## check if the headers contain support for libCEC.
174 ## VC_CECSERVICE_VER needs to be defined
175 AC_MSG_CHECKING([interface/vmcs_host/vc_cec.h compatibility])
176
177 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <interface/vmcs_host/vc_cecservice.h>
178#include <interface/vchiq_arm/vchiq_if.h>
179#if !defined(VC_CECSERVICE_VER)
180#error RPi headers does not contain libCEC support
181#endif]], [[]])],[AC_MSG_RESULT([yes])],[check_rpi_cec_service="no"; AC_MSG_RESULT([no])])
182
183 ## check if the methods we're using can be found in libbcm_host.so, so we don't use an incompatible version
184 AC_CHECK_LIB(bcm_host,vchi_initialise,,check_rpi_cec_service="no")
185 libs_tmp="$LIBS"
186 AC_CHECK_LIB(bcm_host,vc_vchi_cec_init,,check_rpi_cec_service="no")
187 AC_CHECK_LIB(bcm_host,vc_cec_get_logical_address,,check_rpi_cec_service="no")
188 AC_CHECK_LIB(bcm_host,vc_cec_get_physical_address,,check_rpi_cec_service="no")
189 AC_CHECK_LIB(bcm_host,vc_cec_param2message,,check_rpi_cec_service="no")
190 AC_CHECK_LIB(bcm_host,vc_cec_poll_address,,check_rpi_cec_service="no")
191 AC_CHECK_LIB(bcm_host,vc_cec_register_callback,,check_rpi_cec_service="no")
192 AC_CHECK_LIB(bcm_host,vc_cec_release_logical_address,,check_rpi_cec_service="no")
193 AC_CHECK_LIB(bcm_host,vc_cec_set_passive,,check_rpi_cec_service="no")
194 AC_CHECK_LIB(bcm_host,vcos_init,,check_rpi_cec_service="no")
195 AC_CHECK_LIB(bcm_host,vchiq_initialise,,check_rpi_cec_service="no")
196 AC_CHECK_LIB(bcm_host,vchi_initialise,,check_rpi_cec_service="no")
197 AC_CHECK_LIB(bcm_host,vchi_create_connection,,check_rpi_cec_service="no")
198 AC_CHECK_LIB(bcm_host,bcm_host_init,,check_rpi_cec_service="no")
199 LIBS="$libs_tmp"
200
201 if test "x$check_rpi_cec_service" != "xyes" && test "x$use_rpi" = "xyes"; then
202 AC_MSG_ERROR($msg_rpi_api_missing)
203 elif test "x$check_rpi_cec_service" != "xyes"; then
204 use_rpi="no"
205 LIBS="$libs_pre_rpi"
206 fi
207 fi
3e703e8e 208 ;;
209 *-apple-darwin*)
2b44051c
LOK
210 AC_CHECK_HEADER(mach/mach_time.h,,AC_MSG_ERROR($msg_required_header_missing))
211 AC_CHECK_HEADER(CoreVideo/CVHostTime.h,,AC_MSG_ERROR($msg_required_header_missing))
3de59124 212 AC_DEFINE([TARGET_DARWIN], [1], [Darwin target])
5458fd77 213 ;;
3e703e8e 214esac
215
2b44051c
LOK
216## define the build info
217LIB_INFO="host: ${host}, features:"
218
219features="Configured features:\n Pulse-Eight CEC Adapter :\t\tyes"
220LIB_INFO="$LIB_INFO 'P8 USB'"
221AC_DEFINE([HAVE_P8_USB],[1],[Define to 1 to include support for the Pulse-Eight USB-CEC Adapter])
222AM_CONDITIONAL(USE_P8_USB, true)
223
e2b8f1ca
LOK
224if test "x$use_lockdev" = "xyes"; then
225 AC_DEFINE([HAVE_LOCKDEV],[1],[Define to 1 if liblockdev is installed])
226fi
227
2b44051c
LOK
228## mark adapter detection as available if the required deps were found
229if test "x$use_adapter_detection" = "xyes"; then
230 ## mark udev as available if it was found
231 if test "x$use_udev" = "xyes"; then
232 INCLUDES="$INCLUDES $UDEV_CFLAGS"
233 LIBS="$LIBS $UDEV_LIBS"
234 AC_DEFINE([HAVE_LIBUDEV],[1],[Define to 1 if libudev is installed])
235 REQUIRES="$REQUIRES udev"
236 fi
237
238 AC_DEFINE([HAVE_P8_USB_DETECT],[1],[Define to 1 to include autodetection support for the Pulse-Eight USB-CEC Adapter])
239 AM_CONDITIONAL(USE_P8_USB_DETECT, true)
240
241 features="$features\n Pulse-Eight CEC Adapter detection :\tyes"
242 LIB_INFO="$LIB_INFO 'P8 USB detect'"
243else
244 AM_CONDITIONAL(USE_P8_USB_DETECT, false)
245 features="$features\n Pulse-Eight CEC Adapter detection :\tno"
42c02563
LOK
246fi
247
29104708
LOK
248## mark RPi support as available if the required headers and libs were found
249if test "x$use_rpi" != "xno"; then
250 AC_DEFINE([HAVE_RPI_API],[1],[Define to 1 to include RPi support])
251 AM_CONDITIONAL(USE_RPI_API, true)
252 features="$features\n Raspberry Pi support :\t\tyes"
253 LIB_INFO="$LIB_INFO 'RPi'"
254else
255 AM_CONDITIONAL(USE_RPI_API, false)
256 features="$features\n Raspberry Pi support :\t\tno"
257fi
258
79e50026 259## mark TDA995x support as available
51b611bc 260if test "x$use_tda995x" != "xno"; then
261 AC_DEFINE([HAVE_TDA995X_API],[1],[Define to 1 to include CuBox support])
262 AM_CONDITIONAL(USE_TDA995X_API, true)
79e50026
LOK
263 features="$features\n TDA995x support :\t\t\tyes"
264 LIB_INFO="$LIB_INFO 'TDA995x'"
51b611bc 265 CPPFLAGS="$CPPFLAGS $TDA995X_CFLAGS"
4d3a7562 266else
51b611bc 267 AM_CONDITIONAL(USE_TDA995X_API, false)
79e50026 268 features="$features\n TDA995x support :\t\t\tno"
4d3a7562 269fi
270
2b44051c
LOK
271## check if our build system is complete
272AC_CHECK_HEADER(algorithm,,AC_MSG_ERROR($msg_required_header_missing))
273AC_CHECK_HEADER(ctype.h,,AC_MSG_ERROR($msg_required_header_missing))
274AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR($msg_required_header_missing))
275AC_CHECK_HEADER(errno.h,,AC_MSG_ERROR($msg_required_header_missing))
276AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR($msg_required_header_missing))
277AC_CHECK_HEADER(functional,,AC_MSG_ERROR($msg_required_header_missing))
278AC_CHECK_HEADER(locale,,AC_DEFINE([SS_NO_LOCALE],[1],[Define to 1 to exclude locale support]))
279AC_CHECK_HEADER(map,,AC_MSG_ERROR($msg_required_header_missing))
280AC_CHECK_HEADER(netdb.h,,AC_MSG_ERROR($msg_required_header_missing))
281AC_CHECK_HEADER(poll.h,,AC_MSG_ERROR($msg_required_header_missing))
282AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR($msg_required_header_missing))
283AC_CHECK_HEADER(queue,,AC_MSG_ERROR($msg_required_header_missing))
284AC_CHECK_HEADER(semaphore.h,,AC_MSG_ERROR($msg_required_header_missing))
285AC_CHECK_HEADER(set,,AC_MSG_ERROR($msg_required_header_missing))
286AC_CHECK_HEADER(stdarg.h,,AC_MSG_ERROR($msg_required_header_missing))
287AC_CHECK_HEADER(stdint.h,,AC_MSG_ERROR($msg_required_header_missing))
288AC_CHECK_HEADER(stdio.h,,AC_MSG_ERROR($msg_required_header_missing))
289AC_CHECK_HEADER(stdlib.h,,AC_MSG_ERROR($msg_required_header_missing))
290AC_CHECK_HEADER(string,,AC_MSG_ERROR($msg_required_header_missing))
291AC_CHECK_HEADER(string.h,,AC_MSG_ERROR($msg_required_header_missing))
292AC_CHECK_HEADER(termios.h,,AC_MSG_ERROR($msg_required_header_missing))
293AC_CHECK_HEADER(unistd.h,,AC_MSG_ERROR($msg_required_header_missing))
294AC_CHECK_HEADER(vector,,AC_MSG_ERROR($msg_required_header_missing))
295AC_CHECK_HEADER(wchar.h,,AC_MSG_ERROR($msg_required_header_missing))
296AC_CHECK_HEADER(wctype.h,,AC_MSG_ERROR($msg_required_header_missing))
297AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR($msg_required_header_missing))
298AC_CHECK_HEADER(netinet/in.h,,AC_MSG_ERROR($msg_required_header_missing))
299AC_CHECK_HEADER(netinet/tcp.h,,AC_MSG_ERROR($msg_required_header_missing))
300AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR($msg_required_header_missing))
301AC_CHECK_HEADER(sys/time.h,,AC_MSG_ERROR($msg_required_header_missing))
302AC_CHECK_HEADER(sys/types.h,,AC_MSG_ERROR($msg_required_header_missing))
303AC_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 304
2b44051c
LOK
305## add the build date to LIB_INFO
306AC_CHECK_PROG(HAVE_GIT, git, yes)
307if test "x$HAVE_GIT" = "xyes"; then
308 revision=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h" HEAD)
309fi
310if test "x$revision" != "x"; then
311 LIB_INFO="$LIB_INFO, git revision: ${revision}"
312fi
313
314AC_CHECK_PROG(HAVE_DATE, date, yes)
315if test "x$HAVE_DATE" = "xyes"; then
316 LIB_INFO="$LIB_INFO, compiled on: `date -u`"
317else
318 LIB_INFO="$LIB_INFO, compiled on: (unknown date)"
319fi
320
321## add the name of the user who built libCEC to LIB_INFO
322AC_CHECK_PROG(HAVE_WHOAMI, whoami, yes)
323if test "x$HAVE_WHOAMI" = "xyes" ; then
324 LIB_INFO="$LIB_INFO by `whoami`"
325else
326 LIB_INFO="$LIB_INFO by (unknown user)"
327fi
328
329## add the hostname of the build host of libCEC to LIB_INFO
330AC_CHECK_PROG(HAVE_HOSTNAME, hostname, yes)
331if test "x$HAVE_HOSTNAME" = "xyes"; then
332 LIB_INFO="$LIB_INFO@`hostname -f`"
333fi
334
335## add the system info of the build host of libCEC to LIB_INFO
336AC_CHECK_PROG(HAVE_UNAME, uname, yes)
337if test "x$HAVE_UNAME" = "xyes"; then
338 LIB_INFO="$LIB_INFO on `uname -s` `uname -r` (`uname -m`)"
339fi
340
0c271bd0 341## redefine the LIBS, so cec-client isn't linked against things they don't need
2b44051c
LOK
342LIBS_LIBCEC="$LIBS"
343LIBS="$libs_client"
344
d6494a97 345CXXFLAGS="$CXXFLAGS -fPIC -Wall -Wextra -Wno-missing-field-initializers"
2b44051c
LOK
346
347if test "x$use_debug" = "xyes"; then
348 CXXFLAGS="$CXXFLAGS -g"
8cd2b85a 349 AC_DEFINE(CEC_DEBUGGING,"1", "generate libCEC debug output")
2b44051c
LOK
350fi
351
352if test "x$optimisation" = "xyes"; then
353 CXXFLAGS="$CXXFLAGS -O2"
354fi
355
356AC_DEFINE_UNQUOTED(LIB_INFO,"$LIB_INFO", "information about how libCEC was compiled")
7eb13cca 357
6ea2515b
LOK
358AC_SUBST([REQUIRES])
359AC_SUBST([LIBS])
360AC_SUBST([LIBS_LIBCEC])
2b44051c
LOK
361AC_SUBST([LIB_INFO])
362AC_SUBST([USE_P8_USB])
363AC_SUBST([USE_P8_USB_DETECT])
364AC_SUBST([USE_RPI_API])
abbca718 365AC_CONFIG_FILES([src/lib/libcec.pc])
0c271bd0 366AC_OUTPUT([Makefile src/lib/Makefile src/testclient/Makefile])
2b44051c
LOK
367
368cat <<EOB
369
370##############################################################################
371
372libCEC version $VERSION configured
373
374Compilation flags:
375 CXXFLAGS : $CXXFLAGS
376 libCEC LDFLAGS : $LIBS_LIBCEC
377 client LDFLAGS : $LIBS
378
379EOB
380
381echo -e "$features"
382
383cat <<EOB
384
385You can now build libCEC by running:
386 make
387
388##############################################################################
389
390EOB