summaryrefslogtreecommitdiff
path: root/sys-libs/libnbd/files/libnbd-1.22.2-build-Remove-automagic-compiling-of-examples.patch
blob: 6bd9cd09fea544c0652a27ee9b57657bd954d79d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
From 53e0ade7f46525e048cea7bd321cdf370800e18a Mon Sep 17 00:00:00 2001
From: Christopher Byrne <salah.coronya@gmail.com>
Date: Sat, 14 Jun 2025 21:01:17 -0500
Subject: [PATCH 1/2] build: Remove automagic compiling of examples

---
 Makefile.am  |  4 +++
 configure.ac | 93 +++++++++++++++++++++++++++++-----------------------
 2 files changed, 56 insertions(+), 41 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 129e393..f31e067 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -64,6 +64,10 @@ SUBDIRS = \
 	bash-completion \
 	$(NULL)
 
+if BUILD_EXAMPLES 
+SUBDIRS += examples
+endif
+
 noinst_SCRIPTS = run
 
 # Check no files are missing from EXTRA_DIST rules, and that all
diff --git a/configure.ac b/configure.ac
index 84ec09d..d27a605 100644
--- a/configure.ac
+++ b/configure.ac
@@ -308,57 +308,67 @@ AS_IF([test "$with_libxml2" != "no"],[
 ])
 AM_CONDITIONAL([HAVE_LIBXML2], [test "x$LIBXML2_LIBS" != "x"])
 
+dnl Examples
+AC_ARG_ENABLE([examples],
+    [AS_HELP_STRING([--disable-examples],
+                    [disable building of glib and libev examples @<:@default=check@:>@])],
+    [],
+    [with_examples=check])
+
+AS_IF([test "$enable_examples" != "no"],[
 dnl glib2 main loop for examples that interoperate with the glib main loop.
-PKG_CHECK_MODULES([GLIB], [glib-2.0], [
-    printf "glib2 version is "; $PKG_CONFIG --modversion glib-2.0
-    AC_SUBST([GLIB_CFLAGS])
-    AC_SUBST([GLIB_LIBS])
-],[
-    AC_MSG_WARN([glib2 not found, some examples will not be compiled])
-])
-AM_CONDITIONAL([HAVE_GLIB], [test "x$GLIB_LIBS" != "x"])
+    PKG_CHECK_MODULES([GLIB], [glib-2.0], [
+         printf "glib2 version is "; $PKG_CONFIG --modversion glib-2.0
+         AC_SUBST([GLIB_CFLAGS])
+         AC_SUBST([GLIB_LIBS])
+    ], [
+        AC_MSG_WARN([glib2 not found, some examples will not be compiled])
+    ])
 
 dnl libev support for examples that interoperate with libev event loop.
-PKG_CHECK_MODULES([LIBEV], [libev], [
-    printf "libev version is "; $PKG_CONFIG --modversion libev
-    AC_SUBST([LIBEV_CFLAGS])
-    AC_SUBST([LIBEV_LIBS])
-],[
-    dnl no pkg-config for libev, searching manually:
-    AC_CHECK_HEADERS([ev.h], [
-        AC_CHECK_LIB([ev], [ev_time], [
-            AC_SUBST([LIBEV_LIBS], ["-lev"])
-        ],
-        [
-            AC_MSG_WARN([libev not found, some examples will not be compiled])
-        ])
-    ],[
-        AC_MSG_WARN([ev.h not found, some examples will not be compiled])
+    PKG_CHECK_MODULES([LIBEV], [libev], [
+         printf "libev version is "; $PKG_CONFIG --modversion libev
+         AC_SUBST([LIBEV_CFLAGS])
+         AC_SUBST([LIBEV_LIBS])
+         ],[
+dnl no pkg-config for libev, searching manually:
+         AC_CHECK_HEADERS([ev.h], [
+             AC_CHECK_LIB([ev], [ev_time], [
+                 AC_SUBST([LIBEV_LIBS], ["-lev"])
+             ],
+             [
+                 AC_MSG_WARN([libev not found, some examples will not be compiled])
+             ])
+         ],[
+              AC_MSG_WARN([ev.h not found, some examples will not be compiled])
+         ])
     ])
-])
 
-AS_IF([test "x$LIBEV_LIBS" != "x"], [
-    old_CFLAGS="$CFLAGS"
-    CFLAGS="$CFLAGS $LIBEV_CFLAGS -Werror=strict-aliasing -O2"
-    AC_MSG_CHECKING([if the compiler is new enough for good aliasing rules])
-    AC_COMPILE_IFELSE([
-        AC_LANG_PROGRAM([
-            #include <ev.h>
-
-            static void cb (struct ev_loop *l, ev_timer *t, int e) { }
-            static ev_timer timer;
+    AS_IF([test "x$LIBEV_LIBS" != "x"], [
+        old_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $LIBEV_CFLAGS -Werror=strict-aliasing -O2"
+        AC_MSG_CHECKING([if the compiler is new enough for good aliasing rules])
+        AC_COMPILE_IFELSE([
+            AC_LANG_PROGRAM([
+                #include <ev.h>
+
+                static void cb (struct ev_loop *l, ev_timer *t, int e) { }
+                static ev_timer timer;
+            ], [
+                ev_timer_init (&timer, cb, 0, .1);
+            ])
         ], [
-            ev_timer_init (&timer, cb, 0, .1);
+            AC_MSG_RESULT([yes])
+        ], [
+            AC_MSG_RESULT([no])
+            LIBEV_CFLAGS="$LIBEV_CFLAGS -Wno-strict-aliasing"
         ])
-    ], [
-        AC_MSG_RESULT([yes])
-    ], [
-        AC_MSG_RESULT([no])
-        LIBEV_CFLAGS="$LIBEV_CFLAGS -Wno-strict-aliasing"
+        CFLAGS="$old_CFLAGS"
     ])
-    CFLAGS="$old_CFLAGS"
 ])
+AM_CONDITIONAL([HAVE_GLIB], [test "x$GLIB_LIBS" != "x"]) 
 AM_CONDITIONAL([HAVE_LIBEV], [test "x$LIBEV_LIBS" != "x"])
+AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" != "xno" ])
 
 dnl FUSE 3 is optional to build the nbdfuse program.
 AC_ARG_ENABLE([fuse],
@@ -378,6 +388,7 @@ AS_IF([test "x$enable_fuse" != "xno"],[
 ])
 AM_CONDITIONAL([HAVE_FUSE],[test "x$enable_fuse" != "xno"])
 
+
 dnl libublksrv is optional to build the nbdublk program.
 AC_ARG_ENABLE([ublk],
     AS_HELP_STRING([--disable-ublk], [disable ublk (nbdublk) support]),
-- 
2.49.0