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 | 2898702 | 2019-06-17 11:44:06 +0100 | [diff] [blame] | 18 | ABIGAIL_VERSION=2651a362 |
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 | |
| 33 | set -x |
| 34 | |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 35 | PACKAGES="autoconf libtool libxml2-dev pkg-config python3" |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 36 | # Install the dependencies. |
Matthias Maennich | bd5e166 | 2019-04-02 11:39:29 +0100 | [diff] [blame] | 37 | if ! dpkg -s ${PACKAGES} > /dev/null 2>&1 ; then |
Matthias Maennich | 02963ac | 2019-04-15 07:46:55 +0100 | [diff] [blame] | 38 | sudo apt-get install --yes ${PACKAGES} |
Matthias Maennich | bd5e166 | 2019-04-02 11:39:29 +0100 | [diff] [blame] | 39 | fi |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 40 | |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 41 | # Acquire elfutils sources |
| 42 | if [ ! -d "${ELFUTILS_SRC}" ]; then |
| 43 | git clone git://sourceware.org/git/elfutils.git "${ELFUTILS_SRC}" |
| 44 | else |
| 45 | git -C ${ELFUTILS_SRC} fetch |
Matthias Maennich | 7dcb786 | 2019-04-09 15:01:48 +0100 | [diff] [blame] | 46 | fi |
| 47 | |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 48 | git -C ${ELFUTILS_SRC} checkout ${ELFUTILS_VERSION} |
| 49 | |
| 50 | # Build elfutils |
| 51 | pushd "${ELFUTILS_SRC}" |
| 52 | #git clean -dfx |
| 53 | autoreconf -i --force |
| 54 | mkdir -p build/ |
| 55 | pushd build/ |
| 56 | ../configure --prefix="${OUT_DIR}" --enable-maintainer-mode |
| 57 | make -j${NUM_CORES} |
| 58 | make -j${NUM_CORES} install |
| 59 | popd |
| 60 | popd |
| 61 | |
| 62 | # Acquire libabigail sources |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 63 | if [ ! -d "${LIBABIGAIL_SRC}" ]; then |
| 64 | git clone git://sourceware.org/git/libabigail.git "${LIBABIGAIL_SRC}" |
| 65 | else |
| 66 | git -C ${LIBABIGAIL_SRC} fetch |
| 67 | fi |
| 68 | |
Matthias Maennich | 25062fc | 2019-05-29 12:54:46 +0100 | [diff] [blame] | 69 | git -C ${LIBABIGAIL_SRC} checkout ${ABIGAIL_VERSION} |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 70 | |
| 71 | # Build libabigail |
| 72 | pushd "${LIBABIGAIL_SRC}" |
| 73 | #git clean -dfx |
| 74 | autoreconf -i --force |
| 75 | mkdir -p build/ |
| 76 | pushd build/ |
Matthias Maennich | 2f2937c | 2019-06-10 14:41:49 +0100 | [diff] [blame] | 77 | ../configure --prefix="${OUT_DIR}" \ |
| 78 | --enable-cxx11=yes \ |
| 79 | --disable-shared \ |
| 80 | "CPPFLAGS=-I${OUT_DIR}/include" \ |
| 81 | "LDFLAGS=-L${OUT_DIR}/lib" |
| 82 | make -j${NUM_CORES} |
| 83 | make -j${NUM_CORES} install |
Matthias Maennich | f7d7e4d | 2019-03-26 11:46:24 +0000 | [diff] [blame] | 84 | popd |
| 85 | popd |
| 86 | |
| 87 | set +x |
| 88 | |
| 89 | echo |
| 90 | echo "Note: Export following environment before running the executables:" |
| 91 | echo |
| 92 | echo "export PATH=\"${OUT_DIR}/bin:\${PATH}\"" |
Matthias Maennich | bc48ccb | 2019-06-25 15:34:36 +0100 | [diff] [blame^] | 93 | 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] | 94 | echo |
| 95 | echo |