Commit | Line | Data |
---|---|---|
687e7019 JR |
1 | # set -x |
2 | ||
02b998ff | 3 | # Install the perl and its libraries anywhere: |
0a6fcaf8 BF |
4 | case "$userelocatableinc" in |
5 | '') userelocatableinc='define' ;; | |
6 | esac | |
9b0f5f8a | 7 | |
02b998ff BF |
8 | # The Android linker has some unusual behavior: No matter what |
9 | # path is passed in to dlopen(), it'll only use the path's | |
10 | # basename when trying to find a cached library. | |
11 | # Unfortunately, this is quite problematic for us, since for example, | |
12 | # Hash::Util and List::Util both end up creating a Util.so -- | |
13 | # So if you load List::Util and then Hash::Util, the dlopen() for | |
14 | # the latter will return the handle for the former. | |
15 | # See the implementation for details: | |
16 | # https://code.google.com/p/android-source-browsing/source/browse/linker/linker.c?repo=platform--bionic&r=9ec0f03a0d0b17bbb94ac0b9fef6add28a133c3a#1231 | |
17 | # What d_libname_unique does is inform MakeMaker that, rather than | |
18 | # creating Hash/Util/Util.so, it needs to make Hash/Util/Perl_Hash_Util.so | |
19 | d_libname_unique='define' | |
20 | ||
bbbf0767 JR |
21 | # On Android the shell is /system/bin/sh: |
22 | targetsh='/system/bin/sh' | |
687e7019 | 23 | |
19abaf5c JR |
24 | # Down with locales! |
25 | # https://github.com/android/platform_bionic/blob/master/libc/CAVEATS | |
26 | d_locconv='undef' | |
27 | d_setlocale='undef' | |
28 | d_setlocale_r='undef' | |
29 | i_locale='undef' | |
30 | ||
13c14f5c BF |
31 | # https://code.google.com/p/android-source-browsing/source/browse/libc/netbsd/net/getservent_r.c?repo=platform--bionic&r=ca6fe7bebe3cc6ed7e2db5a3ede2de0fcddf411d#95 |
32 | d_getservent_r='undef' | |
33 | ||
76d86663 BF |
34 | # Bionic defines several stubs that just warn and return NULL |
35 | # https://gitorious.org/0xdroid/bionic/blobs/70b2ef0ec89a9c9d4c2d4bcab728a0e72bafb18e/libc/bionic/stubs.c | |
36 | # https://android.googlesource.com/platform/bionic/+/master/libc/bionic/stubs.cpp | |
37 | ||
38 | # If they warn with 'FIX' or 'Android', assume they are the stubs | |
39 | # we want to avoid. | |
40 | ||
41 | # These are all stubs as well, but the core doesn't use them: | |
42 | # getusershell setusershell endusershell | |
43 | ||
44 | # This script UU/archname.cbu will get 'called-back' by Configure. | |
12120791 | 45 | $cat > UU/archname.cbu <<'EOCBU' |
76d86663 BF |
46 | # egrep pattern to detect a stub warning on Android. |
47 | # Right now we're checking for: | |
48 | # Android 2.x: FIX ME! implement FUNC | |
49 | # Android 4.x: FUNC is not implemented on Android | |
50 | android_stub='FIX|Android' | |
51 | ||
12120791 | 52 | $cat > try.c << 'EOM' |
76d86663 BF |
53 | #include <netdb.h> |
54 | int main() { (void) getnetbyname("foo"); return(0); } | |
55 | EOM | |
56 | $cc $ccflags try.c -o try | |
57 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
58 | if test "X$android_warn" != X; then | |
59 | d_getnbyname="$undef" | |
60 | fi | |
61 | ||
12120791 | 62 | $cat > try.c << 'EOM' |
76d86663 BF |
63 | #include <netdb.h> |
64 | int main() { (void) getnetbyaddr((uint32_t)1, AF_INET); return(0); } | |
65 | EOM | |
66 | $cc $ccflags try.c -o try | |
67 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
68 | if test "X$android_warn" != X; then | |
69 | d_getnbyaddr="$undef" | |
70 | fi | |
71 | ||
12120791 | 72 | $cat > try.c << 'EOM' |
76d86663 BF |
73 | #include <stdio.h> |
74 | #include <mntent.h> | |
75 | #include <unistd.h> | |
76 | int main() { (void) getmntent(stdout); return(0); } | |
77 | EOM | |
78 | $cc $ccflags try.c -o try | |
79 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
80 | if test "X$android_warn" != X; then | |
81 | d_getmntent="$undef" | |
82 | fi | |
83 | ||
12120791 | 84 | $cat > try.c << 'EOM' |
76d86663 BF |
85 | #include <netdb.h> |
86 | int main() { (void) getprotobyname("foo"); return(0); } | |
87 | EOM | |
88 | $cc $ccflags try.c -o try | |
89 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
90 | if test "X$android_warn" != X; then | |
91 | d_getpbyname="$undef" | |
92 | fi | |
93 | ||
12120791 | 94 | $cat > try.c << 'EOM' |
76d86663 BF |
95 | #include <netdb.h> |
96 | int main() { (void) getprotobynumber(1); return(0); } | |
97 | EOM | |
98 | $cc $ccflags try.c -o try | |
99 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
100 | if test "X$android_warn" != X; then | |
101 | d_getpbynumber="$undef" | |
102 | fi | |
103 | ||
12120791 | 104 | $cat > try.c << 'EOM' |
76d86663 BF |
105 | #include <sys/types.h> |
106 | #include <pwd.h> | |
107 | int main() { endpwent(); return(0); } | |
108 | EOM | |
109 | $cc $ccflags try.c -o try | |
110 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
111 | if test "X$android_warn" != X; then | |
112 | d_endpwent="$undef" | |
113 | fi | |
114 | ||
12120791 | 115 | $cat > try.c << 'EOM' |
76d86663 BF |
116 | #include <unistd.h> |
117 | int main() { (void) ttyname(STDIN_FILENO); return(0); } | |
118 | EOM | |
119 | $cc $ccflags try.c -o try | |
120 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
121 | if test "X$android_warn" != X; then | |
122 | d_ttyname="$undef" | |
123 | fi | |
124 | ||
125 | EOCBU | |
687e7019 | 126 | |
da8b263a BF |
127 | if $test "X$targetrun" = "Xadb"; then |
128 | ||
687e7019 JR |
129 | case "$src" in |
130 | /*) run=$src/Cross/run | |
131 | targetmkdir=$src/Cross/mkdir | |
132 | to=$src/Cross/to | |
133 | from=$src/Cross/from | |
134 | ;; | |
135 | *) pwd=`test -f ../Configure && cd ..; pwd` | |
136 | run=$pwd/Cross/run | |
137 | targetmkdir=$pwd/Cross/mkdir | |
138 | to=$pwd/Cross/to | |
139 | from=$pwd/Cross/from | |
140 | ;; | |
141 | esac | |
da8b263a | 142 | |
687e7019 JR |
143 | targetrun=adb-shell |
144 | targetto=adb-push | |
145 | targetfrom=adb-pull | |
146 | run=$run-$targetrun | |
147 | to=$to-$targetto | |
148 | from=$from-$targetfrom | |
149 | ||
12120791 | 150 | $cat >$run <<EOF |
687e7019 | 151 | #!/bin/sh |
8995f03f | 152 | doexit="echo \\\$? >$targetdir/output.status" |
77e493b5 | 153 | env='' |
687e7019 JR |
154 | case "\$1" in |
155 | -cwd) | |
156 | shift | |
157 | cwd=\$1 | |
158 | shift | |
159 | ;; | |
160 | esac | |
77e493b5 JR |
161 | case "\$1" in |
162 | -env) | |
163 | shift | |
164 | env=\$1 | |
165 | shift | |
166 | ;; | |
167 | esac | |
687e7019 JR |
168 | case "\$cwd" in |
169 | '') cwd=$targetdir ;; | |
170 | esac | |
77e493b5 JR |
171 | case "\$env" in |
172 | '') env="echo " | |
173 | esac | |
687e7019 JR |
174 | exe=\$1 |
175 | shift | |
77e493b5 | 176 | args=\$@ |
687e7019 JR |
177 | $to \$exe > /dev/null 2>&1 |
178 | ||
179 | # send copy results to /dev/null as otherwise it outputs speed stats which gets in our way. | |
77e493b5 | 180 | # sometimes there is no $?, I dunno why? we then get Cross/run-adb-shell: line 39: exit: XX: numeric argument required |
8995f03f BF |
181 | adb -s $targethost shell "sh -c '(cd \$cwd && \$env ; \$exe \$args > $targetdir/output.stdout 2>$targetdir/output.stderr) ; \$doexit '" > /dev/null |
182 | ||
31b9cdb1 | 183 | $from output.stdout |
8995f03f BF |
184 | $from output.stderr |
185 | $from output.status | |
186 | ||
12120791 BF |
187 | result=\`$cat output.stdout\` |
188 | result_err=\`$cat output.stderr\` | |
189 | result_status=\`$cat output.status\` | |
8995f03f BF |
190 | rm output.stdout output.stderr output.status |
191 | ||
192 | # We get back Ok\r\n on android for some reason, grrr: | |
ca0d4969 BF |
193 | result=\`echo "\$result" | $tr -d '\r'\` |
194 | result_err=\`echo "\$result_err" | $tr -d '\r'\` | |
195 | result_status=\`echo \$result_status | $tr -d '\r'\` | |
8995f03f | 196 | |
77e493b5 | 197 | echo "\$result" |
8995f03f BF |
198 | if test "X\$result_err" != X; then |
199 | echo "\$result_err" >&2 | |
200 | fi | |
201 | ||
202 | # Also, adb doesn't exit with the commands exit code, like ssh does, double-grr | |
203 | exit \$result_status | |
687e7019 JR |
204 | |
205 | EOF | |
aec8ce86 | 206 | $chmod a+rx $run |
687e7019 | 207 | |
12120791 | 208 | $cat >$targetmkdir <<EOF |
687e7019 JR |
209 | #!/bin/sh |
210 | adb -s $targethost shell "mkdir -p \$@" | |
211 | EOF | |
aec8ce86 | 212 | $chmod a+rx $targetmkdir |
687e7019 | 213 | |
12120791 | 214 | $cat >$to <<EOF |
687e7019 JR |
215 | #!/bin/sh |
216 | for f in \$@ | |
217 | do | |
218 | case "\$f" in | |
219 | /*) | |
687e7019 JR |
220 | adb -s $targethost push \$f \$f || exit 1 |
221 | ;; | |
222 | *) | |
687e7019 JR |
223 | (adb -s $targethost push \$f $targetdir/\$f < /dev/null 2>&1) || exit 1 |
224 | ;; | |
225 | esac | |
226 | done | |
227 | exit 0 | |
228 | EOF | |
aec8ce86 | 229 | $chmod a+rx $to |
687e7019 | 230 | |
12120791 | 231 | $cat >$from <<EOF |
687e7019 JR |
232 | #!/bin/sh |
233 | for f in \$@ | |
234 | do | |
235 | $rm -f \$f | |
236 | (adb -s $targethost pull $targetdir/\$f . > /dev/null 2>&1) || exit 1 | |
237 | done | |
238 | exit 0 | |
239 | EOF | |
aec8ce86 | 240 | $chmod a+rx $from |
687e7019 | 241 | |
da8b263a BF |
242 | fi # Cross-compiling with adb |
243 | ||
47f59fc1 BF |
244 | if $test "X$hostosname" = "Xdarwin"; then |
245 | firstmakefile=GNUmakefile; | |
246 | fi |