1From 18e3d62f5c8f957acc45695cb99c24510d23b457 Mon Sep 17 00:00:00 2001
2From: Wang Mingyu <wangmy@cn.fujitsu.com>
3Date: Fri, 25 Dec 2020 14:14:08 +0900
4Subject: [PATCH] talloc: Add configure options for packages
5
6Add configure options for the following packages:
7 - acl
8 - attr
9 - libbsd
10 - libcap
11 - valgrind
12
13Upstream-Status: Inappropriate [oe deterministic build specific]
14
15Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
16
17Modified to apply to version 2.1.10.
18
19Signed-off-by: Joe Slater <joe.slater@windriver.com>
20
21Modified tp apply to version 2.2.0
22Signed-off-by: Changqing Li <changqing.li@windriver.com>
23
24Rebase to 2.4.1
25Remove libaio option
26Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
27
28Rebase to 2.4.2
29Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
30---
31 lib/replace/wscript | 100 ++++++++++++++++++++++++++++++--------------
32 wscript             |   7 +++-
33 2 files changed, 75 insertions(+), 32 deletions(-)
34
35diff --git a/lib/replace/wscript b/lib/replace/wscript
36index 77e655b..2fd7dfb 100644
37--- a/lib/replace/wscript
38+++ b/lib/replace/wscript
39@@ -25,6 +25,34 @@ def options(opt):
40     opt.PRIVATE_EXTENSION_DEFAULT('')
41     opt.RECURSE('buildtools/wafsamba')
42
43+    opt.add_option('--with-acl',
44+                   help=("Enable use of acl"),
45+                   action="store_true", dest='enable_acl')
46+    opt.add_option('--without-acl',
47+                   help=("Disable use of acl"),
48+                   action="store_false", dest='enable_acl', default=False)
49+
50+    opt.add_option('--with-attr',
51+                   help=("Enable use of attr"),
52+                   action="store_true", dest='enable_attr')
53+    opt.add_option('--without-attr',
54+                   help=("Disable use of attr"),
55+                   action="store_false", dest='enable_attr', default=False)
56+
57+    opt.add_option('--with-libbsd',
58+                   help=("Enable use of libbsd"),
59+                   action="store_true", dest='enable_libbsd')
60+    opt.add_option('--without-libbsd',
61+                   help=("Disable use of libbsd"),
62+                   action="store_false", dest='enable_libbsd', default=False)
63+
64+    opt.add_option('--with-libcap',
65+                   help=("Enable use of libcap"),
66+                   action="store_true", dest='enable_libcap')
67+    opt.add_option('--without-libcap',
68+                   help=("Disable use of libcap"),
69+                   action="store_false", dest='enable_libcap', default=False)
70+
71 @Utils.run_once
72 def configure(conf):
73     conf.RECURSE('buildtools/wafsamba')
74@@ -38,18 +66,27 @@ def configure(conf):
75     conf.DEFINE('HAVE_LIBREPLACE', 1)
76     conf.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1)
77
78-    conf.CHECK_HEADERS('linux/types.h crypt.h locale.h acl/libacl.h compat.h')
79-    conf.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h')
80+    conf.CHECK_HEADERS('linux/types.h crypt.h locale.h compat.h')
81+    conf.CHECK_HEADERS('compat.h ctype.h dustat.h')
82     conf.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h')
83     conf.CHECK_HEADERS('locale.h ndir.h pwd.h')
84-    conf.CHECK_HEADERS('shadow.h sys/acl.h')
85-    conf.CHECK_HEADERS('sys/attributes.h attr/attributes.h sys/capability.h sys/dir.h sys/epoll.h')
86+    conf.CHECK_HEADERS('shadow.h')
87+    conf.CHECK_HEADERS('sys/attributes.h sys/dir.h sys/epoll.h')
88     conf.CHECK_HEADERS('sys/fcntl.h sys/filio.h sys/filsys.h sys/fs/s5param.h')
89     conf.CHECK_HEADERS('sys/id.h sys/ioctl.h sys/ipc.h sys/mman.h sys/mode.h sys/ndir.h sys/priv.h')
90     conf.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
91     conf.CHECK_HEADERS('sys/vfs.h sys/xattr.h termio.h termios.h sys/file.h')
92     conf.CHECK_HEADERS('sys/ucontext.h sys/wait.h sys/stat.h')
93
94+    if Options.options.enable_acl:
95+        conf.CHECK_HEADERS('acl/libacl.h sys/acl.h')
96+
97+    if Options.options.enable_attr:
98+        conf.CHECK_HEADERS('attr/attributes.h attr/xattr.h')
99+
100+    if Options.options.enable_libcap:
101+        conf.CHECK_HEADERS('sys/capability.h')
102+
103     if not conf.CHECK_DECLS('malloc', headers='stdlib.h'):
104         conf.CHECK_HEADERS('malloc.h')
105
106@@ -113,8 +150,9 @@ def configure(conf):
107     conf.CHECK_HEADERS('sys/fileio.h sys/filesys.h sys/dustat.h sys/sysmacros.h')
108     conf.CHECK_HEADERS('xfs/libxfs.h netgroup.h')
109
110-    conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h')
111-    conf.CHECK_HEADERS('valgrind/memcheck.h valgrind/helgrind.h valgrind/callgrind.h')
112+    if Options.options.enable_valgrind:
113+        conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h')
114+        conf.CHECK_HEADERS('valgrind/memcheck.h valgrind/helgrind.h valgrind/callgrind.h')
115     conf.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h')
116     conf.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h')
117     conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h')
118@@ -443,31 +481,31 @@ def configure(conf):
119
120     strlcpy_in_bsd = False
121
122-    # libbsd on some platforms provides strlcpy and strlcat
123-    if not conf.CHECK_FUNCS('strlcpy strlcat'):
124-        if conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
125-                               checklibc=True):
126-            strlcpy_in_bsd = True
127-    elif conf.env.enable_fuzzing:
128-        # Just to complicate it more, some versions of Honggfuzz have
129-        # got strlcpy and strlcat in libc, but not in <string.h>
130-        # (unless it is there coincidentally, on a BSD). Therefore we
131-        # can't use CHECK_FUNCS alone to decide whether to add the
132-        # headers to replace.h.
133-        #
134-        # As this is only known to happen on a fuzzing compiler, we'll
135-        # skip the check when not in fuzzing mode.
136-        conf.CHECK_HEADERS('bsd/string.h')
137-
138-    if not conf.CHECK_FUNCS('getpeereid'):
139-        conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
140-    if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
141-        conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h')
142-    if not conf.CHECK_FUNCS('setproctitle_init'):
143-        conf.CHECK_FUNCS_IN('setproctitle_init', 'bsd', headers='sys/types.h bsd/unistd.h')
144-
145-    if not conf.CHECK_FUNCS('closefrom'):
146-        conf.CHECK_FUNCS_IN('closefrom', 'bsd', headers='bsd/unistd.h')
147+    if Options.options.enable_libbsd:
148+        # libbsd on some platforms provides strlcpy and strlcat
149+        if not conf.CHECK_FUNCS('strlcpy strlcat'):
150+            if conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
151+                checklibc=True):
152+                strlcpy_in_bsd = True
153+        elif conf.env.enable_fuzzing:
154+            # Just to complicate it more, some versions of Honggfuzz have
155+            # got strlcpy and strlcat in libc, but not in <string.h>
156+            # (unless it is there coincidentally, on a BSD). Therefore we
157+            # can't use CHECK_FUNCS alone to decide whether to add the
158+            # headers to replace.h.
159+            #
160+            # As this is only known to happen on a fuzzing compiler, we'll
161+            # skip the check when not in fuzzing mode.
162+            conf.CHECK_HEADERS('bsd/string.h')
163+
164+        if not conf.CHECK_FUNCS('getpeereid'):
165+            conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
166+        if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
167+            conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h')
168+        if not conf.CHECK_FUNCS('setproctitle_init'):
169+            conf.CHECK_FUNCS_IN('setproctitle_init', 'bsd', headers='sys/types.h bsd/unistd.h')
170+        if not conf.CHECK_FUNCS('closefrom'):
171+            conf.CHECK_FUNCS_IN('closefrom', 'bsd', headers='bsd/unistd.h')
172
173     conf.CHECK_CODE('''
174                 struct ucred cred;
175diff --git a/wscript b/wscript
176index 8b5e02d..b6e2614 100644
177--- a/wscript
178+++ b/wscript
179@@ -31,7 +31,12 @@ def options(opt):
180         opt.add_option('--enable-talloc-compat1',
181                        help=("Build talloc 1.x.x compat library [False]"),
182                        action="store_true", dest='TALLOC_COMPAT1', default=False)
183-
184+        opt.add_option('--with-valgrind',
185+                       help=("enable use of valgrind"),
186+                       action="store_true", dest='enable_valgrind')
187+        opt.add_option('--without-valgrind',
188+                       help=("disable use of valgrind"),
189+                       action="store_false", dest='enable_valgrind', default=False)
190
191 def configure(conf):
192     conf.RECURSE('lib/replace')
193--
1942.34.1
195
196