Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
| 3 | # Copyright (C) 2019 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 17 | ELFUTILS_VERSION=elfutils-0.176 |
Matthias Maennich | 798d9a9 | 2019-07-09 23:15:42 +0100 | [diff] [blame] | 18 | ABIGAIL_VERSION=d7ae619f |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 19 | |
| 20 | NUM_CORES=$(cat /proc/cpuinfo | grep -c proc) |
| 21 | BASE_DIR=$(readlink -f $(dirname $0)) |
| 22 | OUT_DIR="${BASE_DIR}/abigail-inst/${ABIGAIL_VERSION}" |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 23 | |
| 24 | ELFUTILS_SRC="${BASE_DIR}/elfutils-src" |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 25 | LIBABIGAIL_SRC="${BASE_DIR}/abigail-src" |
| 26 | |
| 27 | # Check output dir. |
| 28 | if [ -e "${OUT_DIR}" ]; then |
| 29 | echo "WARN: ${OUT_DIR} exists. Press enter to continue or Ctrl-C to abort." |
| 30 | read |
| 31 | fi |
| 32 | |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 33 | PACKAGES="autoconf libtool libxml2-dev pkg-config python3" |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 34 | # Install the dependencies. |
Greg Kroah-Hartman | 9344e8a | 2019-07-12 10:29:15 +0200 | [diff] [blame] | 35 | if ! ( hash dpkg 2>/dev/null ); then |
| 36 | echo "WARN: not running on a Debian compatible system!" |
| 37 | echo " Please be sure you have the required packages installed on" |
| 38 | echo " your system before continuing." |
| 39 | echo "" |
| 40 | echo " The list of required packages is, at the minimum:" |
| 41 | echo " ${PACKAGES}" |
| 42 | echo " but some distributions may require more." |
| 43 | echo " You are on your own here, be careful." |
| 44 | echo "" |
| 45 | echo "Press enter to continue or Ctrl-C to abort." |
| 46 | read |
| 47 | elif ! dpkg -s ${PACKAGES} > /dev/null 2>&1 ; then |
| 48 | set -x |
Matthias Maennich | 02963ac | 2019-04-15 07:46:55 +0100 | [diff] [blame] | 49 | sudo apt-get install --yes ${PACKAGES} |
Matthias Maennich | bd5e166 | 2019-04-02 11:39:29 +0100 | [diff] [blame] | 50 | fi |
Greg Kroah-Hartman | 9344e8a | 2019-07-12 10:29:15 +0200 | [diff] [blame] | 51 | set -x |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 52 | |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 53 | # Acquire elfutils sources |
| 54 | if [ ! -d "${ELFUTILS_SRC}" ]; then |
| 55 | git clone git://sourceware.org/git/elfutils.git "${ELFUTILS_SRC}" |
| 56 | else |
| 57 | git -C ${ELFUTILS_SRC} fetch |
Matthias Maennich | 7dcb786 | 2019-04-09 15:01:48 +0100 | [diff] [blame] | 58 | fi |
| 59 | |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 60 | git -C ${ELFUTILS_SRC} checkout ${ELFUTILS_VERSION} |
| 61 | |
| 62 | # Build elfutils |
| 63 | pushd "${ELFUTILS_SRC}" |
| 64 | #git clean -dfx |
| 65 | autoreconf -i --force |
| 66 | mkdir -p build/ |
| 67 | pushd build/ |
| 68 | ../configure --prefix="${OUT_DIR}" --enable-maintainer-mode |
| 69 | make -j${NUM_CORES} |
| 70 | make -j${NUM_CORES} install |
| 71 | popd |
| 72 | popd |
| 73 | |
| 74 | # Acquire libabigail sources |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 75 | if [ ! -d "${LIBABIGAIL_SRC}" ]; then |
| 76 | git clone git://sourceware.org/git/libabigail.git "${LIBABIGAIL_SRC}" |
| 77 | else |
| 78 | git -C ${LIBABIGAIL_SRC} fetch |
| 79 | fi |
| 80 | |
Matthias Maennich | 25062fc | 2019-05-29 12:54:46 +0100 | [diff] [blame] | 81 | git -C ${LIBABIGAIL_SRC} checkout ${ABIGAIL_VERSION} |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 82 | |
| 83 | # Build libabigail |
| 84 | pushd "${LIBABIGAIL_SRC}" |
| 85 | #git clean -dfx |
| 86 | autoreconf -i --force |
| 87 | mkdir -p build/ |
| 88 | pushd build/ |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 89 | ../configure --prefix="${OUT_DIR}" \ |
| 90 | --enable-cxx11=yes \ |
| 91 | --disable-shared \ |
| 92 | "CPPFLAGS=-I${OUT_DIR}/include" \ |
| 93 | "LDFLAGS=-L${OUT_DIR}/lib" |
| 94 | make -j${NUM_CORES} |
| 95 | make -j${NUM_CORES} install |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 96 | popd |
| 97 | popd |
| 98 | |
| 99 | set +x |
| 100 | |
| 101 | echo |
| 102 | echo "Note: Export following environment before running the executables:" |
| 103 | echo |
| 104 | echo "export PATH=\"${OUT_DIR}/bin:\${PATH}\"" |
Matthias Maennich | bc48ccb | 2019-06-25 15:34:36 +0100 | [diff] [blame] | 105 | echo "export LD_LIBRARY_PATH=\"${OUT_DIR}/lib:${OUT_DIR}/lib/elfutils:\${LD_LIBRARY_PATH}\"" |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 106 | echo |
| 107 | echo |