samba4: bump to version 4.1.7 and improve cross build
[buildroot-gz.git] / package / samba4 / samba4-0008-build-unify-and-fix-endian-tests.patch
blob4797e4ca569b503172e4f93bb36ccb62017bed8b
1 From ee4e06b7223fb2925bc887c89216a66029d44862 Mon Sep 17 00:00:00 2001
2 From: Gustavo Zacarias <gustavo@zacarias.com.ar>
3 Date: Tue, 1 Apr 2014 06:41:47 -0300
4 Subject: [PATCH 2/5] build: unify and fix endian tests
6 Unify the endian tests out of lib/ccan/wscript into wafsamba since
7 they're almost cross-compile friendly.
8 While at it fix them to be so by moving the preprocessor directives out
9 of main scope since that will fail.
10 And keep the WORDS_BIGENDIAN, HAVE_LITTLE_ENDIAN and HAVE_BIG_ENDIAN
11 defines separate because of different codebases.
13 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
14 ---
15 buildtools/wafsamba/wscript | 65 ++++++++++++++++++++++++++++++++++++++++++---
16 lib/ccan/wscript | 55 --------------------------------------
17 2 files changed, 62 insertions(+), 58 deletions(-)
19 diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
20 index 7984227..1a2cfe6 100755
21 --- a/buildtools/wafsamba/wscript
22 +++ b/buildtools/wafsamba/wscript
23 @@ -390,9 +390,68 @@ def configure(conf):
24 else:
25 conf.define('SHLIBEXT', "so", quote=True)
27 - conf.CHECK_CODE('long one = 1; return ((char *)(&one))[0]',
28 - execute=True,
29 - define='WORDS_BIGENDIAN')
30 + # First try a header check for cross-compile friendlyness
31 + conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
32 + #define B __BYTE_ORDER
33 + #elif defined(BYTE_ORDER)
34 + #define B BYTE_ORDER
35 + #endif
37 + #ifdef __LITTLE_ENDIAN
38 + #define LITTLE __LITTLE_ENDIAN
39 + #elif defined(LITTLE_ENDIAN)
40 + #define LITTLE LITTLE_ENDIAN
41 + #endif
43 + #if !defined(LITTLE) || !defined(B) || LITTLE != B
44 + #error Not little endian.
45 + #endif
46 + int main(void) { return 0; }""",
47 + addmain=False,
48 + headers="endian.h sys/endian.h",
49 + define="HAVE_LITTLE_ENDIAN")
50 + conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
51 + #define B __BYTE_ORDER
52 + #elif defined(BYTE_ORDER)
53 + #define B BYTE_ORDER
54 + #endif
56 + #ifdef __BIG_ENDIAN
57 + #define BIG __BIG_ENDIAN
58 + #elif defined(BIG_ENDIAN)
59 + #define BIG BIG_ENDIAN
60 + #endif
62 + #if !defined(BIG) || !defined(B) || BIG != B
63 + #error Not big endian.
64 + #endif
65 + int main(void) { return 0; }""",
66 + addmain=False,
67 + headers="endian.h sys/endian.h",
68 + define="HAVE_BIG_ENDIAN")
70 + if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
71 + # That didn't work! Do runtime test.
72 + conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
73 + u.i = 0x01020304;
74 + return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
75 + addmain=True, execute=True,
76 + define='HAVE_LITTLE_ENDIAN',
77 + msg="Checking for HAVE_LITTLE_ENDIAN - runtime")
78 + conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
79 + u.i = 0x01020304;
80 + return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
81 + addmain=True, execute=True,
82 + define='HAVE_BIG_ENDIAN',
83 + msg="Checking for HAVE_BIG_ENDIAN - runtime")
85 + # Extra sanity check.
86 + if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
87 + Logs.error("Failed endian determination. The PDP-11 is back?")
88 + sys.exit(1)
89 + else:
90 + if conf.CONFIG_SET("HAVE_BIG_ENDIAN"):
91 + conf.DEFINE('WORDS_BIGENDIAN', 1)
93 # check if signal() takes a void function
94 if conf.CHECK_CODE('return *(signal (0, 0)) (0) == 1',
95 diff --git a/lib/ccan/wscript b/lib/ccan/wscript
96 index 1c5f337..0e540db 100644
97 --- a/lib/ccan/wscript
98 +++ b/lib/ccan/wscript
99 @@ -25,61 +25,6 @@ def configure(conf):
100 conf.CHECK_CODE('int __attribute__((used)) func(int x) { return x; }',
101 addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
102 define='HAVE_ATTRIBUTE_USED')
103 - # We try to use headers for a compile-time test.
104 - conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
105 - #define B __BYTE_ORDER
106 - #elif defined(BYTE_ORDER)
107 - #define B BYTE_ORDER
108 - #endif
110 - #ifdef __LITTLE_ENDIAN
111 - #define LITTLE __LITTLE_ENDIAN
112 - #elif defined(LITTLE_ENDIAN)
113 - #define LITTLE LITTLE_ENDIAN
114 - #endif
116 - #if !defined(LITTLE) || !defined(B) || LITTLE != B
117 - #error Not little endian.
118 - #endif""",
119 - headers="endian.h sys/endian.h",
120 - define="HAVE_LITTLE_ENDIAN")
121 - conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
122 - #define B __BYTE_ORDER
123 - #elif defined(BYTE_ORDER)
124 - #define B BYTE_ORDER
125 - #endif
127 - #ifdef __BIG_ENDIAN
128 - #define BIG __BIG_ENDIAN
129 - #elif defined(BIG_ENDIAN)
130 - #define BIG BIG_ENDIAN
131 - #endif
133 - #if !defined(BIG) || !defined(B) || BIG != B
134 - #error Not big endian.
135 - #endif""",
136 - headers="endian.h sys/endian.h",
137 - define="HAVE_BIG_ENDIAN")
139 - if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
140 - # That didn't work! Do runtime test.
141 - conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
142 - u.i = 0x01020304;
143 - return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
144 - addmain=True, execute=True,
145 - define='HAVE_LITTLE_ENDIAN',
146 - msg="Checking for HAVE_LITTLE_ENDIAN - runtime")
147 - conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
148 - u.i = 0x01020304;
149 - return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
150 - addmain=True, execute=True,
151 - define='HAVE_BIG_ENDIAN',
152 - msg="Checking for HAVE_BIG_ENDIAN - runtime")
154 - # Extra sanity check.
155 - if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
156 - Logs.error("Failed endian determination. The PDP-11 is back?")
157 - sys.exit(1)
159 conf.CHECK_CODE('return __builtin_choose_expr(1, 0, "garbage");',
160 link=True,
162 1.8.3.2