updated changelog (release)
[deb_libcec.git] / configure.ac
CommitLineData
6ea2515b 1AC_PREREQ(2.59)
2b44051c
LOK
2AC_INIT([libcec], [1:8:0], [http://libcec.pulse-eight.com/])
3AC_CONFIG_HEADERS([config.h])
4AH_TOP([#pragma once])
5
6AM_INIT_AUTOMAKE([foreign])
7m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
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"
26msg_lockdev_missing="required library 'liblockdev' is missing"
27msg_required_header_missing="required header is missing"
28
29## debugging symbols
30AC_ARG_ENABLE([debug],
31 [AS_HELP_STRING([--enable-debug],
32 [include debug symbols (default is no)])],
33 [use_debug=$enableval],
34 [use_debug=no])
35
36## optimisation
37AC_ARG_ENABLE([optimisation],
38 [AS_HELP_STRING([--enable-optimisation],
39 [optimisation flag (default is yes)])],
40 [use_optimisation=$enableval],
41 [use_optimisation=yes])
abbca718 42
2b44051c
LOK
43## add the top dir and include to the include path, so we can include config.h and cec.h
44CPPFLAGS="$CPPFLAGS -I\$(abs_top_srcdir)/src -I\$(abs_top_srcdir)/include"
6ea2515b 45
2b44051c
LOK
46## search for pkg-config
47AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
48if test "x$HAVE_PKG_CONFIG" != "xyes" ; then
49 AC_MSG_WARN($msg_pkg_config_missing)
50fi
51
52## search for pthread, required by all targets
53AC_SEARCH_LIBS([pthread_create],[pthread],,AC_MSG_ERROR($msg_pthread_missing))
54AC_CHECK_FUNCS([pthread_mutexattr_init pthread_cond_init pthread_cond_destroy pthread_cond_signal pthread_cond_broadcast pthread_cond_wait pthread_cond_timedwait])
55
56## search for dlopen, required by all targets
6ea2515b
LOK
57AC_SEARCH_LIBS([dlopen], [dl],
58 [test "$ac_cv_search_dlopen" = "none required" || LIBS_DL=$ac_cv_search_dlopen],
2b44051c
LOK
59 AC_MSG_ERROR($msg_dl_missing))
60AC_CHECK_FUNCS([dlopen dlcose dlsym])
6ea2515b 61
2b44051c 62## platform specific libs, required by all targets
6ea2515b
LOK
63case "${host}" in
64 *-*-linux*)
2b44051c
LOK
65 # for timeutils
66 LIBS="$LIBS -lrt"
6ea2515b
LOK
67 ;;
68 *-apple-darwin*)
2b44051c 69 LIBS="$LIBS -framework CoreVideo -framework IOKit"
6ea2515b
LOK
70 ;;
71esac
72
2b44051c
LOK
73## we found all the libs and headers that we need for the client applications
74libs_client="$LIBS"
6ea2515b 75
2b44051c
LOK
76## search for udev, lockdev and the RPi API, only required by libCEC
77use_udev="no"
78use_adapter_detection="yes"
3e703e8e 79case "${host}" in
80 *-*-linux*)
2b44051c
LOK
81 ## search for udev if pkg-config was found
82 if test "x$HAVE_PKG_CONFIG" = "xyes" ; then
83 PKG_CHECK_MODULES([UDEV],[libudev],use_udev="yes",AC_MSG_WARN($msg_udev_missing))
84 fi
85
86 ## we need dirent.h on linux too
87 if test "$use_udev" = "yes"; then
88 AC_CHECK_HEADER(dirent.h,,[use_udev="no";AC_MSG_WARN($msg_dirent_missing)])
89 fi
6ea2515b 90
2b44051c
LOK
91 if test "$use_udev" != "yes"; then
92 use_adapter_detection="no"
93 fi
6ea2515b 94
2b44051c
LOK
95 ## search for lockdev
96 AC_CHECK_HEADER(lockdev.h,,AC_MSG_ERROR($msg_lockdev_missing))
97 AC_CHECK_LIB(lockdev,dev_unlock,,AC_MSG_ERROR($msg_lockdev_missing))
98
99 AC_CHECK_HEADER(time.h,,AC_MSG_ERROR($msg_required_header_missing))
100 AC_CHECK_HEADER(sys/prctl.h,,AC_MSG_ERROR($msg_required_header_missing))
3e703e8e 101 ;;
102 *-apple-darwin*)
2b44051c
LOK
103 AC_CHECK_HEADER(mach/mach_time.h,,AC_MSG_ERROR($msg_required_header_missing))
104 AC_CHECK_HEADER(CoreVideo/CVHostTime.h,,AC_MSG_ERROR($msg_required_header_missing))
5458fd77 105 ;;
3e703e8e 106esac
107
2b44051c
LOK
108## define the build info
109LIB_INFO="host: ${host}, features:"
110
111features="Configured features:\n Pulse-Eight CEC Adapter :\t\tyes"
112LIB_INFO="$LIB_INFO 'P8 USB'"
113AC_DEFINE([HAVE_P8_USB],[1],[Define to 1 to include support for the Pulse-Eight USB-CEC Adapter])
114AM_CONDITIONAL(USE_P8_USB, true)
115
116## mark adapter detection as available if the required deps were found
117if test "x$use_adapter_detection" = "xyes"; then
118 ## mark udev as available if it was found
119 if test "x$use_udev" = "xyes"; then
120 INCLUDES="$INCLUDES $UDEV_CFLAGS"
121 LIBS="$LIBS $UDEV_LIBS"
122 AC_DEFINE([HAVE_LIBUDEV],[1],[Define to 1 if libudev is installed])
123 REQUIRES="$REQUIRES udev"
124 fi
125
126 AC_DEFINE([HAVE_P8_USB_DETECT],[1],[Define to 1 to include autodetection support for the Pulse-Eight USB-CEC Adapter])
127 AM_CONDITIONAL(USE_P8_USB_DETECT, true)
128
129 features="$features\n Pulse-Eight CEC Adapter detection :\tyes"
130 LIB_INFO="$LIB_INFO 'P8 USB detect'"
131else
132 AM_CONDITIONAL(USE_P8_USB_DETECT, false)
133 features="$features\n Pulse-Eight CEC Adapter detection :\tno"
42c02563
LOK
134fi
135
2b44051c
LOK
136## check if our build system is complete
137AC_CHECK_HEADER(algorithm,,AC_MSG_ERROR($msg_required_header_missing))
138AC_CHECK_HEADER(ctype.h,,AC_MSG_ERROR($msg_required_header_missing))
139AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR($msg_required_header_missing))
140AC_CHECK_HEADER(errno.h,,AC_MSG_ERROR($msg_required_header_missing))
141AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR($msg_required_header_missing))
142AC_CHECK_HEADER(functional,,AC_MSG_ERROR($msg_required_header_missing))
143AC_CHECK_HEADER(locale,,AC_DEFINE([SS_NO_LOCALE],[1],[Define to 1 to exclude locale support]))
144AC_CHECK_HEADER(map,,AC_MSG_ERROR($msg_required_header_missing))
145AC_CHECK_HEADER(netdb.h,,AC_MSG_ERROR($msg_required_header_missing))
146AC_CHECK_HEADER(poll.h,,AC_MSG_ERROR($msg_required_header_missing))
147AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR($msg_required_header_missing))
148AC_CHECK_HEADER(queue,,AC_MSG_ERROR($msg_required_header_missing))
149AC_CHECK_HEADER(semaphore.h,,AC_MSG_ERROR($msg_required_header_missing))
150AC_CHECK_HEADER(set,,AC_MSG_ERROR($msg_required_header_missing))
151AC_CHECK_HEADER(stdarg.h,,AC_MSG_ERROR($msg_required_header_missing))
152AC_CHECK_HEADER(stdint.h,,AC_MSG_ERROR($msg_required_header_missing))
153AC_CHECK_HEADER(stdio.h,,AC_MSG_ERROR($msg_required_header_missing))
154AC_CHECK_HEADER(stdlib.h,,AC_MSG_ERROR($msg_required_header_missing))
155AC_CHECK_HEADER(string,,AC_MSG_ERROR($msg_required_header_missing))
156AC_CHECK_HEADER(string.h,,AC_MSG_ERROR($msg_required_header_missing))
157AC_CHECK_HEADER(termios.h,,AC_MSG_ERROR($msg_required_header_missing))
158AC_CHECK_HEADER(unistd.h,,AC_MSG_ERROR($msg_required_header_missing))
159AC_CHECK_HEADER(vector,,AC_MSG_ERROR($msg_required_header_missing))
160AC_CHECK_HEADER(wchar.h,,AC_MSG_ERROR($msg_required_header_missing))
161AC_CHECK_HEADER(wctype.h,,AC_MSG_ERROR($msg_required_header_missing))
162AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR($msg_required_header_missing))
163AC_CHECK_HEADER(netinet/in.h,,AC_MSG_ERROR($msg_required_header_missing))
164AC_CHECK_HEADER(netinet/tcp.h,,AC_MSG_ERROR($msg_required_header_missing))
165AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR($msg_required_header_missing))
166AC_CHECK_HEADER(sys/time.h,,AC_MSG_ERROR($msg_required_header_missing))
167AC_CHECK_HEADER(sys/types.h,,AC_MSG_ERROR($msg_required_header_missing))
168AC_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 169
2b44051c
LOK
170## add the build date to LIB_INFO
171AC_CHECK_PROG(HAVE_GIT, git, yes)
172if test "x$HAVE_GIT" = "xyes"; then
173 revision=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h" HEAD)
174fi
175if test "x$revision" != "x"; then
176 LIB_INFO="$LIB_INFO, git revision: ${revision}"
177fi
178
179AC_CHECK_PROG(HAVE_DATE, date, yes)
180if test "x$HAVE_DATE" = "xyes"; then
181 LIB_INFO="$LIB_INFO, compiled on: `date -u`"
182else
183 LIB_INFO="$LIB_INFO, compiled on: (unknown date)"
184fi
185
186## add the name of the user who built libCEC to LIB_INFO
187AC_CHECK_PROG(HAVE_WHOAMI, whoami, yes)
188if test "x$HAVE_WHOAMI" = "xyes" ; then
189 LIB_INFO="$LIB_INFO by `whoami`"
190else
191 LIB_INFO="$LIB_INFO by (unknown user)"
192fi
193
194## add the hostname of the build host of libCEC to LIB_INFO
195AC_CHECK_PROG(HAVE_HOSTNAME, hostname, yes)
196if test "x$HAVE_HOSTNAME" = "xyes"; then
197 LIB_INFO="$LIB_INFO@`hostname -f`"
198fi
199
200## add the system info of the build host of libCEC to LIB_INFO
201AC_CHECK_PROG(HAVE_UNAME, uname, yes)
202if test "x$HAVE_UNAME" = "xyes"; then
203 LIB_INFO="$LIB_INFO on `uname -s` `uname -r` (`uname -m`)"
204fi
205
206## redefine the LIBS, so cec-client and cec-config aren't linked against things they don't need
207LIBS_LIBCEC="$LIBS"
208LIBS="$libs_client"
209
210CXXFLAGS="$CXXFLAGS -fPIC -Wall -Wextra -Wno-missing-field-initializers"
211
212if test "x$use_debug" = "xyes"; then
213 CXXFLAGS="$CXXFLAGS -g"
214fi
215
216if test "x$optimisation" = "xyes"; then
217 CXXFLAGS="$CXXFLAGS -O2"
218fi
219
220AC_DEFINE_UNQUOTED(LIB_INFO,"$LIB_INFO", "information about how libCEC was compiled")
7eb13cca 221
6ea2515b
LOK
222AC_SUBST([REQUIRES])
223AC_SUBST([LIBS])
224AC_SUBST([LIBS_LIBCEC])
2b44051c
LOK
225AC_SUBST([LIB_INFO])
226AC_SUBST([USE_P8_USB])
227AC_SUBST([USE_P8_USB_DETECT])
228AC_SUBST([USE_RPI_API])
abbca718 229AC_CONFIG_FILES([src/lib/libcec.pc])
39b1216c 230AC_OUTPUT([Makefile src/lib/Makefile src/testclient/Makefile src/cec-config/Makefile])
2b44051c
LOK
231
232cat <<EOB
233
234##############################################################################
235
236libCEC version $VERSION configured
237
238Compilation flags:
239 CXXFLAGS : $CXXFLAGS
240 libCEC LDFLAGS : $LIBS_LIBCEC
241 client LDFLAGS : $LIBS
242
243EOB
244
245echo -e "$features"
246
247cat <<EOB
248
249You can now build libCEC by running:
250 make
251
252##############################################################################
253
254EOB