1From 5e9e7223a3633ee82b557d21b1f18aa15becd450 Mon Sep 17 00:00:00 2001
2From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
3Date: Mon, 7 Dec 2020 20:38:30 +0100
4Subject: build: add a configure switch for building examples
5
6Example code for bindings is currently always built if bindings are
7enabled. Make it conditional with a new configure switch.
8
9Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
10Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
11[Retrieved from:
12https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/commit/?id=5e9e7223a3633ee82b557d21b1f18aa15becd450]
13Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
14---
15 bindings/cxx/Makefile.am    |  8 +++++++-
16 bindings/python/Makefile.am | 10 ++++++++--
17 configure.ac                |  6 ++++++
18 3 files changed, 21 insertions(+), 3 deletions(-)
19
20diff --git a/bindings/cxx/Makefile.am b/bindings/cxx/Makefile.am
21index 5c40ceb..87463b0 100644
22--- a/bindings/cxx/Makefile.am
23+++ b/bindings/cxx/Makefile.am
24@@ -18,10 +18,16 @@ include_HEADERS = gpiod.hpp
25 pkgconfigdir = $(libdir)/pkgconfig
26 pkgconfig_DATA = libgpiodcxx.pc
27
28-SUBDIRS = . examples
29+SUBDIRS = .
30
31 if WITH_TESTS
32
33 SUBDIRS += tests
34
35 endif
36+
37+if WITH_EXAMPLES
38+
39+SUBDIRS += examples
40+
41+endif
42diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
43index 124f152..5403bcb 100644
44--- a/bindings/python/Makefile.am
45+++ b/bindings/python/Makefile.am
46@@ -6,8 +6,6 @@
47 # Copyright (C) 2017-2018 Bartosz Golaszewski <bartekgola@gmail.com>
48 #
49
50-SUBDIRS = . examples
51-
52 pyexec_LTLIBRARIES = gpiod.la
53
54 gpiod_la_SOURCES = gpiodmodule.c
55@@ -17,8 +15,16 @@ gpiod_la_CFLAGS += -Wall -Wextra -g -std=gnu89 $(PYTHON_CPPFLAGS)
56 gpiod_la_LDFLAGS = -module -avoid-version
57 gpiod_la_LIBADD = $(top_builddir)/lib/libgpiod.la $(PYTHON_LIBS)
58
59+SUBDIRS = .
60+
61 if WITH_TESTS
62
63 SUBDIRS += tests
64
65 endif
66+
67+if WITH_EXAMPLES
68+
69+SUBDIRS += examples
70+
71+endif
72diff --git a/configure.ac b/configure.ac
73index 57c99a8..90a6324 100644
74--- a/configure.ac
75+++ b/configure.ac
76@@ -155,6 +155,12 @@ then
77 	fi
78 fi
79
80+AC_ARG_ENABLE([examples],
81+	[AS_HELP_STRING([--enable-examples], [enable building code examples[default=no]])],
82+	[if test "x$enableval" = xyes; then with_examples=true; fi],
83+	[with_examples=false])
84+AM_CONDITIONAL([WITH_EXAMPLES], [test "x$with_examples" = xtrue])
85+
86 AC_ARG_ENABLE([bindings-cxx],
87 	[AS_HELP_STRING([--enable-bindings-cxx],[enable C++ bindings [default=no]])],
88 	[if test "x$enableval" = xyes; then with_bindings_cxx=true; fi],
89--
90cgit 1.2.3-1.el7
91
92