-
Notifications
You must be signed in to change notification settings - Fork 7
/
generate-prebuilts.sh
executable file
·87 lines (73 loc) · 2.72 KB
/
generate-prebuilts.sh
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
#
# This script is used to generate gnu_efi prebuilts for both ia32 and x86_64.
# The resulting binaries will be copied into prebuilts/{ia32, x86_64}.
#
# Please make sure you have Android's build system setup first, and lunch
# target defined.
#
# Specify "-a" in command line to add these prebuilt binaries for
# git commit.
#
# Note:
# 1. ARCH ia32 and x86 are interchangable here.
# Android uses x86, but EFI uses ia32.
#
PREBUILT_TOP=$ANDROID_BUILD_TOP/hardware/intel/efi_prebuilts/
copy_to_prebuilts()
{
DEST_DIR=$PREBUILT_TOP/gnu-efi/linux-$2/
# Sanity check
if [ ! -s "gnuefi/crt0-efi-$1.o" ] ; then
echo "[ERROR] *** $1: gnuefi/crt0-efi-$1.o does not exist or has size 0. aborting..."
exit 1
fi
if [ ! -s "gnuefi/libgnuefi.a" ] ; then
echo "[ERROR] *** $1: gnuefi/libgnuefi.a does not exist or has size 0. aborting..."
exit 1
fi
if [ ! -s "lib/libefi.a" ] ; then
echo "[ERROR] *** $1: lib/libefi.a does not exist or has size 0. aborting..."
exit 1
fi
cp -v gnuefi/crt0-efi-$1.o $DEST_DIR/lib/crt0-efi-$1.o
cp -v gnuefi/libgnuefi.a $DEST_DIR/lib/libgnuefi.a
cp -v gnuefi/elf_$1_efi.lds $DEST_DIR/lib/elf_$1_efi.lds
cp -v lib/libefi.a $DEST_DIR/lib/libefi.a
cp -v inc/*.h $DEST_DIR/include/efi/
cp -v inc/$1/*.h $DEST_DIR/include/efi/$1/
cp -v inc/protocol/*.h $DEST_DIR/include/efi/protocol/
}
add_prebuilts=0
while getopts "a" opt; do
case "$opt" in
a) add_prebuilts=1;;
esac
done
# Create prebuilts directory (if not already exists)
mkdir -p $PREBUILT_TOP/gnu-efi/linux-x86/include/efi/
mkdir -p $PREBUILT_TOP/gnu-efi/linux-x86/include/efi/ia32
mkdir -p $PREBUILT_TOP/gnu-efi/linux-x86/include/efi/protocol
mkdir -p $PREBUILT_TOP/gnu-efi/linux-x86/lib
mkdir -p $PREBUILT_TOP/gnu-efi/linux-x86_64/include/efi/
mkdir -p $PREBUILT_TOP/gnu-efi/linux-x86_64/include/efi/x86_64
mkdir -p $PREBUILT_TOP/gnu-efi/linux-x86_64/include/efi/protocol
mkdir -p $PREBUILT_TOP/gnu-efi/linux-x86_64/lib
make ARCH=x86_64 clean
make ARCH=ia32 clean
# Generate prebuilts for x86_64
make ARCH=x86_64 CC=$ANDROID_BUILD_TOP/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/bin/x86_64-linux-gcc
copy_to_prebuilts x86_64 x86_64
make ARCH=x86_64 clean
# Generate prebuilts for ia32
make ARCH=ia32 CC=$ANDROID_BUILD_TOP//prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/i686-linux-gcc
copy_to_prebuilts ia32 x86
make ARCH=ia32 clean
if [ "$add_prebuilts" == "1" ]; then
export GIT_DIR=$PREBUILT_TOP/gnu-efi/.git
export GIT_WORK_TREE=$PREBUILT_TOP/gnu-efi
git add -- linux-x86/*
git add -- linux-x86_64/*
unset GIT_DIR
unset GIT_WORK_TREE
echo "[NOTICE] Please remember to commit the prebuilts under $PREBUILT_TOP"
fi