Debian Codegraph @

configure.ac

raw
1 # SPDX-License-Identifier: GPL-2.0-or-later
2 # SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <[email protected]>
3
4 AC_PREREQ([2.71])
5
6 AC_INIT([libgpiod], [2.2.5], [], [],
7 AC_SUBST(EXTRA_VERSION, [])
8 [https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/])
9
10 AC_DEFINE_UNQUOTED([GPIOD_VERSION_STR],
11 ["$PACKAGE_VERSION$EXTRA_VERSION"],
12 [Full library version string.])
13 AC_SUBST(VERSION_STR, [$PACKAGE_VERSION$EXTRA_VERSION])
14
15 # From the libtool manual:
16 #
17 # (...)
18 # 3. If the library source code has changed at all since the last update, then
19 # increment revision ('c:r:a' becomes 'c:r+1:a').
20 # 4. If any interfaces have been added, removed, or changed since the last
21 # update, increment current, and set revision to 0.
22 # 5. If any interfaces have been added since the last public release, then
23 # increment age.
24 # 6. If any interfaces have been removed or changed since the last public
25 # release, then set age to 0.
26 #
27 # Define the libtool version as (C.R.A):
28 # NOTE: this version only applies to the core C library.
29 AC_SUBST(ABI_VERSION, [4.4.1])
30 # Have a separate ABI version for C++ bindings:
31 AC_SUBST(ABI_CXX_VERSION, [3.1.1])
32 # ABI version for libgpiosim (we need this since it can be installed if we
33 # enable tests).
34 AC_SUBST(ABI_GPIOSIM_VERSION, [1.3.0])
35 # ... and another one for GLib bindings:
36 AC_SUBST(ABI_GLIB_VERSION, [1.0.0])
37
38 AC_CONFIG_AUX_DIR([autostuff])
39 AC_CONFIG_MACRO_DIRS([m4])
40 AM_INIT_AUTOMAKE([foreign subdir-objects])
41
42 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
43 m4_pattern_forbid([^AX_],
44 [Unexpanded AX_ macro found. Please install GNU autoconf-archive.])
45
46 AC_CONFIG_SRCDIR([lib])
47 AC_CONFIG_HEADERS([config.h])
48
49 AC_DEFINE([_GNU_SOURCE], [], [We want GNU extensions])
50
51 # Silence warning: ar: 'u' modifier ignored since 'D' is the default
52 AC_SUBST(AR_FLAGS, [cr])
53
54 AM_PROG_AR
55 AC_PROG_CC
56 AC_PROG_CXX
57 AC_PROG_INSTALL
58 AC_PROG_EGREP
59
60 LT_INIT
61 PKG_PROG_PKG_CONFIG([0.28])
62
63 AC_DEFUN([ERR_NOT_FOUND],
64 [AC_MSG_ERROR([$1 not found (needed to build $2)], [1])])
65
66 AC_DEFUN([FUNC_NOT_FOUND_LIB],
67 [ERR_NOT_FOUND([$1()], [the library])])
68
69 AC_DEFUN([HEADER_NOT_FOUND_LIB],
70 [ERR_NOT_FOUND([$1 header], [the library])])
71
72 AC_DEFUN([HEADER_NOT_FOUND_TESTS],
73 [ERR_NOT_FOUND([$1 header], [the test suite])])
74
75 AC_DEFUN([HEADER_NOT_FOUND_CXX],
76 [ERR_NOT_FOUND([$1 header], [C++ bindings])])
77
78 # This is always checked (library needs this)
79 AC_CHECK_INCLUDES_DEFAULT
80
81 AC_FUNC_MALLOC
82 AC_HEADER_STDBOOL
83 AC_CHECK_FUNC([ioctl], [], [FUNC_NOT_FOUND_LIB([ioctl])])
84 AC_CHECK_FUNC([open], [], [FUNC_NOT_FOUND_LIB([open])])
85 AC_CHECK_FUNC([close], [], [FUNC_NOT_FOUND_LIB([close])])
86 AC_CHECK_FUNC([read], [], [FUNC_NOT_FOUND_LIB([read])])
87 AC_CHECK_FUNC([ppoll], [], [FUNC_NOT_FOUND_LIB([ppoll])])
88 AC_CHECK_FUNC([realpath], [], [FUNC_NOT_FOUND_LIB([realpath])])
89 AC_CHECK_FUNC([readlink], [], [FUNC_NOT_FOUND_LIB([readlink])])
90 AC_CHECK_HEADERS([fcntl.h], [], [HEADER_NOT_FOUND_LIB([fcntl.h])])
91 AC_CHECK_HEADERS([getopt.h], [], [HEADER_NOT_FOUND_LIB([getopt.h])])
92 AC_CHECK_HEADERS([dirent.h], [], [HEADER_NOT_FOUND_LIB([dirent.h])])
93 AC_CHECK_HEADERS([poll.h], [], [HEADER_NOT_FOUND_LIB([poll.h])])
94 AC_CHECK_HEADERS([sys/sysmacros.h], [], [HEADER_NOT_FOUND_LIB([sys/sysmacros.h])])
95 AC_CHECK_HEADERS([sys/ioctl.h], [], [HEADER_NOT_FOUND_LIB([sys/ioctl.h])])
96 AC_CHECK_HEADERS([sys/param.h], [], [HEADER_NOT_FOUND_LIB([sys/param.h])])
97 AC_CHECK_HEADERS([sys/stat.h], [], [HEADER_NOT_FOUND_LIB([sys/stat.h])])
98 AC_CHECK_HEADERS([sys/types.h], [], [HEADER_NOT_FOUND_LIB([sys/types.h])])
99 AC_CHECK_HEADERS([linux/const.h], [], [HEADER_NOT_FOUND_LIB([linux/const.h])])
100 AC_CHECK_HEADERS([linux/ioctl.h], [], [HEADER_NOT_FOUND_LIB([linux/ioctl.h])])
101 AC_CHECK_HEADERS([linux/types.h], [], [HEADER_NOT_FOUND_LIB([linux/types.h])])
102
103 AC_ARG_ENABLE([tools],
104 [AS_HELP_STRING([--enable-tools],[enable libgpiod command-line tools [default=no]])],
105 [if test "x$enableval" = xyes; then with_tools=true; fi],
106 [with_tools=false])
107 AM_CONDITIONAL([WITH_TOOLS], [test "x$with_tools" = xtrue])
108
109 AC_DEFUN([FUNC_NOT_FOUND_TOOLS],
110 [ERR_NOT_FOUND([$1()], [tools])])
111
112 AC_ARG_ENABLE([gpioset-interactive],
113 [AS_HELP_STRING([--enable-gpioset-interactive],
114 [enable gpioset interactive mode [default=no]])],
115 [if test "x$enableval" = xyes; then with_gpioset_interactive=true; fi],
116 [with_gpioset_interactive=false])
117 AM_CONDITIONAL([WITH_GPIOSET_INTERACTIVE],
118 [test "x$with_gpioset_interactive" = xtrue])
119
120 if test "x$with_tools" = xtrue
121 then
122 # These are only needed to build tools
123 AC_CHECK_FUNC([daemon], [], [FUNC_NOT_FOUND_TOOLS([daemon])])
124 AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_TOOLS([asprintf])])
125 AC_CHECK_FUNC([scandir], [], [FUNC_NOT_FOUND_TOOLS([scandir])])
126 AC_CHECK_FUNC([versionsort], [], [FUNC_NOT_FOUND_TOOLS([versionsort])])
127 AC_CHECK_FUNC([strtoull], [], [FUNC_NOT_FOUND_TOOLS([strtoull])])
128 AC_CHECK_FUNC([nanosleep], [], [FUNC_NOT_FOUND_TOOLS([nanosleep])])
129 if test "x$with_gpioset_interactive" = xtrue
130 then
131 PKG_CHECK_MODULES([LIBEDIT], [libedit >= 3.1])
132 fi
133 fi
134
135 AC_ARG_ENABLE([tests],
136 [AS_HELP_STRING([--enable-tests],[enable libgpiod tests [default=no]])],
137 [if test "x$enableval" = xyes; then with_tests=true; fi],
138 [with_tests=false])
139 AM_CONDITIONAL([WITH_TESTS], [test "x$with_tests" = xtrue])
140
141 AC_ARG_ENABLE([profiling],
142 [AS_HELP_STRING([--enable-profiling],
143 [enable gcov profiling on the core library and tests [default=no]])],
144 [if test "x$enableval" = xyes; then with_profiling=true; fi],
145 [with_profiling=false])
146 if test "x$with_profiling" = xtrue
147 then
148 AC_SUBST(PROFILING_CFLAGS, ["-fprofile-arcs -ftest-coverage"])
149 AC_SUBST(PROFILING_LDFLAGS, ["-lgcov"])
150 fi
151
152 AC_DEFUN([FUNC_NOT_FOUND_TESTS],
153 [ERR_NOT_FOUND([$1()], [tests])])
154
155 if test "x$with_tests" = xtrue
156 then
157 # For libgpiosim
158 PKG_CHECK_MODULES([KMOD], [libkmod >= 18])
159 PKG_CHECK_MODULES([MOUNT], [mount >= 2.33.1])
160
161 # For core library tests
162 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.50])
163 PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.50])
164
165 AC_CHECK_FUNC([atexit], [], [FUNC_NOT_FOUND_LIB([atexit])])
166 AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_LIB([asprintf])])
167 AC_CHECK_FUNC([prctl], [], [FUNC_NOT_FOUND_LIB([prctl])])
168 AC_CHECK_FUNC([unlink], [], [FUNC_NOT_FOUND_LIB([unlink])])
169 AC_CHECK_FUNC([unlinkat], [], [FUNC_NOT_FOUND_LIB([unlinkat])])
170 AC_CHECK_FUNC([openat], [], [FUNC_NOT_FOUND_LIB([openat])])
171 AC_CHECK_FUNC([mkdirat], [], [FUNC_NOT_FOUND_LIB([mkdirat])])
172 AC_CHECK_FUNC([write], [], [FUNC_NOT_FOUND_LIB([write])])
173 AC_CHECK_FUNC([twalk], [], [FUNC_NOT_FOUND_LIB([twalk])])
174 AC_CHECK_FUNC([tsearch], [], [FUNC_NOT_FOUND_LIB([tsearch])])
175 AC_CHECK_FUNC([tdestroy], [], [FUNC_NOT_FOUND_LIB([tdestroy])])
176 AC_CHECK_FUNC([tdelete], [], [FUNC_NOT_FOUND_LIB([tdelete])])
177 AC_CHECK_HEADERS([sys/utsname.h], [], [HEADER_NOT_FOUND_LIB([sys/utsname.h])])
178 AC_CHECK_HEADERS([sys/mount.h], [], [HEADER_NOT_FOUND_LIB([sys/mount.h])])
179 AC_CHECK_HEADERS([sys/prctl.h], [], [HEADER_NOT_FOUND_LIB([sys/prctl.h])])
180 AC_CHECK_HEADERS([sys/random.h], [], [HEADER_NOT_FOUND_LIB([sys/random.h])])
181 AC_CHECK_HEADERS([linux/version.h], [], [HEADER_NOT_FOUND_LIB([linux/version.h])])
182 AC_CHECK_HEADERS([pthread.h], [], [HEADER_NOT_FOUND_LIB([pthread.h])])
183 AC_CHECK_LIB(pthread, pthread_mutex_lock, [], ERR_NOT_FOUND([pthread library], [tests]))
184
185 if test "x$with_tools" = xtrue
186 then
187 AC_CHECK_PROG([has_shunit2], [shunit2], [true], [false])
188 if test "x$has_shunit2" = "xfalse"
189 then
190 AC_MSG_NOTICE([shunit2 not found - gpio-tools tests cannot be run])
191 fi
192 fi
193 fi
194
195 AC_ARG_ENABLE([examples],
196 [AS_HELP_STRING([--enable-examples], [enable building code examples[default=no]])],
197 [if test "x$enableval" = xyes; then with_examples=true; fi],
198 [with_examples=false])
199 AM_CONDITIONAL([WITH_EXAMPLES], [test "x$with_examples" = xtrue])
200
201 AC_ARG_ENABLE([bindings-cxx],
202 [AS_HELP_STRING([--enable-bindings-cxx],[enable C++ bindings [default=no]])],
203 [if test "x$enableval" = xyes; then with_bindings_cxx=true; fi],
204 [with_bindings_cxx=false])
205 AM_CONDITIONAL([WITH_BINDINGS_CXX], [test "x$with_bindings_cxx" = xtrue])
206
207 if test "x$with_bindings_cxx" = xtrue
208 then
209 LT_LANG([C++])
210 # This needs autoconf-archive
211 AX_CXX_COMPILE_STDCXX_17([ext], [mandatory])
212
213 if test "x$with_tests" = xtrue
214 then
215 PKG_CHECK_MODULES([CATCH2], [catch2-with-main >= 3.0],, [
216 AC_LANG_PUSH([C++])
217 AC_CHECK_HEADERS([catch2/catch_all.hpp], [],
218 [HEADER_NOT_FOUND_CXX([catch2/catch_all.hpp])])
219 AC_LANG_POP([C++])
220 ])
221 fi
222 fi
223
224 AC_ARG_ENABLE([bindings-python],
225 [AS_HELP_STRING([--enable-bindings-python],[enable python3 bindings [default=no]])],
226 [if test "x$enableval" = xyes; then with_bindings_python=true; fi],
227 [with_bindings_python=false])
228 AM_CONDITIONAL([WITH_BINDINGS_PYTHON], [test "x$with_bindings_python" = xtrue])
229
230 if test "x$with_bindings_python" = xtrue
231 then
232 AM_PATH_PYTHON([3.9], [],
233 [AC_MSG_ERROR([python3 not found - needed for python bindings])])
234 fi
235
236 AC_ARG_ENABLE([bindings-rust],
237 [AS_HELP_STRING([--enable-bindings-rust],[enable rust bindings [default=no]])],
238 [if test "x$enableval" = xyes; then with_bindings_rust=true; fi],
239 [with_bindings_rust=false])
240 AM_CONDITIONAL([WITH_BINDINGS_RUST], [test "x$with_bindings_rust" = xtrue])
241
242 if test "x$with_bindings_rust" = xtrue
243 then
244 AC_CHECK_PROG([has_cargo], [cargo], [true], [false])
245 if test "x$has_cargo" = xfalse
246 then
247 AC_MSG_ERROR([cargo not found - needed for rust bindings])
248 fi
249 fi
250
251 AC_ARG_ENABLE([dbus],
252 [AS_HELP_STRING([--enable-dbus], [build dbus daemon [default=no]])],
253 [if test "x$enableval" == xyes; then with_dbus=true; fi],
254 [with_dbus=false])
255 AM_CONDITIONAL([WITH_DBUS], [test "x$with_dbus" = xtrue])
256
257 AC_ARG_ENABLE([bindings-glib],
258 [AS_HELP_STRING([--enable-bindings-glib],[enable GLib 2.0 bindings [default=no]])],
259 [if test "x$enableval" = xyes; then with_bindings_glib=true; fi],
260 [with_bindings_glib=false])
261
262 AC_DEFUN([FUNC_NOT_FOUND_DBUS],
263 [ERR_NOT_FOUND([$1()], [dbus daemon])])
264
265 if test "x$with_dbus" = xtrue
266 then
267 AC_CHECK_FUNC([daemon], [], [FUNC_NOT_FOUND_DBUS([daemon])])
268 AC_CHECK_FUNC([strverscmp], [], [FUNC_NOT_FOUND_DBUS([strverscmp])])
269 PKG_CHECK_MODULES([GUDEV], [gudev-1.0 >= 230])
270 AC_CHECK_PROG([has_gdbus_codegen], [gdbus-codegen], [true], [false])
271 if test "x$has_gdbus_codegen" = xfalse
272 then
273 AC_MSG_ERROR([gdbus-codegen not found - needed to build dbus daemon])
274 fi
275
276 # Imply GLib bindings for D-Bus
277 with_bindings_glib=true
278 fi
279
280 AM_CONDITIONAL([WITH_BINDINGS_GLIB], [test "x$with_bindings_glib" = xtrue])
281
282 AC_DEFUN([GLIB_MKENUMS_NOT_FOUND],
283 [AC_MSG_ERROR([glib-mkenums not found - needed to build GLib bindings])])
284
285 if test "x$with_bindings_glib" = xtrue
286 then
287 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.80])
288 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.80])
289 PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.80])
290 PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.80])
291 PKG_CHECK_VAR([GLIB_MKENUMS], [glib-2.0], [glib_mkenums], [], GLIB_MKENUMS_NOT_FOUND)
292 AC_CHECK_PROG([has_glib_mkenums], [glib-mkenums], [true], [false])
293 if test "x$has_glib_mkenums" == xfalse
294 then
295 GLIB_MKENUMS_NOT_FOUND
296 fi
297
298 AC_CHECK_PROG([has_gi_docgen], [gi-docgen], [true], [false])
299 if test "x$has_gi_docgen" = xfalse
300 then
301 AC_MSG_NOTICE([gi-docgen not found - GLib documentation cannot be generated])
302 fi
303 fi
304 AM_CONDITIONAL([HAS_GI_DOCGEN], [test "x$has_gi_docgen" = xtrue])
305 AM_COND_IF([HAS_GI_DOCGEN], [AC_CONFIG_FILES([bindings/glib/gi-docgen.toml])])
306
307 # GObject-introspection
308 found_introspection=no
309 m4_ifdef([GOBJECT_INTROSPECTION_CHECK],
310 [GOBJECT_INTROSPECTION_CHECK([0.6.2])],
311 [AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")])
312
313 AC_ARG_ENABLE([systemd],
314 [AS_HELP_STRING([--enable-systemd], [enable systemd support [default=no]])],
315 [if test "x$enableval" == xyes; then with_systemd=true; fi],
316 [with_systemd=false])
317 AM_CONDITIONAL([WITH_SYSTEMD], [test "x$with_systemd" = xtrue])
318
319 if test "x$with_systemd" = xtrue
320 then
321 PKG_CHECK_VAR([systemdsystemunitdir], [systemd], [systemdsystemunitdir], [],
322 AC_MSG_ERROR([systemdsystemunitdir not found - needed to enable systemd support]))
323 fi
324
325 if test "x$cross_compiling" = xno
326 then
327 AC_CHECK_PROG([has_help2man], [help2man], [true], [false])
328 fi
329 AM_CONDITIONAL([WITH_MANPAGES], [test "x$has_help2man" = xtrue])
330 if test "x$has_help2man" = xfalse
331 then
332 AC_MSG_NOTICE([help2man not found - man pages and documentation cannot be generated])
333 fi
334
335 AC_DEFUN([DOC_PROG_NOT_FOUND], [AC_MSG_NOTICE([$1 not found - documentation cannot be generated])])
336 AC_CHECK_PROG([has_doxygen], [doxygen], [true], [false])
337 AC_CHECK_PROG([has_sphinx], [sphinx-build], [true], [false])
338 AC_CHECK_PROG([has_pandoc], [pandoc], [true], [false])
339 AM_CONDITIONAL([WITH_DOCS], [test "x$has_doxygen" = xtrue && test "x$has_sphinx" = xtrue && test "x$has_pandoc" = xtrue && test "x$has_help2man" = xtrue])
340 if test "x$has_doxygen" = xfalse
341 then
342 DOC_PROG_NOT_FOUND(["doxygen"])
343 fi
344 if test "x$has_sphinx" = xfalse
345 then
346 DOC_PROG_NOT_FOUND(["sphinx-build"])
347 fi
348 if test "x$has_pandoc" = xfalse
349 then
350 DOC_PROG_NOT_FOUND(["pandoc"])
351 fi
352
353 AC_CONFIG_FILES([Makefile
354 include/Makefile
355 lib/Makefile
356 lib/libgpiod.pc
357 contrib/Makefile
358 docs/Makefile
359 examples/Makefile
360 tools/Makefile
361 tests/Makefile
362 tests/gpiosim/Makefile
363 tests/gpiosim-glib/Makefile
364 tests/harness/Makefile
365 tests/scripts/Makefile
366 bindings/cxx/libgpiodcxx.pc
367 bindings/Makefile
368 bindings/cxx/Makefile
369 bindings/cxx/gpiodcxx/Makefile
370 bindings/cxx/examples/Makefile
371 bindings/cxx/tests/Makefile
372 bindings/glib/gpiod-glib.pc
373 bindings/glib/Makefile
374 bindings/glib/examples/Makefile
375 bindings/glib/tests/Makefile
376 bindings/python/Makefile
377 bindings/python/gpiod/Makefile
378 bindings/python/gpiod/ext/Makefile
379 bindings/python/examples/Makefile
380 bindings/python/tests/Makefile
381 bindings/python/tests/gpiosim/Makefile
382 bindings/python/tests/procname/Makefile
383 bindings/rust/libgpiod-sys/src/Makefile
384 bindings/rust/libgpiod-sys/Makefile
385 bindings/rust/libgpiod/src/Makefile
386 bindings/rust/libgpiod/tests/common/Makefile
387 bindings/rust/libgpiod/tests/Makefile
388 bindings/rust/libgpiod/Makefile
389 bindings/rust/libgpiod/examples/Makefile
390 bindings/rust/Makefile
391 bindings/rust/gpiosim-sys/src/Makefile
392 bindings/rust/gpiosim-sys/Makefile
393 dbus/Makefile
394 dbus/client/Makefile
395 dbus/data/Makefile
396 dbus/lib/Makefile
397 dbus/manager/Makefile
398 dbus/tests/Makefile
399 man/Makefile])
400
401 AC_OUTPUT