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" | |
27 | msg_required_header_missing="required header is missing" | |
28 | ||
29 | ## debugging symbols | |
30 | AC_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 | |
37 | AC_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 |
44 | CPPFLAGS="$CPPFLAGS -I\$(abs_top_srcdir)/src -I\$(abs_top_srcdir)/include" | |
6ea2515b | 45 | |
2b44051c LOK |
46 | ## search for pkg-config |
47 | AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes) | |
48 | if test "x$HAVE_PKG_CONFIG" != "xyes" ; then | |
49 | AC_MSG_WARN($msg_pkg_config_missing) | |
50 | fi | |
51 | ||
52 | ## search for pthread, required by all targets | |
53 | AC_SEARCH_LIBS([pthread_create],[pthread],,AC_MSG_ERROR($msg_pthread_missing)) | |
54 | AC_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 |
57 | AC_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)) |
60 | AC_CHECK_FUNCS([dlopen dlcose dlsym]) | |
6ea2515b | 61 | |
2b44051c | 62 | ## platform specific libs, required by all targets |
6ea2515b LOK |
63 | case "${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 | ;; |
71 | esac | |
72 | ||
2b44051c LOK |
73 | ## we found all the libs and headers that we need for the client applications |
74 | libs_client="$LIBS" | |
6ea2515b | 75 | |
2b44051c LOK |
76 | ## search for udev, lockdev and the RPi API, only required by libCEC |
77 | use_udev="no" | |
78 | use_adapter_detection="yes" | |
3e703e8e | 79 | case "${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 | 106 | esac |
107 | ||
2b44051c LOK |
108 | ## define the build info |
109 | LIB_INFO="host: ${host}, features:" | |
110 | ||
111 | features="Configured features:\n Pulse-Eight CEC Adapter :\t\tyes" | |
112 | LIB_INFO="$LIB_INFO 'P8 USB'" | |
113 | AC_DEFINE([HAVE_P8_USB],[1],[Define to 1 to include support for the Pulse-Eight USB-CEC Adapter]) | |
114 | AM_CONDITIONAL(USE_P8_USB, true) | |
115 | ||
116 | ## mark adapter detection as available if the required deps were found | |
117 | if 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'" | |
131 | else | |
132 | AM_CONDITIONAL(USE_P8_USB_DETECT, false) | |
133 | features="$features\n Pulse-Eight CEC Adapter detection :\tno" | |
42c02563 LOK |
134 | fi |
135 | ||
2b44051c LOK |
136 | ## check if our build system is complete |
137 | AC_CHECK_HEADER(algorithm,,AC_MSG_ERROR($msg_required_header_missing)) | |
138 | AC_CHECK_HEADER(ctype.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
139 | AC_CHECK_HEADER(dlfcn.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
140 | AC_CHECK_HEADER(errno.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
141 | AC_CHECK_HEADER(fcntl.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
142 | AC_CHECK_HEADER(functional,,AC_MSG_ERROR($msg_required_header_missing)) | |
143 | AC_CHECK_HEADER(locale,,AC_DEFINE([SS_NO_LOCALE],[1],[Define to 1 to exclude locale support])) | |
144 | AC_CHECK_HEADER(map,,AC_MSG_ERROR($msg_required_header_missing)) | |
145 | AC_CHECK_HEADER(netdb.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
146 | AC_CHECK_HEADER(poll.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
147 | AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
148 | AC_CHECK_HEADER(queue,,AC_MSG_ERROR($msg_required_header_missing)) | |
149 | AC_CHECK_HEADER(semaphore.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
150 | AC_CHECK_HEADER(set,,AC_MSG_ERROR($msg_required_header_missing)) | |
151 | AC_CHECK_HEADER(stdarg.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
152 | AC_CHECK_HEADER(stdint.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
153 | AC_CHECK_HEADER(stdio.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
154 | AC_CHECK_HEADER(stdlib.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
155 | AC_CHECK_HEADER(string,,AC_MSG_ERROR($msg_required_header_missing)) | |
156 | AC_CHECK_HEADER(string.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
157 | AC_CHECK_HEADER(termios.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
158 | AC_CHECK_HEADER(unistd.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
159 | AC_CHECK_HEADER(vector,,AC_MSG_ERROR($msg_required_header_missing)) | |
160 | AC_CHECK_HEADER(wchar.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
161 | AC_CHECK_HEADER(wctype.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
162 | AC_CHECK_HEADER(arpa/inet.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
163 | AC_CHECK_HEADER(netinet/in.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
164 | AC_CHECK_HEADER(netinet/tcp.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
165 | AC_CHECK_HEADER(sys/socket.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
166 | AC_CHECK_HEADER(sys/time.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
167 | AC_CHECK_HEADER(sys/types.h,,AC_MSG_ERROR($msg_required_header_missing)) | |
168 | 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 | 169 | |
2b44051c LOK |
170 | ## add the build date to LIB_INFO |
171 | AC_CHECK_PROG(HAVE_GIT, git, yes) | |
172 | if test "x$HAVE_GIT" = "xyes"; then | |
173 | revision=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h" HEAD) | |
174 | fi | |
175 | if test "x$revision" != "x"; then | |
176 | LIB_INFO="$LIB_INFO, git revision: ${revision}" | |
177 | fi | |
178 | ||
179 | AC_CHECK_PROG(HAVE_DATE, date, yes) | |
180 | if test "x$HAVE_DATE" = "xyes"; then | |
181 | LIB_INFO="$LIB_INFO, compiled on: `date -u`" | |
182 | else | |
183 | LIB_INFO="$LIB_INFO, compiled on: (unknown date)" | |
184 | fi | |
185 | ||
186 | ## add the name of the user who built libCEC to LIB_INFO | |
187 | AC_CHECK_PROG(HAVE_WHOAMI, whoami, yes) | |
188 | if test "x$HAVE_WHOAMI" = "xyes" ; then | |
189 | LIB_INFO="$LIB_INFO by `whoami`" | |
190 | else | |
191 | LIB_INFO="$LIB_INFO by (unknown user)" | |
192 | fi | |
193 | ||
194 | ## add the hostname of the build host of libCEC to LIB_INFO | |
195 | AC_CHECK_PROG(HAVE_HOSTNAME, hostname, yes) | |
196 | if test "x$HAVE_HOSTNAME" = "xyes"; then | |
197 | LIB_INFO="$LIB_INFO@`hostname -f`" | |
198 | fi | |
199 | ||
200 | ## add the system info of the build host of libCEC to LIB_INFO | |
201 | AC_CHECK_PROG(HAVE_UNAME, uname, yes) | |
202 | if test "x$HAVE_UNAME" = "xyes"; then | |
203 | LIB_INFO="$LIB_INFO on `uname -s` `uname -r` (`uname -m`)" | |
204 | fi | |
205 | ||
206 | ## redefine the LIBS, so cec-client and cec-config aren't linked against things they don't need | |
207 | LIBS_LIBCEC="$LIBS" | |
208 | LIBS="$libs_client" | |
209 | ||
210 | CXXFLAGS="$CXXFLAGS -fPIC -Wall -Wextra -Wno-missing-field-initializers" | |
211 | ||
212 | if test "x$use_debug" = "xyes"; then | |
213 | CXXFLAGS="$CXXFLAGS -g" | |
214 | fi | |
215 | ||
216 | if test "x$optimisation" = "xyes"; then | |
217 | CXXFLAGS="$CXXFLAGS -O2" | |
218 | fi | |
219 | ||
220 | AC_DEFINE_UNQUOTED(LIB_INFO,"$LIB_INFO", "information about how libCEC was compiled") | |
7eb13cca | 221 | |
6ea2515b LOK |
222 | AC_SUBST([REQUIRES]) |
223 | AC_SUBST([LIBS]) | |
224 | AC_SUBST([LIBS_LIBCEC]) | |
2b44051c LOK |
225 | AC_SUBST([LIB_INFO]) |
226 | AC_SUBST([USE_P8_USB]) | |
227 | AC_SUBST([USE_P8_USB_DETECT]) | |
228 | AC_SUBST([USE_RPI_API]) | |
abbca718 | 229 | AC_CONFIG_FILES([src/lib/libcec.pc]) |
39b1216c | 230 | AC_OUTPUT([Makefile src/lib/Makefile src/testclient/Makefile src/cec-config/Makefile]) |
2b44051c LOK |
231 | |
232 | cat <<EOB | |
233 | ||
234 | ############################################################################## | |
235 | ||
236 | libCEC version $VERSION configured | |
237 | ||
238 | Compilation flags: | |
239 | CXXFLAGS : $CXXFLAGS | |
240 | libCEC LDFLAGS : $LIBS_LIBCEC | |
241 | client LDFLAGS : $LIBS | |
242 | ||
243 | EOB | |
244 | ||
245 | echo -e "$features" | |
246 | ||
247 | cat <<EOB | |
248 | ||
249 | You can now build libCEC by running: | |
250 | make | |
251 | ||
252 | ############################################################################## | |
253 | ||
254 | EOB |