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