1From c2241d7a1371ece3b89dfdad4861dcf0a152d5d4 Mon Sep 17 00:00:00 2001
2From: Wang Mingyu <wangmy@cn.fujitsu.com>
3Date: Fri, 25 Dec 2020 15:03:17 +0900
4Subject: [PATCH] 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 0.9.33.
18
19Signed-off-by: Joe Slater <joe.slater@windriver.com>
20
21Update patch to version 0.10.0
22Signed-off-by: Changqing Li <changqing.li@windriver.com>
23
24Update patch to version 0.14.1
25Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
26
27Rebase to 0.16.0
28Remove libaio option
29Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
30---
31 lib/replace/wscript | 100 +++++++++++++++++++++++++++++++-------------
32 wscript             |   6 +++
33 2 files changed, 77 insertions(+), 29 deletions(-)
34
35diff --git a/lib/replace/wscript b/lib/replace/wscript
36index 77e655b..452c741 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,12 +66,24 @@ 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+
89+    if Options.options.enable_acl:
90+        conf.CHECK_HEADERS('acl/libacl.h sys/acl.h')
91+
92+    if Options.options.enable_attr:
93+        conf.CHECK_HEADERS('attr/attributes.h attr/xattr.h')
94+
95+    if Options.options.enable_libcap:
96+        conf.CHECK_HEADERS('sys/capability.h')
97+
98     conf.CHECK_HEADERS('sys/fcntl.h sys/filio.h sys/filsys.h sys/fs/s5param.h')
99     conf.CHECK_HEADERS('sys/id.h sys/ioctl.h sys/ipc.h sys/mman.h sys/mode.h sys/ndir.h sys/priv.h')
100     conf.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
101@@ -113,8 +153,9 @@ def configure(conf):
102     conf.CHECK_HEADERS('sys/fileio.h sys/filesys.h sys/dustat.h sys/sysmacros.h')
103     conf.CHECK_HEADERS('xfs/libxfs.h netgroup.h')
104
105-    conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h')
106-    conf.CHECK_HEADERS('valgrind/memcheck.h valgrind/helgrind.h valgrind/callgrind.h')
107+    if Options.options.enable_valgrind:
108+        conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h')
109+        conf.CHECK_HEADERS('valgrind/memcheck.h valgrind/helgrind.h valgrind/callgrind.h')
110     conf.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h')
111     conf.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h')
112     conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h')
113@@ -443,31 +484,32 @@ def configure(conf):
114
115     strlcpy_in_bsd = False
116
117-    # libbsd on some platforms provides strlcpy and strlcat
118-    if not conf.CHECK_FUNCS('strlcpy strlcat'):
119-        if conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
120-                               checklibc=True):
121-            strlcpy_in_bsd = True
122-    elif conf.env.enable_fuzzing:
123-        # Just to complicate it more, some versions of Honggfuzz have
124-        # got strlcpy and strlcat in libc, but not in <string.h>
125-        # (unless it is there coincidentally, on a BSD). Therefore we
126-        # can't use CHECK_FUNCS alone to decide whether to add the
127-        # headers to replace.h.
128-        #
129-        # As this is only known to happen on a fuzzing compiler, we'll
130-        # skip the check when not in fuzzing mode.
131-        conf.CHECK_HEADERS('bsd/string.h')
132-
133-    if not conf.CHECK_FUNCS('getpeereid'):
134-        conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
135-    if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
136-        conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h')
137-    if not conf.CHECK_FUNCS('setproctitle_init'):
138-        conf.CHECK_FUNCS_IN('setproctitle_init', 'bsd', headers='sys/types.h bsd/unistd.h')
139-
140-    if not conf.CHECK_FUNCS('closefrom'):
141-        conf.CHECK_FUNCS_IN('closefrom', 'bsd', headers='bsd/unistd.h')
142+    if Options.options.enable_libbsd:
143+        # libbsd on some platforms provides strlcpy and strlcat
144+        if not conf.CHECK_FUNCS('strlcpy strlcat'):
145+            if conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h',
146+                                checklibc=True):
147+                strlcpy_in_bsd = True
148+        elif conf.env.enable_fuzzing:
149+            # Just to complicate it more, some versions of Honggfuzz have
150+            # got strlcpy and strlcat in libc, but not in <string.h>
151+            # (unless it is there coincidentally, on a BSD). Therefore we
152+            # can't use CHECK_FUNCS alone to decide whether to add the
153+            # headers to replace.h.
154+            #
155+            # As this is only known to happen on a fuzzing compiler, we'll
156+            # skip the check when not in fuzzing mode.
157+            conf.CHECK_HEADERS('bsd/string.h')
158+
159+        if not conf.CHECK_FUNCS('getpeereid'):
160+            conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
161+        if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
162+            conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h')
163+        if not conf.CHECK_FUNCS('setproctitle_init'):
164+            conf.CHECK_FUNCS_IN('setproctitle_init', 'bsd', headers='sys/types.h bsd/unistd.h')
165+
166+        if not conf.CHECK_FUNCS('closefrom'):
167+            conf.CHECK_FUNCS_IN('closefrom', 'bsd', headers='bsd/unistd.h')
168
169     conf.CHECK_CODE('''
170                 struct ucred cred;
171diff --git a/wscript b/wscript
172index d912a8a..484a6fa 100644
173--- a/wscript
174+++ b/wscript
175@@ -28,6 +28,12 @@ def options(opt):
176     opt.RECURSE('lib/replace')
177     opt.RECURSE('lib/talloc')
178
179+    opt.add_option('--with-valgrind',
180+                   help=("enable use of valgrind"),
181+                   action="store_true", dest='enable_valgrind')
182+    opt.add_option('--without-valgrind',
183+                   help=("disable use of valgrind"),
184+                   action="store_false", dest='enable_valgrind', default=False)
185
186 def configure(conf):
187     conf.RECURSE('lib/replace')
188--
1892.25.1
190
191