aboutsummaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/samba/samba-4.1.12/0005-build-unify-and-fix-endian-tests.patch
blob: 5546b6d65ec0c228d72840171f4226aa2ec35f30 (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
From 81379b6b14ea725c72953be2170b382403ed8728 Mon Sep 17 00:00:00 2001
From: Gustavo Zacarias <gustavo@zacarias.com.ar>
Date: Mon, 21 Apr 2014 10:18:15 -0300
Subject: [PATCH 5/7] build: unify and fix endian tests

Unify the endian tests out of lib/ccan/wscript into wafsamba since
they're almost cross-compile friendly.
While at it fix them to be so by moving the preprocessor directives out
of main scope since that will fail.
And keep the WORDS_BIGENDIAN, HAVE_LITTLE_ENDIAN and HAVE_BIG_ENDIAN
defines separate because of different codebases.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>

Upstream-Status: Backport

Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
---
 buildtools/wafsamba/wscript | 65 ++++++++++++++++++++++++++++++++++++++++++---
 lib/ccan/wscript            | 55 --------------------------------------
 2 files changed, 62 insertions(+), 58 deletions(-)

diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index 7984227..1a2cfe6 100755
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -390,9 +390,68 @@ def configure(conf):
     else:
         conf.define('SHLIBEXT', "so", quote=True)
 
-    conf.CHECK_CODE('long one = 1; return ((char *)(&one))[0]',
-                    execute=True,
-                    define='WORDS_BIGENDIAN')
+    # First try a header check for cross-compile friendlyness
+    conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
+                        #define B __BYTE_ORDER
+                        #elif defined(BYTE_ORDER)
+                        #define B BYTE_ORDER
+                        #endif
+
+                        #ifdef __LITTLE_ENDIAN
+                        #define LITTLE __LITTLE_ENDIAN
+                        #elif defined(LITTLE_ENDIAN)
+                        #define LITTLE LITTLE_ENDIAN
+                        #endif
+
+                        #if !defined(LITTLE) || !defined(B) || LITTLE != B
+                        #error Not little endian.
+                        #endif
+                        int main(void) { return 0; }""",
+                            addmain=False,
+                            headers="endian.h sys/endian.h",
+                            define="HAVE_LITTLE_ENDIAN")
+    conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
+                        #define B __BYTE_ORDER
+                        #elif defined(BYTE_ORDER)
+                        #define B BYTE_ORDER
+                        #endif
+
+                        #ifdef __BIG_ENDIAN
+                        #define BIG __BIG_ENDIAN
+                        #elif defined(BIG_ENDIAN)
+                        #define BIG BIG_ENDIAN
+                        #endif
+
+                        #if !defined(BIG) || !defined(B) || BIG != B
+                        #error Not big endian.
+                        #endif
+                        int main(void) { return 0; }""",
+                            addmain=False,
+                            headers="endian.h sys/endian.h",
+                            define="HAVE_BIG_ENDIAN")
+
+    if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
+        # That didn't work!  Do runtime test.
+        conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
+            u.i = 0x01020304;
+            return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
+                          addmain=True, execute=True,
+                          define='HAVE_LITTLE_ENDIAN',
+                          msg="Checking for HAVE_LITTLE_ENDIAN - runtime")
+        conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
+            u.i = 0x01020304;
+            return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
+                          addmain=True, execute=True,
+                          define='HAVE_BIG_ENDIAN',
+                          msg="Checking for HAVE_BIG_ENDIAN - runtime")
+
+    # Extra sanity check.
+    if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
+        Logs.error("Failed endian determination.  The PDP-11 is back?")
+	sys.exit(1)
+    else:
+        if conf.CONFIG_SET("HAVE_BIG_ENDIAN"):
+            conf.DEFINE('WORDS_BIGENDIAN', 1)
 
     # check if signal() takes a void function
     if conf.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index a0b5406..5b3a910 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -25,61 +25,6 @@ def configure(conf):
     conf.CHECK_CODE('int __attribute__((used)) func(int x) { return x; }',
                     addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
                     define='HAVE_ATTRIBUTE_USED')
-    # We try to use headers for a compile-time test.
-    conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
-                        #define B __BYTE_ORDER
-                        #elif defined(BYTE_ORDER)
-                        #define B BYTE_ORDER
-                        #endif
-
-                        #ifdef __LITTLE_ENDIAN
-                        #define LITTLE __LITTLE_ENDIAN
-                        #elif defined(LITTLE_ENDIAN)
-                        #define LITTLE LITTLE_ENDIAN
-                        #endif
-
-                        #if !defined(LITTLE) || !defined(B) || LITTLE != B
-                        #error Not little endian.
-                        #endif""",
-                           headers="endian.h sys/endian.h",
-                           define="HAVE_LITTLE_ENDIAN")
-    conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
-                        #define B __BYTE_ORDER
-                        #elif defined(BYTE_ORDER)
-                        #define B BYTE_ORDER
-                        #endif
-
-                        #ifdef __BIG_ENDIAN
-                        #define BIG __BIG_ENDIAN
-                        #elif defined(BIG_ENDIAN)
-                        #define BIG BIG_ENDIAN
-                        #endif
-
-                        #if !defined(BIG) || !defined(B) || BIG != B
-                        #error Not big endian.
-                        #endif""",
-                           headers="endian.h sys/endian.h",
-                           define="HAVE_BIG_ENDIAN")
-
-    if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
-        # That didn't work!  Do runtime test.
-        conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
-	  u.i = 0x01020304;
-	  return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
-                        addmain=True, execute=True,
-                        define='HAVE_LITTLE_ENDIAN',
-                        msg="Checking for HAVE_LITTLE_ENDIAN - runtime")
-        conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
-	  u.i = 0x01020304;
-	  return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
-                        addmain=True, execute=True,
-                        define='HAVE_BIG_ENDIAN',
-                        msg="Checking for HAVE_BIG_ENDIAN - runtime")
-
-    # Extra sanity check.
-    if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
-        Logs.error("Failed endian determination.  The PDP-11 is back?")
-        sys.exit(1)
 
     conf.CHECK_CODE('return __builtin_choose_expr(1, 0, "garbage");',
                     link=True,
-- 
1.9.1