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
|
#!/bin/bash -ex
#
# Copyright 2019 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Regenerate host configuration files for the current host
cd `dirname ${BASH_SOURCE[0]}`
ANDROID_BUILD_TOP=$(cd ../..; pwd)
UNAME=$(uname | tr 'A-Z' 'a-z')
NAME=linux_glibc
TARGET=glibc
config_opts=()
if [ $UNAME == "darwin" ]; then
NAME=darwin
TARGET=darwin
# vfork is deprecated on Mac, so always fallback to fork
config_opts+=("ac_cv_func_vfork=no")
# we'd need to link to libiconv
config_opts+=("am_cv_func_iconv=no")
else
export CC="$ANDROID_BUILD_TOP/prebuilts/clang/host/linux-x86/$(cd $ANDROID_BUILD_TOP; build/soong/scripts/get_clang_version.py)/bin/clang"
fi
if [ "$1" = "--musl" ]; then
NAME=linux_musl
TARGET=musl
sysroot="${ANDROID_BUILD_TOP}/prebuilts/build-tools/sysroots/x86_64-linux-musl"
export CFLAGS="--sysroot=${sysroot} -target x86_64-linux-musl -fuse-ld=lld"
export LDFLAGS="--rtlib=compiler-rt"
fi
if [ $NAME == "linux_glibc" ]; then
export CFLAGS="--sysroot=$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot"
export LDFLAGS="--sysroot=$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot -B$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/lib/gcc/x86_64-linux/4.8.3 -L$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/lib/gcc/x86_64-linux/4.8.3 -L$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/x86_64-linux/lib64"
fi
DIR=$NAME-lib
mkdir -p $DIR
cd $DIR
rm -rf tmp
mkdir tmp
cd tmp
../../configure \
--disable-nls \
--enable-relocatable \
--prefix=/nonexistent \
--exec-prefix=/nonexistent/$NAME-x86 \
--datarootdir=/nonexistent/common \
"${config_opts[@]}"
# Don't try to use aclocal/automake/etc
touch ../../aclocal.m4
touch ../../configure
touch ../../Makefile.in
# Don't attempt to update source timestamps
touch ../../doc/stamp-vti
make -fMakefile Makefile
echo 'gensrcs: $(BUILT_SOURCES)' >>Makefile
make -fMakefile gensrcs
make -fMakefile src/bison
mkdir -p ../malloc
rm -rf ../*.h ../malloc/*.h
mv lib/*.h ../
mv lib/malloc/*.h ../malloc/
GENBP=../Android.bp
rm -f $GENBP
cat >$GENBP <<END
// Autogenerated by android_regen.sh
cc_defaults {
name: "libbison_${NAME}_defaults",
target: {
$TARGET: {
srcs: [
$(find lib -name '*.o' | sed "s/libbison_a-//" | sed -E "s/(.*)\.o/\"\1\.c\",/" | LC_ALL=C sort)
],
},
},
}
cc_defaults {
name: "bison_${NAME}_defaults",
target: {
$TARGET: {
srcs: [
$(find src -name '*.o' | sed "s/bison-//" | sed -E "s/(.*)\.o/\"\1\.c\",/" | LC_ALL=C sort)
],
},
},
}
END
${ANDROID_BUILD_TOP}/prebuilts/build-tools/$UNAME-x86/bin/bpfmt -w $GENBP
cd ../
rm -rf tmp
|