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