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' | |
78ada538 BF |
23 | case "$usecrosscompile" in |
24 | define) ;; | |
25 | # If we aren't cross-compiling, then sh should also point | |
26 | # to /system/bin/sh. | |
27 | *) sh=$targetsh ;; | |
28 | esac | |
687e7019 | 29 | |
1db8b1b9 BF |
30 | # Make sure that we look for libm |
31 | libswanted="$libswanted m" | |
32 | ||
19abaf5c JR |
33 | # Down with locales! |
34 | # https://github.com/android/platform_bionic/blob/master/libc/CAVEATS | |
35 | d_locconv='undef' | |
36 | d_setlocale='undef' | |
37 | d_setlocale_r='undef' | |
38 | i_locale='undef' | |
39 | ||
13c14f5c BF |
40 | # https://code.google.com/p/android-source-browsing/source/browse/libc/netbsd/net/getservent_r.c?repo=platform--bionic&r=ca6fe7bebe3cc6ed7e2db5a3ede2de0fcddf411d#95 |
41 | d_getservent_r='undef' | |
42 | ||
76d86663 BF |
43 | # Bionic defines several stubs that just warn and return NULL |
44 | # https://gitorious.org/0xdroid/bionic/blobs/70b2ef0ec89a9c9d4c2d4bcab728a0e72bafb18e/libc/bionic/stubs.c | |
45 | # https://android.googlesource.com/platform/bionic/+/master/libc/bionic/stubs.cpp | |
46 | ||
47 | # If they warn with 'FIX' or 'Android', assume they are the stubs | |
48 | # we want to avoid. | |
49 | ||
50 | # These are all stubs as well, but the core doesn't use them: | |
51 | # getusershell setusershell endusershell | |
52 | ||
53 | # This script UU/archname.cbu will get 'called-back' by Configure. | |
12120791 | 54 | $cat > UU/archname.cbu <<'EOCBU' |
76d86663 BF |
55 | # egrep pattern to detect a stub warning on Android. |
56 | # Right now we're checking for: | |
57 | # Android 2.x: FIX ME! implement FUNC | |
58 | # Android 4.x: FUNC is not implemented on Android | |
59 | android_stub='FIX|Android' | |
60 | ||
12120791 | 61 | $cat > try.c << 'EOM' |
76d86663 BF |
62 | #include <netdb.h> |
63 | int main() { (void) getnetbyname("foo"); return(0); } | |
64 | EOM | |
65 | $cc $ccflags try.c -o try | |
66 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
67 | if test "X$android_warn" != X; then | |
68 | d_getnbyname="$undef" | |
69 | fi | |
70 | ||
12120791 | 71 | $cat > try.c << 'EOM' |
76d86663 BF |
72 | #include <netdb.h> |
73 | int main() { (void) getnetbyaddr((uint32_t)1, AF_INET); return(0); } | |
74 | EOM | |
75 | $cc $ccflags try.c -o try | |
76 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
77 | if test "X$android_warn" != X; then | |
78 | d_getnbyaddr="$undef" | |
79 | fi | |
80 | ||
12120791 | 81 | $cat > try.c << 'EOM' |
76d86663 BF |
82 | #include <stdio.h> |
83 | #include <mntent.h> | |
84 | #include <unistd.h> | |
85 | int main() { (void) getmntent(stdout); return(0); } | |
86 | EOM | |
87 | $cc $ccflags try.c -o try | |
88 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
89 | if test "X$android_warn" != X; then | |
90 | d_getmntent="$undef" | |
91 | fi | |
92 | ||
12120791 | 93 | $cat > try.c << 'EOM' |
76d86663 BF |
94 | #include <netdb.h> |
95 | int main() { (void) getprotobyname("foo"); return(0); } | |
96 | EOM | |
97 | $cc $ccflags try.c -o try | |
98 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
99 | if test "X$android_warn" != X; then | |
100 | d_getpbyname="$undef" | |
101 | fi | |
102 | ||
12120791 | 103 | $cat > try.c << 'EOM' |
76d86663 BF |
104 | #include <netdb.h> |
105 | int main() { (void) getprotobynumber(1); return(0); } | |
106 | EOM | |
107 | $cc $ccflags try.c -o try | |
108 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
109 | if test "X$android_warn" != X; then | |
110 | d_getpbynumber="$undef" | |
111 | fi | |
112 | ||
12120791 | 113 | $cat > try.c << 'EOM' |
76d86663 BF |
114 | #include <sys/types.h> |
115 | #include <pwd.h> | |
116 | int main() { endpwent(); return(0); } | |
117 | EOM | |
118 | $cc $ccflags try.c -o try | |
119 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
120 | if test "X$android_warn" != X; then | |
121 | d_endpwent="$undef" | |
122 | fi | |
123 | ||
12120791 | 124 | $cat > try.c << 'EOM' |
76d86663 BF |
125 | #include <unistd.h> |
126 | int main() { (void) ttyname(STDIN_FILENO); return(0); } | |
127 | EOM | |
128 | $cc $ccflags try.c -o try | |
129 | android_warn=`$run ./try 2>&1 | $egrep "$android_stub"` | |
130 | if test "X$android_warn" != X; then | |
131 | d_ttyname="$undef" | |
132 | fi | |
133 | ||
134 | EOCBU | |
687e7019 | 135 | |
da8b263a BF |
136 | if $test "X$targetrun" = "Xadb"; then |
137 | ||
f4ca4add BF |
138 | $rm $run $to $from $targetmkdir |
139 | ||
687e7019 JR |
140 | case "$src" in |
141 | /*) run=$src/Cross/run | |
142 | targetmkdir=$src/Cross/mkdir | |
143 | to=$src/Cross/to | |
144 | from=$src/Cross/from | |
145 | ;; | |
146 | *) pwd=`test -f ../Configure && cd ..; pwd` | |
147 | run=$pwd/Cross/run | |
148 | targetmkdir=$pwd/Cross/mkdir | |
149 | to=$pwd/Cross/to | |
150 | from=$pwd/Cross/from | |
151 | ;; | |
152 | esac | |
da8b263a | 153 | |
687e7019 JR |
154 | targetrun=adb-shell |
155 | targetto=adb-push | |
156 | targetfrom=adb-pull | |
157 | run=$run-$targetrun | |
158 | to=$to-$targetto | |
159 | from=$from-$targetfrom | |
160 | ||
12120791 | 161 | $cat >$run <<EOF |
687e7019 | 162 | #!/bin/sh |
8995f03f | 163 | doexit="echo \\\$? >$targetdir/output.status" |
77e493b5 | 164 | env='' |
687e7019 JR |
165 | case "\$1" in |
166 | -cwd) | |
167 | shift | |
168 | cwd=\$1 | |
169 | shift | |
170 | ;; | |
171 | esac | |
77e493b5 JR |
172 | case "\$1" in |
173 | -env) | |
174 | shift | |
175 | env=\$1 | |
176 | shift | |
177 | ;; | |
178 | esac | |
687e7019 JR |
179 | case "\$cwd" in |
180 | '') cwd=$targetdir ;; | |
181 | esac | |
77e493b5 JR |
182 | case "\$env" in |
183 | '') env="echo " | |
184 | esac | |
687e7019 JR |
185 | exe=\$1 |
186 | shift | |
77e493b5 | 187 | args=\$@ |
687e7019 JR |
188 | $to \$exe > /dev/null 2>&1 |
189 | ||
190 | # send copy results to /dev/null as otherwise it outputs speed stats which gets in our way. | |
77e493b5 | 191 | # sometimes there is no $?, I dunno why? we then get Cross/run-adb-shell: line 39: exit: XX: numeric argument required |
8995f03f BF |
192 | adb -s $targethost shell "sh -c '(cd \$cwd && \$env ; \$exe \$args > $targetdir/output.stdout 2>$targetdir/output.stderr) ; \$doexit '" > /dev/null |
193 | ||
bb34e29a BF |
194 | rm output.stdout output.stderr output.status 2>/dev/null |
195 | ||
31b9cdb1 | 196 | $from output.stdout |
8995f03f BF |
197 | $from output.stderr |
198 | $from output.status | |
199 | ||
8995f03f | 200 | # We get back Ok\r\n on android for some reason, grrr: |
bb34e29a BF |
201 | $cat output.stdout | $tr -d '\r' |
202 | if test -s output.stderr; then | |
203 | $cat output.stderr | $tr -d '\r' >&2 | |
8995f03f BF |
204 | fi |
205 | ||
bb34e29a BF |
206 | result_status=\`$cat output.status | $tr -d '\r'\` |
207 | ||
208 | rm output.stdout output.stderr output.status | |
209 | ||
8995f03f BF |
210 | # Also, adb doesn't exit with the commands exit code, like ssh does, double-grr |
211 | exit \$result_status | |
687e7019 JR |
212 | |
213 | EOF | |
aec8ce86 | 214 | $chmod a+rx $run |
687e7019 | 215 | |
12120791 | 216 | $cat >$targetmkdir <<EOF |
687e7019 JR |
217 | #!/bin/sh |
218 | adb -s $targethost shell "mkdir -p \$@" | |
219 | EOF | |
aec8ce86 | 220 | $chmod a+rx $targetmkdir |
687e7019 | 221 | |
12120791 | 222 | $cat >$to <<EOF |
687e7019 JR |
223 | #!/bin/sh |
224 | for f in \$@ | |
225 | do | |
226 | case "\$f" in | |
227 | /*) | |
687e7019 JR |
228 | adb -s $targethost push \$f \$f || exit 1 |
229 | ;; | |
230 | *) | |
687e7019 JR |
231 | (adb -s $targethost push \$f $targetdir/\$f < /dev/null 2>&1) || exit 1 |
232 | ;; | |
233 | esac | |
234 | done | |
235 | exit 0 | |
236 | EOF | |
aec8ce86 | 237 | $chmod a+rx $to |
687e7019 | 238 | |
12120791 | 239 | $cat >$from <<EOF |
687e7019 JR |
240 | #!/bin/sh |
241 | for f in \$@ | |
242 | do | |
243 | $rm -f \$f | |
244 | (adb -s $targethost pull $targetdir/\$f . > /dev/null 2>&1) || exit 1 | |
245 | done | |
246 | exit 0 | |
247 | EOF | |
aec8ce86 | 248 | $chmod a+rx $from |
687e7019 | 249 | |
da8b263a BF |
250 | fi # Cross-compiling with adb |
251 | ||
78ada538 BF |
252 | case "$usecrosscompile" in |
253 | define) | |
ff44ff0c BF |
254 | # The tests for this in Configure doesn't play nicely with |
255 | # cross-compiling | |
256 | d_procselfexe="define" | |
47f59fc1 BF |
257 | if $test "X$hostosname" = "Xdarwin"; then |
258 | firstmakefile=GNUmakefile; | |
259 | fi | |
081c3f50 BF |
260 | |
261 | # When cross-compiling, full_csh and d_csh will get the | |
262 | # host's values, which is all sorts of wrong. So unless | |
263 | # full_csh has been set on the command line, set d_csh to | |
264 | # undef. | |
265 | case "$full_csh" in | |
266 | '') d_csh="$undef" | |
267 | ;; | |
268 | esac | |
269 | ||
78ada538 | 270 | ;; |
567e4090 BF |
271 | *) |
272 | ldflags="$ldflags -L/system/lib" | |
273 | ;; | |
78ada538 | 274 | esac |
d600e720 BF |
275 | |
276 | osvers="`$run getprop ro.build.version.release`" | |
055e6a96 BF |
277 | |
278 | # We want osname to be linux-android during Configure, | |
279 | # but plain 'android' afterwards. | |
280 | case "$src" in | |
281 | /*) pwd="$src";; | |
282 | *) pwd=`test -f ../Configure && cd ..; pwd` | |
283 | ;; | |
284 | esac | |
285 | ||
ff44ff0c | 286 | $cat <<'EOO' >> $pwd/config.arch |
055e6a96 BF |
287 | |
288 | osname='android' | |
42b5146c | 289 | eval "libpth='$libpth /system/lib /vendor/lib'" |
ff44ff0c BF |
290 | |
291 | if $test "X$procselfexe" = X; then | |
292 | case "$d_procselfexe" in | |
293 | define) procselfexe='"/proc/self/exe"';; | |
294 | esac | |
295 | fi | |
055e6a96 | 296 | EOO |
ac0b53aa BF |
297 | |
298 | # Android is a linux variant, so run those hints. | |
299 | . ./hints/linux.sh |