summaryrefslogtreecommitdiff
path: root/sys-libs/libnbd/files/libnbd-1.24.0-build-Remove-automagic-compiling-of-examples.patch
blob: 05f1cdfe52b5f19ffd4feffb5398c48be9153ad3 (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
diff --git a/Makefile.am b/Makefile.am
index 32213efa..d587a092 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,6 +65,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 6c7cae8a..920625d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -327,57 +327,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], [
-    PRINT_PKG_VERSION([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], [
+         PRINT_PKG_VERSION([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], [
-    PRINT_PKG_VERSION(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], [
+         PRINT_PKG_VERSION(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],
@@ -397,6 +407,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]),