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